/* Movil y pantallas pequenas (jugabilidad). Archivo aparte para no tocar style.css. Se carga despues de cursors.css.
   - Vertical (telefono): barras de vida/EXP a todo el ancho, tarjeta y barra superior debajo, ventanas como hojas inferiores (una a la vez),
     chat compacto con boton, botones tactiles grandes y seleccion por toque con barra de acciones.
   - Horizontal (telefono acostado, poco alto): ventanas compactas una junto a la otra.
   Reglas generales para tactil: sin zoom del navegador ni desplazamiento accidental, sin pistas de teclado, sin tooltips (no hay hover). */
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
canvas#c { touch-action: none; }
.slot.filled { touch-action: none; }
.dockbtn.chatbtn { display: none; }

@media (pointer: coarse) {
  .dockbtn kbd { display: none; }
  .tip { display: none !important; }
}

/* ---- barra de acciones del item seleccionado (solo modo tactil / compacto; la crea ui.js) ---- */
.actionbar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; margin: 8px -8px -8px; padding: 8px 10px; background: linear-gradient(#262d4a, #151a2c); border-top: 1px solid var(--edge); border-radius: 0 0 11px 11px; }
.ab-info { flex: 1; min-width: 0; font-size: 12px; color: #9be0b2; }
.ab-info b { display: block; font-size: 13px; }
.ab-btns { display: flex; gap: 6px; flex: none; }
.ab-btns button { flex: none; padding: 9px 12px; }
.slot.sel { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ================= vertical (telefono) ================= */
@media (max-width: 640px) {
  #hpbox { top: calc(env(safe-area-inset-top) + 4px); left: 8px; right: 8px; width: auto; transform: none; height: 18px; }
  #goldbox { top: calc(env(safe-area-inset-top) + 41px); left: 8px; transform: none; }
  #expbox { top: calc(env(safe-area-inset-top) + 25px); left: 8px; right: 8px; width: auto; transform: none; height: 12px; }
  #hpnum { font-size: 11px; }
  #expnum { font-size: 9px; }
  #stats { top: calc(env(safe-area-inset-top) + 42px); left: 8px; padding: 5px 9px; font-size: 13px; max-width: 52vw; }
  #stats .pts-btn { margin-top: 3px; }
  #topbar { top: calc(env(safe-area-inset-top) + 42px); right: 8px; gap: 6px; }
  #topbar select { padding: 3px 6px; font-size: 12px; }
  #eventsBar { top: calc(env(safe-area-inset-top) + 82px); right: 8px; margin-top: 0; padding: 4px 8px; font-size: 11px; }
  #board { top: calc(env(safe-area-inset-top) + 78px); padding: 8px 12px; font-size: 14px; }
  #banner { top: 26%; padding: 10px 14px; }

  #dock { left: 8px; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 8px); justify-content: flex-end; gap: 6px; }
  .dockbtn { padding: 10px 12px; font-size: 13px; }
  .dockbtn.chatbtn { display: flex; }

  /* chat: solo las ultimas lineas, sin bloquear toques; el campo aparece al pulsar «Chat» */
  #chat { left: 8px; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 58px); width: auto; pointer-events: none; }
  #log { max-height: 66px; font-size: 12px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 8px; background: rgba(10, 12, 18, .5); }
  #chatIn { display: none; pointer-events: auto; margin-top: 4px; border-radius: 8px; font-size: 16px; }      /* 16 px evita el zoom automatico de iOS */
  body.chat-open #chatIn { display: block; }
  body.chat-open #chat { bottom: calc(env(safe-area-inset-bottom) + var(--kb, 0px) + 8px); z-index: 40; pointer-events: auto; }
  body.chat-open #dock { display: none; }

  /* ventanas: hojas inferiores, una a la vez; ocupan el ancho y se desplazan si no caben */
  .win { left: 6px !important; right: 6px !important; top: auto !important; bottom: calc(env(safe-area-inset-bottom) + 58px) !important; width: auto; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); overflow-y: auto; border-radius: 12px; }
  .win-title { cursor: default; touch-action: auto; }
  .win-body { padding: 8px; }
  .slot { width: 44px; height: 44px; }
  .slot img { max-width: 36px; max-height: 36px; }
  .slot-label { font-size: 9px; }
  .paper { padding: 2px 0 8px; }
  .paper .col { gap: 6px; }
  .doll svg { width: 70px; height: 114px; }
  .doll-name { font-size: 13px; }
  .st-cols { gap: 8px; }
  .plus { width: 28px; height: 28px; }
  .arow { grid-template-columns: 32px 1fr 28px 16px; }
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); max-height: none; overflow: visible; gap: 4px; padding: 0; }
  .grid .slot { width: min(100%, 56px); height: auto; aspect-ratio: 1 / 1; }
  .tab { font-size: 11px; padding: 7px 2px; }
}

/* ================= horizontal (telefono acostado: poco alto) ================= */
@media (max-height: 520px) and (min-width: 641px) {
  #hpbox { top: 6px; height: 16px; }
  #expbox { top: 25px; height: 11px; }
  #stats { top: 6px; left: 8px; padding: 5px 9px; font-size: 13px; }
  #topbar { top: 6px; right: 8px; gap: 6px; }
  #topbar select { padding: 3px 6px; font-size: 12px; }
  #eventsBar { top: 44px; right: 8px; margin-top: 0; font-size: 11px; padding: 4px 8px; }
  #board { top: 44px; padding: 6px 12px; font-size: 14px; }
  #dock { right: 8px; bottom: 8px; }
  #chat { left: 8px; bottom: 8px; width: min(300px, 38vw); }
  #log { max-height: 60px; font-size: 12px; }
  .win { width: min(330px, 46vw); max-height: calc(100vh - 58px); max-height: calc(100dvh - 58px); overflow-y: auto; }      /* deja libre la fila del dock */
  .win-body { padding: 6px; }
  .slot { width: 40px; height: 40px; }
  .slot img { max-width: 32px; max-height: 32px; }
  .paper { padding: 0 0 6px; }
  .paper .col { gap: 5px; }
  .doll svg { width: 58px; height: 94px; }
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); max-height: none; gap: 4px; }
  .grid .slot { width: min(100%, 44px); height: auto; aspect-ratio: 1 / 1; }
  .arow { padding: 1px 4px; }
}

/* sonido en movil: el panel baja junto con la barra superior */
@media (max-width: 640px) { #audioPanel { top: calc(env(safe-area-inset-top) + 80px); right: 8px; } #audioBtn { padding: 3px 8px; font-size: 14px; } }
@media (max-height: 520px) { #audioPanel { top: 40px; right: 8px; } #audioBtn { padding: 3px 8px; font-size: 14px; } }

/* ===== Barras de arriba (2026-10-08): fila 1 = EXP (ambar, abre el equipo) + musica / calidad / idioma; HP y MP debajo (lo que se mira en un combate grande). La tarjeta del personaje se quito. ===== */
#stats { display: none !important; }
#topbar #expbox { position: relative; transform: none; top: auto; left: auto; right: auto; flex: 0 0 190px; width: auto; min-width: 84px; height: 22px; border: 1px solid #6b5522; border-radius: 11px; cursor: pointer; pointer-events: auto; margin-right: 4px; background: #000b; }
#topbar #expfill { background: linear-gradient(#ecc063, #b8832a); }
#topbar #expnum { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
#mpbox { position: fixed; top: 38px; left: 50%; transform: translateX(-50%); width: min(280px, 60vw); height: 14px; background: #000a; border: 1px solid #2c3146; border-radius: 7px; overflow: hidden; }
#mpbox[hidden] { display: none; }
#mpfill { height: 100%; background: linear-gradient(#5aa0f2, #2a62b8); transition: width .2s; }
#mpnum { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; text-shadow: 0 1px 2px #000; }
@media (max-width: 640px) {
  #topbar { left: 8px; right: 8px; top: calc(env(safe-area-inset-top) + 4px); }
  #topbar #expbox { flex: 1 1 84px; height: 26px; margin-right: 0; }
  #topbar #expnum { font-size: 10px; }
  #hpbox { top: calc(env(safe-area-inset-top) + 40px); }
  #mpbox { top: calc(env(safe-area-inset-top) + 62px); left: 8px; right: 8px; width: auto; transform: none; }
}
@media (max-height: 520px) and (min-width: 641px) {
  #topbar #expbox { height: 20px; }
  #mpbox { top: 25px; height: 11px; }
}

/* Creador de heroe en celular: la vista 3D empieza debajo de la fila de controles (musica / calidad / idioma), que tapaba la cabeza del personaje. */
@media (max-width: 700px) {
  #crPanel { height: calc(55vh - 58px); }                 /* el panel cede 58 px para el espaciador: la vista 3D conserva el MISMO tamano de antes */
  #crCanvas { top: 58px; height: calc(100% - 58px); }
}

/* Creador / estilista: botones Cara / Cuerpo sobre la vista 3D (encuadre de la camara). */
#crViewBtns { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 2; }
#crViewBtns button { padding: 5px 11px; font-size: 12px; border-radius: 12px; background: #0009; color: #9aa3b8; border: 1px solid #2c3146; cursor: pointer; }
#crViewBtns button.on { color: #fff; border-color: #d9a441; background: #2a2208; }
@media (max-width: 700px) { #crViewBtns { top: 66px; } }

/* Aviso de reconexion (la conexion se corta cuando el celular apaga la pantalla; ver main.js scheduleReconnect). */
#netBanner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 200; padding: 7px 16px; border-radius: 16px; background: #2a2208; color: #ffd76a; border: 1px solid #d9a441; font-size: 13px; font-weight: 700; pointer-events: none; box-shadow: 0 2px 10px #000a; }
