:root {
  --neon: #ccff00;
  --neon-glow: 0 0 12px rgba(204,255,0,.6), 0 0 30px rgba(204,255,0,.28);
  --bg: #0b0b0b;
  --panel: #151515;
  --panel2: #1d1d1d;
  --line: #2b2b2b;
  --text: #eef5d8;
  --muted: #8b9078;
  --danger: #ff4b3a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Baloo 2', system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
body { background-image: radial-gradient(circle at 20% 15%, rgba(204,255,0,.07), transparent 40%), radial-gradient(circle at 85% 80%, rgba(204,255,0,.05), transparent 45%); }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

#topbar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; min-height: 46px; border-bottom: 1px solid var(--line); background: rgba(10,10,10,.85); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--neon); text-decoration: none; font-family: 'Luckiest Guy', cursive; letter-spacing: 1px; }
.brand img { border-radius: 6px; }
#hud { display: flex; gap: 14px; margin: 0 auto; }
#hud[hidden] { display: none; }
.hud-cell { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 52px; }
.hud-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.hud-cell b { font-family: 'Luckiest Guy', cursive; font-weight: 400; font-size: 20px; color: var(--neon); text-shadow: var(--neon-glow); font-variant-numeric: tabular-nums; }
.top-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: 700 15px 'Baloo 2'; cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { border-color: var(--neon); color: var(--neon); outline: none; }

#stage { position: relative; flex: 1; min-height: 0; display: none; }
#stage.on { display: block; }
#game { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#game canvas { display: block; touch-action: none; }

.coach { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); max-width: min(92%, 420px); padding: 10px 16px; border-radius: 14px; background: rgba(15,15,15,.94); border: 1px solid var(--neon); box-shadow: var(--neon-glow); text-align: center; font-weight: 700; z-index: 4; pointer-events: none; }
.coach[hidden] { display: none; }
.pips { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; align-items: center; z-index: 3; pointer-events: none; }
.pips[hidden] { display: none; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #555; background: transparent; transition: all .15s; }
.pip.on { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 10px var(--danger); }
.pip.warn { animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.35); } }

.screen { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; gap: 6px; }
.screen[hidden] { display: none; }
.logo { width: min(260px, 60vw); image-rendering: pixelated; filter: drop-shadow(0 0 18px rgba(204,255,0,.35)); }
h1 { font-family: 'Luckiest Guy', cursive; font-weight: 400; margin: 0; font-size: clamp(44px, 12vw, 76px); color: var(--neon); text-shadow: var(--neon-glow); letter-spacing: 2px; line-height: 1; }
.tag { margin: 0 0 14px; color: var(--muted); letter-spacing: .25em; text-transform: uppercase; font-weight: 800; font-size: 13px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; width: min(340px, 100%); }
.btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); color: var(--text); font: 800 18px 'Baloo 2', sans-serif; cursor: pointer; padding: 6px 16px; transition: transform .08s, border-color .15s, box-shadow .15s; }
.btn small { font-weight: 500; font-size: 12px; color: var(--muted); margin-top: -3px; }
.btn:hover, .btn:focus-visible { border-color: var(--neon); outline: none; box-shadow: var(--neon-glow); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--neon); color: #0b0b0b; border-color: var(--neon); }
.btn.primary small { color: #333; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; border-color: var(--line); }
.fine { color: var(--muted); font-size: 12px; max-width: 340px; margin-top: 12px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-card { width: min(380px, 100%); max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--neon); border-radius: 18px; padding: 20px; box-shadow: var(--neon-glow); text-align: center; }
.modal-card h2 { margin: 0 0 4px; font-family: 'Luckiest Guy', cursive; font-weight: 400; font-size: 32px; color: var(--neon); text-shadow: var(--neon-glow); }
.modal-card p { margin: 6px 0; color: #cfd8b8; }
.modal-card .btn { width: 100%; margin-top: 8px; }
.stat { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px dashed var(--line); font-weight: 700; }
.stat span:last-child { color: var(--neon); }
.slider-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; text-align: left; font-weight: 700; }
.slider-row input[type=range] { flex: 1; accent-color: var(--neon); }
.slider-row label { min-width: 64px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0; }
.lv { aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--line); background: var(--panel2); color: var(--text); font: 400 18px 'Luckiest Guy'; cursor: pointer; position: relative; }
.lv.done { border-color: var(--neon); color: var(--neon); }
.lv.cur { background: var(--neon); color: #0b0b0b; border-color: var(--neon); }
.lv[disabled] { opacity: .3; cursor: not-allowed; }
.badge { display: inline-block; background: var(--danger); color: #fff; border-radius: 8px; padding: 1px 8px; font-size: 12px; font-weight: 800; }
@media (max-height: 520px) { .logo { display: none; } .screen { justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 480px) {
  #topbar { gap: 6px; padding: 6px 8px; }
  .brand span { display: none; }
  #hud { gap: 8px; }
  .hud-cell { min-width: 44px; }
  .icon-btn { width: 32px; height: 32px; }
}
.share { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.card-prev { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.share-row { display: flex; gap: 8px; }
.share-row .btn { flex: 1; margin-top: 0; text-decoration: none; font-size: 16px; min-height: 46px; }
.x-btn { background: #fff; color: #000; border-color: #fff; }
.x-btn:hover, .x-btn:focus-visible { border-color: var(--neon); }
.modal-card.wide { width: min(560px, 100%); }
.balance { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); font-weight: 800; }
.balance b { font-family: 'Luckiest Guy', cursive; font-weight: 400; font-size: 22px; color: var(--neon); }
.shop-note { font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.shop-h { text-align: left; margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shop-item { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); text-align: left; min-width: 0; }
.shop-item.equipped { border-color: var(--neon); }
.shop-item .prev { width: 100%; height: auto; aspect-ratio: 160 / 104; border-radius: 8px; display: block; }
.shop-meta { display: flex; flex-direction: column; min-width: 0; }
.shop-meta b { font-size: 15px; }
.shop-meta span { font-size: 12px; color: var(--muted); line-height: 1.3; }
.chip { margin-top: auto; border-radius: 10px; border: 2px solid var(--line); background: transparent; color: var(--text); font: 800 14px 'Baloo 2', sans-serif; padding: 6px 8px; cursor: pointer; text-align: center; }
.chip.buy { background: var(--neon); color: #0b0b0b; border-color: var(--neon); }
.chip.on { border-color: var(--neon); color: var(--neon); }
.chip.price { cursor: default; color: var(--muted); }
.chip[disabled] { opacity: .45; cursor: not-allowed; }
.chip:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.account { display: flex; flex-direction: column; }
.account .btn { width: 100%; }
.acct { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 6px 14px; border-radius: 14px; border: 2px solid var(--neon); background: var(--panel); color: var(--text); font: 800 16px 'Baloo 2', sans-serif; cursor: pointer; }
.acct span { color: var(--neon); }
.env-tag { display: inline-block; margin: -6px 0 10px; padding: 2px 10px; border-radius: 999px; background: #3a2a00; color: #ffd23f; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.env-tag[hidden] { display: none; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; max-width: min(92vw, 420px); padding: 10px 16px; border-radius: 12px; background: #111; border: 1px solid var(--neon); color: var(--text); font-weight: 700; box-shadow: var(--neon-glow); text-align: center; }
.balance small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.pack-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.pack { display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; font: 700 13px 'Baloo 2'; }
.pack b { font: 400 28px 'Luckiest Guy'; color: var(--neon); }
.pack:hover, .pack:focus-visible { border-color: var(--neon); outline: none; }
.slider-row input:not([type=range]):not([type=checkbox]) { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: 700 15px 'Baloo 2'; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 8px 0; }
.tab { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font: 800 13px 'Baloo 2'; cursor: pointer; }
.tab.on { background: var(--neon); color: #0b0b0b; border-color: var(--neon); }
.tabs.small .tab { padding: 3px 10px; font-size: 12px; }
.board { list-style: none; margin: 8px 0; padding: 0; text-align: left; max-height: 50vh; overflow: auto; }
.board li { display: flex; gap: 10px; align-items: center; padding: 7px 6px; border-bottom: 1px dashed var(--line); }
.board li.me { background: rgba(204,255,0,.08); }
.board .rk { width: 28px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.board .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.board .sc { color: var(--neon); font-weight: 800; font-variant-numeric: tabular-nums; }
.ts-box { display: flex; justify-content: center; min-height: 0; margin-top: 8px; }
/* Centre the menu when it fits, but never clip its top when it doesn't. */
.screen { justify-content: flex-start; }
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }
.pick-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.pick { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: var(--text); font: 700 13px 'Baloo 2', sans-serif; cursor: pointer; min-width: 0; }
.pick .prev { width: 100%; height: auto; aspect-ratio: 160 / 104; border-radius: 8px; display: block; }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick.on { border-color: var(--neon); box-shadow: var(--neon-glow); }
.pick.on span::before { content: '✓ '; color: var(--neon); }
.pick:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.claimed { margin: 8px 0; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--neon); color: var(--neon); font-weight: 800; background: rgba(204,255,0,.06); }
.lv.locked { opacity: .55; border-style: dashed; }
.lv.locked::after { content: '🔒'; position: absolute; right: 3px; bottom: 1px; font-size: 10px; }
