:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --info: #00b4d8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  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;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  flex: 1;
}
.header-meta {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-secondary);
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}

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

/* --- Game Canvas --- */
.game-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
}

#game-canvas {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-tertiary);
}

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

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
}
.nav-item.primary:focus { background: #33ddff; }
.nav-item.danger {
  background: var(--danger);
  color: white;
}

/* --- Game Over Overlay --- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
}

.game-over-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 4px;
}

.game-over-score {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent-secondary);
  line-height: 1;
}

.game-over-label {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.game-over-best {
  font-size: 14px;
  color: var(--accent-warm);
  margin-bottom: 16px;
}

.overlay-btn {
  width: 240px;
}

/* --- List Items (High Scores) --- */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 400px;
}
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  gap: 12px;
}
.list-item-rank {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary);
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.list-item-rank.gold { color: var(--accent-warm); }
.list-item-rank.silver { color: #c0c0c0; }
.list-item-rank.bronze { color: #cd7f32; }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 500;
}
.list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.list-item-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  background: rgba(0, 255, 136, 0.15);
  color: var(--accent-secondary);
  flex-shrink: 0;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 40px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 16px;
}

/* --- Utility --- */
.hidden { display: none !important; }
