: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;
  --radius-sm: 8px;
  --c0: #ff4466;
  --c1: #ff9944;
  --c2: #ffdd44;
  --c3: #00ff88;
  --c4: #00d4ff;
  --c5: #cc44ff;
}

* { 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;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
}

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

.screen {
  width: 100%; height: 100%;
  position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
  padding: 16px;
}

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

/* ===== Slot (color circle) ===== */
.slot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.slot.c0, .slot.c1, .slot.c2, .slot.c3, .slot.c4, .slot.c5 {
  border-color: rgba(255,255,255,0.35);
}

.slot.c0 { background: var(--c0); }
.slot.c1 { background: var(--c1); }
.slot.c2 { background: var(--c2); }
.slot.c3 { background: var(--c3); }
.slot.c4 { background: var(--c4); }
.slot.c5 { background: var(--c5); }

.slot.lg {
  width: 44px; height: 44px;
  border-width: 2px;
}

.slot.lg.empty {
  background: transparent;
  border: 2px dashed var(--text-muted);
}

.slot.xl {
  width: 52px; height: 52px;
  border-width: 2px;
  box-shadow: 0 0 16px rgba(255,255,255,0.05);
}

/* ===== Feedback peg ===== */
.fb {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.05);
}

.fb.b {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.fb.w {
  background: #ffffff;
  border-color: #ffffff;
}

.fb.lg {
  width: 14px; height: 14px;
}

/* ===== HOME ===== */
.home-content {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
}

.title {
  font-size: 52px; font-weight: 800;
  letter-spacing: 4px;
  color: var(--text-primary);
}

.title .accent {
  color: var(--accent);
  text-shadow: 0 0 24px var(--focus-glow);
}

.subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.stats-mini {
  display: flex;
  background: var(--bg-secondary);
  padding: 10px 4px;
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.stat-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 18px;
  min-width: 80px;
}

.stat-item + .stat-item {
  border-left: 1px solid var(--bg-tertiary);
}

.stat-num {
  font-size: 22px; font-weight: 700;
  color: var(--accent-secondary);
  line-height: 1.1;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 4px;
}

.home-menu {
  display: flex; flex-direction: column;
  gap: 10px;
  width: 340px;
  margin-top: 8px;
}

.menu-btn {
  height: 60px;
  padding: 0 24px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 17px; font-weight: 600;
  letter-spacing: 1.5px;
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-tertiary);
  text-align: left;
}

.menu-btn.primary {
  background: var(--bg-tertiary);
  color: var(--accent);
  border-color: rgba(0, 212, 255, 0.35);
}

.menu-btn.secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--bg-tertiary);
  height: 48px;
  font-size: 13px;
}

.menu-btn:focus {
  background: var(--bg-tertiary);
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  color: var(--text-primary);
}

.menu-btn.primary:focus {
  color: var(--accent);
}

/* ===== HOW TO PLAY ===== */
.how-content {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  gap: 16px;
}

.how-content h2 {
  font-size: 26px;
  color: var(--accent);
  text-align: center;
  letter-spacing: 3px;
  font-weight: 700;
  margin-top: 8px;
}

.how-body {
  flex: 1;
  background: var(--bg-secondary);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  display: flex; flex-direction: column;
  gap: 12px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.how-body strong { color: var(--text-primary); font-weight: 700; }
.how-body p { margin: 0; }

.legend-row {
  display: flex; align-items: center; gap: 14px;
  font-size: 14px;
  padding-left: 8px;
}

.ctl {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-align: center;
  padding-top: 8px;
}

/* ===== GAME ===== */
.game-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  height: 44px;
  flex-shrink: 0;
}

.tries-info {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 3px;
}

.tries-info #tryNum {
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

.back-btn {
  width: 44px; height: 44px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 18px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-tertiary);
}

.header-spacer { width: 44px; height: 44px; }

.board {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 10px;
  display: flex; flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.row {
  display: flex; align-items: center; gap: 12px;
  height: 26px;
  padding: 0 4px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.row.active {
  background: rgba(0, 212, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 212, 255, 0.2);
}

.row-num {
  font-size: 11px;
  color: var(--text-muted);
  width: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.row.active .row-num {
  color: var(--accent);
}

.row-colors {
  display: flex; gap: 6px;
}

.row-feedback {
  display: grid;
  grid-template-columns: repeat(4, 8px);
  gap: 3px;
  margin-left: auto;
}

.current-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 12px 12px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.current-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 600;
}

.current-row {
  display: flex; gap: 14px;
  justify-content: center;
}

.color-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.color-btn {
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  padding: 0;
}

.color-btn.c0 { background: var(--c0); }
.color-btn.c1 { background: var(--c1); }
.color-btn.c2 { background: var(--c2); }
.color-btn.c3 { background: var(--c3); }
.color-btn.c4 { background: var(--c4); }
.color-btn.c5 { background: var(--c5); }

.color-btn:focus {
  border-color: #ffffff;
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--focus-glow);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 10px;
  flex-shrink: 0;
}

.action-btn {
  height: 52px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 15px; font-weight: 600;
  letter-spacing: 1.5px;
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-tertiary);
}

.action-btn.submit {
  color: var(--text-muted);
}

.action-btn.submit.ready {
  color: var(--accent-secondary);
  background: var(--bg-tertiary);
  border-color: rgba(0, 255, 136, 0.35);
}

.action-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ===== RESULT ===== */
.result-content {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
}

.result-title {
  font-size: 52px; font-weight: 800;
  letter-spacing: 4px;
}

.result-title.win {
  color: var(--accent-secondary);
  text-shadow: 0 0 32px rgba(0, 255, 136, 0.4);
}

.result-title.lose {
  color: var(--danger);
  text-shadow: 0 0 32px rgba(255, 68, 102, 0.3);
}

.result-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-top: -6px;
}

.result-code {
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  background: var(--bg-secondary);
  padding: 18px 32px;
  border-radius: var(--radius-md);
}

.result-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  font-weight: 600;
}

.code-display {
  display: flex; gap: 14px;
}

.result-menu {
  display: flex; flex-direction: column;
  gap: 10px;
  width: 320px;
  margin-top: 8px;
}
