:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --bg-elevated: #2a2a3d;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --p1-color: #00d4ff;
  --p2-color: #ff9450;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.45);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

* { 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', Roboto, 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: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 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-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
}
.title {
  font-size: 76px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-bottom: 24px;
}
.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 300px;
  margin-top: 8px;
}
.menu-btn {
  height: 72px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
}
.menu-btn:focus {
  background: var(--bg-elevated);
}
.home-hint {
  margin-top: 32px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ========== GAME SCREEN ========== */
.hud {
  height: 68px;
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  padding: 0 18px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.hud-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 700;
}
.hud-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.hud-p1 .hud-label { color: var(--p1-color); }
.hud-p2 .hud-label { color: var(--p2-color); }
.hud-turn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.hud-turn-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.hud-turn-sub {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.board {
  flex: 1;
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  background: var(--bg-primary);
}

.store {
  background: var(--bg-tertiary);
  border-radius: 38px;
  border: 2px solid var(--bg-elevated);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.store-p2 { grid-column: 1; grid-row: 1 / 3; }
.store-p1 { grid-column: 3; grid-row: 1 / 3; }
.store-p2 { border-color: rgba(255, 148, 80, 0.3); }
.store-p1 { border-color: rgba(0, 212, 255, 0.3); }
.store-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}
.store-p1 .store-label { color: var(--p1-color); }
.store-p2 .store-label { color: var(--p2-color); }
.store-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.row {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  align-items: center;
  justify-items: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.row-top { grid-row: 1; }
.row-bottom { grid-row: 2; }

.row-bottom.active {
  background: rgba(0, 212, 255, 0.06);
  border-color: rgba(0, 212, 255, 0.25);
}
.row-top.active {
  background: rgba(255, 148, 80, 0.06);
  border-color: rgba(255, 148, 80, 0.25);
}

.pit {
  width: 100%;
  max-width: 70px;
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: all 0.15s ease;
}
.pit.empty {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
}
.row-bottom .pit.focusable {
  background: rgba(0, 212, 255, 0.12);
  cursor: pointer;
}
.row-top .pit.focusable {
  background: rgba(255, 148, 80, 0.12);
  cursor: pointer;
}
.pit.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  transform: scale(1.1);
}
.pit.last {
  animation: flash 0.6s ease;
}
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.6); }
  60% { box-shadow: 0 0 18px 4px rgba(0, 255, 136, 0.4); }
  100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

.hint {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-primary);
  letter-spacing: 0.5px;
  border-top: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}

/* ========== GAME OVER SCREEN ========== */
.go-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px;
}
.go-trophy {
  font-size: 80px;
  line-height: 1;
  color: var(--accent-secondary);
  text-shadow: 0 0 32px rgba(0, 255, 136, 0.6);
}
.go-winner {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
}
.go-scores {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 20px 36px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}
.go-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 64px;
}
.go-side-label {
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
  text-transform: uppercase;
}
.go-side-p1 .go-side-label { color: var(--p1-color); }
.go-side-p2 .go-side-label { color: var(--p2-color); }
.go-side-score {
  font-size: 44px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.go-sep {
  font-size: 16px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.go-content .menu {
  width: 240px;
  margin-top: 8px;
  gap: 12px;
}
.go-content .menu-btn {
  height: 60px;
  font-size: 18px;
}

/* ========== RULES SCREEN ========== */
.rules-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 24px;
}
.rules-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
}
.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text-primary);
  max-width: 460px;
  background: var(--bg-tertiary);
  padding: 24px 28px;
  border-radius: var(--radius-md);
}
.rules-list li {
  padding-left: 22px;
  position: relative;
}
.rules-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.rules-content .menu-btn {
  width: 240px;
  height: 60px;
  font-size: 18px;
}
