:root {
  --bg: #1a0d33; --panel: rgba(26, 14, 54, 0.86); --panel-2: rgba(44, 24, 84, 0.9); --line: rgba(190, 160, 255, 0.22);
  --text: #fff7ff; --muted: #c9b8f0; --gold: #ffd23f; --gold-2: #ff9f1c; --mint: #2ef2a0; --coral: #ff4d6d; --sky: #48c8ff; --violet: #9b5de5;
  --radius: 22px; --font: 'Fredoka', 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
#app { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

/* ---------- Botones ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 52px; padding: .55em 1.3em; border-radius: 18px; font-size: 1.15rem; font-weight: 700; letter-spacing: .02em; color: #2a1442;
  background: linear-gradient(180deg, #ffe680, var(--gold) 45%, var(--gold-2)); box-shadow: 0 5px 0 #b8640a, 0 10px 24px rgba(255, 160, 40, .35), inset 0 2px 0 rgba(255,255,255,.6); transition: transform .08s, box-shadow .08s, filter .15s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b8640a, 0 4px 10px rgba(255,160,40,.3), inset 0 2px 0 rgba(255,255,255,.6); }
.btn.mint { color: #06281c; background: linear-gradient(180deg, #a7ffd8, var(--mint) 50%, #12b979); box-shadow: 0 5px 0 #0b7a50, 0 10px 24px rgba(46,242,160,.3), inset 0 2px 0 rgba(255,255,255,.6); }
.btn.mint:active { box-shadow: 0 1px 0 #0b7a50, inset 0 2px 0 rgba(255,255,255,.6); }
.btn.violet { color: #fff; background: linear-gradient(180deg, #c49bff, var(--violet) 55%, #6a2fc2); box-shadow: 0 5px 0 #4a1d8f, 0 10px 24px rgba(155,93,229,.35), inset 0 2px 0 rgba(255,255,255,.35); }
.btn.violet:active { box-shadow: 0 1px 0 #4a1d8f, inset 0 2px 0 rgba(255,255,255,.35); }
.btn.ghost { color: var(--text); background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--line); }
.btn.big { min-height: 66px; font-size: 1.55rem; padding: .5em 2em; border-radius: 22px; }
.btn.small { min-height: 40px; font-size: .95rem; padding: .35em .9em; border-radius: 14px; }
.btn[disabled] { filter: grayscale(.8) brightness(.75); pointer-events: none; }
.btn .ad-ico { display: inline-grid; place-items: center; width: 1.55em; height: 1.1em; border-radius: 5px; background: rgba(0,0,0,.18); font-size: .7em; font-weight: 700; }
.icon-btn { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(20, 10, 44, .55); box-shadow: inset 0 0 0 2px var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); position: relative; }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 26px; height: 26px; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--coral); color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); animation: pop 1.6s ease-in-out infinite; }

/* ---------- Pantallas ---------- */
#screens > .screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); animation: fadeIn .25s ease-out; }
.screen.modal { justify-content: center; background: radial-gradient(ellipse at center, rgba(16, 6, 36, .55), rgba(10, 4, 24, .82)); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.card { width: min(440px, 100%); background: linear-gradient(180deg, var(--panel-2), var(--panel)); border-radius: var(--radius); padding: 22px 20px 20px; box-shadow: 0 0 0 2px var(--line), 0 20px 60px rgba(0,0,0,.5); text-align: center; animation: rise .35s cubic-bezier(.2, 1.4, .4, 1); }
.card h2 { margin: 0 0 4px; font-size: 1.9rem; letter-spacing: .02em; }
.card .sub { margin: 0 0 16px; color: var(--muted); font-size: 1rem; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }

/* Portada */
.title-screen { justify-content: space-between; pointer-events: none; }
.title-screen > * { pointer-events: auto; }
.topbar { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px 0 8px; border-radius: 22px; background: rgba(20,10,44,.6); box-shadow: inset 0 0 0 2px var(--line); font-weight: 700; font-size: 1.15rem; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.coin-ico { width: 28px; height: 28px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 45%, #c88a00); box-shadow: inset 0 0 0 2px #b07800, 0 0 12px rgba(255,210,63,.6); display: grid; place-items: center; color: #8a5a00; font-weight: 800; font-size: 15px; }
.coin-ico::after { content: 'C'; }
.logo { text-align: center; margin-top: 4vh; }
.logo h1 { margin: 0; font-size: clamp(3rem, 12vw, 6.2rem); line-height: .9; font-weight: 700; letter-spacing: .02em; background: linear-gradient(180deg, #fff 10%, #ffe680 45%, #ff9f1c 75%, #ff4d6d); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #6a1b6b) drop-shadow(0 0 24px rgba(255, 120, 160, .55)); }
.logo h1 span { display: block; font-size: .62em; letter-spacing: .3em; padding-left: .3em; background: linear-gradient(180deg, #d6fff0, var(--mint)); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 3px 0 #0b5a40) drop-shadow(0 0 18px rgba(46,242,160,.6)); }
.logo p { margin: 12px 0 0; color: var(--muted); font-size: clamp(.95rem, 3.4vw, 1.2rem); }
.logo .wave { width: min(240px, 50vw); height: 34px; margin: 6px auto 0; display: block; }
.title-bottom { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.best-line { color: var(--muted); font-size: 1.05rem; }
.best-line b { color: var(--gold); font-size: 1.2rem; }
.menu-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.menu-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 74px; padding: 10px 0 8px; border-radius: 18px; background: rgba(20,10,44,.6); box-shadow: inset 0 0 0 2px var(--line); font-size: .85rem; font-weight: 600; position: relative; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.menu-btn:active { transform: scale(.95); }
.menu-btn svg { width: 30px; height: 30px; }
.headstart { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 16px; background: rgba(46, 242, 160, .12); box-shadow: inset 0 0 0 2px rgba(46,242,160,.4); font-weight: 600; }
.headstart.on { background: rgba(46, 242, 160, .28); }
.mission-strip { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .9rem; }
.mission-strip i { width: 22px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); }
.mission-strip i.done { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.tap-hint { font-size: 1rem; color: var(--muted); animation: breathe 1.6s ease-in-out infinite; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l)); }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hud-score { text-shadow: 0 3px 0 rgba(30,10,60,.8), 0 0 18px rgba(0,0,0,.4); }
.hud-score .s { font-size: clamp(1.9rem, 7vw, 2.6rem); font-weight: 700; line-height: 1; }
.hud-score .m { font-size: 1rem; color: var(--muted); font-weight: 600; }
.hud-score .x { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 8px; background: rgba(255,210,63,.18); color: var(--gold); font-size: .85rem; vertical-align: middle; }
.hud-right { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.hud-coins { pointer-events: none; }
.hud-coins.bump { animation: bump .18s ease-out; }
.hud-combo { position: absolute; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); font-weight: 700; font-size: clamp(1.1rem, 4.5vw, 1.6rem); color: var(--gold); text-shadow: 0 3px 0 #6a1b6b, 0 0 16px rgba(255,210,63,.6); opacity: 0; transition: opacity .2s; white-space: nowrap; }
.hud-combo.on { opacity: 1; }
.hud-combo .bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); margin-top: 3px; overflow: hidden; }
.hud-combo .bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.hud-powers { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); display: flex; gap: 8px; }
.pw { position: relative; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(20,10,44,.7); animation: rise .3s ease-out; }
.pw svg.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.pw img { width: 34px; height: 34px; }
.hud-pause { width: 46px; height: 46px; }

/* Textos flotantes */
#fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 700; white-space: nowrap; text-align: center; animation: floatUp 1.1s ease-out forwards; text-shadow: 0 3px 0 rgba(40,10,70,.9), 0 0 14px rgba(0,0,0,.35); }
.pop.trick { font-size: clamp(1.4rem, 6vw, 2.2rem); color: var(--gold); }
.pop.trick small { display: block; font-size: .55em; color: #fff; }
.pop.perfect { font-size: clamp(1.1rem, 4.5vw, 1.6rem); color: var(--mint); }
.pop.small { font-size: 1rem; color: #fff; animation-duration: .8s; }
.pop.coin10 { font-size: 1.3rem; color: var(--gold); }

#hint { position: absolute; left: 50%; bottom: calc(18% + var(--safe-b)); transform: translateX(-50%); padding: 14px 22px; border-radius: 18px; background: rgba(20, 10, 44, .78); box-shadow: 0 0 0 2px var(--line), 0 10px 30px rgba(0,0,0,.4); font-size: clamp(1.1rem, 4.5vw, 1.4rem); font-weight: 600; text-align: center; pointer-events: none; animation: rise .3s ease-out; max-width: calc(100% - 32px); }
#hint .finger { display: block; margin: 0 auto 6px; width: 44px; height: 44px; animation: tap 1s ease-in-out infinite; }
#hint.hold .finger { animation: hold 1.4s ease-in-out infinite; }

/* Toasts */
#toasts { position: absolute; left: 50%; top: calc(70px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 24px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 16px; background: rgba(20,10,44,.9); box-shadow: 0 0 0 2px rgba(46,242,160,.45), 0 10px 30px rgba(0,0,0,.4); font-weight: 600; animation: toastIn .35s cubic-bezier(.2,1.4,.4,1), toastOut .3s ease-in 2.6s forwards; }
.toast.gold { box-shadow: 0 0 0 2px rgba(255,210,63,.55), 0 10px 30px rgba(0,0,0,.4); }

/* Revivir */
.revive-ring { width: 120px; height: 120px; margin: 4px auto 16px; position: relative; display: grid; place-items: center; }
.revive-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.revive-ring .num { font-size: 2.6rem; font-weight: 700; }

/* Fin de partida */
.over-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 14px; }
.stat { padding: 10px; border-radius: 16px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat .v { font-size: 1.5rem; font-weight: 700; }
.stat.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 12px; }
.stat.wide .v { color: var(--gold); font-size: 1.9rem; }
.big-score { font-size: clamp(2.4rem, 10vw, 3.4rem); font-weight: 700; line-height: 1; margin: 6px 0 2px; }
.new-best { display: inline-block; padding: 4px 14px; margin-bottom: 8px; border-radius: 12px; background: var(--gold); color: #2a1442; font-weight: 700; animation: pop 1s ease-in-out infinite; }
.cause { color: var(--coral); font-weight: 600; margin-bottom: 4px; }
.mini-missions { text-align: left; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }

/* Paneles con pestañas (tienda, misiones…) */
.panel-screen { justify-content: flex-start; background: linear-gradient(180deg, rgba(14,6,32,.86), rgba(14,6,32,.95)); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.panel-head { width: min(720px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 1.7rem; }
.panel-body { width: min(720px, 100%); flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 4px 2px 20px; }
.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.06); padding: 5px; border-radius: 16px; margin-bottom: 14px; }
.tab { flex: 1; min-height: 42px; border-radius: 12px; font-weight: 600; color: var(--muted); }
.tab.on { background: var(--violet); color: #fff; box-shadow: 0 3px 0 #4a1d8f; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px; border-radius: 18px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); text-align: center; }
.item.equipped { box-shadow: inset 0 0 0 3px var(--mint), 0 0 18px rgba(46,242,160,.25); }
.item .name { font-weight: 700; font-size: 1.05rem; }
.item svg.av { width: 90px; height: 90px; }
.item .price { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.item .price .coin-ico { width: 20px; height: 20px; font-size: 11px; }
.upgrade { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); margin-bottom: 10px; text-align: left; }
.upgrade img { width: 56px; height: 56px; }
.upgrade .name { font-weight: 700; font-size: 1.1rem; }
.upgrade .desc { color: var(--muted); font-size: .85rem; margin: 2px 0 6px; }
.pips { display: flex; gap: 4px; }
.pips i { flex: 1; max-width: 34px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.14); }
.pips i.on { background: var(--mint); box-shadow: 0 0 6px var(--mint); }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); text-align: left; margin-bottom: 10px; }
.mission.done { box-shadow: inset 0 0 0 2px var(--mint); }
.mission .txt { font-weight: 600; }
.mission .rw { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--gold); }
.mission .rw .coin-ico { width: 20px; height: 20px; font-size: 11px; }
.progress { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: rgba(255,255,255,.12); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), #a7ffd8); border-radius: 5px; transition: width .4s; }
.mult-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 16px; background: rgba(255,210,63,.14); box-shadow: inset 0 0 0 2px rgba(255,210,63,.4); font-weight: 700; color: var(--gold); font-size: 1.2rem; margin-bottom: 12px; }
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.dayc { padding: 10px 4px; border-radius: 14px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dayc b { color: var(--text); font-size: 1rem; }
.dayc.past { opacity: .5; }
.dayc.today { box-shadow: inset 0 0 0 3px var(--gold), 0 0 16px rgba(255,210,63,.35); color: var(--text); }
.dayc.big { grid-column: span 1; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.06); margin-bottom: 10px; text-align: left; }
.seg { display: flex; gap: 4px; background: rgba(0,0,0,.25); padding: 4px; border-radius: 12px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { min-height: 36px; padding: 0 12px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--violet); color: #fff; }
.setting input { width: 160px; max-width: 45vw; height: 40px; border-radius: 12px; border: 0; padding: 0 12px; font: inherit; color: var(--text); background: rgba(0,0,0,.3); box-shadow: inset 0 0 0 2px var(--line); -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.rank-list { list-style: none; padding: 0; margin: 0; text-align: left; }
.rank-list li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; margin-bottom: 6px; background: rgba(255,255,255,.05); }
.rank-list li.me { box-shadow: inset 0 0 0 2px var(--mint); }
.rank-list .pos { font-weight: 700; color: var(--gold); text-align: center; }
.rank-list .sc { font-weight: 700; }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.howto { text-align: left; line-height: 1.5; color: #eee4ff; }
.howto h1 { font-size: 1.4rem; margin: 0 0 8px; }
.howto h2 { font-size: 1.15rem; margin: 18px 0 6px; color: var(--gold); }
.howto ul { padding-left: 1.2em; margin: 0; }
.howto li { margin-bottom: 4px; }
.howto kbd { padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.15); font-family: inherit; }

/* Anuncio de prueba */
.dev-ad { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(5,2,12,.92); animation: fadeIn .2s; }
.dev-ad-box { width: min(360px, 90vw); padding: 20px; border-radius: 22px; background: #fff; color: #222; text-align: center; font-family: system-ui, sans-serif; }
.dev-ad-tag { font-size: .8rem; color: #888; text-transform: uppercase; letter-spacing: .1em; }
.dev-ad-art { height: 180px; margin: 12px 0; border-radius: 14px; display: grid; place-items: center; background: repeating-linear-gradient(45deg, #eee, #eee 12px, #f6f6f6 12px, #f6f6f6 24px); font-size: 3rem; font-weight: 800; color: #bbb; }
.dev-ad-count { font-weight: 700; margin-bottom: 12px; }
.dev-ad .btn.ghost { color: #444; box-shadow: inset 0 0 0 2px #ddd; }

/* Carga */
#loader { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); z-index: 40; transition: opacity .5s; }
#loader.out { opacity: 0; pointer-events: none; }
.logo-mark { width: 72px; height: 72px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 45%, #c88a00); box-shadow: 0 0 30px rgba(255,210,63,.6); animation: spin 1.2s linear infinite; }
.loader-text { color: var(--muted); }
.noscript { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; }

@keyframes fadeIn { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.96) } }
@keyframes pop { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.08) } }
@keyframes bump { 50% { transform: scale(1.15) } }
@keyframes breathe { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6) } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15) } 30% { transform: translate(-50%, -70%) scale(1) } 100% { opacity: 0; transform: translate(-50%, -180%) scale(1) } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.9) } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) } }
@keyframes tap { 0%, 100% { transform: translateY(0) scale(1) } 40% { transform: translateY(6px) scale(.9) } }
@keyframes hold { 0% { transform: translateY(0) } 20%, 80% { transform: translateY(6px) scale(.9) } 100% { transform: translateY(0) } }
@keyframes spin { to { transform: rotateY(360deg) } }

@media (max-height: 520px) {
  .logo { margin-top: 0; }
  .logo h1 { font-size: clamp(2.2rem, 9vh, 3.4rem); }
  .logo p { margin-top: 4px; font-size: .9rem; }
  .btn.big { min-height: 54px; font-size: 1.3rem; }
  .menu-btn { width: 64px; padding: 6px 0; font-size: .75rem; }
  .menu-btn svg { width: 24px; height: 24px; }
  .card { padding: 14px 16px; }
  .card h2 { font-size: 1.5rem; }
  .over-stats { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
  .stat.wide { grid-column: span 2; }
  .stat .v { font-size: 1.2rem; }
  .big-score { font-size: 2.2rem; }
  .mini-missions { display: none; }
  .revive-ring { width: 84px; height: 84px; margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; } }

/* Modo captura para la imagen de compartir (?og). */
.og .topbar, .og .title-bottom, .og .logo p { display: none !important; }
.og .logo { margin-top: 9vh; }
.og .logo h1 { font-size: 7.4rem; }

.btn svg { width: 22px; height: 22px; flex: none; }
/* Con un menú abierto, los avisos van arriba del todo y los modales dejan sitio. */
body.in-menu #toasts { top: calc(10px + var(--safe-t)); }
body.in-menu .screen.modal { padding-top: calc(66px + var(--safe-t)); }
.logo p, .best-line, .tap-hint { text-shadow: 0 2px 0 rgba(20, 8, 40, .9), 0 0 12px rgba(20, 8, 40, .9); }
.logo p { color: #efe6ff; }

/* Pantallas que no caben: se pueden desplazar en vez de cortarse. */
#screens > .screen { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen.modal .card { max-height: 100%; overflow-y: auto; }
.screen.modal { justify-content: safe center; }

/* Móvil en horizontal y pantallas muy bajas. */
@media (max-height: 450px) {
  .title-screen { justify-content: flex-start; gap: 6px; }
  .topbar .pill, .icon-btn { height: 40px; }
  .icon-btn { width: 40px; }
  .logo { margin-top: -6px; }
  .logo h1 { font-size: 2.3rem; }
  .logo .wave, .logo p, .tap-hint { display: none; }
  .title-bottom { gap: 8px; margin-top: auto; }
  .best-line { font-size: .85rem; }
  .headstart { padding: 3px 4px 3px 10px; font-size: .85rem; }
  .btn.big { min-height: 48px; font-size: 1.2rem; padding: .3em 1.6em; }
  .menu-row { gap: 6px; }
  .menu-btn { width: 60px; padding: 5px 0 4px; font-size: .7rem; gap: 2px; }
  .menu-btn svg { width: 22px; height: 22px; }
  body.in-menu .screen.modal { padding-top: calc(8px + var(--safe-t)); }
  body.in-menu #toasts { top: auto; bottom: calc(8px + var(--safe-b)); }
  .card { padding: 10px 14px; }
  .card h2 { font-size: 1.25rem; }
  .card .sub { margin-bottom: 6px; font-size: .85rem; }
  .big-score { font-size: 1.9rem; margin: 2px 0 0; }
  .new-best { margin-bottom: 2px; padding: 2px 10px; font-size: .85rem; }
  .over-stats { margin: 4px 0 8px; }
  .stat { padding: 5px 6px; }
  .stat .k { font-size: .7rem; }
  .col { gap: 6px; }
  .modal .col .btn { min-height: 40px; }
}
@media (max-height: 450px) and (min-width: 560px) {
  .screen.modal .card { width: min(620px, 100%); }
  .over-card .col { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; }
  .over-card .col > .dbl-slot, .over-card .col > .hs-slot { grid-column: 1 / -1; }
  .over-card .col > .dbl-slot:empty, .over-card .col > .hs-slot:empty { display: none; }
}

/* Aviso de peligro fuera de pantalla (borde derecho). */
.haz { position: absolute; top: 0; right: calc(8px + var(--safe-r)); width: 40px; height: 40px; border-radius: 12px 50% 50% 12px; display: grid; place-items: center;
  background: rgba(255, 45, 85, .85); color: #fff; font: 700 20px/1 var(--font); box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 0 18px rgba(255, 45, 85, .8); transform-origin: right center; transition: transform .08s linear; animation: hazPulse .5s ease-in-out infinite alternate; }
.haz[data-k="drone"] { border-radius: 50%; }
.haz[data-k="gap"] { background: rgba(255, 140, 40, .9); box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 0 18px rgba(255, 140, 40, .8); }
@keyframes hazPulse { to { box-shadow: 0 0 0 3px #fff, 0 0 26px rgba(255, 45, 85, 1); } }

@media (max-height: 450px) {
  .best-line { padding: 2px 12px; border-radius: 10px; background: rgba(20, 8, 40, .72); }
}

/* ---------- Temporada, letras, zonas y cofres ---------- */
.season-line { margin-top: 10px; }
.season-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: rgba(20, 8, 40, .65); box-shadow: inset 0 0 0 2px var(--sc, var(--violet)); font-size: .9rem; font-weight: 600; color: #fff; }
.season-pill svg { width: 16px; height: 16px; color: var(--sc, var(--gold)); }
.letters-line { margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: .85rem; color: var(--muted); text-shadow: 0 2px 0 rgba(20, 8, 40, .9); }
.letters { display: inline-flex; gap: 4px; }
.letters i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-style: normal; font-weight: 700; font-size: .85rem; color: rgba(255,255,255,.45); background: rgba(20, 8, 40, .65); box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }
.letters i.on { color: #5a2a00; background: linear-gradient(180deg, #fff3a8, var(--gold)); box-shadow: 0 0 10px rgba(255,210,63,.6); }
.hud-letters { position: absolute; left: calc(12px + var(--safe-l)); top: calc(78px + var(--safe-t)); }
.hud-letters .letters i { width: 20px; height: 20px; font-size: .75rem; }
.zone-banner { position: absolute; left: 50%; top: 28%; transform: translate(-50%, -50%); text-align: center; font-weight: 700; font-size: clamp(1.8rem, 7vw, 3rem); color: #fff; text-shadow: 0 4px 0 rgba(40,10,70,.9), 0 0 24px rgba(255,255,255,.5); animation: zoneIn 2.4s ease-out forwards; pointer-events: none; white-space: nowrap; }
.zone-banner small { display: block; font-size: .45em; letter-spacing: .3em; color: var(--gold); }
@keyframes zoneIn { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7) } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) } 20% { transform: translate(-50%, -50%) scale(1) } 80% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%, -62%) } }
.btn.chest-btn { color: #2a1442; background: linear-gradient(180deg, #ffe0f4, #ff9ad5 50%, #e05aa8); box-shadow: 0 5px 0 #9c2f72, 0 10px 24px rgba(255, 120, 200, .35), inset 0 2px 0 rgba(255,255,255,.6); }
.btn.chest-btn:active { box-shadow: 0 1px 0 #9c2f72, inset 0 2px 0 rgba(255,255,255,.6); }
.chest-modal { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: radial-gradient(circle, rgba(60, 20, 90, .7), rgba(8, 3, 20, .92)); animation: fadeIn .2s; }
.chest-box { text-align: center; }
.chest { font-size: 120px; line-height: 1; animation: chestShake .9s ease-in-out; filter: drop-shadow(0 0 30px rgba(255, 200, 80, .6)); }
.chest-prize { display: none; flex-direction: column; align-items: center; gap: 8px; color: #fff; font-weight: 600; }
.chest-prize b { color: var(--gold); font-size: 1.3rem; }
.chest-prize .av { width: 120px; height: 120px; }
.chest-big { display: flex; align-items: center; gap: 10px; font-size: 3rem; font-weight: 700; color: var(--gold); text-shadow: 0 4px 0 rgba(40,10,70,.9); }
.chest-modal.open .chest { display: none; }
.chest-modal.open .chest-prize { display: flex; animation: rise .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes chestShake { 0%, 100% { transform: rotate(0) scale(1) } 20% { transform: rotate(-8deg) scale(1.05) } 40% { transform: rotate(8deg) scale(1.1) } 60% { transform: rotate(-10deg) scale(1.15) } 80% { transform: rotate(10deg) scale(1.2) } }
.season-stat { flex-wrap: wrap; }
.season-stat .tok { font-size: 1.6rem; }
.season-stat .v { color: var(--mint) !important; }
.track-mini { flex: 1 1 100%; height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.track-mini i { display: block; height: 100%; background: linear-gradient(90deg, var(--sc, var(--mint)), #fff); }
.track-mini.big { height: 12px; margin-top: 8px; }
.season-card .season-prizes { display: flex; justify-content: center; gap: 10px; margin: 6px 0; }
.season-card .season-prizes .av { width: 84px; height: 84px; }
.season-tokens { margin-top: 6px; font-weight: 700; }
.letters-box { margin-top: 14px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.06); }
.tiers { width: min(440px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.tier { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.05); }
.tier .tn { font-weight: 700; color: var(--muted); text-align: center; }
.tier .tr { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.tier .tc { font-size: .85rem; color: var(--muted); }
.tier.done { background: rgba(46, 242, 160, .12); }
.tier.done .tc { color: var(--mint); font-weight: 700; }
.tier.next { box-shadow: inset 0 0 0 2px var(--gold); }
@media (max-height: 450px) {
  .season-line, .letters-line { display: none; }
  .hud-letters { top: calc(64px + var(--safe-t)); }
}

/* Fin de partida: «Otra vez» y «Menú» siempre a la vista; las fichas en una sola línea. */
.over-card { display: flex; flex-direction: column; }
/* El fondo se vuelve opaco antes del primer botón: lo que pasa por debajo al desplazar no asoma junto a los botones. */
.over-card .col { position: sticky; bottom: -20px; margin: 0 -20px -20px; padding: 18px 20px 20px; background: linear-gradient(180deg, rgba(26,14,54,0), var(--panel) 14px); }
.season-stat { padding: 6px 10px !important; gap: 8px !important; }
.season-stat .tok { font-size: 1.1rem; }
.season-stat .v { font-size: 1.1rem !important; }
.season-stat .track-mini { flex: 1 1 60px; height: 6px; }
@media (max-height: 450px) { .over-card .col { margin: 0 -14px -10px; padding: 8px 14px 10px; } }

/* Telegram a pantalla completa: márgenes del sistema + zona de los botones flotantes de Telegram. */
body.tg-full {
  --safe-t: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-b: calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-l: calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px));
  --safe-r: calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px));
}
