/* ============ PokéSurvivor — interfaz estilo Mundo Misterioso ============
 * Cajas azules con doble borde blanco, como los menús de PMD, y fuente pixel
 * local (Pixelify Sans, OFL).
 */
/* Pixelify Sans con los números redibujados para que no se confundan (tools/make_font.py). */
@font-face {
  font-family: 'Pixelify';
  src: url('../fonts/PixelifyPS-400.ttf') format('truetype');
  font-weight: 400 550;
  font-display: block;
}
@font-face {
  font-family: 'Pixelify';
  src: url('../fonts/PixelifyPS-700.ttf') format('truetype');
  font-weight: 551 900;
  font-display: block;
}

:root {
  --ink: #ffffff;
  --muted: #b9cbf0;
  --box1: #2c519f;
  --box2: #1a3170;
  --edge: #f4f8ff;
  --edge-in: #5b83d6;
  --edge-out: #0b1838;
  --gold: #ffd23f;
  --gold2: #f0a31e;
  --red: #ff5f6d;
  --green: #5fe08a;
  --shadow: #0a1430;
  --r1: #9fb1c9; --r2: #5fe08a; --r3: #4fb4ff; --r4: #c47bff; --r5: #ffcb3d;
  --font: 'Pixelify', 'Segoe UI', system-ui, sans-serif;
  /* MicaSurvivor (M5 batch 10): viewport units of the menus' (virtual) viewport, see "UI scale" at the end */
  --ui: 1; --vw: 1vw; --vh: 1vh; --dvh: 1dvh;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: #050914;
  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-gacha, #scr-friends, #scr-rank, #scr-lobby, #scr-profile,
  #scr-lexicon, #scr-lexpop, #scr-tcard { padding-top: 66px; }   /* (M5 batch 11: the Lexicon, an entry, the trainer card) */
}
.scr.dim { background: radial-gradient(circle at 50% 40%, rgba(10,20,50,.55), rgba(3,6,16,.88)); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- caja PMD ---------- */
.box {
  position: relative;
  background: 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, #3d67c0, #26468f);
  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), como en PMD */
.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: 14px; 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 .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: #fff; margin-top: 6px; letter-spacing: 3px; text-transform: uppercase; }

/* ---------- test de personalidad ---------- */
.test-box { width: min(620px, 100%); }
.progress { height: 8px; background: rgba(0,0,0,.35); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.progress i { display: block; height: 100%; background: var(--gold); transition: width .25s; }
.q { font-size: 22px; margin: 0 0 16px; min-height: 2.6em; }
.answers { display: flex; flex-direction: column; gap: 8px; }
.answer {
  appearance: none; text-align: left; cursor: pointer;
  padding: 12px 16px 12px 34px; position: relative;
  background: rgba(0,0,0,.18); border: 2px solid rgba(244,248,255,.25); border-radius: 9px;
  font-size: 17px; text-shadow: 2px 2px 0 var(--shadow);
}
.answer::before {
  content: ''; position: absolute; left: 10px; top: 50%; width: 12px; height: 18px; margin-top: -9px;
  background: var(--ico-cursor) no-repeat center / contain; image-rendering: pixelated; opacity: 0;
}
.answer:hover { background: rgba(255,255,255,.1); border-color: var(--edge); }
.answer:hover::before { opacity: 1; }

.result { width: min(560px, 100%); text-align: center; }
.result .trait { font-size: 30px; color: var(--gold); margin: 4px 0; }
.stage {
  display: block; margin: 8px auto 6px;
  /* Recuadro estilo PMD: 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, #5b83d6);
  border-radius: 14px;
  box-shadow: 0 0 0 3px #0b1838, 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 #0b1838, 0 0 22px rgba(154,230,255,.55), inset 0 0 0 2px rgba(255,255,255,.08); }

/* ---------- rejilla de Pokémon ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; max-height: calc(56 * var(--vh)); 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, calc(6 * var(--vw)), 64px); }
.partner-card { text-align: center; margin-top: 10px; }
.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, calc(52 * var(--vw))); }
  .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, calc(5 * var(--vw)), 52px); }
  #menu-partner { height: min(calc(30 * var(--vh)), 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); }

/* ---------- gacha ---------- */
.banner {
  position: relative; border-radius: 12px; overflow: hidden;
  background:
    radial-gradient(circle at 80% 30%, rgba(255,210,63,.35), transparent 45%),
    radial-gradient(circle at 15% 80%, rgba(196,123,255,.35), transparent 50%),
    linear-gradient(135deg, #3a1d6e, #1b2f78 55%, #0f4d6e);
  border: 2px solid rgba(244,248,255,.4);
  padding: 18px;
}
.banner h3 { font-size: 28px; color: var(--gold); text-shadow: 3px 3px 0 #2a0f55; }
.banner .feat {
  /* Debajo del texto, nunca encima: los legendarios a ×2 son grandes. */
  display: flex; align-items: flex-end; justify-content: center; gap: 6px;
  margin: 8px -10px -18px; height: 190px; overflow: hidden;
}
.banner .feat canvas { flex: 0 0 auto; }
.rates { font-size: 14px; }
.rates div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed rgba(244,248,255,.15); }

#pull-fx {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; gap: 18px; padding: 14px 10px;
  /* Si las 10 cartas no caben (móvil en horizontal) se puede desplazar, y
     "Continuar" se queda siempre a la vista abajo (antes quedaba fuera y no
     había forma de cerrar sin recargar la página). */
  overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(circle at 50% 45%, #1b2d63, #03060f 70%);
}
/* Centrado vertical que no corta por arriba cuando no cabe. */
#pull-fx::before, #pull-fx::after { content: ''; margin: auto; }
#pull-close { position: sticky; bottom: 8px; z-index: 2; flex-shrink: 0; box-shadow: 0 4px 18px rgba(0,0,0,.6); }
@media (max-height: 520px) {
  #pull-fx { gap: 10px; }
  .pull-results { gap: 6px; }
  .pcard { width: 100px; padding: 5px 3px; border-radius: 10px; }
  .pcard canvas { width: 84px; height: auto; }
  .pcard b { font-size: 12px; }
  .pcard .tag { font-size: 10px; }
  .pcard .stars { font-size: 11px; }
}
#pull-fx.hidden { display: none; }
.ball {
  width: 120px; height: 120px; border-radius: 50%; position: relative;
  background: linear-gradient(180deg, #ff4d4d 0 47%, #1a1a1a 47% 53%, #f4f4f4 53% 100%);
  border: 5px solid #1a1a1a;
  box-shadow: 0 0 0 0 var(--glow, #fff);
}
.ball::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: #f4f4f4; border: 5px solid #1a1a1a;
}
.ball.drop { animation: drop .55s cubic-bezier(.3,1.6,.6,1) both; }
.ball.shake { animation: shake .45s ease-in-out 3; }
.ball.burst { animation: burst .45s ease-out forwards; }
@keyframes drop { from { transform: translateY(-60vh) rotate(-200deg); } to { transform: none; } }
@keyframes shake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-18deg); } 75% { transform: rotate(18deg); } }
@keyframes burst {
  0% { box-shadow: 0 0 0 0 var(--glow); }
  60% { box-shadow: 0 0 80px 40px var(--glow); transform: scale(1.15); }
  100% { box-shadow: 0 0 200px 120px transparent; transform: scale(0); opacity: 0; }
}
/* Mensaje de apoyo al acabar una partida (run-ui.js). */
.support-ask { position: relative; margin-top: 4px; padding: 10px 34px 12px 12px; border-radius: 10px; text-align: center;
  background: rgba(255,210,63,.08); border: 2px solid rgba(255,210,63,.45); }
.support-ask p { margin: 0 0 8px; font-size: 13px; color: var(--ink); line-height: 1.35; }
.support-ask .btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.support-ask .x { position: absolute; top: 4px; right: 6px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.pull-results { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 900px; }
.pcard {
  width: 150px; padding: 10px 6px; text-align: center; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(0,0,0,.3));
  border: 3px solid var(--rc, #fff);
  box-shadow: 0 0 22px var(--rc, #fff);
  animation: pop .3s ease-out both;
  text-shadow: 2px 2px 0 var(--shadow);
}
.pcard .stars { color: var(--rc); font-size: 14px; }
.pcard b { display: block; font-size: 16px; }
.pcard .tag { font-size: 12px; margin-top: 2px; }
.pcard .new { color: var(--gold); font-weight: 700; }
.pcard.r5 { animation: pop .3s ease-out both, legend 1.4s ease-in-out infinite alternate; }
@keyframes legend { to { box-shadow: 0 0 40px var(--rc), 0 0 80px var(--rc); } }

/* ---------- cartas de nivel ---------- */
.cards { display: flex; flex-direction: column; gap: 10px; width: min(560px, 100%); }
.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 .ds .cc-chance { color: #ffd23f; }   /* MicaSurvivor (M5): "Can freeze (15%)." */
.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; }
.stars-row { display: inline-flex; gap: 1px; vertical-align: middle; }
.cell .stars-row { display: flex; justify-content: center; margin-top: 2px; }
.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; }
.pcard.shiny { animation: pop .3s ease-out both, legend 1.1s ease-in-out infinite alternate; }
.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; }

/* ============ nube, aviso legal ============ */
.btn.google { background: linear-gradient(180deg, #ffffff, #dfe6f2); color: #1f2a44; text-shadow: none; }
.sync { display: inline-block; width: 9px; height: 9px; margin-left: 8px; border-radius: 2px;
  box-shadow: 0 0 0 2px #0b1838; vertical-align: 1px; }
.sync.ok { background: #5fe08a; }
.sync.syncing, .sync.pending { background: #ffd23f; }
.sync.offline { background: #ff5f6d; }
.sync.local { background: #9fb1c9; }
.sync.guest { display: none; }
.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 y Apoyar (60) */
.boot { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  background: #050914; color: var(--muted); font-size: 18px; }

/* ---------- amigos, sala, invitaciones y ranking ---------- */
.fr-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(52 * var(--vh)); overflow-y: auto; padding-right: 4px; }
.fr-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  background: rgba(0,0,0,.22); border: 2px solid rgba(244,248,255,.14);
}
.fr-row b { font-size: 17px; }
.fr-row .st { color: var(--muted); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 2px; background: #6b7a94; flex: 0 0 10px; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.play { background: var(--gold); }
.dot.pend { background: var(--r4); }
#fr-add { margin: 10px 0 0; }
#fr-add .field { min-width: 180px; }

.lobby-members { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.lob-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px;
  border-radius: 10px; background: rgba(0,0,0,.25); border: 3px solid var(--pc, rgba(244,248,255,.2));
  min-height: 170px; justify-content: center; text-align: center;
}
.lob-card b { font-size: 17px; color: var(--pc); }
.lob-card small { color: var(--muted); font-size: 12px; }
.lob-card .conn { font-size: 12px; color: var(--green); }
.lob-card .conn.wait { color: var(--gold); }
.lob-card.empty { border-style: dashed; border-color: rgba(244,248,255,.18); color: var(--muted); }
/* MicaSurvivor (M5 batch 12b): the relay's minutes left today (gold; red when nearly or fully used up) */
#lobby-note .relay-left { color: var(--gold); }
#lobby-note .relay-left.low { color: #ff8a96; }

.invite-pop {
  /* MicaSurvivor (M5 batch 12b): bottom LEFT, so it never covers the menu's last items (upstream: right) */
  position: fixed; left: 18px; bottom: 54px; z-index: 70; width: min(340px, calc(100% - 32px));
  padding: 14px 16px; animation: pop .2s ease-out;
}
.invite-pop img { vertical-align: middle; }

.rk-tools { gap: 8px; margin-bottom: 8px; }
.rk-tools .field { width: 220px; padding: 6px 10px; font-size: 15px; }
.rk-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(46 * var(--vh)); overflow-y: auto; padding-right: 4px; }
.rk-row {
  display: grid; grid-template-columns: 54px auto 1fr auto 26px; gap: 10px; align-items: center;
  padding: 4px 12px; border-radius: 8px; background: rgba(0,0,0,.2); border: 2px solid transparent;
}
.rk-row .pos { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 4px; color: var(--muted); }
.rk-row.top1 .pos { color: var(--gold); }
.rk-row.top2 .pos { color: #dfe7f5; }
.rk-row.top3 .pos { color: #e0a36b; }
.rk-row .mons { display: flex; }
.rk-row .who { display: flex; flex-direction: column; min-width: 0; }
.rk-row .who b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-row .who small { color: var(--muted); font-size: 12px; }
.rk-row .time { font-size: 22px; font-weight: 700; color: #fff; }
.rk-row.mine { border-color: var(--gold); background: rgba(255,210,63,.1); }
.rk-rep { background: none; border: 0; padding: 4px; cursor: pointer; opacity: .35; line-height: 0; }
.rk-rep:hover { opacity: 1; }
.rk-rep.sent { opacity: .12; cursor: default; }
.rk-row.mod-row { grid-template-columns: 54px 1fr auto; }
.rk-row.mod-row.rep { grid-template-columns: 54px auto 1fr auto auto; }
.mod-warn { color: #ff8a96 !important; }
.mod-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rk-me { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: rgba(0,0,0,.25); font-size: 15px; min-height: 20px; }

.cards.done .card { pointer-events: none; opacity: .45; }
.cards.done .card.picked { opacity: 1; border-color: var(--gold); }
#lvl-wait { color: var(--gold); font-size: 15px; }

/* MicaSurvivor (M5 batch 12b): a phone held sideways (844x390): compact member cards, so the whole lobby fits */
@media (max-height: 520px) {
  .lob-card { min-height: 0; padding: 4px 6px; }
  .lob-card canvas { height: 64px; width: auto; }
  #scr-lobby h3 { margin: 8px 0 4px !important; }
  #scr-lobby .row[style*="margin-top:14px"] { margin-top: 8px !important; }
}
@media (max-width: 760px) {
  .lobby-members { grid-template-columns: repeat(2, 1fr); }
  .rk-row { grid-template-columns: 40px auto 1fr auto 22px; gap: 6px; }
}

/* ---------- tickets y mejoras por Pokémon ---------- */
.tickets-line img, #tickets-pill img, #cost-1 img, #cost-10 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); }

/* ---------- tragaperras del gacha ---------- */
#slot { width: min(528px, calc(92 * var(--vw)), calc(66 * var(--vh))); height: auto; image-rendering: pixelated; cursor: pointer;
  filter: drop-shadow(0 0 30px rgba(255,90,90,.35)); animation: pop .25s ease-out both; }

/* ---------- misiones, logros, perfil y objetos ---------- */
.goals-body { max-height: calc(62 * var(--vh)); 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; }
.fav-slots { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0; }
.fav-slot {
  width: 140px; min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; background: rgba(0,0,0,.28); border: 3px dashed rgba(244,248,255,.25); cursor: pointer; text-align: center;
}
.fav-slots.view .fav-slot { cursor: default; border-style: solid; border-color: rgba(255,210,63,.55); }
.fav-slot b { font-size: 14px; }
.profile-box { width: min(640px, 100%); max-height: calc(90 * var(--vh)); overflow-y: auto; }
.prof-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: -10px; }
.prof-head h2 { margin: 0; }
.prof-title { color: var(--gold); font-size: 15px; border: 2px solid var(--gold); border-radius: 8px; padding: 1px 8px; }
.prof-marks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.prof-marks div { background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; }
.prof-marks span { color: var(--muted); font-size: 12px; }
.prof-marks b { font-size: 18px; }
.prof-medals { display: flex; flex-wrap: wrap; gap: 8px; }
.prof-medals .pm { width: 84px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.prof-medals small { font-size: 10px; color: var(--muted); }
a.plink { color: inherit; text-decoration: none; border-bottom: 1px dotted rgba(244,248,255,.4); }
a.plink:hover { color: var(--gold); }
#user-pill { cursor: pointer; }
.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); }
/* Vínculo (premio de los legendarios): rosa */
.bond-title { color: #ff8ad8; }
.card.bond { border-color: #ff8ad8; background: linear-gradient(90deg, rgba(255,138,216,.18), rgba(255,138,216,.04)); }
.card.bond .nm { color: #ff8ad8; }
@media (max-height: 520px) {
  #scr-bond .bond-hint { display: none; }
  #scr-bond .box { width: min(820px, 100%); }
  #bond-cards { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
}
@media (max-width: 760px) { .mission { grid-template-columns: 1fr; } .prof-marks { grid-template-columns: repeat(2, 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; }
/* Colocar los botones (layout-ui.js): por delante de Ajustes */
#scr-layout { z-index: 66; display: block; background: radial-gradient(circle at 50% 40%, #24452c, #0d1a12); touch-action: none; }
#scr-layout.hidden { display: none; }
.lay-thing { position: absolute; z-index: 2; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.lay-thing.held { cursor: grabbing; filter: drop-shadow(0 0 8px rgba(255,210,63,.8)); }
.lay-thing.hidden { display: none; }
.lay-bar { display: flex; gap: 9px; }
.lay-slot { position: relative; width: 54px; height: 54px; flex: none; border-radius: 12px; background: rgba(10,16,28,.8); border: 1.2px solid rgba(140,170,210,.4); }
.lay-slot.on { border: 2.5px solid var(--gold); }
.lay-slot.item { margin-right: 9px; background: rgba(10,16,28,.55); }
.lay-slot i { position: absolute; left: 4px; top: 2px; font-style: normal; font-size: 10px; color: rgba(180,200,230,.7); }
.lay-tag { position: absolute; left: 50%; top: -18px; transform: translateX(-50%); font-size: 11px; color: var(--gold); white-space: nowrap; pointer-events: none; }
.lay-pause { border-radius: 10px; background: rgba(10,16,28,.7); border: 2px solid rgba(244,248,255,.8); box-sizing: border-box; }
.lay-pause b { position: absolute; top: 9px; width: 5px; height: 18px; background: #f4f8ff; }
.lay-pause b:first-child { left: 11px; } .lay-pause b:last-child { left: 20px; }
.lay-stick { border-radius: 50%; background: rgba(10,20,48,.3); border: 3px solid rgba(244,248,255,.6); box-sizing: border-box; }
.lay-stick .knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(255,210,63,.85); border: 3px solid #a55f00; box-sizing: border-box; }
.lay-panel { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(340px, calc(100% - 32px)); padding: 10px 14px; text-align: center; opacity: .95; }
.lay-panel h3 { margin: 0 0 6px; font-size: 14px; }
#lay-mode { justify-content: center; align-items: center; gap: 6px; margin: 0; }
.lay-help { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.lay-turn { color: var(--gold); font-size: 13px; margin: 4px 0; }
.lay-btns { justify-content: center; gap: 8px; margin-top: 6px; }
.box.settings { width: min(640px, 100%); max-height: calc(calc(100 * var(--dvh)) - 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-login, #scr-test, #scr-result, #scr-starters, #scr-nick, #scr-levelup, #scr-pause,
  #scr-over, #scr-item, #scr-tower, #scr-settings, #scr-legal, #scr-profile { 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; }
  #user-pill { max-width: 130px; overflow: hidden; white-space: nowrap; }
  .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(calc(34 * var(--vh)), 130px); width: auto; }
  .partner-card { margin-top: 2px; }
  .partner-card .nm { font-size: 17px; }
  .partner-card .lv { font-size: 12px; }
  .menu-right { width: min(calc(54 * var(--vw)), 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(calc(100 * var(--dvh)) - 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(calc(30 * var(--vh)), 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; }
.tap-blink { color: #fff !important; font-size: 20px; margin-top: 22px !important; animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.login-tag { margin: -6px 0 12px; font-size: 13px; color: var(--muted); text-align: center; }
.login-official { margin: -6px 0 12px; font-size: 12px; color: var(--muted); text-align: center; opacity: .85; }
.login-links { margin-top: 10px; font-size: 13px; text-align: center; }
.login-links a { color: #9fd4ff; }

/* ---------- apoyar el proyecto ---------- */
#scr-support { z-index: 60; }
.box.support { width: min(560px, 100%); }
/* Mejoras: botones y veto */
.upg-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.upg-btns.two { flex-direction: column; align-items: stretch; }   /* M5 lote 3: Elegir encima de la compra, como el port */
.ban-picker { grid-column: 1 / -1; }
.tm-picker { grid-column: 1 / -1; }   /* M5 lote 3: editor de la MT */
.tm-picker .chip.on { background: rgba(255,210,63,.18); }
#item-cards .item-new { margin: 0 0 2px; text-align: left; }
#item-cards .item-new img { vertical-align: middle; margin-right: 4px; }
.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; }
/* Novedades */
.news-btn { position: relative; }
.news-btn .dot { display: none; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; background: #ff5f6d; box-shadow: 0 0 0 2px var(--shadow); }
.news-btn.new .dot { display: block; }
.box.news-box { width: min(640px, 100%); max-height: calc(calc(100 * var(--dvh)) - 90px); display: flex; flex-direction: column; }
.news-body { overflow-y: auto; padding-right: 4px; }
.news-day { padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.1); }
.news-day:last-child { border-bottom: 0; }
.news-day h3 { color: var(--gold); margin: 14px 0 6px; font-size: 18px; }
.news-day h3 small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.news-part { margin: 6px 0 8px; }
.news-tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 4px; color: #0b1020; text-shadow: none; }
.news-tag.new { background: #5fe08a; } .news-tag.chg { background: #4fb4ff; } .news-tag.fix { background: #ffb347; }
.news-day ul { margin: 0; padding-left: 20px; }
.news-day li { margin: 4px 0; line-height: 1.35; font-size: 15px; }
@media (max-width: 760px) { .news-btn span { display: none; } }
.sup-tab { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 15px; }
.sup-tab td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sup-tab td.num { text-align: right; white-space: nowrap; }
.sup-tab tr.tot td { font-weight: 700; color: var(--gold); border-bottom: 0; }
#btn-support span { margin-left: 2px; }
@media (max-height: 520px) { #btn-support span { display: none; } }
/* ============ Pokémon 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); }
}

/* ================= MicaSurvivor additions (not upstream) ================= */
.mica-credit { font-size: 12px; color: var(--muted); letter-spacing: 0; text-transform: none; }
.logo .t3 { margin-top: 4px; }
.legal { overflow-y: auto; }
.mica-credits .notice { font-family: monospace; font-size: 13px; background: rgba(0, 0, 0, .3); padding: 6px 8px; border-radius: 6px; word-break: break-word; }
.artist-list { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; font-size: 13px; }
.artist-list li { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.artist-list small { color: var(--muted); }
@media (max-height: 520px) { .menu-left .logo .t3 { display: none; } }
/* ================= MicaSurvivor (M2): controller (js/core/pad.js) =================
   body.pad-input = a controller is the active input: key prompts give way to button
   glyphs, and the focused control gets a gold ring. Keyboard / mouse use turns it off. */
.pad-glyph { display: inline-flex; vertical-align: middle; line-height: 0; }
.pad-glyph svg { display: block; }
.key-p, .pad-hint { display: none; }
body.pad-input .key-k, body.pad-input .kbd-hint, body.pad-input .touch-hint { display: none !important; }
body.pad-input .key-p { display: inline-flex; gap: 3px; align-items: center; vertical-align: middle; }
body.pad-input .pad-hint { display: block; }
.card .key .pad-glyph { display: none; }
body.pad-input .card .key { display: none !important; }
body.pad-input .card.pad-focus .key { display: block !important; border: 0; padding: 0; }
body.pad-input .card.pad-focus .key .pad-glyph { display: inline-flex; }
body.pad-input .pad-focus {
  outline: 3px solid #ffd23f !important; outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(255,210,63,.22), 0 0 18px rgba(255,210,63,.5) !important;
}
body.pad-input .card.pad-focus { background: rgba(255,255,255,.1); transform: translateX(4px); }
body.pad-input .menu-item.pad-focus { background: rgba(255,255,255,.08); }
body.pad-input .menu-item.pad-focus::before { opacity: 1; transform: none; }
.pad-hint-bar {
  position: fixed; right: 16px; bottom: 10px; z-index: 85; display: flex; gap: 14px; align-items: center;
  padding: 5px 12px; background: rgba(10,16,28,.85); border: 1px solid rgba(140,170,210,.3); border-radius: 10px;
  font-size: 14px; color: #c8d6ee; pointer-events: none;
}
.pad-hint-bar span { display: inline-flex; align-items: center; gap: 5px; }
.pad-bind { min-width: 150px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.pad-row > span { display: inline-flex; gap: 6px; }

/* MicaSurvivor (M3): the Magepunk leaderboard reuses #scr-rank without the Firebase filters */
.mica-board #rk-mode, .mica-board #rk-period, .mica-board .rk-tools { display: none; }
#scr-rank:not(.mica-board) #rk-rules { display: none; }   /* (DLC D16: the current / legacy board tabs, our board only) */
.mica-back { color: var(--muted); }

/* MicaSurvivor (M5): a Pokémon's ability (Pokédex, partner card, starters, pause) */
.ability { margin: 8px 0 6px; padding: 7px 10px; border-radius: 10px; background: rgba(255,217,138,.08); border: 1px solid rgba(255,217,138,.25); text-align: left; font-size: 13px; line-height: 1.35; }
.ability b { display: flex; align-items: center; gap: 6px; color: #ffd98a; font-size: 14px; }
.ability span { display: block; color: #c8d6ee; margin-top: 2px; }
.ability.short { display: inline-block; margin: 6px 0 0; padding: 3px 8px; background: none; border-color: transparent; }
.ability.short b { font-size: 13px; }
#starter-info .ability { margin: 6px 0 0; }
#pause-ability { margin: 6px auto 10px; max-width: 380px; }
#res-ability { max-width: 360px; margin: 6px auto 0; }

/* MicaSurvivor (M5 batch 4): Z-moves — gacha crystals, the Pokédex line + choice, the Z-crystal missions */
.rates .zc-rate { border-bottom: 0; align-items: center; margin-top: 8px; }
.rates .zc-rate span:first-child { display: inline-flex; align-items: center; gap: 6px; color: #7fe0ff; }
.rates .zc-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; border-bottom: 0; padding: 2px 0 4px; }
.zc-grid span { display: flex; justify-content: center; }
.zc-grid span.off, .zc-ic.off img { opacity: .35; filter: grayscale(.6); }
.zc-found { flex-basis: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; color: #ffd23f; font-size: 17px; margin-top: 4px; }
.z-line { display: flex; align-items: center; gap: 6px; margin: 6px 0 4px; font-size: 14px; color: #ffb86b; }
.z-line.off { color: #8a96b0; font-size: 13px; }
.z-line.off img { opacity: .4; filter: grayscale(.7); }
.seg.z-pick { width: 100%; flex-direction: column; gap: 0; }
.z-pick button { justify-content: center; font-size: 13px; }
.ach.zc .zc-ic { flex: 0 0 52px; display: flex; justify-content: center; }
.ach.zc.unlocked:not(.ok) { border-color: rgba(127,224,255,.45); }
/* MicaSurvivor M5 lote 5: la ficha del Dynamax (pestaña Cristales Z) */
.dyn-card { margin-bottom: 10px; }
.ach.dyn { border-color: rgba(255,61,110,.55); }
.dyn-ic { flex: 0 0 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; background: #240812; border: 3px solid #ff3d6e; box-shadow: 0 0 12px rgba(255,61,110,.55); }
.dyn-ic.off { color: #999ead; border-color: #808594; box-shadow: none; }
/* ---------- MicaSurvivor (M5 lote 6): modos rápidos (port menu.gd "Elige un modo") y vetar cartas ---------- */
.modes-box { max-height: calc(calc(100 * var(--vh)) - 90px); overflow-y: auto; }
.modes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 8px; }
.mode-card {
  appearance: none; cursor: pointer; text-align: left; color: inherit; font: inherit;
  display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: center;
  padding: 7px 12px; border-radius: 10px; border: 2px solid rgba(244,248,255,.25); background: rgba(255,255,255,.04);
}
.mode-card:hover, .mode-card:focus-visible { border-color: var(--edge); background: rgba(255,255,255,.09); outline: none; }
.mode-card .mode-ico { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; background: rgba(0,0,0,.28); }
.mode-card b { display: block; font-size: 19px; color: var(--gold); text-shadow: 2px 2px 0 var(--shadow); }
.mode-card small { display: block; font-size: 13px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.mode-card small span + span { display: block; margin-top: 3px; color: #e8eeff; }
.mode-group { display: flex; flex-direction: column; gap: 5px; }
.mode-group .mode-card { flex: 1; }
.mode-sub { font-size: 14px; padding: 4px 12px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.modes-h { font-size: 15px; color: var(--gold); margin: 12px 0 6px; }
/* MicaSurvivor (DLC D0b): an Expedition mode not playable yet ("Coming soon": reachable, not startable) */
.mode-card.soon { opacity: .62; cursor: default; }
.mode-card.soon .soon-tag { color: var(--gold); font-weight: bold; letter-spacing: .5px; }
.modes-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.mod-tog {
  appearance: none; cursor: pointer; text-align: left; color: inherit; font: inherit;
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px; border: 2px solid rgba(244,248,255,.22); background: rgba(0,0,0,.2);
}
.mod-tog b { display: block; font-size: 15px; }
.mod-tog small { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
.mod-tog .mod-ico { display: grid; place-items: center; opacity: .55; }
.mod-tog .mod-sw { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,.1); color: var(--muted); }
.mod-tog.on { border-color: #ff8a5b; background: rgba(255,120,80,.14); }
.mod-tog.on .mod-ico { opacity: 1; }
.mod-tog.on .mod-sw { background: #ff8a5b; color: #2b1200; }
.mod-tog:hover, .mod-tog:focus-visible { border-color: var(--edge); outline: none; }
.party-grid { margin-top: 8px; max-height: calc(calc(100 * var(--vh)) - 230px); overflow-y: auto; }
/* MicaSurvivor (M5 lote 7): el selector del equipo (los elegidos, con su número) */
.team-count { margin: 6px 0 0; color: var(--gold); font-weight: 700; }
.team-grid .cell .team-no { position: absolute; top: 3px; right: 6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--gold); color: #2b1d00; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.team-grid { max-height: calc(calc(100 * var(--vh)) - 260px); }
.pause-mode { color: #ffb36b; margin: 4px 0 8px; }
.over-mode { color: #ffb36b; font-weight: 700; }
.over-mode p { margin: 0; }
.lvl-extras { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.ban-btn { border-color: rgba(255,107,122,.6); }
.ban-btn.on { background: #5a1f2a; border-color: #ff6b7a; color: #ffd0d6; }
.ban-hint { color: #ff9aa5; margin: 6px 0 0; }
.cards.ban-mode .card { border-color: #ff6b7a; box-shadow: 0 0 0 2px rgba(255,107,122,.35); }
.cards.ban-mode .card.no-ban { opacity: .4; border-color: rgba(244,248,255,.18); box-shadow: none; cursor: not-allowed; }
@media (max-height: 520px) {
  .mode-card { grid-template-columns: 40px 1fr; padding: 7px 9px; }
  .mode-card .mode-ico { width: 40px; height: 40px; }
  .mode-card .mode-ico img { width: 32px; height: 32px; }
  .mode-card b { font-size: 16px; }
  .mode-card small { font-size: 12px; }
}
/* MicaSurvivor (M5 batch 8): the Tower's rest and risk cards (main.gd 3485-3532): the golden legendary card, "No risks" */
#scr-tower .box { width: min(640px, 100%); }
.tower-cards { margin: 0 auto; width: 100%; }
.tower-cards.risk .card { border-color: rgba(255,91,138,.55); }
.tower-cards .card.legend { border-color: var(--gold); background: linear-gradient(90deg, rgba(255,210,63,.24), rgba(255,210,63,.05)); box-shadow: 0 0 18px rgba(255,210,63,.35); }
.tower-cards .card.legend .nm { color: var(--gold); }
.tower-cards .card.skip { border-color: rgba(143,163,196,.5); background: rgba(0,0,0,.12); }
@media (max-height: 520px) {
  .tower-cards { gap: 6px; }
  .tower-cards .card { padding: 6px 10px; gap: 10px; }
  .tower-cards .card .ico { flex-basis: 38px; height: 38px; }
  .tower-cards .card .nm { font-size: 15px; }
  .tower-cards .card .ds { font-size: 12px; }
}

/* ================= MicaSurvivor (M5 batch 10): UI scale (js/core/display.js) =================
 * Like the port's content_scale_factor: each menu layer is laid out in a virtual viewport of 100vw/k x 100dvh/k
 * and scaled by k, so it still fills the screen exactly; the viewport units inside use --vw / --vh / --dvh.
 * Only while the scale isn't 100 % (html.ui-scaled), so the default layout is untouched. The canvas HUD scales
 * itself (hud.js). display.js keeps k within what fits (the media-query brackets don't change). */
html.ui-scaled { --vw: calc(1vw / var(--ui)); --vh: calc(1vh / var(--ui)); --dvh: calc(1dvh / var(--ui)); }
html.ui-scaled .scr { inset: auto; left: 0; top: 0; width: calc(100vw / var(--ui)); height: calc(100vh / var(--ui)); height: calc(100dvh / var(--ui));
  transform: scale(var(--ui)); transform-origin: 0 0; }
html.ui-scaled .topbar { transform: scale(var(--ui)); transform-origin: top right; }
html.ui-scaled .sound-panel { top: calc(14px + 48px * var(--ui)); transform: scale(var(--ui)); transform-origin: top right; }
html.ui-scaled .credits-line { transform: scale(var(--ui)); transform-origin: bottom left; }
html.ui-scaled .pad-hint-bar { transform: scale(var(--ui)); transform-origin: bottom right; }
html.ui-scaled .invite-pop { transform: scale(var(--ui)); transform-origin: bottom left; }
html.ui-scaled .toast { transform: translateX(-50%) scale(var(--ui)); transform-origin: bottom center; }
html.ui-scaled .ach-pop { transform: translateX(-50%) scale(var(--ui)); transform-origin: top center; }
/* the sliders (Settings > Graphics > Display, and the field of view on the pause screen) */
.set-range .range-line { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.set-range input[type=range] { flex: 1; min-width: 0; height: 24px; border-radius: 0;
  background: linear-gradient(rgba(0,0,0,.4), rgba(0,0,0,.4)) center / 100% 8px no-repeat; }
.range-val { min-width: 46px; text-align: right; color: var(--gold); font-weight: 700; }
.set-row small.range-note { margin-top: 3px; }
.set-row small.range-note:empty { display: none; }
body.touch .set-range input[type=range] { height: 34px; background-size: 100% 12px; }
body.touch .set-range input[type=range]::-webkit-slider-thumb { width: 26px; height: 26px; border-radius: 6px; }
body.touch .set-range input[type=range]::-moz-range-thumb { width: 24px; height: 24px; }
/* with touch, a scaled-down menu control never gets under 24 px */
html.ui-scaled body.touch .scr button, html.ui-scaled body.touch .scr .chip, html.ui-scaled body.touch .scr .gen-tab { min-height: max(24px, calc(24px / var(--ui))); }
.pause-fov { text-align: left; margin: 2px 0 8px; }
.pause-fov .set-row { border-bottom: 0; padding: 2px 0; }
@media (max-height: 520px) { .pause-fov .set-row small:not(.range-note) { display: none; } }

/* ================= MicaSurvivor (M5 batch 11): damage breakdown, titles, trainer card, Lexicon ================= */
/* the run-over damage table (menu.gd 1801-1890) */
.over-dmg .dm-wrap { margin-top: 4px; }
.over-dmg .dm-wrap.scroll { max-height: 180px; overflow-y: auto; }
.dm-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.dm-table th { color: var(--muted); font-size: 11px; font-weight: 400; text-transform: uppercase; padding: 0 4px 2px; }
.dm-table th:not(:first-child), .dm-table td:not(:first-child) { text-align: right; white-space: nowrap; }
.dm-table td { padding: 2px 4px; border-top: 1px solid rgba(244,248,255,.08); }
.dm-table td.dm-src { overflow-wrap: anywhere; }
.dm-table td.dm-src img { vertical-align: middle; }
.dm-table td.dm-src small { color: var(--muted); }
.stats .dm-table b { font-size: 14px; color: var(--gold); }
.dm-table .dm-pct { color: var(--muted); font-size: 12px; }
.dm-table tr:not(.dm-move) .dm-nm { color: #8fe3b0; }
/* titles (menu.gd _goals_titles) */
.title-cur { margin: 4px 0 2px; }
#title-none { margin: 4px 0 8px; }
.title-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.title-row { 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); }
.title-row.ok { border-color: rgba(255,210,63,.45); }
.title-row.on { border-color: var(--gold); background: rgba(255,210,63,.12); }
.title-row .a-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.title-row .a-txt small { color: var(--muted); font-size: 12px; }
.title-row:not(.ok) .a-txt b { color: #8a94b0; }
.menu-title { color: var(--gold); font-size: 14px; margin-top: 2px; }
.prof-btns { gap: 10px; flex-wrap: wrap; margin-top: 16px; }
/* the trainer card (menu.gd _show_card) */
.tcard-box { width: min(640px, 100%); max-height: 100%; overflow-y: auto; }
.tcard { text-align: center; }
.tcard-name { margin: 0; color: var(--gold); font-size: 34px; overflow-wrap: anywhere; }
.tcard-title { color: var(--muted); font-size: 18px; margin-bottom: 4px; }
.tcard-mons { display: flex; justify-content: center; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 4px 0 8px; }
.tcard-cells, .tcard-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: left; }
.tcard-modes { grid-template-columns: repeat(4, 1fr); }
.tcard-mons canvas { max-height: 110px; width: auto; }
.tcard-cells div, .tcard-modes div { background: rgba(5,10,26,.55); border: 2px solid rgba(128,158,230,.35); border-radius: 10px; padding: 6px 10px; display: flex; flex-direction: column; min-width: 0; }
.tcard-cells span, .tcard-modes span { color: #9fb4dc; font-size: 12px; }
.tcard-cells b { font-size: 22px; }
.tcard-modes b { font-size: 15px; }
.tcard-h { margin: 12px 0 6px; color: var(--gold); }
/* the Lexicon (menu.gd 3047-3194) */
.lex-tabs { flex-wrap: wrap; }
.lex-h { margin: 4px 0 6px; color: var(--gold); }
.lex-g { margin: 12px 0 6px; font-size: 16px; }
.lex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.lex-card { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  background: rgba(0,0,0,.2); border: 2px solid rgba(244,248,255,.1); color: var(--ink); font: inherit; min-width: 0; }
.lex-card:hover, .lex-card.pad-focus { border-color: var(--gold); }
.lex-card.dim .lex-tx b { color: #8fa3c4; }
.lex-card.dim .lex-ic img { filter: grayscale(.8) brightness(.7); }
.lex-ic { flex: 0 0 auto; min-width: 40px; display: flex; justify-content: center; }
.lex-tx { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lex-tx b { font-size: 16px; }
.lex-tx small { font-size: 12px; }
.lex-ds { color: #c8d6ee; font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lex-types .type { font-size: 10px; }
.lex-dot { display: inline-block; width: 26px; height: 26px; border-radius: 50%; margin-top: 4px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); }
.lex-card .dyn-ic, .lexpop-ic .dyn-ic { font-size: 13px; }
.lexpop-box { width: min(560px, 100%); max-height: 100%; overflow-y: auto; }
.lexpop-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.lexpop-head h2 { margin: 0; }
.lexpop-ic { flex: 0 0 auto; min-width: 56px; display: flex; justify-content: center; }
.lexpop-ic img { width: 56px; height: auto; }
.lexpop-sub { font-size: 14px; }
#lexpop-body p { margin: 6px 0; color: #c8d6ee; }
.lexpop-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 8px 0 10px; }
.lexpop-facts div { background: rgba(0,0,0,.25); border-radius: 8px; padding: 5px 8px; display: flex; flex-direction: column; min-width: 0; }
.lexpop-facts span { color: var(--muted); font-size: 12px; }
.lexpop-facts b { font-size: 15px; overflow-wrap: anywhere; }
#scr-tcard .row, #scr-lexpop .row { justify-content: center; margin-top: 10px; }
/* the run-over screen grew a table: it scrolls inside the screen instead of running off it */
#scr-over .box { max-height: 100%; overflow-y: auto; }
@media (max-width: 760px) { .tcard-cells, .tcard-modes { grid-template-columns: repeat(2, 1fr); } .lexpop-facts { grid-template-columns: 1fr; } }
@media (max-height: 520px) {
  #scr-over .box { width: min(640px, 100%) !important; }
  #scr-over .stats { grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 10px; }
  #scr-over .stats > div { padding: 5px 8px; }
  #scr-over .stats b { font-size: 18px; }
  #scr-over h2 { margin: 0; }
  .lex-tabs { gap: 4px; margin-bottom: 8px; }
  .lex-tabs .tab { padding: 4px 6px; font-size: 12px; }
  .lex-h { margin: 0 0 4px; font-size: 15px; }
  .over-dmg .dm-wrap.scroll { max-height: none; }
  .tcard-box { width: min(820px, 100%); padding: 6px 12px; }
  .tcard-name { font-size: 22px; display: inline; }
  .tcard-title { display: inline; margin-left: 10px; font-size: 15px; }
  .tcard-mons { margin: 0 0 2px; }
  .tcard-mons canvas { max-height: 42px; }
  .tcard-cells { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .tcard-modes { gap: 4px; }
  .tcard-cells div, .tcard-modes div { padding: 3px 8px; }
  .tcard-cells span, .tcard-modes span { font-size: 11px; }
  .tcard-modes b { font-size: 13px; }
  .tcard-h { margin: 4px 0 3px; font-size: 13px; }
  #scr-tcard .row { margin-top: 6px; }
  #scr-tcard .btn { padding: 4px 18px; }
  .tcard-cells b { font-size: 15px; }
  .lex-grid, .ach-grid, .title-list { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ---------- MicaSurvivor (M5 batch 12c): watching a friend live / a replay ---------- */
#watch-bar {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); z-index: 25;
  display: flex; align-items: center; gap: 8px; max-width: min(460px, calc(100vw - 20px));
  padding: 5px 6px 5px 10px; border-radius: 10px; background: rgba(8,14,32,.82); border: 2px solid rgba(244,248,255,.35);
  font-size: 14px; text-shadow: 1px 1px 0 var(--shadow);
}
#watch-bar .wb-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#watch-bar .wb-eye img { display: block; }
#watch-bar .wb-live { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; letter-spacing: .5px; }
#watch-bar .wb-n { color: var(--muted); font-size: 12px; white-space: nowrap; }
#watch-bar .wb-n:empty { display: none; }
#watch-bar .btn.small { padding: 3px 10px; font-size: 13px; flex: 0 0 auto; }
#watch-ctrl {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  display: flex; align-items: center; gap: 6px; width: min(760px, calc(100vw - 20px));
  padding: 5px 10px; border-radius: 10px; background: rgba(8,14,32,.85); border: 2px solid rgba(244,248,255,.3);
}
#watch-ctrl .btn.small { padding: 3px 9px; font-size: 13px; min-width: 34px; flex: 0 0 auto; }
#watch-ctrl .wc-sp.on { background: var(--gold); color: #1a1406; text-shadow: none; border-color: var(--gold); }
#watch-ctrl .wc-seek { position: relative; flex: 1 1 auto; min-width: 80px; height: 22px; display: flex; align-items: center; }
#watch-ctrl input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; margin: 0; position: relative; z-index: 1; background: transparent; height: 22px; cursor: pointer; }
#watch-ctrl input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(244,248,255,.28); }
#watch-ctrl input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(244,248,255,.28); }
#watch-ctrl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -4px; border-radius: 4px; background: var(--gold); border: 2px solid #1a1406; }
#watch-ctrl input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 4px; background: var(--gold); border: 2px solid #1a1406; }
#watch-ctrl .wc-marks { position: absolute; left: 7px; right: 7px; top: 0; bottom: 0; pointer-events: none; }
#watch-ctrl .wm { position: absolute; top: 2px; width: 2px; height: 6px; margin-left: -1px; border-radius: 1px; background: #ff5f6d; }
#watch-ctrl .wm-bk { background: #ffd23f; }
#watch-ctrl .wm-z, #watch-ctrl .wm-dx { background: #c47bff; top: auto; bottom: 2px; }
#watch-ctrl .wc-time { font-size: 13px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
#scr-watch-end .box { width: min(460px, 100%); }
#scr-watch-end .stats b { font-size: 19px; }
/* the run summary's "Share replay" */
.over-share { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.over-share .field { flex: 1 1 100%; font-size: 13px; padding: 5px 8px; user-select: text; text-align: center; }
.over-share .share-msg { flex: 1 1 100%; font-size: 12px; color: var(--muted); text-align: center; }
.over-share .share-msg:empty { display: none; }
/* the friends screen: live now + your recent replays */
.fr-live, .fr-replays { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.fr-live:empty, .fr-replays:empty { display: none; }
.fr-h { margin: 6px 0 2px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.fr-h.hidden { display: none; }
.fr-row .live-badge { background: var(--red); color: #fff; font-size: 11px; padding: 0 5px; border-radius: 4px; }
@media (max-height: 520px) {
  #watch-bar { top: 6px; right: 6px; font-size: 12px; padding: 3px 4px 3px 8px; }
  #watch-ctrl { bottom: 4px; padding: 3px 8px; }
  #scr-watch-end .box { padding: 10px 14px; }
  #scr-watch-end .stats { margin: 6px 0 8px; gap: 5px; }
  #scr-watch-end .stats > div { padding: 4px 8px; }
}
/* MicaSurvivor (DLC D4): the Expedition League (js/expedition/league.js): the level-up's news, evolution cards, the
   "Choose your League member" screen (#modes-league) and the Classic card's pick button */
.lvl-note { display: flex; flex-direction: column; gap: 2px; align-items: center; margin: 4px auto 8px; padding: 6px 12px; max-width: 560px;
  border-radius: 10px; border: 2px solid var(--gold); background: rgba(255,210,63,.14); color: var(--gold); font-weight: 800; font-size: 14px; text-align: center; }
.card .ico.ico-mon { flex-basis: 56px; width: 56px; height: 48px; background: rgba(255,255,255,.08) !important; }
.lg-wrap { display: grid; grid-template-columns: minmax(230px, 36%) 1fr; gap: 10px; margin-top: 6px; align-items: start; }
.lg-card { border: 2px solid rgba(244,248,255,.2); border-radius: 10px; background: rgba(0,0,0,.22); padding: 8px 10px; font-size: 13px;
  max-height: calc(calc(100 * var(--vh)) - 170px); overflow-y: auto; }
.lg-top { display: flex; gap: 8px; align-items: center; }
.lg-top canvas { display: block; }
.lg-name { font-size: 17px; margin-right: 6px; }
.lg-rank { display: inline-block; font-size: 11px; font-weight: 800; color: #14181f; border-radius: 8px; padding: 1px 7px; vertical-align: 2px; }
.lg-role { color: var(--muted); margin-top: 2px; }
.lg-role span { color: #cfe3ff; }
.lg-card .ability { margin: 6px 0 0; }
.lg-sec { margin-top: 7px; font-weight: 800; color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.lg-kit { list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.lg-kit li { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-lv { font-size: 11px; color: var(--muted); min-width: 34px; }
.lg-evo, .lg-mat, .lg-stats { color: #dfe7f3; line-height: 1.35; }
.lg-mat, .lg-stats { color: var(--muted); font-size: 12px; margin-top: 3px; }
.lg-ch { display: flex; justify-content: space-between; gap: 8px; }
.lg-ch.done b, .lg-ok, .lg-free { color: #7fd18b; font-weight: 800; }
.lg-go { margin-top: 8px; width: 100%; }
.lg-grid { margin-top: 0; max-height: calc(calc(100 * var(--vh)) - 170px); grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.lg-grid .cell small.lg-cr { display: block; font-size: 10px; font-weight: 800; }
.lg-grid .cell .badge-r { position: absolute; top: 3px; right: 5px; }
.lg-later { grid-column: 1 / -1; color: var(--muted); font-size: 12px; padding: 6px 4px; }
@media (max-width: 600px) { .lg-wrap { grid-template-columns: 1fr; } .lg-card, .lg-grid { max-height: none; } }
@media (max-height: 460px) {
  /* (the modes box is 100vh - 90 px high: its padding and the heading take ~85 px of it) */
  .lg-card { font-size: 12px; padding: 6px 8px; max-height: calc(calc(100 * var(--vh)) - 180px); }
  .lg-grid { max-height: calc(calc(100 * var(--vh)) - 180px); grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .lg-wrap { margin-top: 2px; }
  .lg-head h3 { margin: 0; font-size: 15px; }
  .lvl-note { font-size: 12px; padding: 3px 10px; margin: 2px auto 4px; }
}
