/* ============================================================================================================
   Móvil (body.mobile, ver main.js y mobile.js): en horizontal, a pantalla completa y pensado para los pulgares,
   como los juegos de Supercell. Poco en pantalla: en la partida, sólo el turno, el viento y los mandos; lo demás va
   en un menú. Botones gordos con un código de color fijo: amarillo para lo principal (jugar, seguir), verde para lo
   secundario, rojo para avisos y salir, azul para los de iconos. Las ventanas se cierran tocando fuera.
   Colores: sólo variables del tema (o mezclas de ellas), para que sigan al ambiente
   ============================================================================================================ */

/* ---------- la página no se mueve ni se desplaza con el dedo (sólo lo de dentro de cada panel) ----------
   (los tamaños por el alto de la pantalla van en svh, el alto con la barra del navegador a la vista: con vh, al
   encogerse y estirarse esa barra (Samsung Internet, Chrome), el logo y lo demás crecían y menguaban sin parar) */
html.mobile { font-size: 13px; }
html.mobile, html.mobile body { overflow: hidden; overscroll-behavior: none; }
html.mobile body { position: fixed; inset: 0; }
/* (el fondo con una partida de la IA, sólo en el menú principal; en el resto, liso con su trama: main.js la para) */
body.mobile:not([data-scr="menu"]) #menu-bg { display: none; }
body.mobile:not([data-scr="menu"]) { background: var(--edge); }
/* (en su lugar, el fondo animado de mobile.js, como el de la intro; sin el velo de encima, que lo taparía) */
#m-bg { display: none; }
body.mobile:not([data-scr="menu"]):not([data-scr="game"]) #m-bg { display: block; position: fixed; left: 0; top: 0; z-index: 0; pointer-events: none; image-rendering: pixelated; }
body.mobile #scr-lobby::before, body.mobile #scr-room::before { display: none; }
.m-only { display: none; }

/* ---------- al abrirlo: «toca para jugar» (el toque pone la pantalla completa y la gira); en vertical sin pantalla
   completa (iPhone, o si el navegador no la deja), el aviso de girar el móvil ---------- */
#m-rotate, #m-tap { display: none; }
body.mobile.m-canfull:not(.m-full) #m-tap {
  display: flex; position: fixed; inset: 0; z-index: 401; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  border: 0; font: inherit; cursor: pointer; background: var(--edge); color: var(--well); text-align: center; padding: 24px;
}
body.mobile #m-tap b { font-size: 1.6rem; animation: m-blink 1.2s steps(2) infinite; }
body.mobile #m-tap span { opacity: .75; }
/* (un dedo en pixel art que toca) */
body.mobile .m-finger { width: 56px; height: 64px; background: var(--tap-ic) center / contain no-repeat; image-rendering: pixelated; animation: m-press 1.2s steps(2) infinite; }
@keyframes m-blink { 50% { opacity: .55; } }
@keyframes m-press { 50% { transform: translateY(6px); } }
@media (orientation: portrait) {
  body.mobile:not(.m-canfull) #m-rotate, body.mobile.m-full #m-rotate {
    display: flex; position: fixed; inset: 0; z-index: 400; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: var(--edge); color: var(--well); text-align: center; padding: 24px;
  }
  body.mobile #m-rotate b { font-size: 1.6rem; }
  body.mobile #m-rotate span { opacity: .75; }
  /* (un móvil en pixel art que se tumba) */
  body.mobile .m-phone { width: 46px; height: 80px; box-shadow: 0 0 0 5px var(--well), inset 0 -10px 0 color-mix(in srgb, var(--well) 25%, transparent); animation: m-turn 1.6s steps(4) infinite; }
}
@keyframes m-turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ---------- botones: gordos, con el borde de abajo más oscuro ---------- */
body.mobile .btn { min-height: 36px; padding: 5px 12px; font-size: 1rem; }
body.mobile .btn.small { min-height: 30px; padding: 4px 10px; }
body.mobile .btn.big { min-height: 44px; font-size: 1.1rem; padding: 6px 14px; }
body.mobile .btn.primary {
  background: var(--yellow); color: var(--ink); text-shadow: none;
  box-shadow: 0 0 0 3px var(--edge), inset 0 -5px 0 color-mix(in srgb, var(--yellow) 55%, var(--ink));
}
body.mobile .btn.go {
  background: var(--leaf); color: var(--well); text-shadow: 2px 2px 0 color-mix(in srgb, var(--leaf) 50%, var(--ink));
  box-shadow: 0 0 0 3px var(--edge), inset 0 -5px 0 color-mix(in srgb, var(--leaf) 55%, var(--ink));
}
body.mobile .btn.danger {
  background: var(--danger); color: var(--danger-ink);
  box-shadow: 0 0 0 3px var(--edge), inset 0 -5px 0 color-mix(in srgb, var(--danger) 55%, var(--ink));
}
body.mobile .btn:active { transform: translateY(2px); }
body.mobile .btn:hover { transform: none; }
body.mobile input, body.mobile select { min-height: 32px; font-size: .95rem; }
/* (el idioma, arriba a la derecha y pequeño; los FPS están en las opciones) */
body.mobile #fps-btn { display: none; }
body.mobile #lang-btn { min-height: 30px; padding: 2px 8px; font-size: .85rem; }
body.mobile #version { display: none; }

/* ---------- ventanas: casi toda la altura, se desplazan por dentro ---------- */
body.mobile .modal { padding: 8px calc(8px + env(safe-area-inset-right)) 8px calc(8px + env(safe-area-inset-left)); }
body.mobile .modal-card { width: min(820px, 100%); max-height: calc(100vh - 16px); max-height: calc(100svh - 16px); padding: 10px 14px; box-sizing: border-box; }
body.mobile .modal-card h2 { font-size: 1.3rem; margin-bottom: 8px; }
body.mobile .modal-card .close { width: 38px; height: 38px; }

/* ---------- menú principal: el logo arriba, JUGAR abajo a la derecha ---------- */
body.mobile #scr-menu { align-items: stretch; justify-content: stretch; }
body.mobile .menu-card { position: absolute; inset: 0; width: auto; margin: 0; }
body.mobile .menu-card .tagline, body.mobile .menu-card .credits { display: none; }
body.mobile .menu-card .logo { position: absolute; left: calc(12px + env(safe-area-inset-left)); top: 8px; margin: 0; }
body.mobile #logo-cv { width: auto; height: min(30vh, 120px); height: min(30svh, 120px); aspect-ratio: 256 / 146; margin: 0; }
/* (el nombre: arriba a la derecha, como el perfil, debajo del idioma) */
body.mobile .menu-card > .field { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: 46px; width: 170px; margin: 0; }
body.mobile .menu-card > .field span { font-size: .7rem; }
body.mobile .menu-card .menu-buttons {
  position: absolute; left: calc(12px + env(safe-area-inset-left)); right: calc(12px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: row; align-items: flex-end; gap: 8px;
}
body.mobile .menu-card .menu-buttons .btn::after { display: none; }
body.mobile .menu-card .menu-buttons .btn:hover { transform: none; }
/* (lo de menos uso: botones cuadrados con su icono, abajo a la izquierda) */
body.mobile #btn-tutorial, body.mobile #btn-trailer, body.mobile #btn-opts, body.mobile #btn-help {
  order: 0; width: 42px; height: 42px; min-height: 0; padding: 0; justify-content: center; font-size: 0; gap: 0; flex: none;
  background: var(--btn); color: var(--ink); box-shadow: 0 0 0 3px var(--edge), inset 0 -4px 0 color-mix(in srgb, var(--btn) 55%, var(--ink));
}
body.mobile .menu-buttons .btn .pxi { transform: scale(1.4); }
body.mobile #btn-local, body.mobile #btn-online { white-space: nowrap; justify-content: center; flex: none; width: auto; }
/* (los colores, los del menú del ordenador: siguen al ambiente con «Colores según el mapa») */
body.mobile #btn-local { order: 1; margin-left: auto; min-height: 0; height: 46px; padding: 2px 14px; background: var(--cream); color: var(--ink); box-shadow: 0 0 0 3px var(--edge), inset 0 -5px 0 color-mix(in srgb, var(--cream) 60%, var(--ink)); }
body.mobile #btn-local small { display: none; }
body.mobile #btn-online { order: 2; min-height: 56px; min-width: 170px; font-size: 1.3rem; background: var(--pink); color: #fff; text-shadow: 2px 2px 0 var(--pink-2); box-shadow: 0 0 0 3px var(--edge), inset 0 -5px 0 var(--pink-2); }
body.mobile #btn-local .pxi, body.mobile #btn-online .pxi { transform: none; }
body.mobile #btn-local .pxi { height: 30px; width: auto; }

/* ---------- lobby y sala: una pestaña por panel, en una barra abajo ---------- */
body.mobile .topbar { gap: 8px; padding: 0 0 4px; }
body.mobile .topbar h2 { font-size: 1.15rem; }
body.mobile #scr-lobby, body.mobile #scr-room {
  padding: calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(54px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  box-sizing: border-box;
}
body.mobile .m-tabbed { display: flex !important; flex-direction: column; gap: 0; min-height: 0; flex: 1; }
body.mobile .m-tabbed .col { display: contents; }
body.mobile .m-tabbed .panel { display: none; flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 10px 12px; }
body.mobile .m-tabbed .panel.m-on { display: flex; flex-direction: column; }
body.mobile .m-tabbed .panel.m-on > * { flex-shrink: 0; }
body.mobile .m-tabbed .panel-head h3 { font-size: .95rem; }
.m-tabs { display: none; }
body.mobile .m-tabs {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 5px; justify-content: flex-start;
  padding: 5px calc(8px + env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: var(--edge);
}
body.mobile .m-tab {
  flex: 0 1 120px; min-height: 38px; border: 0; font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; position: relative;
  background: color-mix(in srgb, var(--well) 18%, var(--edge)); color: var(--well);
}
body.mobile .m-tab.on { background: var(--yellow); color: var(--ink); box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--yellow) 55%, var(--ink)); }
/* (algo nuevo en el chat: un punto rojo) */
body.mobile .m-tab.dot::after { content: ''; position: absolute; top: 5px; right: 8px; width: 10px; height: 10px; background: var(--danger); box-shadow: 0 0 0 2px var(--edge); }
/* (empezar, amarillo, en la misma barra que las pestañas, a la derecha) */
body.mobile .start-row { position: fixed; right: calc(8px + env(safe-area-inset-right)); bottom: calc(4px + env(safe-area-inset-bottom)); z-index: 21; gap: 6px; }
body.mobile .start-row .btn.big { min-height: 40px; padding: 2px 14px; font-size: 1rem; }
body.mobile #btn-start { min-width: 160px; }
/* los ajustes: el mapa y su semilla a la izquierda; los ajustes, a la derecha */
body.mobile .room-grid > .panel:nth-child(2).m-on { display: grid; grid-template-columns: minmax(180px, 30%) 1fr; grid-template-rows: auto auto 1fr; gap: 0 12px; align-content: start; }
body.mobile .room-grid > .panel:nth-child(2) > .panel-head { grid-column: 1 / 3; }
body.mobile .room-grid > .panel:nth-child(2) .map-preview { grid-column: 1; grid-row: 2; margin: 0; }
body.mobile .room-grid > .panel:nth-child(2) .mode-desc { grid-column: 1; grid-row: 3; font-size: .75rem; }
body.mobile .room-grid > .panel:nth-child(2) .settings { grid-column: 2; grid-row: 2 / 4; grid-template-columns: 1fr 1fr; gap: 0 10px; }
body.mobile .map-preview canvas { width: 100%; height: auto; }
body.mobile .mp-row { flex-wrap: wrap; justify-content: flex-start; }
body.mobile .chat-panel { min-height: 0; }

/* ---------- la sala: los equipos de pie (style.css), más pequeños; el resumen de la partida, estrecho ---------- */
body.mobile .room-grid > .panel:first-child { padding: 4px 0 0; }
body.mobile .room-grid > .panel:first-child .panel-head { margin-bottom: 2px; }
body.mobile .stage { gap: 8px; }
body.mobile .room-info { width: 168px; gap: 4px; }
body.mobile .ri-desc { display: none; }
body.mobile .ri-title { font-size: .72rem; }
body.mobile .ri-icons { gap: 4px; }
body.mobile .ri-chip { height: 24px; min-width: 24px; font-size: .62rem; }
body.mobile .ri-chip .pxi { max-height: 18px; width: auto; }
body.mobile .ri-chip.boss img { height: 30px; }
body.mobile .dress-btn .pxi { height: 30px; width: auto; }
body.mobile .player-list { padding: 0 4px 4px 34px; }
body.mobile .player { flex-basis: 84px; width: 84px; margin-left: -30px; }
body.mobile .player .swatch { width: 78px; height: 18px; margin-top: -12px; }
body.mobile .player .btn.pkick, body.mobile .player .btn.pspec, body.mobile .player .btn.pcolor { top: 20px; }
body.mobile .player:nth-child(even) .pname { margin-bottom: -12px; }
body.mobile .player:nth-child(odd) :is(.pkick, .pspec, .pcolor) { top: 2px; }
body.mobile .player .pkick { right: 4px; } body.mobile .player :is(.pspec, .pcolor) { left: 4px; }
body.mobile .player:nth-child(even) { margin-bottom: 52px; }
body.mobile .ri-chip:not(.num):not(.soon) b { display: none; }
body.mobile .ri-chip.soon b { font-size: .55rem; line-height: 1.05; max-width: 64px; } /* (el modo, sólo su icono: su nombre, al mantener el dedo) */
body.mobile #ri-map { box-shadow: 0 0 0 2px var(--edge); }
body.mobile .player .charbtn img { height: min(20vh, 78px); height: min(20svh, 78px); }
body.mobile .player .pname { font-size: .72rem; }
body.mobile .player .pname small { font-size: .6rem; }
body.mobile .add-row { gap: 6px; padding: 0 6px; }
body.mobile .add-row .btn, body.mobile .add-row select { min-height: 30px; font-size: .8rem; }
body.mobile .add-row select { flex: none; width: auto; }

/* ---------- la partida: el mapa entero, y encima sólo lo justo ---------- */
body.mobile #hud { zoom: 1; }
body.mobile #hud-buttons, body.mobile #minimap, body.mobile #key-hint, body.mobile #camnav, body.mobile #hud-weapon,
body.mobile #hud-round, body.mobile #pip-box, body.mobile #game-chat-form { display: none !important; }
/* arriba a la izquierda: de quién es el turno y el tiempo */
body.mobile #hud-turn { top: calc(6px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); transform: none; padding: 2px 4px 2px 8px; gap: 6px; }
body.mobile #turn-team { font-size: .6rem; }
body.mobile #turn-worm { font-size: .85rem; }
body.mobile #turn-next { display: none; }
body.mobile #turn-timer { width: 30px; height: 30px; font-size: 1rem; }
/* arriba en el centro: el viento, pequeño */
body.mobile #hud-wind { top: calc(6px + env(safe-area-inset-top)); bottom: auto; right: auto; left: 50%; transform: translateX(-50%); padding: 2px 6px; font-size: .5rem; align-items: center; gap: 2px; }
body.mobile .wind-bar { width: 72px; }
/* arriba a la derecha (junto al menú): la vida de cada equipo, en barritas */
body.mobile #hud-teams { top: calc(6px + env(safe-area-inset-top)); bottom: auto; left: auto; right: calc(52px + env(safe-area-inset-right)); width: 96px; padding: 3px 5px; gap: 2px; }
body.mobile .tbar { font-size: .5rem; gap: 3px; }
body.mobile .tbar .tname { display: none; }
body.mobile .tbar .track { height: 5px; }
body.mobile .tbar .num { width: 18px; }
body.mobile #boss-warn { top: calc(40px + env(safe-area-inset-top)); font-size: .75rem; }
body.mobile #center-msg { font-size: 1.25rem; top: 32%; }
body.mobile #pause-banner { font-size: 1.3rem; }
/* el chat: sólo los dos últimos mensajes, pequeños, debajo del turno (el chat se abre desde el menú) */
body.mobile #game-chat { top: calc(44px + env(safe-area-inset-top)); bottom: auto; left: calc(8px + env(safe-area-inset-left)); width: min(280px, 34vw); }
body.mobile #game-chat:not(.open) #game-chat-log { font-size: .62rem; max-height: none; }
body.mobile #game-chat:not(.open) #game-chat-log div:nth-last-child(n+3) { display: none; }
body.mobile #game-chat.open { top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); width: min(520px, 70vw); z-index: 30; }
body.mobile #game-chat.open #game-chat-form { display: block !important; }
body.mobile #game-chat.open #game-chat-log { max-height: 46vh; max-height: 46svh; }
/* la mecha, junto al botón del arma */
body.mobile #hud-fuse { bottom: calc(var(--m-atk) + 30px + env(safe-area-inset-bottom)); left: auto; right: calc(var(--m-atk) / 2 + 64px + env(safe-area-inset-right)); transform: none; padding: 2px 6px; z-index: 9; }
body.mobile #hud-fuse .hbtn { width: 32px; height: 32px; }
body.mobile .fz-help { display: none; }
/* el tutorial: abajo en el centro (arriba están el turno, el viento y los equipos), sólo sus botones en una línea; el bocadillo de
   Flan, más pequeño */
body.mobile #tut-bar { top: auto; bottom: calc(4px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); flex-direction: row; align-items: center; gap: 5px; padding: 3px 6px; }
body.mobile #tut-step { display: none; }
body.mobile #tut-bar .btn { white-space: nowrap; font-size: .55rem; padding: 3px 6px; min-height: 0; }
body.mobile #tut-panel { max-width: min(340px, 48vw); padding: 6px 10px; }
body.mobile #tut-panel.mid { max-width: min(560px, 80vw); }
body.mobile #tut-text { font-size: 1rem; }
body.mobile #tut-face { width: 40px; height: 46px; }
body.mobile #tut-face img { width: 40px; height: 54px; margin-bottom: -8px; }

/* ---------- el arsenal: un carrusel de armas abajo, que se desliza con el dedo ---------- */
body.mobile #weapon-panel:not(.hidden) {
  display: flex; flex-direction: column; gap: 4px; left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right));
  top: auto; bottom: calc(6px + env(safe-area-inset-bottom)); transform: none; width: auto; max-height: none; padding: 6px 8px 4px; z-index: 12; zoom: 1; animation: slideup .15s steps(3);
}
body.mobile #weapon-panel .wp-head, body.mobile .wp-tip { display: none; }
/* (la ficha del arma tocada, como en el ordenador: arriba a la derecha, pegada al carrusel, con su previa y cómo se usa) */
body.mobile #wp-desc {
  position: absolute; right: 0; bottom: calc(100% + 6px); width: min(250px, 38vw); min-height: 0; margin: 0; padding: 5px 7px;
  font-size: .6rem; max-height: calc(100vh - 150px); max-height: calc(100svh - 150px); overflow-y: auto;
}
body.mobile #wp-desc .wc-tags, body.mobile #wp-desc .wc-round { display: none; }
body.mobile #wp-desc .wc-head { margin: 0; gap: 4px; font-size: .72rem; }
body.mobile #wp-desc .wprev { width: 100%; margin: 4px 0 3px; }
body.mobile #wp-desc .wc-desc { margin: 0; line-height: 1.3; font-size: .68rem; color: color-mix(in srgb, var(--ink) 75%, var(--well)); }
/* (tutorial: el arma que hay que elegir queda fuera del carrusel: una flecha hacia ese lado) */
body.mobile #weapon-panel[data-more="r"]::after, body.mobile #weapon-panel[data-more="l"]::after {
  content: '▶'; position: absolute; right: -6px; bottom: 26px; font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--yellow);
  text-shadow: 3px 3px 0 var(--edge); pointer-events: none; animation: th-nudge .6s steps(2) infinite alternate;
}
body.mobile #weapon-panel[data-more="l"]::after { content: '◀'; right: auto; left: -6px; --dir: 1; }
@keyframes th-nudge { to { transform: translateX(calc(var(--dir, -1) * -8px)); } }
body.mobile #wp-grid { display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: 6px; padding: 4px 2px 6px; scroll-snap-type: x proximity; touch-action: pan-x; scrollbar-width: none; }
body.mobile #wp-grid::-webkit-scrollbar { display: none; }
/* (en la partida todo tiene touch-action: none; el carrusel sí se desliza, también empezando encima de un arma) */
body.mobile #wp-grid, body.mobile #wp-grid * { touch-action: pan-x; }
body.mobile #wp-grid .wbtn { flex: 0 0 52px; height: 52px; aspect-ratio: auto; scroll-snap-align: start; }
/* (el nombre de cada grupo, de lado, entre sus armas) */
body.mobile #wp-grid .wp-cat { flex: none; writing-mode: vertical-rl; transform: rotate(180deg); margin: 0; padding: 0 1px; border: 0; border-right: 2px dashed var(--cream-2); font-size: .5rem; text-align: center; }

/* ---------- los mandos ---------- */
body.mobile { --m-move: min(30vh, 116px); --m-atk: min(33vh, 126px); }
@supports (height: 1svh) { body.mobile { --m-move: min(30svh, 116px); --m-atk: min(33svh, 126px); } }
#tpad, #tmenu { display: none; }
/* (el menú de la partida, también con el mando en el ordenador: Start; abierto, se ve aunque luego se toque el teclado
   o el ratón, que si no se quedaba oculto con la partida en pausa) */
#tmenu:not(.hidden) { display: grid; z-index: 60; }
body.mobile #scr-game #tpad { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 8; }
body.mobile.replay #tpad { display: none; }
#tpad > * { pointer-events: auto; position: absolute; }
.tjoy { touch-action: none; }
/* (círculos de pixel art: los pinta mobile.js, pixRounds, con los colores del tema) */
.tjoy .tj-ring { position: absolute; inset: 0; background: var(--px-ring) center / 100% 100% no-repeat; image-rendering: pixelated; }
.tjoy .tj-knob {
  position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%;
  background: var(--px-knob) center / 100% 100% no-repeat; image-rendering: pixelated; transition: transform .08s;
}
.tjoy.on .tj-knob { transition: none; }
#tj-move { left: calc(22px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom)); width: var(--m-move); height: var(--m-move); }
#tj-aim { right: calc(24px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); width: var(--m-atk); height: var(--m-atk); }
/* (el de ataque: rojo como el ataque) */
#tj-aim .tj-knob { background-image: var(--px-knobr); }
#tj-aim.on .tj-ring { background-image: var(--px-ringr); }
/* (vuelto al centro: soltarlo no dispara) */
.tj-cancel { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); font-size: 1.3rem; font-weight: 700; color: var(--well); text-shadow: 2px 2px 0 var(--edge); opacity: 0; pointer-events: none; }
#tj-aim.on.cancel .tj-cancel { opacity: 1; }
#tj-aim.on.cancel .tj-knob { background-image: var(--px-knob); }
.tbtn {
  border: 0; padding: 0; display: grid; place-items: center; cursor: pointer; touch-action: none;
  width: 52px; height: 52px; background: var(--px-yel) center / 100% 100% no-repeat; image-rendering: pixelated; color: var(--ink);
}
.tbtn.on { transform: translateY(2px); filter: brightness(.9); }
.tbtn.mini { width: 40px; height: 40px; background-image: var(--px-sky); }
/* saltar: a la izquierda del de ataque; la voltereta, encima de saltar; el arma, encima del de ataque */
#tb-jump { right: calc(var(--m-atk) + 40px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); }
#tb-jump .pxi { transform: rotate(90deg); }
#tb-flip { right: calc(var(--m-atk) + 46px + env(safe-area-inset-right)); bottom: calc(84px + env(safe-area-inset-bottom)); font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--ink); }
#tb-weapon { right: calc(var(--m-atk) / 2 + 24px - 28px + env(safe-area-inset-right)); bottom: calc(var(--m-atk) + 26px + env(safe-area-inset-bottom)); width: 56px; height: 56px; background: var(--well); box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset 0 -5px 0 color-mix(in srgb, var(--well) 70%, var(--ink)); }
#tb-weapon .pxi { transform: scale(.8); }
#tb-weapon.has-new::after { content: ''; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; background: var(--danger); box-shadow: 0 0 0 2px var(--edge); }
#tb-cam { left: calc(var(--m-move) + 78px + env(safe-area-inset-left)); bottom: calc(20px + env(safe-area-inset-bottom)); }
/* (las flechas de la cámara, a los lados de la diana: pasan de un personaje a otro) */
#tb-camprev { left: calc(var(--m-move) + 32px + env(safe-area-inset-left)); bottom: calc(20px + env(safe-area-inset-bottom)); }
#tb-camnext { left: calc(var(--m-move) + 124px + env(safe-area-inset-left)); bottom: calc(20px + env(safe-area-inset-bottom)); }
body.tut:not(.tut-cam) #tb-camprev, body.tut:not(.tut-cam) #tb-camnext { display: none; }
#tb-menu { top: calc(6px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); width: 38px; height: 38px; background: var(--well); box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset 0 -4px 0 color-mix(in srgb, var(--well) 70%, var(--ink)); }
/* (fuera de tu turno, los mandos de mover y atacar se apagan; el menú y la cámara, no) */
body.mobile:not(.myturn) #tj-move, body.mobile:not(.myturn) #tj-aim, body.mobile:not(.myturn) #tb-jump, body.mobile:not(.myturn) #tb-flip { opacity: .45; }
/* el menú de la partida */
body.mobile #tmenu:not(.hidden) { display: grid; z-index: 60; }
body.mobile #tmenu .modal-card { width: min(440px, 100%); }
.tmenu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tmenu-list #tm-resume, .tmenu-list #tm-exit { grid-column: 1 / 3; }
/* el dedo del tutorial: hace el gesto de cada paso encima del botón de verdad (o del mapa); la punta, en el sitio */
#tut-hand { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 21; pointer-events: none; }
#tut-hand.hidden { display: none; }
#tut-hand .th-f {
  position: absolute; left: -14px; top: 0; width: 40px; height: 44px; background: var(--tap-ic) center / contain no-repeat;
  image-rendering: pixelated; filter: drop-shadow(3px 3px 0 var(--edge)); animation: 1.4s ease-in-out infinite;
}
#tut-hand .th-f.b { display: none; }
#tut-hand.rev .th-f { animation-direction: reverse; }
#tut-hand[data-g="tap"] .th-f { animation-name: th-tap; animation-duration: .9s; }
#tut-hand[data-g="hold"] .th-f { animation-name: th-hold; animation-duration: 1.8s; }
#tut-hand[data-g="aim"] .th-f { animation-name: th-aim; animation-duration: 2.2s; }
#tut-hand[data-g="lr"] .th-f { animation-name: th-lr; animation-duration: 1.6s; }
#tut-hand[data-g="pan"] .th-f { animation-name: th-pan; animation-duration: 1.8s; }
#tut-hand[data-g="swipe"] .th-f { animation-name: th-swipe; }
#tut-hand[data-g="pinch"] .th-f { animation-name: th-pinch-a; animation-duration: 1.6s; }
#tut-hand[data-g="pinch"] .th-f.b { display: block; animation-name: th-pinch-b; }
/* (la voltereta: empuja el joystick hacia atrás, ◀, y va a tocar la voltereta, ↶) */
#tut-hand .th-s { display: none; position: absolute; left: 0; top: -54px; transform: translateX(-50%); font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--yellow); text-shadow: 3px 3px 0 var(--edge); opacity: 0; animation: 2.4s infinite; }
#tut-hand[data-g="flip"] .th-s { display: block; }
#tut-hand .th-s.s2 { left: var(--dx); top: calc(var(--dy) - 58px); }
#tut-hand[data-g="flip"] .th-s.s1 { animation-name: th-s1; }
#tut-hand[data-g="flip"] .th-s.s2 { animation-name: th-s2; }
#tut-hand[data-g="flip"] .th-f { animation-name: th-flip; animation-duration: 2.4s; }
@keyframes th-flip {
  0% { transform: translate(0, 12px); opacity: 0; } 8% { transform: scale(.85); opacity: 1; } 28%, 40% { transform: translate(-30px, 0) scale(.85); opacity: 1; }
  52% { transform: translate(var(--dx), calc(var(--dy) + 12px)); } 62%, 72% { transform: translate(var(--dx), var(--dy)) scale(.85); }
  84% { transform: translate(var(--dx), calc(var(--dy) + 12px)); opacity: 1; } 100% { transform: translate(var(--dx), calc(var(--dy) + 12px)); opacity: 0; }
}
@keyframes th-s1 { 0%, 8% { opacity: 0; } 20%, 44% { opacity: 1; } 52%, 100% { opacity: 0; } }
@keyframes th-s2 { 0%, 56% { opacity: 0; } 62%, 84% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes th-tap { 0%, 100% { transform: translate(0, 12px); } 50% { transform: scale(.85); } }
@keyframes th-hold { 0% { transform: translate(0, 14px); opacity: 0; } 20%, 80% { transform: scale(.85); opacity: 1; } 100% { transform: translate(0, 14px); opacity: 0; } }
@keyframes th-aim { 0% { transform: translate(0, 14px); opacity: 0; } 15% { transform: scale(.85); opacity: 1; } 45%, 85% { transform: translate(-34px, -30px) scale(.85); opacity: 1; } 100% { transform: translate(-34px, -18px); opacity: 0; } }
@keyframes th-lr { 0%, 100% { transform: translate(-30px, 0) scale(.85); } 50% { transform: translate(30px, 0) scale(.85); } }
@keyframes th-pan { 0% { transform: translate(80px, 0) scale(.85); opacity: 0; } 15% { opacity: 1; } 75% { transform: translate(-80px, 0) scale(.85); opacity: 1; } 100% { transform: translate(-80px, 0) scale(.85); opacity: 0; } }
@keyframes th-swipe { 0% { transform: translate(60px, 0) scale(.85); opacity: 0; } 15% { opacity: 1; } 75% { transform: translate(-60px, 0) scale(.85); opacity: 1; } 100% { transform: translate(-60px, 0) scale(.85); opacity: 0; } }
@keyframes th-pinch-a { 0%, 100% { transform: translate(-8px, 8px) scale(.85); } 60% { transform: translate(-50px, 40px) scale(.85); } }
@keyframes th-pinch-b { 0%, 100% { transform: translate(8px, -8px) scale(.85); } 60% { transform: translate(50px, -40px) scale(.85); } }

/* el brillo del tutorial, en los mandos */
#tpad .tut-glow { animation: tutglow .8s steps(2) infinite alternate; }

/* ---------- el armario: a pantalla completa, el personaje en grande sobre su pedestal y las prendas en tarjetas ---------- */
body.mobile #wardrobe { padding: 0; place-items: stretch; }
body.mobile .ward-card {
  width: 100%; max-height: none; height: 100%; margin: 0; padding: calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  display: flex; flex-direction: column; background: radial-gradient(ellipse at 18% 62%, color-mix(in srgb, var(--sky) 55%, var(--edge)) 0, var(--edge) 70%); color: var(--well);
}
body.mobile .ward-card h2 { position: absolute; margin: 0; font-size: 1.1rem; color: var(--well); text-shadow: 2px 2px 0 var(--ink); }
body.mobile .ward-body { flex: 1; min-height: 0; margin: 0; gap: 12px; flex-wrap: nowrap; align-items: stretch; }
/* (a la izquierda: el personaje de pie, sin marco, sobre su pedestal, y su nombre debajo) */
body.mobile .ward-side { width: 32%; min-width: 200px; margin: 0; padding-top: 22px; justify-content: center; gap: 6px; overflow-y: auto; }
body.mobile #ward-preview { width: auto; height: min(48vh, 200px); height: min(48svh, 200px); aspect-ratio: 144 / 192; box-shadow: none; }
body.mobile .ward-name { margin-top: 2px; color: var(--well); font-size: 1rem; font-weight: 700; text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink); }
body.mobile #ward-nudges, body.mobile #ward-search { display: none; }
body.mobile .ward-btns { flex-wrap: nowrap; gap: 6px; }
body.mobile .ward-btns .btn { min-height: 30px; padding: 2px 8px; font-size: .78rem; background: var(--sky); color: var(--ink); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 color-mix(in srgb, var(--sky) 55%, var(--ink)); }
body.mobile .ward-names .ward-label, body.mobile .ward-names small { color: color-mix(in srgb, var(--well) 70%, transparent); font-size: .65rem; }
body.mobile #ward-names input { font-size: .75rem; padding: 2px 4px; min-height: 26px; }
/* (a la derecha: las pestañas y los grupos, cada uno en una fila que se desliza; debajo, las tarjetas) */
body.mobile .ward-main { min-width: 0; gap: 6px; padding-bottom: 44px; }
body.mobile .ward-tabs, body.mobile .ward-cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 3px; }
body.mobile .ward-tabs::-webkit-scrollbar, body.mobile .ward-cats::-webkit-scrollbar { display: none; }
body.mobile .ward-tabs .btn { flex: none; min-height: 34px; padding: 3px 14px; background: color-mix(in srgb, var(--well) 18%, var(--edge)); color: var(--well); box-shadow: 0 0 0 3px var(--ink); }
body.mobile .ward-tabs .btn.on { background: var(--yellow); color: var(--ink); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 color-mix(in srgb, var(--yellow) 55%, var(--ink)); }
body.mobile .ward-filter { flex-wrap: nowrap; }
body.mobile .ward-cats .chip { flex: none; padding: 3px 10px; font-size: .75rem; background: color-mix(in srgb, var(--well) 12%, var(--edge)); color: var(--well); box-shadow: 0 0 0 2px var(--ink); }
body.mobile .ward-cats .chip.on { background: var(--leaf); color: var(--well); }
body.mobile .ward-grid { flex: 1; max-height: none; min-height: 0; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; padding: 4px; background: none; align-content: start; }
body.mobile .ward-tile { background: color-mix(in srgb, var(--sky) 35%, var(--well)); box-shadow: 0 0 0 3px var(--ink), inset 0 -5px 0 color-mix(in srgb, var(--sky) 45%, var(--ink)); padding: 4px 0 6px; }
body.mobile .ward-tile span { color: var(--ink); font-size: .6rem; }
body.mobile .ward-tile.on { background: var(--yellow); box-shadow: 0 0 0 3px var(--ink), inset 0 -5px 0 color-mix(in srgb, var(--yellow) 55%, var(--ink)); }
body.mobile .ward-empty { color: var(--well); }
/* (Listo, amarillo, abajo a la derecha) */
body.mobile .ward-card > .start-row { position: absolute; right: calc(10px + env(safe-area-inset-right)); bottom: calc(6px + env(safe-area-inset-bottom)); }
body.mobile #ward-done { min-height: 40px; min-width: 130px; font-size: 1.05rem; }
body.mobile .tbar .tpos { width: 10px; height: 10px; font-size: .45rem; margin-right: 0; }
