:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  width: 100%;
  min-height: 64px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center;
}
.btn-primary {
  background: linear-gradient(135deg, #0c4f5e, #0a2a33);
  color: var(--accent);
  border-color: rgba(0, 212, 255, 0.25);
}
.btn-ghost { background: var(--bg-secondary); color: var(--text-secondary); }

/* ---------- Home ---------- */
.home-inner {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 40px 48px; gap: 28px;
}
.logo { text-align: center; }
.logo-glyph {
  width: 84px; height: 84px; margin: 0 auto 18px;
  border-radius: 18px;
  background: var(--bg-secondary);
  border: 2px solid rgba(0, 212, 255, 0.25);
  position: relative;
  box-shadow: inset 0 0 0 14px var(--bg-primary), 0 0 30px rgba(0,212,255,0.12);
}
.logo-glyph .dot {
  position: absolute; right: 26px; bottom: 26px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}
.title { font-size: 46px; font-weight: 800; letter-spacing: 3px; line-height: 1; }
.title span { color: var(--accent); }
.tagline { margin-top: 12px; color: var(--text-secondary); font-size: 17px; }
.menu { display: flex; flex-direction: column; gap: 14px; }
.menu .btn { min-height: 72px; }
.foot-hint { text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------- Bars / headers ---------- */
.bar {
  height: 64px; display: flex; align-items: center; padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.bar-title { font-size: 24px; font-weight: 700; }
.bar-foot { padding: 16px 24px; background: var(--bg-primary); }

/* ---------- Scroll body ---------- */
.scroll-body {
  flex: 1; overflow-y: auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 12px;
}
.how-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; background: var(--bg-secondary); border-radius: var(--radius-md); }
.how-ic { font-size: 26px; line-height: 1.2; }
.how-row b { font-size: 18px; }
.how-row p { color: var(--text-secondary); font-size: 15px; margin-top: 3px; line-height: 1.4; }

/* ---------- Settings rows ---------- */
.row {
  width: 100%; min-height: 64px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-secondary); border-radius: var(--radius-md);
}
.row-label { font-size: 19px; font-weight: 600; }
.row-val { font-size: 17px; color: var(--accent); font-weight: 600; }
.row-danger .row-val { color: var(--danger); }

/* ---------- Level select ---------- */
.levels-grid {
  flex: 1; padding: 20px 24px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 14px; align-content: start;
}
.level-card {
  min-height: 96px; border-radius: var(--radius-md);
  background: var(--bg-secondary);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  padding: 14px 18px; gap: 2px;
}
.level-card .lvl-num { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1; }
.level-card .lvl-name { font-size: 16px; font-weight: 600; }
.level-card .lvl-sub { font-size: 13px; color: var(--text-secondary); }
.level-card.locked { opacity: 0.4; cursor: default; }
.level-card.locked .lvl-num { color: var(--text-muted); }

/* ---------- HUD ---------- */
.hud {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.hud-lvl { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.hud-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.hud-src {
  font-size: 13px; font-weight: 700; letter-spacing: 1px;
  padding: 5px 10px; border-radius: 8px;
  background: var(--bg-tertiary); color: var(--text-secondary);
}
.hud-src.tilt { color: var(--accent-secondary); background: rgba(0,255,136,0.12); }

/* ---------- Play / canvas ---------- */
.play { flex: 1; display: flex; align-items: center; justify-content: center; }
.canvas-wrap { border-radius: var(--radius-md); padding: 4px; line-height: 0; }
.canvas-wrap:focus { box-shadow: 0 0 24px var(--focus-glow); }
#board { display: block; border-radius: 8px; }

/* ---------- Countdown ---------- */
.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(5,5,10,0.55), rgba(5,5,10,0.15));
}
.countdown span {
  font-size: 140px; font-weight: 800; color: var(--accent);
  text-shadow: 0 0 40px rgba(0,212,255,0.6);
  animation: pop 0.6s ease;
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,5,9,0.9);
}
.panel {
  width: 380px; padding: 28px; border-radius: 18px;
  background: var(--bg-primary);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; gap: 12px;
}
.panel-title { font-size: 30px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.panel-title.win { color: var(--accent-secondary); text-shadow: 0 0 24px rgba(0,255,136,0.4); }
.result { background: var(--bg-secondary); border-radius: var(--radius-md); padding: 8px 16px; margin-bottom: 8px; }
.result-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-size: 18px; }
.result-row span { color: var(--text-secondary); }
.result-row b { font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
