:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --bg-quaternary: #1C1E21;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --gold: #ffcc44;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.5);
  --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', 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: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 24px var(--focus-glow);
}

.hidden { display: none !important; }

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

#home h1 {
  font-size: 54px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -1.5px;
  text-align: center;
  line-height: 1;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 10px;
  margin-bottom: 36px;
  letter-spacing: 0.5px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 360px;
}

.menu-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 500;
  padding: 18px 24px;
  border-radius: var(--radius-md);
  min-height: 72px;
  width: 100%;
  text-align: center;
}

.menu-btn span {
  color: var(--accent);
  font-weight: 700;
}

.menu-btn:focus {
  background: var(--bg-quaternary);
}

.hint {
  margin-top: 36px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* ===== SETTINGS / HOW ===== */
#settings,
#how {
  padding: 40px 32px;
  align-items: center;
  justify-content: center;
}

#settings h2,
#how h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--text-primary);
  text-align: center;
}

.disc-options {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.disc-opt {
  width: 80px;
  height: 80px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 32px;
  font-weight: 700;
  border-radius: var(--radius-md);
}

.disc-opt.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: #000;
}

.info {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 28px;
}

.info span {
  color: var(--accent);
  font-weight: 700;
}

#settings .menu-btn,
#how .menu-btn {
  width: 240px;
}

.rules {
  list-style: none;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 480px;
}

.rules li {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-secondary);
  padding-left: 18px;
  position: relative;
}

.rules li::before {
  content: '\2022';
  color: var(--accent);
  position: absolute;
  left: 0;
  font-weight: bold;
  font-size: 18px;
  line-height: 1;
}

.rules li b {
  color: var(--accent);
  font-weight: 700;
}

/* ===== GAME ===== */
#game {
  padding: 10px;
  gap: 8px;
}

.game-hud {
  display: flex;
  justify-content: space-around;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 90px;
}

.hud-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.hud-item span:last-child {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.board {
  flex: 1;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  position: relative;
  padding: 48px 6px 4px;
}

.peg {
  position: relative;
  width: 175px;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.peg-carry {
  position: absolute;
  top: 8px;
  left: 50%;
  height: 22px;
  border-radius: 6px;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 18px rgba(0, 212, 255, 0.6), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
  z-index: 5;
  transform: translateX(-50%);
}

.peg:focus .peg-carry.active {
  display: block;
  animation: float 1.2s ease-in-out infinite alternate;
}

@keyframes float {
  from { transform: translateX(-50%) translateY(0); }
  to   { transform: translateX(-50%) translateY(-6px); }
}

.peg-rod {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 260px;
  background: linear-gradient(180deg, #3a3a4a 0%, #1a1a2a 100%);
  border-radius: 5px;
  z-index: 1;
}

.peg-base {
  position: absolute;
  bottom: 22px;
  left: 12px;
  right: 12px;
  height: 14px;
  background: linear-gradient(180deg, #4a4a5a, #2a2a3a);
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.peg-label {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
}

.peg-stack {
  position: absolute;
  bottom: 36px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 2px;
  z-index: 2;
}

.disc {
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.4);
}

.peg.flash-error {
  animation: shake 0.32s ease-out;
}

.peg.flash-error::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: rgba(255, 68, 102, 0.2);
  pointer-events: none;
  z-index: 10;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.game-controls {
  display: flex;
  gap: 8px;
}

.game-btn {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  padding: 10px;
  border-radius: var(--radius-md);
  min-height: 46px;
}

/* ===== WIN ===== */
#win {
  align-items: center;
  justify-content: center;
  padding: 30px 40px;
}

.win-title {
  font-size: 56px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-secondary), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 20px;
  text-align: center;
  line-height: 1;
}

.win-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  min-width: 110px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}

.win-msg {
  color: var(--accent-secondary);
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0 18px;
  min-height: 20px;
  letter-spacing: 0.5px;
}

#win .menu-btn {
  width: 280px;
  margin-bottom: 10px;
}
