:root {
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --surface-sunken: #efece4;
  --ink: #23272e;
  --ink-soft: #6b7280;
  --line: #ddd8cc;
  --accent: #b4531f;
  --accent-ink: #ffffff;
  --centre: #f0c23c;
  --centre-ink: #3a2c06;
  --good: #2f7d4f;
  --bad: #b23b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 16, 8, 0.06), 0 8px 24px rgba(20, 16, 8, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1b1f24;
    --surface-sunken: #23282f;
    --ink: #e8e6e1;
    --ink-soft: #9aa2ad;
    --line: #313840;
    --accent: #e8763a;
    --accent-ink: #1b1005;
    --centre: #f0c23c;
    --centre-ink: #3a2c06;
    --good: #5fbf85;
    --bad: #e2706e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px 16px 48px;
  -webkit-text-size-adjust: 100%;
}

.masthead {
  max-width: 900px;
  margin: 0 auto 24px;
  text-align: center;
}

.masthead h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 6px;
  font-weight: 700;
}

.tagline {
  margin: 0 auto;
  max-width: 58ch;
  color: var(--ink-soft);
  font-size: 0.925rem;
}

.board {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.play,
.answers {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* --- status --- */

.statusbar {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat:last-child {
  text-align: right;
}

.stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  text-align: left;
}

.timer.paused {
  color: var(--ink-soft);
}

.timer.paused::after {
  content: " paused";
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 220ms ease;
}

.progress-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--bg);
  opacity: 0.85;
}

.puzzle-label {
  margin: 0 0 14px;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--ink-soft);
}

.puzzle-label.practice {
  color: var(--accent);
}

/* --- grid --- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 280px;
  margin: 0 auto 20px;
}

.tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface-sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, background 120ms ease;
  font-family: inherit;
}

.tile:hover {
  transform: translateY(-1px);
}

.tile:active {
  transform: translateY(1px);
}

.tile.centre {
  background: var(--centre);
  color: var(--centre-ink);
  border-color: transparent;
}

.tile.spent {
  opacity: 0.32;
}

/* --- entry --- */

.entry {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

#guess {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  font-size: 1.05rem;
  font-family: inherit;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--surface-sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}

#guess::placeholder {
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink-soft);
}

#guess:focus-visible,
.btn:focus-visible,
.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  background: var(--surface-sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease;
}

.btn:hover {
  background: var(--line);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn:disabled:hover {
  background: var(--surface-sunken);
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

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

.message {
  margin: 0 0 14px;
  min-height: 1.5em;
  font-size: 0.9rem;
  font-weight: 600;
}

.message.good {
  color: var(--good);
}

.message.bad {
  color: var(--bad);
}

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

.controls .btn {
  flex: 1 1 auto;
}

/* --- answers --- */

.answers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.answers-head h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.pill {
  background: var(--surface-sunken);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 22rem;
  overflow-y: auto;
}

.word-list li {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.word-list li.found {
  border-color: var(--good);
  color: var(--good);
}

.word-list li.missed {
  opacity: 0.6;
}

.word-list li.nine {
  background: var(--centre);
  color: var(--centre-ink);
  border-color: transparent;
  font-weight: 700;
}

.empty {
  color: var(--ink-soft);
  font-size: 0.875rem;
  margin: 0;
}

.colophon {
  max-width: 900px;
  margin: 28px auto 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.colophon p {
  margin: 0;
}

@media (max-width: 720px) {
  .board {
    grid-template-columns: minmax(0, 1fr);
  }

  .word-list {
    max-height: none;
  }
}
