:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --correct: #3d9c4a;
  --present: #d4a02c;
  --absent: #484f58;
  --key-bg: #21262d;
  --key-border: #30363d;
  --focus: #58a6ff;
  --font: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

#app {
  width: 100%;
  max-width: 500px;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  background: linear-gradient(135deg, #3d9c4a 0%, #8b949e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.view {
  animation: fadeIn 0.2s ease;
}

.view.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Setup */
#setup-view h2 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
}

.setup-desc {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.hole-options {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.hole-btn {
  flex: 1;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--key-border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.hole-btn:hover {
  border-color: var(--correct);
  background: rgba(61, 156, 74, 0.1);
}

.custom-holes {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.custom-holes label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#custom-holes {
  width: 4rem;
  padding: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--key-border);
  border-radius: 8px;
  color: var(--text);
}

#start-custom-btn {
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-radius: 8px;
  cursor: pointer;
}

#start-custom-btn:hover {
  background: var(--surface);
}

/* Board */
.game-meta {
  text-align: center;
  margin-bottom: 1rem;
}

#puzzle-progress {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.5rem;
  aspect-ratio: 5 / 6;
  max-height: 320px;
  width: 100%;
  max-width: min(320px, 95vw);
}

.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 5vw, 1.75rem);
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface);
  border: 2px solid var(--key-border);
  border-radius: 6px;
  transition: transform 0.1s, border-color 0.15s, background 0.2s;
}

.cell.filled {
  border-color: var(--text-muted);
}

.cell.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.cell.present {
  background: var(--present);
  border-color: var(--present);
  color: #1a2332;
}

.cell.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
}

.message {
  min-height: 1.5em;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.message.error {
  color: #f85149;
}

/* Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key {
  min-width: 28px;
  height: 48px;
  padding: 0 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text);
  background: var(--absent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, transform 0.05s;
}

.key:hover {
  background: var(--key-border);
}

.key:active {
  transform: scale(0.96);
}

.key.correct {
  background: var(--correct);
  color: #fff;
}

.key.present {
  background: var(--present);
  color: #1a2332;
}

.key.absent {
  background: var(--key-bg);
  color: var(--text-muted);
}

.key.wide {
  min-width: 42px;
  font-size: 0.75rem;
}

.game-actions {
  text-align: center;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn.primary {
  background: var(--correct);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.1);
}

.btn.primary:active {
  transform: scale(0.98);
}

.btn.hidden {
  display: none !important;
}

/* Stats */
#stats-view h2 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

.stats-summary {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stats-summary .stat {
  text-align: center;
}

.stats-summary .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stats-summary .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.stats-puzzles {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stats-puzzle-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--key-border);
}

.stats-puzzle-card h3 {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.stats-puzzle-card .mini-board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  max-width: 220px;
  margin: 0 auto;
  aspect-ratio: 5 / 6;
}

.stats-puzzle-card .mini-board .row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

.stats-puzzle-card .mini-board .cell {
  font-size: 0.75rem;
  border-width: 1px;
}

.stats-puzzle-card .puzzle-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.stats-actions {
  text-align: center;
}
