:root {
  --bg: #07060D; --panel: #13111F; --line: #2A2540; --text: #EDEBF5; --muted: #A6A1BD;
  --gold: #FFD23F; --gold-d: #B88A00; --green: #14F195; --green-d: #0A8F5A; --lead: #B98CFF; --lead-d: #6B3FC4; --red: #FF6B8A;
  --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(--lead); 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(--gold); } .green { color: var(--green); } .red { color: var(--red); } .lead { color: var(--lead); }
.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(--lead); }

.hero { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 18px; }
.hero-gems { width: 238px; height: 44px; }
.logo { margin: 0; font-family: var(--pixel); font-size: 30px; line-height: 1.3; text-align: center; letter-spacing: 1px; }
.logo span { color: var(--gold); text-shadow: 4px 4px 0 var(--gold-d), 8px 8px 0 #1E1A33; }
.big-logo { font-size: 50px; line-height: 1.2; color: var(--lead); letter-spacing: 6px; text-shadow: 4px 4px 0 var(--lead-d), 8px 8px 0 #1E1A33; }
.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(--gold); }
.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(--lead); color: var(--bg); border: 0; border-radius: 14px; font-family: var(--pixel); font-size: 14px; box-shadow: 0 5px 0 var(--lead-d); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--lead-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-alt { 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(--gold); 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: #6E6890; }

/* 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: 6px; 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; }
.field { flex: 1; min-height: 0; position: relative; border: 1px solid var(--line); border-radius: 14px; background: #0B0915; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#game { width: 100%; height: 100%; display: block; object-fit: contain; }
.paused { position: absolute; inset: 0; background: rgba(7, 6, 13, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 40px; }
.paused[hidden] { display: none; }
.goalrow { display: flex; align-items: center; gap: 8px; font-family: var(--pixel); }
.goalrow .hud-l { white-space: nowrap; }
.goalbar { flex: 1; height: 5px; border-radius: 3px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
#goalbar-fill { height: 100%; background: var(--lead); transform-origin: left; transform: scaleX(0); }
.lvup { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 22px; border: 2px solid var(--gold); border-radius: 12px; background: rgba(7, 6, 13, .85); font-family: var(--pixel); text-align: center; animation: lvup 1s ease-out forwards; z-index: 2; }
.lvup b { color: var(--gold); font-size: 18px; } .lvup span { color: var(--muted); font-size: 9px; line-height: 1.5; }
.lvup[hidden] { display: none; }
@keyframes lvup { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.85); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; } }
.paused button { width: 100%; max-width: 240px; }
#play .field { flex: none; align-self: center; width: min(100%, calc(100dvh - 220px)); aspect-ratio: 1; border-radius: 10px; margin: auto 0; }
#game { touch-action: none; }
.hud .icon-btn { width: 44px; height: 44px; }
#sound-btn.off #sound-wave { display: none; }
.timebar { height: 8px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
#timebar-fill { height: 100%; background: linear-gradient(90deg, var(--lead), var(--gold)); transform-origin: left; }
.legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-size: 10px; color: var(--muted); text-align: center; }
.legend span { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--panel); border-radius: 10px; padding: 8px 4px; }
.legend i { width: 22px; height: 22px; border-radius: 50%; display: block; background: var(--lead); }
.legend .lg-line { border-radius: 4px; background: linear-gradient(transparent 40%, #fff 40% 60%, transparent 60%), var(--lead); }
.legend .lg-burst { box-shadow: 0 0 0 3px rgba(185, 140, 255, .35); border: 2px solid #fff; }
.legend .lg-bomb { background: radial-gradient(circle, #fff 18%, #2A2148 22%); border: 2px solid var(--text); }
.legend .lg-time { background: none; border: 3px solid var(--gold); }

/* 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(--gold); 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(--lead); 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; }
