/* Pokémon — Red Summit Challenge. Consola GBA 3:2 (240x160 x3) + UI web fuera
   de la pantalla. Fuente pixelada vendored (OFL), sin suavizado.
   Press Start 2P: arcade clásica, letras y dígitos 0/6/8/9 muy distinguibles. */
@font-face {
  font-family: 'Press Start 2P';
  src: url('../assets/fonts/pressstart2p-400.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Press Start 2P';
  src: url('../assets/fonts/pressstart2p-400.ttf') format('truetype');
  font-weight: 700; font-display: swap;
}
:root {
  --bg: #20242c; --panel: #28324a; --panel2: #2f3d63;
  --ink: #eef2ff; --muted: #9fb0d8; --accent: #d62828; --accent2: #ffd166;
  --fr-cream: #f8f0d8; --fr-ink: #181818; --fr-border: #181818;
  --hp-green: #40c850; --hp-yellow: #f8c838; --hp-red: #f03838;
  --border: #3d4d7a; --bezel: #1a2430;
  --font-pixel: 'Press Start 2P', 'Courier New', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace; }
html { -webkit-text-size-adjust: 100%; }
/* Nunca scroll horizontal en móvil: el pad a sangre y la consola caben siempre. */
html, body { overflow-x: hidden; }
body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; }
#app { width: min(1080px, 100vw); padding: 12px; }
#app h1, #app h2, #app h3, #app .guide-heading { font-family: var(--font-pixel); letter-spacing: 1px; }
/* Barra superior fina (el héroe vive en la pantalla de título) */
header.game-head { display: flex; justify-content: center; align-items: baseline; gap: 12px;
  position: relative;
  padding: 10px 12px 14px; background: #101528; border: 3px solid #000; border-radius: 10px; }
header.game-head .donate { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; gap: 9px;
  font-family: var(--font-pixel); font-size: 14px; letter-spacing: .5px; color: #fff; text-decoration: none;
  text-shadow: 2px 2px 0 #7c1f1f; background: #ff5e5b; border: 3px solid #000; border-radius: 10px; padding: 8px 12px;
  box-shadow: 4px 4px 0 #000, inset 0 2px 0 rgba(255,255,255,.35);
  animation: donate-nudge 3.2s steps(2) infinite; }
header.game-head .donate svg { width: 24px; height: 24px; }
header.game-head .donate svg .steam { animation: donate-steam 1.1s steps(2) infinite; }
header.game-head .donate svg .s2 { animation-delay: .55s; }
header.game-head .donate:hover { background: #ff7673; }
header.game-head .donate:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; animation: none; }
@keyframes donate-nudge { 0%, 88%, 100% { transform: translateY(0); } 91%, 95% { transform: translateY(-3px); } }
@keyframes donate-steam { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (max-width: 640px) { header.game-head .donate { font-size: 13px; padding: 7px 10px; top: 8px; right: 8px; } header.game-head .donate svg { width: 22px; height: 22px; } }
@media (max-width: 1000px) {
  header.game-head { flex-direction: column; align-items: center; gap: 8px; }
  header.game-head .donate { position: static; animation: none; }
  header.game-head .sub { text-align: center; }
  header.game-head h1 { letter-spacing: 3px; }
}
@media (max-width: 480px) {
  .hero-alt { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { header.game-head .donate, header.game-head .donate svg .steam { animation: none; } }
header.game-head h1 { margin: 0; font-family: var(--font-pixel); font-weight: 700;
  font-size: clamp(28px, 6vw, 44px); letter-spacing: 2px; white-space: nowrap; line-height: 1;
  color: #ffd166;
  background: linear-gradient(180deg, #fff6d8 5%, #ffe9a8 28%, #ffd166 45%, #f4842b 55%, #d62828 72%, #ff6b6b 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  filter: drop-shadow(2px 3px 0 #000) drop-shadow(0 0 16px rgba(255,80,60,.35)); }
header.game-head .sub { color: var(--muted); font-size: 12px; text-align: right; }
/* Héroe de portada: noche de cima, nieve animada, retrato de Rojo + titular */
.screen.hero { position: relative; overflow: hidden; padding: clamp(18px, 4vw, 44px);
  background: linear-gradient(#0b1020 0 55%, #16233d 78%, #1d2f52 100%); }
.hero-snow { position: absolute; inset: -40px 0 0; pointer-events: none; opacity: .7;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 110px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 150px 60px, #dfe9f1 50%, transparent 51%),
    radial-gradient(2px 2px at 60px 150px, #fff 50%, transparent 51%);
  background-size: 160px 160px; animation: snowfall 9s linear infinite; }
@keyframes snowfall { from { transform: translate(0, 0); } to { transform: translate(-40px, 160px); } }
@media (prefers-reduced-motion: reduce) { .hero-snow { animation: none; } }
.hero-grid { position: relative; display: grid; grid-template-columns: 240px 1fr; gap: clamp(16px, 4vw, 48px);
  align-items: center; }
.hero-grid > * { min-width: 0; }
.hero-art { position: relative; margin: 0 auto; }
#hero-red { width: 240px; height: auto; image-rendering: pixelated; image-rendering: crisp-edges;
  filter: drop-shadow(0 10px 0 rgba(0,0,0,.4)); }
.hero-vs { position: absolute; right: 6px; bottom: 10px; background: var(--accent); color: #fff;
  border: 3px solid #000; border-radius: 10px; font-family: var(--font-pixel); font-weight: bold;
  font-size: 22px; padding: 2px 12px; box-shadow: 3px 3px 0 #000; transform: rotate(-6deg); }
.hero-kicker { color: var(--accent2); font-weight: bold; letter-spacing: 2px; font-size: 13px; margin: 0 0 6px; }
.hero-title { margin: 0 0 10px; font-size: clamp(26px, 4.5vw, 44px); line-height: 1.15; color: #fff;
  text-shadow: 3px 3px 0 #000; overflow-wrap: break-word; }
.hero-title span { color: #ff5b5b; }
.hero-sub { color: #c9d6ea; font-size: clamp(14px, 2vw, 17px); max-width: 56ch; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.hero-badges .badge { font-size: 14px; padding: 4px 12px; }
.hero-play { width: 100%; font-size: clamp(15px, 2vw, 19px) !important; padding: 16px 14px !important; margin: 4px 0 10px; white-space: normal; line-height: 1.5; }
.hero-alt { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feat-grid { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.feat { background: rgba(0,0,0,.35); border: 2px solid var(--border); border-radius: 10px; padding: 12px; }
.feat b { display: block; color: var(--accent2); font-family: var(--font-pixel); margin-bottom: 4px; letter-spacing: 1px; }
.feat span { color: var(--muted); font-size: 13px; }
.hero-help { margin-top: 14px; }
@media (max-width: 720px) {
  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero-badges, .hero-alt { justify-content: center; }
  #hero-red { width: 120px; }
  .feat-grid { grid-template-columns: 1fr; }
}
.screen { display: none; background: var(--panel); border: 4px solid var(--border);
  border-radius: 10px; padding: 14px; margin-top: 10px; box-shadow: 0 0 0 4px #000; }
.console { max-width: 752px; margin-left: auto; margin-right: auto; }
.screen.active { display: block; }
h2 { margin: 4px 0 10px; font-size: 20px; color: var(--accent2); }
p.small, .muted { color: var(--muted); font-size: 13px; }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 12px 0; }
button.px { background: var(--panel2); color: var(--ink); border: 3px solid #000;
  outline: 2px solid var(--border); border-radius: 8px; padding: 12px 10px; font: inherit;
  font-weight: bold; cursor: pointer; box-shadow: 3px 3px 0 #000; }
button.px:hover { background: #2e3d6e; transform: translate(-1px, -1px); }
button.px.primary { background: #b51f2e; outline-color: var(--accent2); }
button.px.green { background: #1d6b3c; }
button.px:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; padding: 2px 8px; border: 2px solid #000; border-radius: 20px;
  background: #0e1530; font-size: 12px; color: var(--accent2); }
/* Consola GBA: bisel + pantalla 3:2 que llena la columna (como DailyRed) */
.console { margin-top: 10px; }
.bezel { padding: 8px; background: var(--bezel); border-radius: 14px; }
.gscreen { position: relative; aspect-ratio: 3 / 2; width: 100%; overflow: hidden;
  border-radius: 6px; background: #000; line-height: 0;
  display: flex; align-items: center; justify-content: center; }
.gscreen canvas { position: static; flex: 0 0 auto;
  image-rendering: pixelated; image-rendering: crisp-edges; background: #000; }
/* Blindaje: el lienzo nunca desborda aunque el JS lo dimensione mal
   (pantalla oculta al medir, iframe estrecho); se conserva el 3:2. */
#screen-game .gscreen canvas { max-width: 100%; height: auto; }
/* (el diálogo del monte se eliminó con el overworld; el combate dibuja lo suyo en canvas) */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.button-quiet { font-family: var(--font-pixel); font-size: 15px; padding: 8px 14px; border-radius: 8px;
  background: transparent; color: var(--ink); border: 2px solid var(--border); cursor: pointer; }
.button-quiet:hover { border-color: var(--muted); }
/* Cruceta táctil + botones (solo puntero grueso; en escritorio manda el teclado).
   Contraste alto: teclas claras sobre fondo oscuro, siempre visibles. */
.pad { display: none; grid-template-columns: auto auto; justify-content: space-between;
  grid-template-areas: "dpad face" "meta meta";
  align-items: center; gap: 14px 10px; margin-top: 18px; padding: 14px 12px 8px;
  max-width: 100%;
  touch-action: none; user-select: none; -webkit-user-select: none; }
@media (pointer: coarse) { .pad { display: grid; } }
/* En táctil el pad queda pegado abajo: siempre a mano sin hacer scroll. */
@media (pointer: coarse) {
  #screen-game .pad {
    position: sticky; bottom: 0; z-index: 5;
    background: #141b36; border-top: 3px solid #000;
    margin: 14px -14px -14px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 10px 8px;
  }
}
/* (el pad táctil compacto vive junto a las reglas base, más abajo) */
.dpad { grid-area: dpad; position: relative; width: 144px; height: 144px; touch-action: none; }
.dpad-arm { position: absolute; width: 48px; height: 48px; background: var(--bezel); }
.dpad-up { left: 48px; top: 0; border-radius: 8px 8px 0 0; }
.dpad-down { left: 48px; bottom: 0; border-radius: 0 0 8px 8px; }
.dpad-left { left: 0; top: 48px; border-radius: 8px 0 0 8px; }
.dpad-right { right: 0; top: 48px; border-radius: 0 8px 8px 0; }
.dpad-center { left: 48px; top: 48px; }
.dpad[data-dir="up"] .dpad-up, .dpad[data-dir="down"] .dpad-down,
.dpad[data-dir="left"] .dpad-left, .dpad[data-dir="right"] .dpad-right { background: var(--accent); }
.face { grid-area: face; display: flex; gap: 16px; padding-right: 4px; }
.pad-button { width: 68px; height: 68px; border-radius: 50%; border: none;
  font: 700 24px/1 var(--font-pixel); color: #fff; background: var(--bezel); touch-action: none; }
.pad-a { transform: translateY(-22px); }
.pad-button.is-down, .pad-pill.is-down { background: var(--accent); }
.meta { grid-area: meta; display: flex; justify-content: center; gap: 20px; }
.pad-pill { padding: 8px 18px; border: none; border-radius: 999px;
  font: 600 15px/1 var(--font-pixel); color: #fff; background: #5a6c80; touch-action: none; }
/* Táctil: tamaño compacto + contraste alto (este bloque va DESPUÉS de las
   reglas base a propósito: el antiguo `@media ≤640px` nunca se aplicaba porque
   la cascada lo anulaba — de ahí el pad gigante que desbordaba en móvil). */
@media (pointer: coarse) {
  #screen-game .dpad { width: 114px; height: 114px; }
  #screen-game .dpad-arm { width: 38px; height: 38px; background: #2e3d6e; border: 2px solid #000; }
  #screen-game .dpad-up, #screen-game .dpad-down, #screen-game .dpad-center { left: 38px; }
  #screen-game .dpad-left, #screen-game .dpad-right { top: 38px; }
  #screen-game .face { gap: 12px; padding-right: 0; }
  #screen-game .pad-button { width: 60px; height: 60px; font-size: 20px; background: #2e3d6e;
    border: 3px solid #000; box-shadow: 2px 2px 0 #000; }
  #screen-game .pad-a { transform: translateY(-14px); }
  #screen-game .meta { gap: 14px; flex-wrap: wrap; }
  #screen-game .pad-pill { font-size: 13px; padding: 8px 14px; border: 2px solid #000; }
}
/* Móvil apaisado: aún más compacto para que pantalla + pad quepan sin scroll. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  #screen-game .console { max-width: min(100%, calc((100vh - 200px) * 1.5)); max-width: min(100%, calc((100dvh - 200px) * 1.5)); }
  #screen-game .bezel { padding: 5px; }
  #screen-game .pad { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  #screen-game .dpad { width: 102px; height: 102px; }
  #screen-game .dpad-arm { width: 34px; height: 34px; }
  #screen-game .dpad-up, #screen-game .dpad-down, #screen-game .dpad-center { left: 34px; }
  #screen-game .dpad-left, #screen-game .dpad-right { top: 34px; }
  #screen-game .pad-button { width: 52px; height: 52px; font-size: 18px; }
}
/* Guía de teclado + pie */
.guide { margin-top: 24px; padding-top: 16px; border-top: 2px solid var(--border); }
.guide-heading { margin: 0 0 8px; }
.keys { margin: 0; }
.keys div { display: grid; grid-template-columns: 12em 1fr; gap: 12px; align-items: baseline; padding: 4px 0; }
.keys dt { display: flex; flex-wrap: wrap; gap: 4px; }
.keys dd { margin: 0; color: var(--muted); }
.guide-note { color: var(--muted); font-size: 13px; }
/* Lista de días (un intento por día; jugados bloqueados con resultado) */
#day-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.day-row { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #0e1530; border: 2px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-size: 14px; }
.day-row.day-open { cursor: pointer; border-color: var(--accent2); }
.day-row.day-open:hover { background: #1a2340; }
.day-row.day-win { opacity: .75; border-color: #2e7d32; }
.day-row.day-loss { opacity: .75; border-color: #7d2e2e; }
.day-row.day-today { outline: 2px solid var(--accent2); }
/* La batalla se dibuja en #bv-canvas (js/ui/battleview.js); bajo la pantalla solo
   quedan el registro (historial) y el panel de datos/diagnóstico. */
/* (cajas PS y barras: ahora dibujadas en el canvas de batalla) */
/* (diálogo y menús de combate: ahora dibujados en el canvas de batalla) */
/* Registro fuera del flujo: cajón colapsable */
.log-drawer { margin-top: 8px; background: #0e1530; border: 2px dashed var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
.log-drawer summary { cursor: pointer; color: var(--muted); }
#battle-log { max-height: 220px; overflow-y: auto; padding: 8px 4px; font-size: 13px; }
.log-turn { color: var(--accent2); font-weight: bold; margin-top: 10px; letter-spacing: 1px; }
.log-dmg { color: var(--muted); margin-left: 14px; font-style: italic; }
/* Panel DATOS: dos columnas (tuyo | rival), filas etiqueta→valor legibles */
.data-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.data-card { background: #0e1530; border: 2px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.data-card h3 { margin: 0 0 6px; font-size: 15px; color: var(--accent2); }
.dr { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0;
  border-bottom: 1px dashed #2c3a5e; font-size: 13px; line-height: 1.35; }
.dr span { color: var(--muted); flex: 0 0 auto; }
.dr b { text-align: right; font-weight: bold; }
.dr.hl b { color: var(--accent2); font-size: 14px; }
.dr.dim b { color: var(--muted); font-weight: normal; font-size: 12px; }
@media (max-width: 640px) { .data-cols { grid-template-columns: 1fr; } }
/* (efectos, menús y paneles de combate: ahora dibujados en el canvas de batalla) */
/* Marco GBA: área de juego contenida, texto pixelado nítido */
#app { width: min(1120px, 100vw); }
.screen { max-width: 752px; margin-left: auto; margin-right: auto; }
#screen-game { max-width: none; }
/* Batalla: pantalla + lateral (registro y datos al lado, no debajo) */
.battle-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.battle-layout > * { min-width: 0; }
.battle-layout .console { max-width: none; }
.battle-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.battle-side .log-drawer { margin-top: 0; }
.battle-side #battle-log { max-height: 62vh; }
@media (max-width: 1020px) {
  .battle-layout { grid-template-columns: 1fr; }
  .battle-side #battle-log { max-height: 220px; }
}
#app, #app button { -webkit-font-smoothing: none; }
/* Sin retardo de doble-toque en botones (crucial en el iframe de itch.io). */
#app button, #app .pad-button, #app .pad-pill, #app .dpad-arm { touch-action: manipulation; }
#screen-game .pad, #screen-game .pad * { touch-action: none; }
/* Team builder */
.slot { background: #0e1530; border: 2px solid var(--border); border-radius: 8px; padding: 8px; margin: 8px 0; }
.slot h3 { margin: 0 0 6px; font-size: 15px; }
.slot .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px; }
select, input[type="text"], input[type="number"] { font: inherit; background: #fff; color: #111;
  border: 2px solid #000; border-radius: 6px; padding: 6px; width: 100%; }
label.f { font-size: 12px; color: var(--muted); display: block; margin: 4px 0; }
/* Summary */
table.sum { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
table.sum th, table.sum td { border: 1px solid var(--border); padding: 4px 6px; text-align: left; }
table.sum th { background: #0e1530; color: var(--accent2); }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 12px; }
.type-badge { padding: 1px 6px; border-radius: 10px; border: 1px solid #000; font-size: 11px; color: #fff; background: #666; }
.kbd { border: 1px solid var(--border); padding: 0 6px; border-radius: 4px; background: #000; }
@media (max-width: 640px) {
  .app { padding: 8px; }
  .bezel { padding: 5px; border-radius: 10px; }
}
/* Modo Draft: ternas de 3 cartas */
.draft-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.draft-card { background: #0e1530; border: 2px solid var(--border); border-radius: 8px;
  padding: 10px 6px; text-align: center; cursor: pointer; min-width: 0; }
.draft-card:hover { border-color: var(--accent2); background: #1a2340; }
.draft-card img { width: 96px; height: 96px; image-rendering: pixelated; }
.draft-card b { display: block; color: var(--accent2); font-family: var(--font-pixel); font-size: 14px; overflow-wrap: break-word; }
.draft-card span { color: var(--muted); font-size: 12px; }
.draft-card.covered b { font-size: 40px; }
#screen-draft { max-width: none; }
.draft-card img.pack { width: 190px; height: auto; max-height: 290px; object-fit: contain; }
.draft-card.covered:hover img.pack { filter: brightness(1.12); }
.draft-card.revealed { display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; min-height: 340px; }
.draft-card.revealed img { width: 170px; height: 170px; }
/* Equipo del draft: 6 cartas (siluetas que se rellenan) */
.draft-party { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 12px 0; }
.draft-slot { background: linear-gradient(#1a2340, #0e1530); border: 2px dashed var(--border);
  border-radius: 10px; min-height: 150px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 8px 4px; }
.draft-slot.empty b { font-size: 44px; color: var(--muted); font-family: var(--font-pixel); }
.draft-slot.empty span { color: var(--muted); font-size: 12px; }
.draft-slot.full { border: 2px solid var(--accent2); background: linear-gradient(#232f55, #141b36);
  box-shadow: 0 0 12px rgba(255,209,102,.25); }
.draft-slot.full img { width: 80px; height: 80px; image-rendering: pixelated; }
.draft-slot.full b { color: #fff; font-family: var(--font-pixel); font-size: 12px; overflow-wrap: break-word; max-width: 100%; }
.draft-slot.full span { color: var(--muted); font-size: 11px; }
.draft-card.breaking img.pack { animation: packshake .45s; }
@keyframes packshake {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-4deg) scale(1.05); }
  50% { transform: rotate(4deg) scale(1.08); }
  75% { transform: rotate(-2deg) scale(1.05); }
  100% { transform: rotate(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .draft-card.breaking img.pack { animation: none; } }
.draft-card.revealed { outline: 2px solid var(--accent2); }
.draft-card.revealed span { display: block; }
@media (max-width: 640px) {
  .draft-grid { grid-template-columns: 1fr; }
  .draft-card img { width: 72px; height: 72px; }
  .draft-card img.pack { width: 150px; max-height: 220px; }
  .draft-card.revealed { min-height: 0; }
  .draft-card.revealed img { width: 120px; height: 120px; }
  .draft-party { grid-template-columns: repeat(3, 1fr); }
}
