/* The floor every product stands on. To give a product its own look, edit
   the tokens in :root (and their dark twins below) — the palette, the type
   scale, the shape — and the rules underneath spend them consistently. */
:root {
  color-scheme: light dark;

  /* Palette. Warm neutrals, one accent. Keep the contrast when changing. */
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --bg: #faf9f7;
  --surface: #ffffff;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --block: #2c2a28;

  /* Type scale. */
  --step-0: 0.9375rem; /* small print */
  --step-1: 1.0625rem; /* body */
  --step-2: 1.375rem; /* section headings */
  --step-3: clamp(2.25rem, 6vw, 3rem); /* the masthead */

  /* Shape. */
  --radius: 10px;
  --shadow: 0 1px 2px rgb(28 25 23 / 0.05), 0 6px 20px rgb(28 25 23 / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece9e6;
    --muted: #a39d97;
    --line: #2e2b28;
    --bg: #151312;
    --surface: #1e1b1a;
    --accent: #66bd92;
    --accent-ink: #10251b;
    --block: #c9c4bf;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    var(--step-1) / 1.6 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

.masthead,
main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* The product's name and its one sentence: the first thing a visitor reads,
   so it is the largest thing on the page, marked with the product's own
   colour rather than fenced off by a rule line. */
.masthead {
  padding-top: 4rem;
  padding-bottom: 2rem;
}

.masthead::before {
  content: "";
  display: block;
  width: 2.25rem;
  height: 0.3rem;
  border-radius: 999px;
  background: var(--accent);
  margin-bottom: 1.25rem;
}

.masthead h1 {
  margin: 0 0 0.5rem;
  font-size: var(--step-3);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 750;
  text-wrap: balance;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: var(--step-1);
  max-width: 34rem;
  text-wrap: pretty;
}

main {
  padding-bottom: 3rem;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: var(--step-2);
  letter-spacing: -0.015em;
  font-weight: 650;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Form controls, so a first form never ships in the browser's default dress. */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.5rem 0.75rem;
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
  padding-inline: 1rem;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

/* The board-selection screen: one card per puzzle a visitor can pick. */
.boards {
  display: grid;
  gap: 1.25rem;
}

.board {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem 1.4rem;
  display: grid;
  gap: 0.85rem;
}

.board__title {
  margin: 0;
  font-size: var(--step-2);
  letter-spacing: -0.015em;
  font-weight: 650;
}

.board__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--step-0);
}

/* A difficulty is a labelled chip, so a visitor spots the easy from the hard
   at a glance and never reads "easy" and "hard" as the same colour. */
.board__difficulty {
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.board__difficulty--easy {
  color: var(--accent);
  border-color: var(--accent);
}

.board__difficulty--medium {
  color: #8a5a2b;
  border-color: #8a5a2b;
}

@media (prefers-color-scheme: dark) {
  .board__difficulty--medium {
    color: #d8a36a;
    border-color: #d8a36a;
  }
}

.board__difficulty--hard {
  color: #9a3b3b;
  border-color: #9a3b3b;
}

@media (prefers-color-scheme: dark) {
  .board__difficulty--hard {
    color: #e08a8a;
    border-color: #e08a8a;
  }
}

.board__size,
.board__words {
  white-space: nowrap;
}

.board__play {
  justify-self: start;
}

/* A thumbnail of the grid: filled squares for the letters, gaps for the
   blocks. It shows the shape of the puzzle before a visitor presses play. */
.board__preview {
  display: flex;
  justify-content: flex-start;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1.1rem);
  grid-template-rows: repeat(var(--rows), 1.1rem);
  gap: 2px;
}

.board__cell {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 2px;
}

.board__cell--letter {
  background: var(--accent);
  opacity: 0.85;
}

.board__cell--block {
  background: var(--block);
  opacity: 0.12;
}

/* An empty state is a designed state, not an absence. */
.empty {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Playable board chrome. */
.play-board {
  display: grid;
  gap: 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--step-0);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.back-link::before {
  content: "←";
}

.back-link:hover {
  color: var(--accent);
}

.play-title {
  margin: 0;
  font-size: var(--step-2);
  font-weight: 650;
  letter-spacing: -0.015em;
}

/* Playable crossword grid.
   The cell count is set via --cols and --rows inline. Each cell is a
   fixed fraction of a min() so the grid stays readable on a phone. */
.play-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 3px;
  width: min(100%, 24rem);
  aspect-ratio: var(--cols) / var(--rows);
}

.play-cell {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  min-width: 0;
  min-height: 0;
}

.play-block {
  background: var(--block);
  opacity: 0.85;
  border-radius: 3px;
}

.play-input {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(0.875rem, 4.5vw, 1.25rem);
  font-weight: 650;
  border-radius: 0;
  caret-color: transparent;
}

.play-input:focus {
  outline: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* A word solved: every cell holds the right letter, so the cells light up
   green on the spot. The accent is already the product's green in both
   schemes — a strong tint here reads as "right" against the neutral cells. */
.play-cell--solved {
  background: var(--accent);
  border-color: var(--accent);
}

.play-cell--solved .play-input {
  color: var(--accent-ink);
}

.cell-number {
  position: absolute;
  top: 0.1rem;
  left: 0.15rem;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}

/* Clue lists sit below the grid and read clearly on narrow screens. */
.play-board .across-clues,
.play-board .down-clues {
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

.play-board ol {
  margin: 0;
  padding-left: 1.5rem;
  display: grid;
  gap: 0.4rem;
  color: var(--ink);
  font-size: var(--step-1);
}

.play-board li {
  padding-left: 0.35rem;
}
