:root {
  --bg: #070A12; --panel: #101726; --line: #23304A; --text: #EAF0FA; --muted: #9DA9C2;
  --sky: #7CC7FF; --sky-d: #2F7FC0; --green: #14F195; --green-d: #0A8F5A; --purple: #B98CFF; --gold: #FFD23F; --red: #FF8A8A;
  --pixel: "Press Start 2P", monospace; --mono: "Space Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); -webkit-tap-highlight-color: transparent; }
body { display: flex; justify-content: center; overscroll-behavior: none; }
#app { width: 100%; max-width: 440px; min-height: 100dvh; position: relative; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.screen { display: none; flex-direction: column; gap: 16px; padding: max(16px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom)); min-height: 100dvh; }
.screen.active { display: flex; }

.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.gap { gap: 10px; } .gap-s { gap: 8px; } .gap > * { flex: 1; }
.center { text-align: center; align-items: center; }
.pad-top { padding-top: 28px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .tiny { font-size: 11px; line-height: 1.5; margin: 0; }
.accent { color: var(--sky); } .accent2 { color: var(--green); } .red { color: var(--red); }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 0; font-weight: 400; }

.topbar { display: flex; justify-content: space-between; align-items: center; }
.tag { font-family: var(--pixel); font-size: 9px; color: var(--muted); }
.chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: none; border-radius: 999px; padding: 0 14px; min-height: 44px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--sky); }

.hero { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 18px; }
.logo-stack { width: 132px; height: 64px; }
.logo { margin: 0; font-family: var(--pixel); font-size: 30px; line-height: 1.3; text-align: center; letter-spacing: 1px; }
.logo span { color: var(--sky); }
.logo.small { font-size: 14px; text-align: left; }
h2.logo { font-size: 22px; }
.sub { margin: 0; font-size: 14px; color: var(--muted); text-align: center; max-width: 280px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.pool { font-family: var(--pixel); font-size: 22px; color: var(--sky); }
.pool.small { font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 12px; }
.stats div, .mini { background: var(--bg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.mini { background: var(--panel); padding: 14px; }
.stats b { font-size: 15px; } .mini b { font-size: 18px; }

.btn-primary { min-height: 56px; background: var(--sky); color: var(--bg); border: 0; border-radius: 14px; font-family: var(--pixel); font-size: 14px; box-shadow: 0 5px 0 var(--sky-d); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--sky-d); }
.btn-primary:disabled { opacity: .5; }
.btn-primary.big { min-height: 66px; font-size: 18px; }
.btn-ghost { min-height: 48px; background: none; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; font-weight: 700; }
.btn-ghost.slim { flex: none; padding: 0 16px; }
.btn-gold { min-height: 58px; background: none; border: 2px solid var(--gold); color: var(--gold); border-radius: 14px; font-weight: 700; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; background: none; font-size: 22px; }
.badge { background: var(--green); color: var(--bg); font-weight: 700; font-size: 12px; padding: 5px 10px; border-radius: 6px; }
.score-big { font-family: var(--pixel); font-size: 32px; }

input { width: 100%; min-height: 48px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 15px; }
input::placeholder { color: #66738F; }

/* play */
#play { gap: 10px; padding-top: max(12px, env(safe-area-inset-top)); touch-action: none; user-select: none; -webkit-user-select: none; }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--pixel); font-size: 11px; }
.hud > div { display: flex; flex-direction: column; gap: 6px; }
.hud .c { align-items: center; } .hud .r { align-items: flex-end; }
.hud-l { color: var(--muted); font-size: 8px; }
.hud .nextbox { align-items: center; gap: 4px; }
#next { width: 54px; height: 34px; display: block; }
.field { flex: 1; min-height: 0; position: relative; border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; }
#game { display: block; max-width: 100%; max-height: 100%; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 0 0 4px #0C1322, 0 0 32px rgba(124, 199, 255, .08); }
.paused { position: absolute; inset: 0; border-radius: 12px; background: rgba(7, 10, 18, .9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 40px; }
.paused[hidden] { display: none; }
.paused button { width: 100%; max-width: 240px; }
.controls { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pad { min-width: 44px; height: 64px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; font-size: 22px; touch-action: none; }
.pad.on { background: var(--line); }
.pad.drop { background: var(--green); color: var(--bg); border: 0; box-shadow: 0 5px 0 var(--green-d); font-size: 26px; }
.pad.drop.on { transform: translateY(3px); box-shadow: 0 2px 0 var(--green-d); background: var(--green); }

/* lists */
.list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: 14px; }
.list li.top { background: var(--panel); }
.list .rk { width: 28px; font-weight: 700; color: var(--muted); }
.list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .pz { color: var(--sky); font-size: 12px; }
#history li { background: var(--panel); }
.me-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; border: 2px solid var(--sky); font-size: 14px; font-weight: 700; }
.me-row .nm { flex: 1; }
.split { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-size: 11px; text-align: center; }
.split div { background: var(--bg); border-radius: 8px; padding: 8px 4px; display: flex; flex-direction: column; gap: 2px; }

.banner { margin-top: auto; display: flex; justify-content: center; min-height: 50px; }
.banner[hidden] { display: none; }
