:root {
  --bg: #0d1220;
  --bg2: #151c30;
  --panel: #1a2238;
  --panel2: #222c48;
  --line: rgba(255,255,255,.10);
  --text: #f3eee2;
  --muted: #a9b0c4;
  --gold: #f2b632;
  --gold2: #ffd76a;
  --goldDark: #9c6f14;
  --red: #e0533d;
  --green: #4cc38a;
  --blue: #3aa0ff;
  --purple: #9b6bff;
  --radius: 14px;
  --head: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen { position: absolute; inset: 0; }

/* ---------- Pantallas de menú ---------- */
.ui-screen {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(180deg, rgba(10,40,90,.10) 0, rgba(10,22,44,.55) 300px, rgba(9,16,32,.93) 520px, var(--bg) 760px),
    url("../assets/backgrounds/csbtc-world.jpg") center top / 100% auto no-repeat,
    var(--bg);
}

/* Móvil: el logo CSBTC debe verse COMPLETO, sin recortar letras */
@media (max-width: 768px) {
  .ui-screen {
    background:
      linear-gradient(180deg, rgba(10,40,90,.10) 0, rgba(10,22,44,.55) 260px, rgba(9,16,32,.93) 420px, var(--bg) 620px),
      url("../assets/backgrounds/csbtc-world.jpg") center top / contain no-repeat,
      var(--bg);
  }
}
.wrap { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.topbar h1 { font-family: var(--head); font-size: 30px; margin: 0; letter-spacing: .5px; flex: 1; }
.back { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.back:hover { background: var(--panel2); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.chip img { width: 18px; height: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.panel { background: linear-gradient(180deg, var(--panel), #161d31); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { font-family: var(--head); font-size: 22px; margin: 0 0 10px; }
.grid { display: grid; gap: 12px; }
.notice { border-left: 4px solid var(--gold); background: rgba(242,182,50,.08); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.notice.red { border-color: var(--red); background: rgba(224,83,61,.10); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 800; font-family: var(--head); font-size: 19px; letter-spacing: .4px; background: var(--panel2); border: 1px solid var(--line); text-decoration: none; }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.gold { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #2a1a00; border-color: var(--goldDark); box-shadow: 0 4px 0 var(--goldDark); }
.btn.gold:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--goldDark); }
.btn.red { background: var(--red); border-color: #9b2a1a; }
.btn.small { font-size: 16px; padding: 7px 12px; border-radius: 10px; }
.btn.block { width: 100%; }

/* Menú principal */
.hero { text-align: center; padding: 18px 0 10px; min-height: 300px; }
.logo { font-family: var(--head); font-weight: 800; font-size: clamp(38px, 8vw, 64px); line-height: .95; letter-spacing: 1px; margin: 0; color: #fff; -webkit-text-stroke: 2px #1b2238; paint-order: stroke fill; text-shadow: 0 4px 0 #1b2238, 0 8px 18px rgba(0,0,0,.45); }
.logo .k { color: var(--gold2); }
.logo small { display: block; font-size: .42em; letter-spacing: 6px; color: #fff; margin-top: 6px; }
.tagline { margin: 6px auto 0; display: inline-block; background: rgba(10,18,36,.6); border-radius: 99px; padding: 4px 14px; font-weight: 600; }
.rank-line { margin: 4px 0 0; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.rank-line b { color: var(--gold2); }
.you-piece { font-family: "Segoe UI Symbol","DejaVu Sans","Noto Sans Symbols 2",serif; font-size: 92px; line-height: 1; color: #f5c842; -webkit-text-stroke: 2.5px #fff; paint-order: stroke fill; filter: drop-shadow(0 0 12px rgba(255,214,80,.75)) drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.hero-art { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 14px 0 6px; font-size: 52px; line-height: 1; }
.hero-art .p { filter: drop-shadow(0 4px 0 rgba(0,0,0,.4)); }
.hero-art img { width: 56px; height: 56px; animation: spin 3s linear infinite; }
@keyframes spin { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(.2); } }
.player-card { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 16px; }
.xpbar { height: 8px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--purple)); }
.play-big { font-size: 30px; padding: 16px 36px; border-radius: 16px; min-width: 260px; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 18px; }
/* .menu-tile base eliminado: ahora vive al final del archivo (Cambio 3c) */

/* Campaña: tablero de 64 casillas */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.tab { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 700; white-space: nowrap; }
.tab.on { background: var(--gold); color: #2a1a00; border-color: var(--goldDark); }
.tab.locked { opacity: .55; }
.campaign { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
@media (max-width: 820px) { .campaign { grid-template-columns: 1fr; } }
.board { display: grid; grid-template-columns: repeat(8, 1fr); border: 6px solid #3a2a1a; border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.4); aspect-ratio: 1; }
.sq { position: relative; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--head); font-weight: 800; font-size: clamp(13px, 2.6vw, 20px); color: #2a1a0a; aspect-ratio: 1; }
.sq.l { background: #efdcb6; } .sq.d { background: #b58358; color: #fff3df; }
.sq .st { font-size: clamp(8px, 1.6vw, 11px); letter-spacing: -1px; color: #c58a00; line-height: 1; }
.sq.d .st { color: #ffe08a; }
.sq.lock { filter: grayscale(.8) brightness(.6); cursor: not-allowed; }
.sq.lock::after { content: "🔒"; position: absolute; font-size: 10px; bottom: 2px; right: 3px; }
.sq.cur { outline: 3px solid var(--gold); outline-offset: -3px; animation: pulse 1.2s infinite; }
.sq.sel { outline: 3px solid var(--blue); outline-offset: -3px; }
.sq .bossic { position: absolute; top: 1px; left: 3px; font-size: clamp(10px, 2vw, 15px); }
.sq.boss { background: #6a2a20 !important; color: #ffd76a; }
.sq.mini { background: #7a4a2a !important; color: #ffd76a; }
@keyframes pulse { 50% { outline-color: rgba(242,182,50,.3); } }
.detail h3 { font-family: var(--head); font-size: 26px; margin: 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.diff { height: 8px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.diff > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { font-size: 12px; background: rgba(255,255,255,.07); border-radius: 99px; padding: 3px 9px; }
.stars { color: var(--gold); letter-spacing: 2px; }
.stars .off { color: rgba(255,255,255,.18); }

/* Tarjetas (poderes, mejoras, logros) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: linear-gradient(180deg, var(--panel), #161d31); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card.locked { opacity: .55; }
.card.equipped { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.card-h { display: flex; align-items: center; gap: 10px; }
.card-h .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 28px; background: rgba(255,255,255,.06); flex: none; }
.card-h b { font-family: var(--head); font-size: 21px; display: block; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.pips { display: flex; gap: 4px; }
.pips i { width: 16px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); }
.pips i.on { background: var(--gold); }
.ach.done { border-color: rgba(76,195,138,.6); }
.ach .ic { font-size: 24px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input { background: #0f1526; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); width: 100%; }
.input:focus { outline: 2px solid var(--gold); }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; min-width: 0; }
input[type=range] { width: 100%; accent-color: var(--gold); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--gold); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.msg { font-size: 14px; min-height: 20px; }
.msg.err { color: #ff8a73; } .msg.ok { color: #7fe0a8; }

.streak { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0; }
.streak div { background: rgba(255,255,255,.06); border-radius: 10px; padding: 8px 2px; text-align: center; font-size: 12px; }
.streak div b { display: block; font-family: var(--head); font-size: 18px; color: var(--gold); }
.streak div.on { background: rgba(242,182,50,.22); outline: 1px solid var(--gold); }

/* ---------- Pantalla de juego ---------- */
.game-screen { background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(8px + env(safe-area-inset-top)) 10px 0; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.hud-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud .pill { background: rgba(8,12,22,.72); border: 1px solid rgba(255,255,255,.12); border-radius: 99px; padding: 5px 11px; font-family: var(--head); font-weight: 800; font-size: 19px; display: inline-flex; gap: 6px; align-items: center; backdrop-filter: blur(4px); }
.hud .pill img { width: 20px; height: 20px; }
.hud .hearts { color: #ff4d5e; letter-spacing: 1px; }
.hud .hearts .off { color: rgba(255,255,255,.2); }
.hud .mult { color: #ffb24a; }
.hud .mult.x10 { color: #ff4dd2; text-shadow: 0 0 8px #ff4dd2; }
.hud .grow { flex: 1; }
.hud .prog { height: 6px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; }
.hud .prog > i { display: block; height: 100%; background: var(--gold); transition: width .1s linear; }
.hud .pause-btn { pointer-events: auto; width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(8,12,22,.72); font-size: 18px; font-weight: 900; }
.hud .energy { width: 120px; height: 10px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; }
.hud .energy > i { display: block; height: 100%; background: linear-gradient(90deg, #3aa0ff, #b98cff); }
.hud .energy.full > i { background: linear-gradient(90deg, #ffcf33, #ff8a3a); }
.bossbar { background: rgba(8,12,22,.8); border: 1px solid rgba(255,90,58,.6); border-radius: 10px; padding: 4px 10px 6px; max-width: 520px; width: 100%; margin: 0 auto; }
.bossbar .nm { display: flex; justify-content: space-between; font-family: var(--head); font-weight: 800; font-size: 16px; color: #ffd0c4; }
.bossbar .bar { height: 10px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.bossbar .bar > i { display: block; height: 100%; background: linear-gradient(90deg, #ff3a1a, #ff8a3a); transition: width .15s; }

.powers { position: absolute; right: 10px; top: calc(96px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; }
.pw { pointer-events: auto; position: relative; width: 52px; height: 52px; border-radius: 14px; border: 2px solid rgba(255,255,255,.25); background: rgba(8,12,22,.78); font-size: 26px; display: grid; place-items: center; overflow: hidden; }
.pw.ready { border-color: var(--gold); box-shadow: 0 0 12px rgba(242,182,50,.5); }
.pw .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); }
.pw .key { position: absolute; top: 1px; left: 4px; right: 3px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; font-weight: 800; color: var(--muted); }
.pw.locked { opacity: .35; }

.touch { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.touch .grp { display: flex; gap: 10px; align-items: flex-end; }
.tbtn { pointer-events: auto; width: 66px; height: 66px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(10,14,26,.55); color: #fff; font-size: 26px; font-weight: 900; display: grid; place-items: center; touch-action: none; backdrop-filter: blur(3px); }
.tbtn.big { width: 82px; height: 82px; font-size: 32px; background: rgba(242,182,50,.35); border-color: rgba(255,215,106,.8); }
.tbtn.atk { background: rgba(224,83,61,.4); border-color: rgba(255,140,120,.8); }
.tbtn.on { transform: scale(.94); background: rgba(255,255,255,.3); }

/* Superposiciones (pausa y resultados) */
.overlay { position: absolute; inset: 0; background: rgba(5,8,16,.72); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; backdrop-filter: blur(3px); }
/* La ventana nunca se sale de la pantalla: su contenido se desplaza y los botones quedan siempre visibles abajo */
.overlay > .modal { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.overlay > .modal .btns { margin: 10px 0 6px; }
.modal { background: linear-gradient(180deg, #1d2640, #121829); border: 1px solid rgba(255,255,255,.14); border-radius: 18px; padding: 20px; width: min(460px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal h2 { font-family: var(--head); font-size: 40px; margin: 0; }
.modal h2.win { color: var(--gold); }
.modal h2.lose { color: #ff7a63; }
.bigstars { font-size: 46px; letter-spacing: 6px; margin: 6px 0; }
.bigstars span { display: inline-block; color: rgba(255,255,255,.15); transform: scale(.6); transition: transform .35s cubic-bezier(.3,1.8,.5,1), color .2s; }
.bigstars span.on { color: var(--gold); transform: scale(1); text-shadow: 0 0 16px rgba(242,182,50,.7); }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; text-align: left; margin: 12px 0; font-size: 15px; }
.res-grid b { float: right; font-variant-numeric: tabular-nums; }
.res-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.res-list li { background: rgba(242,182,50,.12); border-radius: 8px; padding: 7px 10px; font-size: 14px; font-weight: 600; }
.modal .btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.share-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.share-row a { text-decoration: none; }

.toasts { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: #1d2640; border: 1px solid var(--gold); color: var(--text); padding: 9px 14px; border-radius: 12px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: tin .25s ease-out; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 440px) { .hud .lvl { display: none; } }
@media (max-width: 520px) {
  .hud .pill { font-size: 16px; padding: 4px 9px; }
  .hud .energy { width: 80px; }
  .pw { width: 46px; height: 46px; font-size: 22px; }
  .tbtn { width: 58px; height: 58px; }
  .tbtn.big { width: 74px; height: 74px; }
  .topbar h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { .hero-art img, .sq.cur { animation: none; } }

.acc-chip { cursor: pointer; border-color: rgba(242,182,50,.55); color: var(--gold2); }
.acc-chip:hover { background: var(--panel2); }

/* Coronación: ascenso de pieza */
.promo { text-align: center; margin: 0 0 12px; padding: 14px; border-radius: 14px; background: radial-gradient(circle at 50% 35%, rgba(245,194,58,.35), rgba(245,194,58,.05) 70%); border: 1px solid rgba(245,194,58,.6); }
.promo b { display: block; font-family: var(--head); font-size: 26px; color: var(--gold2); }
.promo p { margin: 4px 0 0; }
.promo-piece { font-family: "Segoe UI Symbol","DejaVu Sans","Noto Sans Symbols 2",serif; font-size: 96px; line-height: 1; color: #f5c842; -webkit-text-stroke: 2.5px #fff; paint-order: stroke fill; filter: drop-shadow(0 0 16px rgba(255,214,80,.9)); animation: crown 1.2s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes crown { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 60% { transform: scale(1.18) rotate(6deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .promo-piece { animation: none; } }

.perks { list-style: none; margin: 0; padding: 0; }
.perks li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); opacity: .45; }
.perks li.on { opacity: 1; }
.perks .pp { font-family: "Segoe UI Symbol","DejaVu Sans","Noto Sans Symbols 2",serif; font-size: 30px; color: #f5c842; -webkit-text-stroke: 1px #fff; paint-order: stroke fill; width: 34px; text-align: center; }

/* Revivir con un mate en 1 */
.revive { max-width: 380px; }
.rev-timer { height: 6px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.rev-timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #e0533d, #f5c23a); transition: width .1s linear; }
.mini-board { display: grid; grid-template-columns: repeat(8, 1fr); width: min(320px, 82vw); aspect-ratio: 1; margin: 6px auto; border: 3px solid #3a2a1a; border-radius: 6px; overflow: hidden; }
.mini-board .sq { border: 0; padding: 0; display: grid; place-items: center; font-size: clamp(22px, 7vw, 34px); line-height: 1; }
.mini-board .sq.l { background: #efe0bf; } .mini-board .sq.d { background: #a8784f; }
.mini-board .sq.sel { box-shadow: inset 0 0 0 3px #f5c23a; }
.mini-board .sq.hl { background: #f2d66a; }
.mini-board .pc { font-family: "Segoe UI Symbol","DejaVu Sans","Noto Sans Symbols 2",serif; }
.mini-board .pc.w { color: #fffdf6; -webkit-text-stroke: 1.2px #222; paint-order: stroke fill; }
.mini-board .pc.b { color: #16151c; -webkit-text-stroke: .8px #ddd; paint-order: stroke fill; }
/* Misiones y apariencia */
.mission { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mission > div { flex: 1; } .mission .xpbar { margin: 6px 0 2px; }
.mission.done { opacity: .55; }
.cos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.cos { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; text-align: center; }
.cos.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.cos small { color: var(--gold2); display: inline-flex; gap: 3px; align-items: center; } .cos small img { width: 14px; height: 14px; }
.cos .sw { width: 30px; height: 18px; border-radius: 6px; border: 2px solid; display: block; }
.cos .tr-none { border-color: var(--line); } .cos .tr-sparks { background: radial-gradient(circle, #ffd76a 30%, transparent 32%) 0 0/8px 8px; border-color: #ffd76a; }
.cos .tr-coins { background: radial-gradient(circle, #f5c23a 40%, transparent 42%) 0 0/10px 10px; border-color: #b8862a; } .cos .tr-rainbow { background: linear-gradient(90deg, red, orange, yellow, lime, cyan, violet); border-color: #fff; }

.ad-demo { position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,.85); display: grid; place-items: center; color: #fff; text-align: center; }
.ad-demo i { display: block; height: 4px; background: var(--gold); animation: adbar 3s linear forwards; margin-top: 10px; }
@keyframes adbar { from { width: 0; } to { width: 220px; } }

.stat-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat-card b { display: block; font-family: var(--head); font-size: 30px; color: var(--gold2); }
.stat-card span { font-size: 12px; color: var(--muted); }
.deaths { display: inline-flex; align-items: flex-end; gap: 2px; height: 26px; }
.deaths i { width: 8px; min-height: 2px; background: var(--red); border-radius: 2px 2px 0 0; display: block; }

/* Modo Aventura */
#adv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.adv-pause { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 10px; width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(8,12,22,.72); color: #fff; font-size: 16px; font-weight: 900; z-index: 3; }
.tbtn.run { font-size: 16px; letter-spacing: .5px; background: rgba(95,227,255,.28); border-color: rgba(160,240,255,.8); }
.tbtn.pw { font-size: 24px; background: rgba(255,157,46,.45); border-color: rgba(255,210,140,.9); box-shadow: 0 0 14px rgba(255,157,46,.7); }
.tbtn.sp { font-size: 22px; background: rgba(245,194,58,.45); border-color: rgba(255,230,150,.95); box-shadow: 0 0 12px rgba(245,194,58,.6); }
.tbtn.sp[hidden] { display: none; }
.tbtn.run.on { background: rgba(95,227,255,.9); color: #06202a; border-color: #ffffff; box-shadow: 0 0 16px rgba(95,227,255,.95); transform: none; }
#screen-adv .touch { z-index: 2; }
#screen-adv .overlay { z-index: 4; }

/* Ajustes → Teclas */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 8px 22px; }
.kb-h { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0 6px; }
.kb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.kb-name { font-weight: 600; min-width: 0; }
.kb-keys { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.kb { min-width: 64px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); border-bottom-width: 3px; background: var(--panel2); font-weight: 800; font-size: 14px; font-family: inherit; color: inherit; cursor: pointer; }
.kb.empty { color: var(--muted); font-weight: 600; }
.kb.listen { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 10px rgba(242,182,50,.45); animation: kbPulse 1s ease-in-out infinite; }
@keyframes kbPulse { 50% { opacity: .6; } }
.adv-world { font-family: var(--head); font-size: 22px; margin: 22px 0 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }

/* Pantallas bajas (móvil en horizontal): resultados compactos */
@media (max-height: 560px) {
  .overlay { padding: 8px; }
  .overlay > .modal { padding: 12px 16px; width: min(640px, 100%); }
  .overlay > .modal .btns { margin: 6px 0 4px; }
  .modal h2 { font-size: 28px; }
  .bigstars { font-size: 30px; margin: 0; }
  .res-grid { grid-template-columns: repeat(4, 1fr); gap: 2px 12px; margin: 6px 0; font-size: 13px; }
  .res-list { gap: 4px; margin: 6px 0; }
  .res-list li { padding: 4px 8px; font-size: 13px; }
  .res-hint { display: none; }
}

/* ========================================================= */
/* Botón AVENTURA transparente real (Cambio 2 v2)            */
/* ========================================================= */
.btn-aventura-glass {
  background: rgba(0, 0, 0, 0.12) !important;
  -webkit-backdrop-filter: blur(3px) saturate(120%);
  backdrop-filter: blur(3px) saturate(120%);
  border: 1.5px solid #FFD76A !important;
  color: #FFD76A !important;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85),
    0 0 12px rgba(0,0,0,0.6);
  box-shadow:
    0 0 0 1px rgba(255, 215, 106, 0.25) inset,
    0 6px 24px rgba(0,0,0,0.35),
    0 0 22px rgba(255, 215, 106, 0.35);
  transition: background .25s ease, box-shadow .25s ease, border-color .25s ease, transform .18s ease;
}
.btn-aventura-glass:hover {
  background: rgba(0, 0, 0, 0.22) !important;
  border-color: #FFE79A !important;
  box-shadow:
    0 0 0 1px rgba(255, 231, 154, 0.4) inset,
    0 10px 34px rgba(0,0,0,0.45),
    0 0 32px rgba(255, 215, 106, 0.55);
  transform: translateY(-2px);
}
.btn-aventura-glass:active {
  transform: translateY(0);
  box-shadow:
    0 0 0 1px rgba(255, 215, 106, 0.25) inset,
    0 4px 14px rgba(0,0,0,0.35);
}
.btn-aventura-glass .av-map {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.9)) drop-shadow(0 0 6px rgba(255, 215, 106, 0.55));
  transition: transform .25s ease;
}
.btn-aventura-glass:hover .av-map {
  transform: rotate(-6deg) scale(1.08);
}
.btn-aventura-glass span {
  color: #FFD76A;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85);
}
@media (prefers-reduced-motion: reduce) {
  .btn-aventura-glass,
  .btn-aventura-glass:hover,
  .btn-aventura-glass .av-map,
  .btn-aventura-glass:hover .av-map { transition: none; transform: none; }
}

/* ========================================================= */
/* Ocultar "Cómo Jugar" en móvil cuando hay juego activo     */
/* (en PC nunca se aplica: solo @media max-width 768px)       */
/* ========================================================= */
@media (max-width: 768px) {
  body:has(#screen-game:not([hidden])) .welcome-help-btn,
  body:has(#screen-adv:not([hidden])) .welcome-help-btn {
    display: none !important;
  }
}

/* ========================================================= */
/* Botón Salir del juego (esquina superior derecha)          */
/* ========================================================= */
.exit-game-btn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  z-index: 9997;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 30px;
  background: rgba(10, 15, 30, 0.65);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1.5px solid rgba(255, 215, 106, 0.55);
  color: #FFD76A;
  font: 700 14px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  transition: background .2s, border-color .2s, transform .15s;
}
.exit-game-btn:hover {
  background: rgba(10, 15, 30, 0.85);
  border-color: #FFE79A;
  transform: translateY(-1px);
}
/* Ocultar en pantalla de juego (carrera o aventura) */
body:has(#screen-game:not([hidden])) .exit-game-btn,
body:has(#screen-adv:not([hidden])) .exit-game-btn {
  display: none !important;
}

/* ========================================================= */
/* Aventura móvil: botones táctiles que quepan en pantalla   */
/* (el grupo derecho tiene 5 botones: ★ ⚡ RUN ▼ ▲)          */
/* ========================================================= */
@media (max-width: 520px) {
  #adv-touch .grp { gap: 5px; }
  #adv-touch .tbtn { width: 50px; height: 50px; font-size: 20px; }
  #adv-touch .tbtn.big { width: 56px; height: 56px; font-size: 24px; }
  #adv-touch .tbtn.run { font-size: 12px; letter-spacing: 0; }
  #adv-touch .tbtn.sp { font-size: 18px; }
  #adv-touch .tbtn.pw { font-size: 18px; }
}

/* ========================================================= */
/* Rejilla de tiles TRANSPARENTE v2 (Cambio 3c)              */
/* ========================================================= */
.menu-grid { gap: 12px; }

.menu-tile {
  position: relative;
  background: rgba(0, 0, 0, 0.06) !important;
  -webkit-backdrop-filter: blur(4px) saturate(130%);
  backdrop-filter: blur(4px) saturate(130%);
  border: 1.5px solid #FFD76A !important;
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 86px;
  overflow: hidden;
  color: #FFD76A !important;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85),
    0 0 12px rgba(0,0,0,0.6);
  box-shadow:
    0 0 0 1px rgba(255, 215, 106, 0.35) inset,
    0 6px 24px rgba(0,0,0,0.4),
    0 0 26px rgba(255, 215, 106, 0.4);
  transition: background .25s ease, box-shadow .25s ease, border-color .25s ease, transform .18s ease;
}

.menu-tile:hover {
  background: rgba(0, 0, 0, 0.15) !important;
  border-color: #FFE79A !important;
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(255, 231, 154, 0.5) inset,
    0 10px 34px rgba(0,0,0,0.5),
    0 0 36px rgba(255, 215, 106, 0.6);
}

.menu-tile:active {
  transform: translateY(0);
  box-shadow:
    0 0 0 1px rgba(255, 215, 106, 0.3) inset,
    0 4px 14px rgba(0,0,0,0.4);
}

.menu-tile .ic {
  font-size: 26px;
  line-height: 1;
  display: inline-block;
  transition: transform .25s ease;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.95)) drop-shadow(0 0 8px rgba(255, 215, 106, 0.55));
}
.menu-tile:hover .ic { transform: scale(1.1); }

.menu-tile b {
  font-family: var(--head);
  font-size: 20px;
  color: #FFD76A !important;
  letter-spacing: .3px;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85);
}
.menu-tile .muted.small { color: #FFD76A !important; opacity: .85; }

.menu-tile .badge {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 99px;
  box-shadow: 0 0 10px rgba(224, 83, 61, 0.6);
  z-index: 1;
  text-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .menu-tile,
  .menu-tile:hover,
  .menu-tile .ic,
  .menu-tile:hover .ic { transition: none; transform: none; }
}

@media (max-width: 520px) {
  .menu-tile { min-height: 80px; padding: 12px 10px; }
  .menu-tile b { font-size: 18px; }
  .menu-tile .ic { font-size: 24px; }
}

/* ========================================================= */
/* Botón "Jugar · carrera" estilo cristal (como AVENTURA)    */
/* ========================================================= */
.btn[data-act="play"] {
  background: rgba(0, 0, 0, 0.12) !important;
  -webkit-backdrop-filter: blur(3px) saturate(120%);
  backdrop-filter: blur(3px) saturate(120%);
  border: 1.5px solid #FFD76A !important;
  color: #FFD76A !important;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85),
    0 0 12px rgba(0,0,0,0.6);
  box-shadow:
    0 0 0 1px rgba(255, 215, 106, 0.25) inset,
    0 6px 24px rgba(0,0,0,0.35),
    0 0 22px rgba(255, 215, 106, 0.35);
  transition: background .25s ease, box-shadow .25s ease, border-color .25s ease, transform .18s ease;
}
.btn[data-act="play"]:hover {
  background: rgba(0, 0, 0, 0.22) !important;
  border-color: #FFE79A !important;
  box-shadow:
    0 0 0 1px rgba(255, 231, 154, 0.4) inset,
    0 10px 34px rgba(0,0,0,0.45),
    0 0 32px rgba(255, 215, 106, 0.55);
  transform: translateY(-2px);
}
.btn[data-act="play"] span {
  color: #FFD76A;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85);
}
@media (prefers-reduced-motion: reduce) {
  .btn[data-act="play"],
  .btn[data-act="play"]:hover { transition: none; transform: none; }
}

/* ========================================================= */
/* Rank-line y tagline: letras grandes, Barlow Condensed,    */
/* dorado artístico (Cambio 5)                               */
/* ========================================================= */
.rank-line {
  font-family: var(--head);
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 700;
  letter-spacing: .4px;
  color: #fff;
  text-shadow:
    0 1px 3px rgba(0,0,0,0.9),
    0 0 8px rgba(0,0,0,0.7);
  margin: 6px 0 4px;
}
.rank-line b {
  color: #FFD76A;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 10px rgba(255, 215, 106, 0.6);
}

.tagline {
  font-family: var(--head);
  font-size: clamp(20px, 2.8vw, 30px);
  font-weight: 700;
  letter-spacing: .6px;
  color: #FFD76A;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85),
    0 0 14px rgba(255, 215, 106, 0.35);
  margin: 10px auto 0;
  display: inline-block;
  background: rgba(10,18,36,0.55);
  border: 1px solid rgba(255, 215, 106, 0.3);
  border-radius: 99px;
  padding: 6px 18px;
}

/* ========================================================= */
/* Layout 3 columnas en PC (Cambio 4B)                       */
/* ========================================================= */
.menu-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}
.menu-col-left,
.menu-col-right {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.menu-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

@media (min-width: 900px) {
  .menu-layout {
    display: grid;
    grid-template-columns: 1fr minmax(320px, 460px) 1fr;
    gap: 24px;
    align-items: start;
  }
  .menu-col-left,
  .menu-col-right {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .menu-center {
    position: sticky;
    top: 16px;
  }
}

/* ========================================================= */
/* Móvil: botones AVENTURA+Jugar arriba (Cambio 4C)          */
/* ========================================================= */
@media (max-width: 899px) {
  .menu-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .menu-center {
    order: -1;
    text-align: center;
  }
  .menu-col-left  { order: 0; }
  .menu-col-right { order: 1; }
}

/* ========================================================= */
/* SVG del personaje (Cambio 6)                              */
/* ========================================================= */
.you-piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  /* anula los estilos de glifo que ya no aplican */
  font-size: 0;
  -webkit-text-stroke: 0;
  filter: none;
}
.you-piece .piece-svg,
.piece-svg {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  transition: transform .25s ease, filter .25s ease;
}
.panel:hover .you-piece .piece-svg {
  transform: scale(1.05);
  filter: drop-shadow(0 0 18px rgba(255, 215, 106, 0.7));
}
.perks .pp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 44px;
  font-size: 0;
  -webkit-text-stroke: 0;
}
.perks .pp .piece-svg {
  width: 34px;
  height: auto;
}

/* ========================================================= */
/* Piezas Lichess (img) en Personaje (Cambio 7)              */
/* ========================================================= */
.piece-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  transition: transform .25s ease, filter .25s ease;
}
.you-piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  font-size: 0;
  -webkit-text-stroke: 0;
  filter: none;
  min-height: 200px;
}
.you-piece .piece-img {
  width: 180px;
  height: auto;
}
.panel:hover .you-piece .piece-img {
  transform: scale(1.05);
}
.perks .pp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  min-width: 54px;
  height: 58px;
  font-size: 0;
  -webkit-text-stroke: 0;
}
.perks .pp .piece-img {
  width: 46px;
  height: auto;
}

/* ========================================================= */
/* Poderes v2: slots, cards cristal, badges (Cambio 8)       */
/* ========================================================= */
.power-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}
.power-slots .slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 76px;
  padding: 10px 8px;
  border: 1.5px dashed rgba(255,215,106,0.35);
  border-radius: 12px;
  background: rgba(0,0,0,0.12);
  text-align: center;
}
.power-slots .slot.empty { opacity: 0.55; }
.power-slots .slot.filled {
  border-style: solid;
  background: rgba(0,0,0,0.2);
  box-shadow: 0 0 18px rgba(255,215,106,0.15);
}
.power-slots .slot-ic { font-size: 26px; line-height: 1; }
.power-slots .slot-name { font-size: 12px; font-weight: 700; color: var(--gold2); }

/* Cards de poder: estilo cristal + borde dorado */
.power-card {
  position: relative;
  background: rgba(0, 0, 0, 0.12) !important;
  -webkit-backdrop-filter: blur(4px) saturate(120%);
  backdrop-filter: blur(4px) saturate(120%);
  border: 1.5px solid rgba(255,215,106,0.45) !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35), 0 0 18px rgba(255,215,106,0.12);
  transition: transform .2s ease, box-shadow .25s ease, border-color .25s ease;
}
.power-card:hover {
  transform: translateY(-2px);
  border-color: #FFD76A !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 26px rgba(255,215,106,0.35);
}
.power-card.equipped {
  border-color: #FFE79A !important;
  box-shadow: 0 0 0 1px #FFD76A inset, 0 0 26px rgba(255,215,106,0.45);
}
.power-card .effect {
  font-size: 13px;
  line-height: 1.45;
  color: #e9eef7;
  margin-top: 2px;
}
.power-card .pips-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.power-card .pips-label { font-size: 12px; color: var(--gold2); font-weight: 700; }
.power-card .coin-ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.badge-equipped {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #FFD76A;
  color: #2a1a00;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: .3px;
  box-shadow: 0 0 10px rgba(255,215,106,0.6);
}
.power-card.locked { opacity: 0.55; }

/* ========================================================= */
/* Personaje v3: paneles cristal, badges, mejoras (Cambio 9) */
/* ========================================================= */
.panel {
  background: rgba(0, 0, 0, 0.12) !important;
  -webkit-backdrop-filter: blur(4px) saturate(120%);
  backdrop-filter: blur(4px) saturate(120%);
  border: 1.5px solid rgba(255,215,106,0.4) !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35), 0 0 18px rgba(255,215,106,0.1);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.panel:hover {
  border-color: rgba(255,215,106,0.7) !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4), 0 0 26px rgba(255,215,106,0.25);
}
.panel h2 {
  font-family: var(--head);
  font-size: 22px;
  margin: 0 0 10px;
  color: #FFD76A;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7);
}
.rank-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 14px;
  border-radius: 99px;
  background: rgba(255,215,106,0.15);
  border: 1px solid rgba(255,215,106,0.55);
  color: #FFD76A;
  font-family: var(--head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
}
.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 16px;
  border-radius: 99px;
  background: linear-gradient(180deg, #ffd76a, #f2b632);
  color: #2a1a00;
  font-family: var(--head);
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 0 #9c6f14, 0 6px 20px rgba(255,215,0,0.4);
}
.points-badge img { width: 18px; height: 18px; }
.xp-missing {
  font-size: 12px;
  color: var(--gold2);
  margin-top: 2px;
  min-height: 16px;
  font-weight: 600;
}
.badge-current {
  display: inline-block;
  background: #FFD76A;
  color: #2a1a00;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 7px;
  border-radius: 99px;
  letter-spacing: .3px;
  vertical-align: 2px;
  margin-left: 4px;
}
.perks li.current {
  border-left: 3px solid #FFD76A;
  padding-left: 10px;
  background: rgba(255,215,106,0.06);
  border-radius: 6px;
}
.section-title {
  font-family: var(--head);
  font-size: 24px;
  color: #FFD76A;
  margin: 24px 0 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 10px rgba(0,0,0,0.7);
}
.upgrade-card {
  background: rgba(0, 0, 0, 0.12) !important;
  -webkit-backdrop-filter: blur(4px) saturate(120%);
  backdrop-filter: blur(4px) saturate(120%);
  border: 1.5px solid rgba(255,215,106,0.4) !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35), 0 0 18px rgba(255,215,106,0.1);
  transition: transform .2s ease, border-color .25s ease, box-shadow .25s ease;
}
.upgrade-card:hover {
  transform: translateY(-2px);
  border-color: #FFD76A !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 26px rgba(255,215,106,0.35);
}
