: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;
  -webkit-font-smoothing: antialiased;
}

#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; }
.hidden { display: none !important; }

.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);
}

.c-danger { color: var(--danger); }
.c-good { color: var(--accent-secondary); }

/* ============ HOME ============ */
.home-inner {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; padding: 40px;
}

.logo {
  position: relative;
  width: 150px; height: 90px;
  display: flex; align-items: center; justify-content: center;
}
.logo-head {
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #1e1e2e, #0a0a0f);
  border: 3px solid var(--accent);
  box-shadow: 0 0 26px var(--focus-glow);
  transform: rotate(-16deg);
}
.logo-arrow {
  position: absolute; font-size: 22px; color: var(--accent-secondary);
  opacity: 0.85;
}
.logo-arrow.left { left: 4px; animation: nudgeL 1.6s ease-in-out infinite; }
.logo-arrow.right { right: 4px; animation: nudgeR 1.6s ease-in-out infinite; }
@keyframes nudgeL { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-6px); } }
@keyframes nudgeR { 0%,100% { transform: translateX(0); } 50% { transform: translateX(6px); } }

.title {
  font-size: 56px; font-weight: 800; letter-spacing: 5px;
  background: linear-gradient(120deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline { font-size: 19px; color: var(--text-secondary); }

.hi-row {
  display: flex; align-items: baseline; gap: 12px;
  background: var(--bg-primary); border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md); padding: 10px 22px;
}
.hi-label { font-size: 14px; letter-spacing: 2px; color: var(--text-muted); }
.hi-value { font-size: 30px; font-weight: 800; color: var(--accent-secondary); }

.menu { display: flex; flex-direction: column; gap: 14px; width: 320px; margin-top: 6px; }

.menu-btn {
  height: 64px; border-radius: var(--radius-md);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 21px; font-weight: 700; letter-spacing: 1.5px;
  display: flex; align-items: center; justify-content: center;
}
.menu-btn.primary {
  background: linear-gradient(120deg, rgba(0,212,255,0.18), rgba(0,255,136,0.16));
  border-color: rgba(0, 212, 255, 0.35);
}
.menu-btn:focus { background: var(--bg-tertiary); }

.sensor-note {
  font-size: 13px; color: var(--text-muted); margin-top: 4px;
  letter-spacing: 0.5px;
}
.sensor-note.on { color: var(--accent-secondary); }

/* ============ PANELS (howto / pause / over) ============ */
.panel {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 22px; padding: 44px;
}
.panel-title {
  font-size: 36px; font-weight: 800; letter-spacing: 3px;
}
.panel-title.danger { color: var(--danger); text-shadow: 0 0 24px rgba(255,68,102,0.4); }

.ctl-list { list-style: none; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
.ctl-list li {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-primary); border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md); padding: 14px 18px;
}
.key {
  flex-shrink: 0; min-width: 92px; text-align: center;
  background: var(--bg-tertiary); border-radius: 8px;
  padding: 8px 10px; font-size: 16px; font-weight: 700;
  letter-spacing: 1px; color: var(--accent);
}
.desc { font-size: 16px; color: var(--text-secondary); line-height: 1.35; }
.hint { font-size: 16px; color: var(--text-secondary); max-width: 460px; text-align: center; line-height: 1.45; }

.score-row { display: flex; gap: 20px; }
.score-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-primary); border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md); padding: 18px 36px; min-width: 150px;
}
.score-label { font-size: 14px; letter-spacing: 2px; color: var(--text-muted); }
.score-value { font-size: 46px; font-weight: 800; }
.new-best {
  font-size: 20px; font-weight: 800; letter-spacing: 2px;
  color: var(--accent-secondary); text-shadow: 0 0 18px rgba(0,255,136,0.45);
}

/* ============ GAME ============ */
#game { display: block; }
#canvas {
  position: absolute; top: 0; left: 0;
  width: 600px; height: 600px;
}

.hud {
  position: absolute; top: 0; left: 0; right: 0;
  height: 72px; display: flex; justify-content: space-between;
  align-items: center; padding: 0 26px;
  background: linear-gradient(180deg, var(--bg-primary), rgba(10,10,15,0.0));
  border-bottom: 1px solid rgba(255,255,255,0.05);
  pointer-events: none;
}
.hud-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 90px; }
.hud-cell.lives { min-width: 120px; }
.hud-label { font-size: 12px; letter-spacing: 2px; color: var(--text-muted); }
.hud-value { font-size: 26px; font-weight: 800; }
.hud-cell.lives .hud-value { color: var(--danger); letter-spacing: 3px; font-size: 24px; }

.tilt-wrap {
  position: absolute; top: 78px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
}
.tilt-track {
  position: relative; width: 220px; height: 10px;
  background: var(--bg-primary); border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
}
.tilt-center {
  position: absolute; left: 50%; top: -3px; width: 2px; height: 16px;
  background: var(--text-muted); transform: translateX(-50%);
}
.tilt-marker {
  position: absolute; top: 50%; left: 50%;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 14px var(--focus-glow);
  transform: translate(-50%, -50%);
  transition: left 0.05s linear;
}
.tilt-mode {
  font-size: 11px; letter-spacing: 2px; color: var(--text-muted);
}
.tilt-mode.sensor { color: var(--accent-secondary); }

.game-focus {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 4px;
  border: none !important; box-shadow: none !important;
}

.banner {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg-primary); border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md); padding: 18px 34px;
  font-size: 26px; font-weight: 800; letter-spacing: 2px;
  color: var(--accent); text-align: center;
  box-shadow: 0 0 30px rgba(0,0,0,0.6);
}
