:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #687386;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: #d8d0bf;
  --accent: #1f7a76;
  --accent-dark: #135452;
  --bad: #bd3f33;
  --good: #276c43;
  --gold: #c08519;
  --shadow: 0 16px 40px rgba(24, 33, 47, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(31, 122, 118, 0.08) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(180deg, #f5efe2 0%, #e8f1ef 100%);
  color: var(--ink);
}

.topbar {
  border-bottom: 1px solid rgba(24, 33, 47, 0.12);
  background: rgba(255, 250, 240, 0.9);
  backdrop-filter: blur(8px);
}

.topbar nav {
  max-width: 1050px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  gap: 10px;
}

.topbar a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
  border: 1px solid rgba(31, 122, 118, 0.28);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fffdf8;
}

.shell {
  width: min(1050px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.intro {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.35rem, 8vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
  margin-bottom: 0;
}

.lede {
  max-width: 680px;
  color: #334157;
  font-size: 1.04rem;
  line-height: 1.55;
  margin-bottom: 0;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 10px;
}

.scoreboard div,
.copy-block,
.controls,
.ledger {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(24, 33, 47, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scoreboard div {
  padding: 12px;
  min-width: 88px;
}

.scoreboard span,
.label-row span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.scoreboard strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.press {
  display: grid;
  gap: 14px;
}

.copy-block {
  padding: 18px;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.line,
.tile-line {
  min-height: 76px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.line {
  padding: 16px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(1.05rem, 3.8vw, 1.6rem);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.tile-line {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.char-tile {
  width: 38px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #cfc5b2;
  border-radius: 6px;
  background: #fffefa;
  color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 1.18rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.char-tile.space {
  color: transparent;
  background-image: linear-gradient(90deg, transparent 42%, rgba(104, 115, 134, 0.45) 42%, rgba(104, 115, 134, 0.45) 58%, transparent 58%);
}

.char-tile.selected {
  border-color: var(--gold);
  background: #ffe7ab;
  box-shadow: inset 0 0 0 2px rgba(192, 133, 25, 0.28);
}

.char-tile.corrected {
  border-color: var(--good);
  background: #dff4e5;
}

.char-tile.missed,
.char-tile.false {
  border-color: var(--bad);
  background: #ffe0dc;
}

.controls {
  margin: 14px 0;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.controls p {
  margin: 0;
  color: #334157;
  line-height: 1.45;
}

.buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 11px 13px;
  background: var(--accent);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#hintBtn {
  background: #7a4d11;
}

#newBtn {
  background: #45546a;
}

.ledger {
  padding: 16px 18px;
}

.ledger h2 {
  margin-bottom: 10px;
}

.ledger ol {
  margin: 0;
  padding-left: 22px;
  color: #334157;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .intro,
  .controls {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    grid-template-columns: repeat(3, 1fr);
  }

  .controls {
    align-items: stretch;
  }

  .buttons {
    justify-content: stretch;
  }

  button {
    flex: 1 1 120px;
  }

  .char-tile {
    width: 32px;
    height: 38px;
    font-size: 1rem;
  }
}
