/* ============ DigiSurvivor — interfaz "Mundo Digital" ============
 * Cajas azul noche con doble borde, acento cian y una rejilla de datos muy
 * suave; dorado para lo importante. Fuente pixel local (Pixelify Sans, OFL).
 * (Base: la interfaz de PokéSurvivor, MIT.)
 */
/* Pixelify Sans con los números redibujados para que no se confundan (tools/make_font.py). */
@font-face {
  font-family: 'Pixelify';
  src: url('../assets/fonts/PixelifyPS-400.ttf') format('truetype');
  font-weight: 400 550;
  font-display: block;
}
@font-face {
  font-family: 'Pixelify';
  src: url('../assets/fonts/PixelifyPS-700.ttf') format('truetype');
  font-weight: 551 900;
  font-display: block;
}

:root {
  --ink: #ffffff;
  --muted: #a9c4ec;
  --box1: #17407f;
  --box2: #0b2153;
  --edge: #e6f7ff;
  --edge-in: #2fb5ee;      /* cian "digital" */
  --edge-out: #040b22;
  --cyan: #6fe3ff;
  --grid: rgba(111,227,255,.06);
  --gold: #ffd23f;
  --gold2: #f0a31e;
  --red: #ff5f6d;
  --green: #5fe08a;
  --shadow: #050d26;
  --r1: #9fb1c9; --r2: #5fe08a; --r3: #4fb4ff; --r4: #c47bff; --r5: #ffcb3d;
  --font: 'Pixelify', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: #030818;
  color: var(--ink);
  font: 16px/1.35 var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: none;
}
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
#game { display: block; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; }
button { font: inherit; color: inherit; }
input { font: inherit; }

/* ---------- capas de pantalla ---------- */
.scr {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .2s ease-out;
}
.scr.hidden { display: none; }
/* Pantallas que se abren con la barra superior a la vista: empiezan debajo de ella. */
@media (min-height: 521px) {
  #scr-goals, #scr-dex, #scr-upgrades, #scr-inc { padding-top: 66px; }
}
.scr.dim { background:
  repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 32px),
  repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 32px),
  radial-gradient(circle at 50% 40%, rgba(8,24,60,.55), rgba(2,6,18,.9)); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- cajas ---------- */
.box {
  position: relative;
  background:
    repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 24px),
    linear-gradient(180deg, var(--box1), var(--box2));
  border: 3px solid var(--edge);
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--edge-out), inset 0 0 0 2px var(--edge-in), 0 18px 50px rgba(0,0,0,.55);
  padding: 22px 24px;
  text-shadow: 2px 2px 0 var(--shadow);
  animation: pop .22s ease-out;
  max-height: 100%;
  overflow: auto;
}
.box h1, .box h2, .box h3 { margin: 0 0 6px; font-weight: 700; letter-spacing: .5px; }
.box h2 { font-size: 26px; }
.box h3 { font-size: 18px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.gold { color: var(--gold); }
.center { text-align: center; }

/* ---------- botones ---------- */
.btn {
  appearance: none; cursor: pointer;
  padding: 10px 20px;
  border: 3px solid var(--edge);
  border-radius: 9px;
  background: linear-gradient(180deg, #2f72cc, #163f8c);
  box-shadow: 0 0 0 2px var(--edge-out), 0 4px 0 var(--edge-out);
  font-size: 17px; font-weight: 700;
  text-shadow: 2px 2px 0 var(--shadow);
  transition: transform .06s, filter .12s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--edge-out), 0 2px 0 var(--edge-out); }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; transform: none; }
.btn.gold {
  background: linear-gradient(180deg, #ffe37a, #f0a31e);
  color: #3a2300; text-shadow: 1px 1px 0 rgba(255,255,255,.4);
  border-color: #fff7d6;
}
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(244,248,255,.35); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* Lista de menú con cursor (flecha pixel art) */
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  appearance: none; background: none; border: 0; cursor: pointer;
  text-align: left; padding: 8px 10px 8px 30px; border-radius: 6px;
  font-size: 22px; font-weight: 700; letter-spacing: .5px;
  text-shadow: 2px 2px 0 var(--shadow);
  position: relative;
}
.menu-item small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.menu-item::before {
  content: ''; position: absolute; left: 6px; top: 50%; margin-top: -12px; width: 16px; height: 24px;
  background: var(--ico-cursor) no-repeat center / contain; image-rendering: pixelated;
  opacity: 0; transition: opacity .1s, transform .1s; transform: translateX(-4px);
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(255,255,255,.08); outline: none; }
.menu-item:hover::before, .menu-item:focus-visible::before { opacity: 1; transform: none; }
.menu-item.play { font-size: 30px; color: var(--gold); }
.menu-item { display: grid; grid-template-columns: 34px 1fr; column-gap: 8px; align-items: center; }
.menu-item small { grid-column: 2; }
.mi-ico { grid-row: span 2; display: flex; }

/* ---------- formularios ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 8px; cursor: pointer; border-radius: 8px;
  background: rgba(0,0,0,.2); border: 2px solid transparent;
  text-align: center; font-weight: 700;
}
.tab.on { border-color: var(--edge); background: rgba(255,255,255,.1); }
label { display: block; font-size: 14px; color: var(--muted); margin: 8px 0 4px; }
.field {
  width: 100%; padding: 10px 12px;
  background: #0f1f4a; color: #fff;
  border: 2px solid var(--edge-in); border-radius: 8px;
  font-size: 17px; outline: none;
}
.field:focus { border-color: var(--edge); }
.err { color: #ffb0b8; min-height: 20px; font-size: 14px; margin: 8px 0 0; }
.note { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- pantalla de inicio ---------- */
.logo { text-align: center; margin-bottom: 18px; }
.logo h1.t1 { margin: 0; }
.logo .t1 { font-size: 46px; font-weight: 700; line-height: 1; color: var(--gold);
  text-shadow: 3px 3px 0 #a55f00, 6px 6px 0 var(--shadow); letter-spacing: 1px; }
.logo .t2 { font-size: 18px; color: var(--cyan); margin-top: 6px; letter-spacing: 3px; text-transform: uppercase;
  text-shadow: 0 0 10px rgba(111,227,255,.6), 2px 2px 0 var(--shadow); }

.stage {
  display: block; margin: 8px auto 6px;
  /* Recuadro: fondo oscuro y borde del color del tipo (--stage-c). */
  background:
    radial-gradient(ellipse at 50% 88%, rgba(120,170,255,.22), transparent 60%),
    linear-gradient(180deg, rgba(20,36,78,.88), rgba(8,14,34,.92));
  border: 3px solid var(--stage-c, #2fb5ee);
  border-radius: 14px;
  box-shadow: 0 0 0 3px #040b22, 0 10px 30px rgba(0,0,0,.45), inset 0 0 0 2px rgba(255,255,255,.06);
}
.stage.shiny { box-shadow: 0 0 0 3px #040b22, 0 0 22px rgba(154,230,255,.55), inset 0 0 0 2px rgba(255,255,255,.08); }

/* ---------- rejilla de la colección ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; max-height: 56vh; overflow-y: auto; padding: 4px;
}
.cell {
  position: relative; cursor: pointer; text-align: center;
  background: rgba(0,0,0,.2); border: 2px solid rgba(244,248,255,.18); border-radius: 10px;
  padding: 4px 2px 6px; transition: transform .08s, border-color .12s, background .12s;
}
.cell:hover { transform: translateY(-2px); border-color: var(--edge); background: rgba(255,255,255,.08); }
.cell.on { border-color: var(--gold); background: rgba(255,210,63,.14); }
.cell.locked { cursor: default; opacity: .75; }
.cell.locked:hover { transform: none; border-color: rgba(244,248,255,.18); }
.cell canvas { display: block; margin: 0 auto; }
.cell b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .no { position: absolute; top: 3px; left: 6px; font-size: 11px; color: var(--muted); }
.cell .stars { font-size: 10px; letter-spacing: -1px; }
.cell .partner { position: absolute; top: 3px; right: 5px; font-size: 12px; }

.wide { width: min(980px, 100%); }
.split { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
.panel {
  background: rgba(0,0,0,.2); border: 2px solid rgba(244,248,255,.2); border-radius: 10px; padding: 14px;
}
.stat { display: grid; grid-template-columns: 90px 1fr 34px; gap: 8px; align-items: center; font-size: 14px; margin: 5px 0; }
.stat .bar { height: 8px; background: rgba(0,0,0,.35); border-radius: 6px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--gold); }
.type {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700;
  color: #10131a; text-shadow: none; margin-right: 4px;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  appearance: none; cursor: pointer; padding: 4px 10px; border-radius: 20px;
  background: rgba(0,0,0,.25); border: 2px solid rgba(244,248,255,.25); font-size: 13px;
  text-shadow: 1px 1px 0 var(--shadow);
}
.chip.on { border-color: var(--gold); color: var(--gold); }

/* ---------- menú principal ---------- */
#scr-menu { justify-content: space-between; align-items: stretch; padding: 0; }
.menu-left {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 30px; min-width: 0;
}
.menu-left .logo .t1 { font-size: clamp(36px, 6vw, 64px); }
.partner-card { text-align: center; margin-top: 10px; }
/* El compañero del menú, dentro de un Digivice (T-110): carcasa de dos tonos y botones a la derecha. */
.partner-card .stage#menu-partner {
  border-radius: 26px;
  box-shadow: 0 0 0 7px #0d2456, 0 0 0 9px rgba(111,227,255,.6), 0 0 0 12px #040b22, 0 14px 34px rgba(0,0,0,.5);
}
.partner-card .dv { position: relative; display: inline-block; margin: 8px 0 12px; }
.partner-card .dv .stage { margin: 0; }
.partner-card .dv-btns { position: absolute; right: -30px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
.partner-card .dv-btns i { display: block; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe37a, #c08a10);
  box-shadow: 0 0 0 2px #040b22; }
.partner-card .nm { font-size: 24px; font-weight: 700; text-shadow: 3px 3px 0 var(--shadow); }
.partner-card .lv { color: var(--muted); font-size: 14px; text-shadow: 2px 2px 0 var(--shadow); }
.menu-right {
  width: min(380px, 100%); display: flex; flex-direction: column;
  /* Arriba deja sitio a la barra superior; si no cabe todo, se desplaza
     (los márgenes auto lo centran sin que se salga por arriba). */
  padding: 70px 24px 18px; gap: 14px; overflow-y: auto;
  background: linear-gradient(90deg, transparent, rgba(5,10,25,.65) 30%);
}
.menu-right > :first-child { margin-top: auto; }
.menu-right > :last-child { margin-bottom: auto; }
/* Portátiles con poca altura: menú más compacto y, si hace falta, en dos columnas. */
@media (max-height: 780px) and (min-height: 521px) {
  .menu-right { padding-top: 62px; gap: 10px; }
  .menu-right .box { padding: 10px 14px; }
  .menu-item { font-size: 17px; padding: 5px 10px; }
  .menu-item.play { font-size: 24px; }
  .menu-item small { font-size: 11px; }
}
@media (max-height: 660px) and (min-height: 521px) {
  .menu-right { width: min(500px, 52vw); }
  .menu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; }
  .menu-item.play { grid-column: span 2; }
  .menu-item small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-left .logo .t1 { font-size: clamp(32px, 5vw, 52px); }
  #menu-partner { height: min(30vh, 200px); width: auto; }
}
.topbar {
  position: fixed; top: 14px; right: 16px; z-index: 25;
  display: flex; gap: 10px; align-items: center;
}
.pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 30px;
  background: rgba(10,20,50,.85); border: 2px solid var(--edge);
  box-shadow: 0 0 0 2px var(--edge-out);
  font-weight: 700; text-shadow: 2px 2px 0 var(--shadow);
}
.coin {
  display: inline-block; width: 18px; height: 18px; vertical-align: -3px;
  background: var(--ico-coin) no-repeat center / contain; image-rendering: pixelated;
}
.credits-line {
  position: fixed; left: 14px; bottom: 10px; z-index: 25; font-size: 12px; color: rgba(185,203,240,.7);
  text-shadow: 1px 1px 0 #000;
}

/* ---------- mejoras ---------- */
.upg { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.upg-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.upg-item .ic { font-size: 26px; text-align: center; }
.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips i { width: 12px; height: 6px; border-radius: 2px; background: rgba(0,0,0,.4); }
.pips i.on { background: var(--gold); }

/* Newsletter (js/ui/news.js): aviso al acabar la run y en el menú, y su ventana. */
.news-ask { position: relative; margin-top: 8px; padding: 10px 30px; border-radius: 10px; text-align: center;
  background: rgba(255,210,63,.1); border: 2px solid rgba(255,210,63,.5); }
.menu-right .news-ask { margin: 0; background: rgba(26,49,112,.92); }
.news-ask p { margin: 0 0 8px; font-size: 14px; color: var(--ink); line-height: 1.35; }
.news-ask .x { position: absolute; top: 2px; right: 4px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 2px 6px; }
.news-never { display: block; margin: 6px auto 0; background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px;
  text-decoration: underline; cursor: pointer; }
#scr-news { z-index: 66; }
/* Compartir la run (js/ui/share.js). */
.over-btns { justify-content: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
/* Pantalla de muerte (T-147): las estadísticas hacen scroll y «Otra vez»/«Menú» quedan siempre a la vista,
 * aunque el aviso de newsletter ocupe sitio (antes los tapaba en pantallas bajas). */
#scr-over .box { display: flex; flex-direction: column; overflow: hidden; }
#scr-over .over-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-bottom: 8px; }
#scr-over .news-ask { margin-top: 0; padding: 6px 28px; }
#scr-over .news-ask p { font-size: 13px; margin: 0 0 6px; }
#scr-over .over-btns, #scr-over .kbd-hint { flex: none; }
#btn-share:disabled { opacity: .5; }
#scr-share { z-index: 66; }
.share-img { display: block; width: 100%; height: auto; margin: 8px 0 12px; border-radius: 8px; border: 2px solid var(--edge-in); image-rendering: auto; }
.share-btns { justify-content: center; gap: 8px; flex-wrap: wrap; }   /* por delante del fin de run y del aviso legal */
.news-intro { margin: 4px 0 10px; font-size: 14px; color: var(--muted); line-height: 1.4; }
.news-note { margin: 0 0 8px; font-size: 13px; color: var(--gold); }
.news-form { display: flex; flex-direction: column; gap: 8px; }
.news-form input[type=email] { font: 16px system-ui, sans-serif; padding: 9px 12px; border-radius: 8px; border: 2px solid var(--edge-in);
  background: #0d1a3d; color: var(--ink); width: 100%; }
.news-form input[type=email]:focus { outline: none; border-color: var(--gold); }
.news-form .chk { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.35; text-align: left; cursor: pointer; }
.news-form .chk input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--gold); }
.news-form .btn { align-self: center; }
.news-msg { margin: 0; min-height: 1.2em; font-size: 13px; text-align: center; color: var(--muted); }
.news-msg.bad { color: var(--red); }
.news-fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.news-fine a { color: #9fd4ff; }
.news-gift { margin: 0; font-size: 13px; color: var(--gold); text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; }
.news-done { margin: 8px 0; font-size: 15px; color: var(--green); text-align: center; line-height: 1.4; }

/* ---------- cartas de nivel ---------- */
.cards { display: flex; flex-direction: column; gap: 10px; width: min(560px, 100%); }
/* Digivolución: una columna por forma, con su sprite grande */
.digi-box { width: min(760px, 100%); }
.digi-title { color: #7fe0ff; text-shadow: 0 0 12px rgba(127,224,255,.6); }
.cards.digi-cards { flex-direction: row; justify-content: center; width: 100%; }
.card.digi { flex: 1 1 0; max-width: 220px; flex-direction: column; align-items: center; gap: 6px; padding: 8px 8px 10px;
  border-color: rgba(127,224,255,.45); text-align: center; position: relative; }
.card.digi:hover { transform: translateY(-4px); }
.card.digi canvas { width: 150px; height: 140px; max-width: 100%; border-radius: 10px; background: rgba(127,224,255,.08); }
.card.digi .nm { font-size: 18px; font-weight: 700; }
.card.digi .key { position: absolute; top: 6px; right: 8px; }
@media (max-height: 430px) { .card.digi canvas { height: 104px; } }
.card {
  display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  background: rgba(0,0,0,.2); border: 2px solid rgba(244,248,255,.3); border-radius: 12px;
  padding: 12px 14px; transition: transform .08s, background .12s, border-color .12s;
}
.card:hover { background: rgba(255,255,255,.1); border-color: var(--edge); transform: translateX(4px); }
.card .ico { flex: 0 0 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; }
.card .txt { flex: 1; }
.card .nm { font-weight: 700; font-size: 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card .ds { color: var(--muted); font-size: 14px; }
.card .key { font-size: 13px; color: var(--muted); border: 2px solid rgba(244,248,255,.3); border-radius: 6px; padding: 2px 8px; }
.tag-chip { font-size: 11px; padding: 2px 7px; border-radius: 5px; color: #10131a; text-shadow: none; font-weight: 700; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 18px; }
.stats > div { background: rgba(0,0,0,.22); border-radius: 9px; padding: 8px 10px; }
.stats > div > span:first-child { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.stats b { font-size: 22px; }

kbd {
  display: inline-block; padding: 0 6px; border: 2px solid rgba(244,248,255,.4); border-bottom-width: 3px;
  border-radius: 5px; font: inherit; font-size: 13px; text-shadow: none;
}

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 60;
  padding: 10px 18px; border-radius: 10px;
  background: rgba(10,20,50,.95); border: 2px solid var(--edge);
  text-shadow: 2px 2px 0 var(--shadow); animation: pop .2s ease-out;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: rgba(244,248,255,.3); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) and (min-height: 521px) {
  #scr-menu { flex-direction: column; overflow-y: auto; }
  .menu-right { width: 100%; background: rgba(5,10,25,.7); }
  .split { grid-template-columns: 1fr; }
  .logo .t1 { font-size: 34px; }
}

/* ============ iconos pixel art ============ */
img.pix { image-rendering: pixelated; image-rendering: crisp-edges; vertical-align: middle; }
.badge-r { position: absolute; top: 3px; right: 4px; }
.move-icons { display: flex; flex-wrap: wrap; gap: 3px; margin: 0 0 10px; }
.card .ico img { display: block; }
.upg-item .ic { display: flex; justify-content: center; }

/* ============ pestañas de generación ============ */
.gen-tabs { display: flex; gap: 5px; overflow-x: auto; padding: 4px 2px 8px; margin-top: 6px; }
.gen-tab {
  appearance: none; cursor: pointer; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
  padding: 6px 12px; border-radius: 9px;
  background: rgba(0,0,0,.25); border: 2px solid rgba(244,248,255,.22);
  text-shadow: 2px 2px 0 var(--shadow);
}
.gen-tab b { font-size: 15px; }
.gen-tab small { font-size: 11px; color: var(--muted); }
.gen-tab:hover { border-color: var(--edge); }
.gen-tab.on { border-color: var(--gold); background: rgba(255,210,63,.14); }
.gen-tab.on b { color: var(--gold); }

/* ============ normal / shiny ============ */
.seg { display: flex; justify-content: center; gap: 0; margin: 2px auto 8px; width: max-content;
  border: 2px solid rgba(244,248,255,.35); border-radius: 9px; overflow: hidden; }
.seg button { appearance: none; cursor: pointer; background: rgba(0,0,0,.25); border: 0;
  padding: 5px 14px; font-size: 14px; display: flex; gap: 5px; align-items: center;
  text-shadow: 2px 2px 0 var(--shadow); }
.seg button.on { background: rgba(154,230,255,.22); color: #c9f3ff; }
.caught > span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.caught-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.caught-row > div { text-align: center; }
.caught-row small { display: block; font-size: 12px; color: #c9f3ff; }

/* ============ sonido ============ */
.sound-panel { position: fixed; top: 62px; right: 16px; z-index: 30; width: 270px; padding: 14px 16px; }
.sound-inline { margin: 6px auto 16px; max-width: 320px; }
.snd-row { display: grid; grid-template-columns: 20px 64px 1fr; gap: 8px; align-items: center; margin-bottom: 10px; font-size: 14px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 8px;
  background: rgba(0,0,0,.4); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 4px;
  background: var(--gold); border: 2px solid #fff7d6; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 4px; background: var(--gold); border: 2px solid #fff7d6; }
#btn-sound { padding: 5px 9px; display: flex; }
.btn-lang { font-weight: 700; letter-spacing: 1px; min-width: 38px; }
.lang-corner { position: absolute; top: 14px; right: 16px; z-index: 2; }
@media (max-height: 520px) { .lang-corner { top: 10px; right: 18px; } }

/* ============ nube, aviso legal ============ */
.legal-link { color: var(--muted); }
.legal-link:hover { color: #fff; }
.credits-line a { color: inherit; }
.legal h3 { margin: 14px 0 4px; color: var(--gold); font-size: 17px; }
.legal p { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.legal a { color: #9fd4ff; }
#scr-legal { z-index: 65; }   /* por delante de Ajustes (60) */
.boot { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  background: #030818; color: var(--muted); font-size: 18px; }

/* ---------- huevos y mejoras de cada compañero ---------- */
#tickets-pill img { vertical-align: middle; }
.upg-head { display: flex; gap: 14px; align-items: center; margin: 6px 0 12px; }
.upg-head .stage { width: 120px; height: 96px; flex: 0 0 120px; }
select.field { font-family: var(--font); }

/* ---------- misiones, logros y objetos ---------- */
.goals-body { max-height: 62vh; overflow-y: auto; padding-right: 6px; }
.goals-h { margin: 6px 0 4px; }
.goals-h h3 { margin: 0; }
.mission {
  display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center;
  padding: 10px 12px; margin-bottom: 6px; border-radius: 8px;
  background: rgba(0,0,0,.22); border: 2px solid rgba(244,248,255,.14);
}
.mission.ready { border-color: var(--gold); background: rgba(255,210,63,.1); }
.mission.claimed { opacity: .55; }
.mission small, .ach small { color: var(--muted); font-size: 12px; }
.mission .bar, .ach .bar { height: 7px; background: rgba(0,0,0,.4); border-radius: 6px; overflow: hidden; margin: 4px 0 2px; }
.mission .bar i, .ach .bar i { display: block; height: 100%; background: var(--gold); }
.m-rw, .a-rw { font-size: 13px; color: var(--ink); }
.m-rw img, .a-rw img, .tag-chip img { vertical-align: middle; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.ach {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px;
  background: rgba(0,0,0,.2); border: 2px solid rgba(244,248,255,.1);
}
.ach.ok { border-color: rgba(255,210,63,.6); }
.ach .a-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.leg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.leg-cell { display: flex; flex-direction: column; align-items: center; padding: 4px; border-radius: 8px; background: rgba(0,0,0,.25); border: 2px solid transparent; }
.leg-cell.ok { border-color: rgba(255,210,63,.5); }
.leg-cell small { font-size: 10px; color: var(--muted); text-align: center; }
.ach-pop {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 80;
  display: flex; gap: 10px; align-items: center; padding: 10px 16px; animation: pop .2s ease-out;
  border-color: var(--gold) !important;
}
.ach-pop b { display: block; color: var(--gold); }
.ach-pop small { color: var(--muted); }
.card.evo { border-color: var(--gold); background: linear-gradient(90deg, rgba(255,210,63,.18), rgba(255,210,63,.04)); }
.card.evo .nm { color: var(--gold); }
/* Técnica de firma y Datos legendarios en las cartas (ADR-021). */
.card.sig { border-color: #ffd23f; }
/* Resumen: daño de cada ataque (T-113). */
.dmg-list { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; text-align: left; }
.dmg-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; gap: 8px; align-items: center; font-size: 13px; }
.dmg-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dmg-row .nm img { vertical-align: middle; }
.dmg-row small { color: var(--muted); }
.dmg-row i { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--c) var(--w), rgba(0,0,0,.4) var(--w)); }
.dmg-row b { font-size: 12px; white-space: nowrap; }
#menu-partner-info .aff { font-size: 12px; color: var(--gold); margin-top: 3px; }
.card.digi .tech { font-size: 12px; color: var(--gold); margin-top: 2px; }
.card.digi .tech img { vertical-align: middle; }
#lvl-box.legend h2 { color: #ff8ad8; }
#lvl-box.legend .card { border-color: rgba(255,138,216,.6); background: linear-gradient(90deg, rgba(255,138,216,.16), rgba(255,138,216,.03)); }
@media (max-width: 760px) { .mission { grid-template-columns: 1fr; }}

/* ================= móvil y táctil ================= */
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
body { touch-action: manipulation; }
/* iPhone: sin esto, mantener el dedo en el joystick sacaba "Copiar / Seleccionar
   todo" (Safari sólo hace caso a la versión -webkit- y no lo hereda bien). */
body, body * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* Con táctil no tienen sentido las pistas de teclas. */
body.touch kbd, body.touch .card .key, body.touch .kbd-hint { display: none !important; }
#rotate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 10, 30, .94);
}
#rotate.hidden { display: none; }
#rotate .box { max-width: 320px; }
#rotate-ico { animation: rot-hint 1.6s steps(4) infinite; display: inline-block; }
@keyframes rot-hint { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); } }

/* ---------- ajustes ---------- */
#scr-settings { z-index: 60; }
.box.settings { width: min(640px, 100%); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; }
.set-body { overflow-y: auto; padding-right: 4px; min-height: 0; }
#set-tabs { flex-wrap: wrap; }
#set-tabs .gen-tab { padding: 6px 12px; }
.set-h { color: var(--gold); font-size: 17px; margin: 14px 0 6px; }
.set-h:first-child { margin-top: 4px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.set-row b { display: block; }
.set-row small { display: block; color: var(--muted); font-size: 12px; }
.set-row .switch { min-width: 58px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.set-chips { margin: 6px 0 10px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; font-size: 14px; }
.keys span { color: var(--muted); }
.credits { margin: 4px 0 12px; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.credits b { color: var(--ink); }
.about-logo { text-align: center; font-size: 34px; font-weight: 700; color: var(--gold); text-shadow: 2px 2px 0 #a55f00, 4px 4px 0 var(--shadow); margin-top: 6px; }
.btn.danger { background: #8a1f2e; border-color: #ff8a96; }
.row.wrap { flex-wrap: wrap; }
.touch-hint { display: none; }
body.touch .touch-hint { display: block; }
#pause-sound + .row, #scr-pause .row { flex-wrap: wrap; }
a.btn { text-decoration: none; display: inline-block; color: var(--ink); }

/* ================= pantallas bajas (móvil en horizontal) =================
 * Todo más compacto: la barra superior deja sitio, el menú va en dos
 * columnas y la línea de créditos se esconde (está en Ajustes → Acerca de). */
@media (max-height: 520px) {
  .scr { padding: 50px 10px 6px; }
  /* Sin barra superior encima: no hace falta dejarle hueco. */
   #scr-starters, #scr-levelup, #scr-pause,
  #scr-over, #scr-item, #scr-settings, #scr-legal { padding: 6px 10px; }
  .split { grid-template-columns: 1fr; }
  .logo .t1 { font-size: 30px; }
  .box { padding: 10px 14px; border-radius: 10px; }
  .box h2 { font-size: 20px; }
  .box h3 { font-size: 16px; }
  .sub { font-size: 13px; margin-bottom: 8px; }
  .note { margin-top: 8px; font-size: 12px; }
  .btn { padding: 7px 14px; }
  .btn.small { padding: 4px 9px; font-size: 13px; }
  .topbar { top: 5px; right: 6px; gap: 5px; }
  .pill { padding: 2px 8px; font-size: 13px; gap: 5px; }
  .topbar .btn.small { padding: 2px 6px; }
  .credits-line { display: none !important; }
  .sound-panel { top: 40px; }

  #scr-menu { flex-direction: row; padding: 0; overflow: hidden; }
  .menu-left { padding: 50px 8px 6px; }
  .menu-left .logo { margin-bottom: 2px; }
  .menu-left .logo .t1 { font-size: 28px; }
  .logo .t2 { font-size: 10px; margin-top: 2px; letter-spacing: 2px; }
  #menu-partner { height: min(34vh, 130px); width: auto; }
  .partner-card { margin-top: 2px; }
  .partner-card .nm { font-size: 17px; }
  .partner-card .lv { font-size: 12px; }
  .menu-right { width: min(54vw, 420px); padding: 50px 8px 6px; gap: 6px; justify-content: flex-start; overflow-y: auto; }
  .menu-right .box { padding: 6px 8px; }
  .menu-right > .box:last-child { display: none; }
  .menu-right > :first-child { margin-top: 0; }
  .ach-pop { top: auto; bottom: 8px; }
  .menu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 4px; }
  .menu-item { font-size: 15px; padding: 4px 6px; grid-template-columns: 22px 1fr; column-gap: 6px; }
  .menu-item small { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-item.play { grid-column: span 2; font-size: 21px; }
  .menu-item::before { display: none; }
  .mi-ico img { width: 20px; height: 20px; }
  .box.settings { max-height: calc(100dvh - 12px); }
}
/* Móviles muy bajos (iPhone SE y similares): sin subtítulos en el menú, para que quepa entero. */
@media (max-height: 400px) {
  .menu-right { padding-top: 48px; }
  .menu-item small { display: none; }
  .menu-item { font-size: 14px; padding: 5px 6px; }
  .menu-item.play { font-size: 19px; }
  .menu-item.play small { display: block; }
  #menu-partner { height: min(30vh, 110px); }
}

/* ---------- pantalla de carga (lo primero que se ve y lo que lee Google) ---------- */
.boot-in { text-align: center; padding: 20px; max-width: 640px; }
.boot-in h1 { margin: 0 0 8px; font-size: clamp(38px, 8vw, 64px); color: var(--gold); text-shadow: 3px 3px 0 #a55f00, 6px 6px 0 var(--shadow); font-weight: 700; }
.boot-in p { margin: 6px 0; color: var(--muted); }
.boot-in a { color: #9fd4ff; }
.boot-ld { color: #fff; margin-top: 18px !important; }
.boot.noscript { z-index: 90; }
/* "Pulsa para empezar": encima de todo, se ve el mundo de fondo. */
.tapstart { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(5,9,20,.35), rgba(5,9,20,.8)); animation: fade .4s; }
.tapstart .boot-in p { color: #dfe7ff; text-shadow: 2px 2px 0 #000; }
.tapstart .logo { margin-bottom: 10px; }
.tapstart .logo .t1 { font-size: clamp(40px, 9vw, 72px); }
.tapstart .logo .t2 { font-size: clamp(13px, 2.6vw, 20px); }
.tapstart .boot-in p.tap-tag { color: var(--muted); font-size: clamp(14px, 2.4vw, 18px); margin: 4px 0 26px; }
/* Botón de Digivice: marco cian, fondo azul noche y una flecha dorada que late. */
.tap-btn { display: inline-flex; align-items: center; gap: 12px; padding: 12px 26px; font-size: 20px; color: #fff;
  background: linear-gradient(var(--box1), var(--box2)); border: 2px solid var(--edge-in); border-radius: 12px;
  box-shadow: 0 0 0 2px var(--edge-out), inset 0 0 0 1px rgba(230,247,255,.35), 0 0 22px rgba(111,227,255,.35);
  text-shadow: 2px 2px 0 var(--shadow); animation: tap-glow 1.6s ease-in-out infinite; }
.tap-arrow { width: 0; height: 0; border: 8px solid transparent; border-left: 13px solid var(--gold); border-right: 0;
  animation: tap-nudge 1.6s ease-in-out infinite; }
@keyframes tap-glow { 50% { box-shadow: 0 0 0 2px var(--edge-out), inset 0 0 0 1px rgba(230,247,255,.35), 0 0 34px rgba(111,227,255,.7); } }
@keyframes tap-nudge { 50% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .tap-btn, .tap-arrow { animation: none; } }

/* Mejoras: botones y veto */
.upg-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ban-picker { grid-column: 1 / -1; }
.bind-panel { grid-column: 1 / -1; }
.bind-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bind-slot { display: flex; align-items: center; gap: 6px; margin: 0; }
.bind-slot span { font-weight: 700; color: var(--gold); min-width: 14px; }
.bind-slot select { width: 100%; min-width: 0; }
@media (max-width: 760px) { .bind-slots { grid-template-columns: repeat(2, 1fr); } }
.ban-moves { display: flex; flex-wrap: wrap; gap: 6px; }
.ban-moves .chip { display: inline-flex; align-items: center; gap: 5px; }
.ban-moves .chip.ban { background: rgba(255,95,109,.25); border-color: #ff5f6d; color: #ffd3d8; text-decoration: line-through; }
/* ============ Colección en móvil horizontal ============
 * La lista a la izquierda y la ficha (con "Elegir de compañero") a la derecha,
 * siempre a la vista: antes la ficha quedaba debajo de la lista y había que
 * bajar hasta el borde para encontrar el botón. */
@media (max-height: 520px) {
  #scr-dex .box { height: 100%; display: flex; flex-direction: column; padding: 8px 10px; }
  #scr-dex .gen-tabs { margin-top: 2px; padding-bottom: 4px; flex: 0 0 auto; }
  #scr-dex .split { grid-template-columns: 1fr minmax(190px, 36%); gap: 8px; flex: 1; min-height: 0; margin-top: 2px !important; }
  #scr-dex .split > div:first-child { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  #scr-dex .gen-tabs, #scr-dex .filters { scrollbar-width: none; }
  #scr-dex .gen-tabs::-webkit-scrollbar, #scr-dex .filters::-webkit-scrollbar { display: none; }
  #scr-dex .filters { flex-wrap: nowrap; overflow-x: auto; margin-bottom: 4px; flex: 0 0 auto; }
  #scr-dex .chip { flex: 0 0 auto; padding: 2px 8px; font-size: 12px; }
  #scr-dex .grid { max-height: none; flex: 1; min-height: 0; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 5px; }
  #scr-dex .cell canvas { width: 69px; height: 60px; }
  #scr-dex .cell b { font-size: 11px; }
  #dex-detail { min-height: 0; overflow-y: auto; padding: 6px 8px; display: flex; flex-direction: column; }
  #dex-detail .stage { width: 132px; height: 114px; margin: 2px auto 4px; }
  #dex-detail h3 { margin: 0; }
  #dex-detail .stat { grid-template-columns: 62px 1fr 34px; gap: 4px; font-size: 12px; margin: 2px 0; }
  #dex-detail p { margin: 4px 0 !important; font-size: 12px !important; }
  #dex-detail .move-icons { margin-bottom: 4px; }
  /* El botón de elegir, pegado abajo de la ficha: se ve aunque la ficha no quepa. */
  #dex-detail .btn { position: sticky; bottom: 0; order: 9; margin-top: auto; padding: 8px 6px; font-size: 15px;
    box-shadow: 0 -6px 10px rgba(5,10,25,.6); }
}

/* Sin ligaduras: la "fi" de la fuente pixel parecía una "A" (ver tools/make_font.py). */
body { font-variant-ligatures: none; font-feature-settings: "liga" 0, "dlig" 0; }

/* ============ Incubadora (T-061) ============ */
.inc-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.inc-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.inc-slot small { color: var(--muted); font-size: 12px; line-height: 1.25; }
.inc-slot .btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.inc-slot.ready { border-color: var(--gold); background: rgba(255,210,63,.1); }
.inc-egg { height: 80px; display: flex; align-items: flex-end; justify-content: center;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
.inc-egg.empty { opacity: .22; filter: grayscale(1) brightness(1.4); }
.inc-egg.bob img { animation: inc-bob 2.4s ease-in-out infinite; }
.inc-egg.shake img { animation: inc-shake .9s steps(6) infinite; transform-origin: 50% 90%; }
.inc-egg.shake.hard img { animation-duration: .35s; }
@keyframes inc-bob { 50% { transform: translateY(-4px); } }
@keyframes inc-shake { 0%, 50%, 100% { transform: rotate(0); } 15% { transform: rotate(-9deg); } 30% { transform: rotate(8deg); } 40% { transform: rotate(-4deg); } }
.inc-bar { width: 100%; height: 8px; background: rgba(0,0,0,.35); border-radius: 6px; overflow: hidden; }
.inc-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), #9ae6ff); }
.inc-slot.ready .inc-bar i { background: var(--gold); }
.inc-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.inc-foot small { color: var(--muted); font-size: 12px; }
.inc-have { font-size: 20px; margin: 6px 0; display: flex; align-items: center; gap: 6px; }
.inc-code .field { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 1px;
  font-family: Consolas, "Courier New", monospace; font-weight: 700; }   /* la letra pixel confunde 2/Z y 5/S */
.inc-msg { min-height: 18px; margin: 6px 0 0; font-size: 13px; color: var(--gold); }
.inc-msg.bad { color: #ffb0b8; }
.inc-news { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.inc-news a { color: #9fd4ff; }
/* Eclosión: encima de la pantalla, el huevo tiembla, destello blanco y sale el Digimon. */
.inc-reveal { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,40,90,.92), rgba(4,8,22,.97)); cursor: pointer; }
.inc-reveal .inc-egg.big { height: 170px; }
.inc-reveal.flash::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(111,227,255,.5), rgba(111,227,255,.18) 55%, rgba(111,227,255,0) 80%);
  animation: inc-flash .6s ease-out forwards; }       /* destello cian suave, nunca blanco a pantalla llena (T-135) */
@keyframes inc-flash { from { opacity: 1; } to { opacity: 0; } }
.inc-card { text-align: center; cursor: default; padding: 10px; animation: fade .4s; }
.inc-card h2 { margin: 4px 0; }
.inc-kicker { font-size: 18px; margin: 0 0 4px; }
@media (max-width: 760px) {
  .inc-foot { grid-template-columns: 1fr; }
}
@media (max-height: 520px) {
  #scr-inc .box { padding: 8px 10px; max-height: 100%; overflow-y: auto; }
  #scr-inc .sub { margin-bottom: 4px; }
  .inc-slots { gap: 6px; }
  .inc-slot { padding: 6px; gap: 3px; }
  .inc-egg { height: 52px; }
  .inc-egg img { width: 48px; height: 48px; }
  .inc-foot { grid-template-columns: 1fr 1fr; margin-top: 6px; gap: 6px; }
  .inc-foot .panel { padding: 6px 8px; }
  .inc-have { font-size: 16px; margin: 2px 0; }
  .inc-reveal .inc-egg.big { height: 120px; }
  .inc-reveal .inc-egg.big img { width: 110px; height: 110px; }
  #inc-mon { width: 150px; height: 130px; margin: 2px auto; }
  .inc-card h2 { font-size: 20px; margin: 0; }
}
/* El huevo enseña su elemento: halo del color del tipo. */
.inc-slot.busy .inc-egg, .inc-slot.ready .inc-egg { filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)) drop-shadow(0 0 10px var(--egg-c, transparent)); }
.inc-type { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.inc-type .type { margin: 0; }

/* ---------- botón Newsletter del menú: el regalo de bienvenida llama la atención ---------- */
.menu-item.news.gift { background: linear-gradient(90deg, rgba(255,210,63,.16), rgba(255,210,63,.04)); box-shadow: inset 0 0 0 2px rgba(255,210,63,.45); animation: news-glow 1.8s ease-in-out infinite; }
.menu-item.news.gift .mi-ico { animation: news-bob 1.8s ease-in-out infinite; }
@keyframes news-glow { 50% { box-shadow: inset 0 0 0 2px rgba(255,210,63,.95), 0 0 14px rgba(255,210,63,.45); } }
@keyframes news-bob { 50% { transform: translateY(-3px) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .menu-item.news.gift, .menu-item.news.gift .mi-ico { animation: none; } }
@media (max-height: 660px) { .menu-item.news { grid-column: span 2; } }

/* Texto sólo para buscadores y lectores de pantalla (portada del juego, que es un canvas). */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-height: 400px) { .menu-item.news.gift small { display: block; } }
.menu-item small.gold { color: var(--gold); }
