: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; }

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

/* ===== HOME SCREEN ===== */
#home {
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 40px 20px;
}

.title-block {
  text-align: center;
  margin-top: 20px;
}

.title {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 10px;
  line-height: 1;
  color: var(--text-primary);
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.25);
}

.title.accent {
  color: var(--accent-secondary);
  text-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
}

.subtitle {
  margin-top: 18px;
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--text-secondary);
  font-weight: 500;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.menu-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 0 32px;
  min-width: 300px;
  height: 64px;
  border-radius: var(--radius-md);
}

.menu-btn.focusable:focus {
  background: var(--bg-secondary);
  color: var(--accent);
  border-color: var(--focus-ring);
  box-shadow: 0 0 24px var(--focus-glow);
}

.hiscore-display {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--text-secondary);
  font-weight: 600;
}

.hiscore-display span {
  color: var(--accent);
  font-weight: 800;
  margin-left: 6px;
}

/* ===== HOW TO PLAY ===== */
.screen-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-bottom: 1px solid rgba(0, 212, 255, 0.25);
}

.screen-header h2 {
  font-size: 24px;
  letter-spacing: 6px;
  color: var(--accent);
  font-weight: 800;
}

.content {
  flex: 1;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
  justify-content: center;
}

.instructions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.instructions li {
  font-size: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 18px;
}

.key {
  background: var(--bg-tertiary);
  padding: 10px 18px;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 2px;
  min-width: 96px;
  text-align: center;
  font-size: 14px;
}

.key-desc {
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.scoring {
  background: var(--bg-tertiary);
  padding: 18px 26px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 360px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.dot {
  width: 18px;
  height: 14px;
  display: inline-block;
  border-radius: 2px;
  flex-shrink: 0;
}

.dot-top { background: var(--danger); }
.dot-mid { background: var(--accent); }
.dot-bot { background: var(--accent-secondary); }
.dot-ufo { background: #ffaa00; }

.menu-footer {
  padding-bottom: 28px;
}

/* ===== GAME SCREEN ===== */
#game {
  background: var(--bg-primary);
}

.hud {
  height: 60px;
  background: var(--bg-primary);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid rgba(0, 212, 255, 0.3);
  flex-shrink: 0;
}

.hud-item {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-item span {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 900;
  min-width: 40px;
  text-align: right;
}

#canvas {
  display: block;
  width: 600px;
  height: 540px;
  background: #000;
}

/* ===== OVERLAY ===== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.overlay-content {
  background: var(--bg-tertiary);
  padding: 36px 44px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(0, 212, 255, 0.2);
}

.overlay-title {
  font-size: 36px;
  letter-spacing: 8px;
  color: var(--accent);
  margin-bottom: 14px;
  font-weight: 900;
}

/* ===== GAME OVER ===== */
#gameover {
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.gameover-title {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--danger);
  text-shadow: 0 0 24px rgba(255, 68, 102, 0.4);
}

.final-stats {
  background: var(--bg-tertiary);
  padding: 24px 36px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 320px;
  border: 1px solid rgba(0, 212, 255, 0.15);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-secondary);
}

.stat-row span:last-child {
  color: var(--accent);
  font-size: 20px;
  font-weight: 900;
}

.new-hi {
  font-size: 18px;
  letter-spacing: 5px;
  color: var(--accent-secondary);
  font-weight: 900;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.04); }
}
