:root {
  --bg:          #000000;
  --bg2:         #0a0a0f;
  --bg3:         #14141f;
  --bg4:         #1a1a2e;
  --txt:         #ffffff;
  --txt2:        #a0a0b0;
  --blue:        #00d4ff;
  --blue-glow:   rgba(0, 212, 255, 0.5);
  --red:         #ff4466;
  --red-glow:    rgba(255, 68, 102, 0.5);
  --green:       #00ff88;
  --warn:        #ffaa00;
  --focus-ring:  #00d4ff;
  --r-sm:        8px;
  --r-md:        14px;
  --r-lg:        20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--txt);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* ── Screens ── */
.screen {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  position: absolute; top: 0; left: 0;
}
.screen.hidden { display: none; }

/* ── Header ── */
.header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: var(--bg2);
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 600; flex: 1; }
.back-btn {
  background: transparent; color: var(--txt);
  font-size: 22px; padding: 8px 12px;
  border-radius: var(--r-sm); border: 2px solid transparent;
}

/* ── Content ── */
.content {
  flex: 1; padding: 20px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}

/* ── Focus ── */
.focusable {
  border: 2px solid transparent;
  cursor: pointer; transition: all 0.15s ease;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--blue-glow);
}

/* ── Buttons ── */
.btn-primary, .btn-secondary, .btn-danger {
  width: 100%; padding: 16px;
  border-radius: var(--r-md);
  font-size: 16px; font-weight: 600;
  text-align: center; border: 2px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: #000; }
.btn-primary:focus { background: #33ddff; box-shadow: 0 0 24px var(--blue-glow); }
.btn-secondary { background: var(--bg3); color: var(--txt); }
.btn-secondary:focus { background: var(--bg4); border-color: var(--focus-ring); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:focus { box-shadow: 0 0 24px var(--red-glow); }

/* ── HOME ── */
.home-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 32px 40px;
}
.home-logo { font-size: 72px; line-height: 1; }
.home-title { font-size: 42px; font-weight: 800; letter-spacing: -1px; }
.home-sub { font-size: 15px; color: var(--txt2); text-align: center; }
.hiscore-pill {
  background: var(--bg3); border-radius: 40px;
  padding: 8px 20px; display: flex; gap: 10px; align-items: center;
}
.hiscore-label { font-size: 11px; font-weight: 700; color: var(--txt2); letter-spacing: 2px; }
.hiscore-val { font-size: 22px; font-weight: 700; color: var(--blue); }
.home-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

/* ── HELP ── */
.help-list { gap: 16px; }
.help-row { display: flex; gap: 14px; align-items: flex-start; }
.help-icon { font-size: 28px; flex-shrink: 0; width: 40px; text-align: center; }
.help-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.help-desc { font-size: 13px; color: var(--txt2); line-height: 1.5; }

/* ── CONTROL SELECT ── */
.control-content { gap: 20px; justify-content: center; }
.control-option {
  width: 100%; display: flex; align-items: center; gap: 20px;
  padding: 24px 20px; background: var(--bg3);
  border-radius: var(--r-lg); border: 2px solid transparent;
  text-align: left; cursor: pointer;
}
.control-option:focus {
  border-color: var(--focus-ring);
  background: var(--bg4);
  box-shadow: 0 0 28px var(--blue-glow);
}
.control-icon  { font-size: 44px; flex-shrink: 0; }
.control-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.control-desc  { font-size: 13px; color: var(--txt2); }

/* ── GAME ── */
#game { position: relative; }
#game-canvas { position: absolute; top: 0; left: 0; width: 600px; height: 600px; }

.game-hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px;
  pointer-events: none; z-index: 10;
}
.hud-left { display: flex; flex-direction: column; gap: 4px; }
.hud-score {
  font-size: 28px; font-weight: 800; color: var(--txt);
  text-shadow: 0 0 12px rgba(255,255,255,0.4);
}
.hud-combo {
  font-size: 16px; font-weight: 700; color: var(--warn);
  text-shadow: 0 0 10px rgba(255,170,0,0.6);
}
.hud-combo.combo-pop { animation: pop 0.25s ease; }
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.saber-color-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 3px;
  padding: 4px 12px; border-radius: 20px;
}
.saber-color-badge.blue { background: rgba(0,212,255,0.2); color: var(--blue); }
.saber-color-badge.red  { background: rgba(255,68,102,0.2); color: var(--red); }

.switch-warning {
  font-size: 13px; font-weight: 800; letter-spacing: 2px;
  color: var(--warn);
  animation: warn-flash 0.5s ease infinite alternate;
}
@keyframes warn-flash {
  from { opacity: 1; }
  to   { opacity: 0.3; }
}
.switch-timer {
  font-size: 22px; font-weight: 800; color: var(--warn);
  text-shadow: 0 0 12px rgba(255,170,0,0.7);
  min-height: 28px;
}

.hud-right { display: flex; flex-direction: column; align-items: flex-end; }
.hud-lives { font-size: 22px; letter-spacing: 3px; color: var(--red); }
.hud-lives.danger { animation: heartbeat 0.6s ease infinite; }
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

/* ── PAUSE / GAME OVER overlays ── */
.overlay-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px; padding: 40px;
  background: rgba(0, 0, 0, 0.85);
}
.overlay-content h1 { font-size: 36px; font-weight: 800; }
.overlay-score { font-size: 18px; color: var(--txt2); }
.overlay-score span { color: var(--blue); font-weight: 700; }
.overlay-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.gameover-icon { font-size: 56px; }
.score-block { text-align: center; }
.score-final { font-size: 64px; font-weight: 900; color: var(--blue); line-height: 1; }
.score-label { font-size: 12px; font-weight: 700; letter-spacing: 3px; color: var(--txt2); }
.new-best-badge {
  background: rgba(255,170,0,0.2); color: var(--warn);
  border-radius: 20px; padding: 6px 16px;
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
}
.best-row { display: flex; gap: 8px; align-items: center; font-size: 16px; color: var(--txt2); }
.best-label { font-weight: 700; letter-spacing: 2px; font-size: 11px; }
.best-row span { color: var(--txt); font-weight: 700; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 60px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--bg4); color: var(--txt);
  padding: 10px 22px; border-radius: 24px;
  font-size: 14px; border: 1px solid var(--blue);
  transition: transform 0.3s ease; z-index: 200; pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); }
.toast.warning { border-color: var(--warn); }
.toast.error   { border-color: var(--red); }

.hidden { display: none !important; }
