: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 {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 380px; min-height: 76px; padding: 0 24px;
  background: var(--bg-tertiary); color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 24px; font-weight: 600; letter-spacing: 0.3px;
}
.btn-primary { background: linear-gradient(135deg, #0a8bb0, #00d4ff); color: #04141a; }
.btn-tag {
  background: rgba(0, 0, 0, 0.25); color: var(--accent);
  font-size: 18px; font-weight: 700; padding: 4px 12px; border-radius: 8px;
}
.btn-primary .btn-tag { background: rgba(4, 20, 26, 0.3); color: #04141a; }

/* ---------- Home ---------- */
.home-inner {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 24px;
}
.logo { display: flex; gap: 8px; margin-bottom: 4px; }
.seg { width: 30px; height: 30px; border-radius: 7px; }
.seg-1 { background: #0a6a86; }
.seg-2 { background: #0a99c0; }
.seg-3 { background: var(--accent); box-shadow: 0 0 14px var(--focus-glow); }
.seg.food { background: var(--accent-secondary); border-radius: 50%; box-shadow: 0 0 14px rgba(0,255,136,0.45); }
.title {
  font-size: 52px; font-weight: 800; letter-spacing: 2px; line-height: 1;
  display: flex; flex-direction: column; align-items: center;
}
.title-accent { color: var(--accent); }
.subtitle { font-size: 20px; color: var(--text-secondary); margin-bottom: 8px; }
.menu { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.best {
  margin-top: 6px; font-size: 20px; color: var(--text-secondary);
}
.best span { color: var(--accent-secondary); font-weight: 700; font-size: 24px; }
.hint { font-size: 15px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Top bar (howto) ---------- */
.bar {
  height: 72px; display: flex; align-items: center; padding: 0 28px;
  background: var(--bg-secondary); border-bottom: 1px solid var(--bg-tertiary);
}
.bar h2 { font-size: 28px; font-weight: 700; }
.bar-foot {
  padding: 18px 0 26px; display: flex; justify-content: center;
  background: var(--bg-secondary); border-top: 1px solid var(--bg-tertiary);
}

/* ---------- How to play ---------- */
.howto-body { flex: 1; padding: 22px 28px; overflow: hidden; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 18px; }
.steps li { display: flex; align-items: flex-start; gap: 16px; }
.step-ic {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 12px;
  background: var(--bg-tertiary); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.steps b { font-size: 21px; display: block; margin-bottom: 2px; }
.steps p { font-size: 16px; color: var(--text-secondary); line-height: 1.35; }

/* ---------- Game HUD ---------- */
.hud {
  height: 60px; flex: 0 0 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.hud-stat { display: flex; flex-direction: column; line-height: 1.05; }
.hud-right { align-items: flex-end; }
.hud-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.hud-val { font-size: 28px; font-weight: 800; }
.hud-right .hud-val { color: var(--accent-secondary); }

.tilt-meter {
  position: relative; width: 56px; height: 56px; border-radius: 12px;
  background: var(--bg-tertiary);
  background-image:
    linear-gradient(rgba(255,255,255,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 50% 50%; background-position: center;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.tilt-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--focus-glow);
  transition: transform 0.08s linear;
}
.meter-label {
  position: absolute; font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-muted); display: none;
}
.tilt-meter.no-sensor .tilt-dot { display: none; }
.tilt-meter.no-sensor .meter-label { display: block; }

/* ---------- Board ---------- */
.board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
#board {
  width: 480px; height: 480px;
  border: 2px solid var(--bg-tertiary); border-radius: var(--radius-md);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.08);
  background: var(--bg-primary);
}
.game-hint {
  flex: 0 0 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-muted);
}

/* ---------- Overlay (pause) ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 5;
  background: rgba(10, 10, 15, 0.9);
  display: flex; align-items: center; justify-content: center;
}
.overlay-card {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 36px 44px; background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary); border-radius: 18px;
}
.overlay-card h2 { font-size: 34px; font-weight: 800; margin-bottom: 6px; }

/* ---------- Game over ---------- */
.over-inner {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px;
}
.over-title { font-size: 46px; font-weight: 800; color: var(--danger); letter-spacing: 1px; }
.over-scores { display: flex; gap: 56px; }
.over-block { display: flex; flex-direction: column; align-items: center; }
.over-num { font-size: 56px; font-weight: 800; line-height: 1; }
.over-num.accent { color: var(--accent-secondary); }
.over-cap { font-size: 16px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }
.new-best { font-size: 22px; color: var(--accent); font-weight: 700; }
