:root {
  --paper: #f4f8f5;
  --ink: #172121;
  --muted: #5a6663;
  --line: #d4ded8;
  --white: #ffffff;
  --leaf: #2f7d55;
  --leaf-dark: #235f42;
  --gold: #d9aa2e;
  --coral: #d96459;
  --blue: #3975a6;
  --shadow: 0 18px 44px rgba(23, 33, 33, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 33, 33, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 33, 33, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.site-header {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: 5px 5px 0 var(--gold);
}

.brand-title,
.brand-subtitle {
  display: block;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.86rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  padding: 8px 11px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a.active {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
  outline: none;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.intro-section {
  min-height: 280px;
  padding: 42px 0 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 32px;
  align-items: end;
}

.intro-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--leaf-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.25rem, 8vw, 5.4rem);
  line-height: 0.96;
}

h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
}

.intro-copy p:last-child,
.page-heading p:last-child,
.coming-soon p,
.featured-panel p,
.theme-card p {
  color: var(--muted);
  font-size: 1.05rem;
}

.intro-copy p:last-child {
  max-width: 560px;
}

.card-art span,
.mini-crossword span,
.large-crossword span,
.wordle-preview span,
.search-preview span,
.anagram-preview span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 6px;
  font-weight: 800;
  user-select: none;
}

.intro-image {
  margin: 0;
}

.intro-image img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding: 8px 0 52px;
}

.game-card {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--ink);
  box-shadow: 0 24px 54px rgba(23, 33, 33, 0.18);
  outline: none;
}

.card-art {
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
}

.crossword-art,
.mini-crossword,
.large-crossword {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.crossword-art span,
.mini-crossword span,
.large-crossword span {
  color: var(--ink);
  background: #eef5f1;
  border: 1px solid #bfd0c6;
}

.crossword-art span:empty,
.mini-crossword span:empty,
.large-crossword span.empty {
  background: var(--ink);
  border-color: var(--ink);
}

.wordle-art,
.wordle-preview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.wordle-art span,
.wordle-preview span {
  color: var(--white);
  background: #6a7170;
  border: 1px solid rgba(23, 33, 33, 0.15);
}

.wordle-art span:nth-child(1),
.wordle-art span:nth-child(4),
.wordle-art span:nth-child(8),
.wordle-preview .correct {
  background: var(--leaf);
}

.wordle-art span:nth-child(2),
.wordle-art span:nth-child(7),
.wordle-preview .near {
  background: var(--gold);
  color: var(--ink);
}

.wordsearch-art,
.search-preview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  position: relative;
}

.wordsearch-art::after {
  content: "";
  position: absolute;
  left: 2%;
  right: 2%;
  top: 49%;
  height: 26%;
  border: 3px solid var(--coral);
  border-radius: 8px;
  pointer-events: none;
}

.wordsearch-art span,
.search-preview span {
  color: var(--ink);
  background: #eaf1ee;
  border: 1px solid #cadbd3;
}

.anagram-art,
.anagram-preview {
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.anagram-art span,
.anagram-preview span {
  width: 46px;
  color: var(--ink);
  background: #f5ce4f;
  border: 1px solid #b78c17;
  box-shadow: 3px 3px 0 rgba(23, 33, 33, 0.16);
  transform: rotate(var(--tilt, 0deg));
}

.anagram-art span:nth-child(1) { --tilt: -8deg; }
.anagram-art span:nth-child(2) { --tilt: 6deg; }
.anagram-art span:nth-child(3) { --tilt: -3deg; }
.anagram-art span:nth-child(4) { --tilt: 9deg; }
.anagram-art span:nth-child(5) { --tilt: -6deg; }
.anagram-art span:nth-child(6) { --tilt: 4deg; }

.card-text {
  display: block;
}

.card-title,
.card-description,
.card-action {
  display: block;
}

.card-title {
  margin-bottom: 9px;
  font-size: 1.55rem;
  font-weight: 850;
}

.card-description {
  color: var(--muted);
}

.card-action {
  width: fit-content;
  padding: 9px 12px;
  color: var(--white);
  background: var(--ink);
  border-radius: 8px;
  font-weight: 800;
}

.page-heading,
.coming-soon {
  padding: 54px 0 30px;
  max-width: 780px;
}

.featured-panel {
  margin: 10px 0 26px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--white);
  background: var(--leaf-dark);
  border-radius: 8px;
}

.featured-panel .eyebrow,
.featured-panel p {
  color: #e8f2ed;
}

.primary-link,
.theme-card a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--white);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.primary-link:hover,
.primary-link:focus-visible,
.theme-card a:hover,
.theme-card a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-bottom: 52px;
}

.theme-card {
  min-height: 360px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.theme-card .mini-crossword {
  width: min(180px, 100%);
}

.theme-level {
  margin: 0 0 8px;
  color: var(--leaf-dark);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.theme-card p {
  margin: 10px 0 0;
}

.theme-card a {
  align-self: flex-start;
  color: var(--white);
  background: var(--ink);
}

.coming-soon {
  min-height: 540px;
}

.puzzle-shell {
  min-height: 520px;
  padding: 54px 0 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 32px;
  align-items: center;
}

.puzzle-copy {
  max-width: 700px;
}

.puzzle-copy p {
  color: var(--muted);
  font-size: 1.05rem;
}

.puzzle-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.secondary-button {
  min-height: 42px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--ink);
  outline: none;
}

.puzzle-board {
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.large-crossword {
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.large-crossword span {
  min-width: 0;
  font-size: clamp(0.8rem, 3vw, 1.4rem);
}

.clue-section {
  padding: 0 0 52px;
}

.clue-section h2 {
  margin-bottom: 16px;
}

.clue-list {
  max-width: 780px;
  margin: 0;
  padding-left: 24px;
  color: var(--muted);
  font-size: 1.05rem;
}

.clue-list li + li {
  margin-top: 10px;
}

.theme-choice {
  min-height: 560px;
  padding: 54px 0 52px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 1fr);
  gap: 28px;
  align-items: center;
}

.theme-choice p {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.05rem;
}

.word-count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.word-count-card {
  min-height: 220px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease;
}

.word-count-card:hover,
.word-count-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--ink);
  outline: none;
}

.word-count-card span {
  width: 58px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--ink);
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 850;
}

.word-count-card strong {
  display: block;
  font-size: 1.5rem;
}

.word-count-card small {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.crossword-app {
  width: 95vw;
  margin-left: 50%;
  padding: 10px 0 52px;
  display: flex;
  flex-direction: column;
  transform: translateX(-50%);
}

.crossword-app:fullscreen {
  width: 100%;
  margin-left: 0;
  overflow: auto;
  padding: 24px;
  transform: none;
  background:
    linear-gradient(90deg, rgba(23, 33, 33, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 33, 33, 0.035) 1px, transparent 1px),
    var(--paper);
}

.crossword-app:fullscreen .play-crossword-grid {
  --cell-size: clamp(22px, 2.2vw, 32px);
}

.crossword-topbar {
  order: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 22px 0;
}

.crossword-topbar h1 {
  font-size: clamp(2.2rem, 7vw, 4.9rem);
}

.crossword-topbar p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.crossword-meta span {
  padding: 8px 11px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.crossword-layout {
  display: contents;
}

.crossword-board-panel,
.crossword-clues {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crossword-board-panel {
  order: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.crossword-toolbar {
  order: 2;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 0;
}

.crossword-toolbar button,
.crossword-frame-button,
.crossword-clues button {
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.crossword-toolbar button {
  min-height: 40px;
  padding: 8px 11px;
  color: var(--white);
  background: var(--ink);
  border: 1px solid var(--ink);
  font-weight: 800;
}

.crossword-toolbar button:nth-child(2) {
  color: var(--ink);
  background: var(--gold);
  border-color: #b78c17;
}

.crossword-toolbar button:nth-child(3),
.crossword-toolbar button:nth-child(4) {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.crossword-toolbar button:hover,
.crossword-toolbar button:focus-visible,
.crossword-frame-button:hover,
.crossword-frame-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.crossword-status {
  order: 3;
  min-height: 30px;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.crossword-status[data-type="success"] {
  color: var(--leaf-dark);
}

.crossword-status[data-type="error"] {
  color: #b73228;
}

.crossword-grid-wrap {
  order: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  overflow-x: auto;
  padding: 8px 0 10px;
  position: relative;
}

.crossword-frame-button {
  position: absolute;
  top: 14px;
  right: 8px;
  z-index: 7;
  min-height: 34px;
  padding: 7px 10px;
  color: var(--white);
  background: rgba(23, 33, 33, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 8px 22px rgba(23, 33, 33, 0.28);
  font-size: 0.86rem;
  font-weight: 850;
}

.crossword-frame-button:hover,
.crossword-frame-button:focus-visible {
  background: var(--blue);
}

.play-crossword-grid {
  --cell-size: clamp(20px, 2.4vw, 30px);
  display: grid;
  grid-template-columns: repeat(var(--crossword-width), var(--cell-size));
  width: max-content;
  margin: 0;
  border: 2px solid var(--ink);
  background: var(--ink);
  gap: 2px;
}

.play-cell {
  width: var(--cell-size);
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  background: #f8fbf8;
}

.play-cell.block {
  background: var(--ink);
}

.play-cell input {
  width: 100%;
  height: 100%;
  padding: 8px 1px 1px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: none;
  text-align: center;
  text-transform: uppercase;
  font: 800 clamp(0.72rem, 1.8vw, 1rem) Arial, Helvetica, sans-serif;
}

.play-cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  z-index: 1;
  min-width: 14px;
  min-height: 14px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(248, 251, 248, 0.9);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.5rem;
  font-weight: 850;
  line-height: 1;
}

.play-cell-number:hover,
.play-cell-number:focus-visible {
  color: var(--white);
  background: var(--blue);
  outline: none;
}

.play-cell.active {
  background: #e8f2ed;
}

.play-cell.selected {
  box-shadow: inset 0 0 0 3px var(--blue);
}

.play-cell.correct {
  background: #dff2e7;
}

.play-cell.wrong {
  background: #ffd6d2;
}

.crossword-clue-popup {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 8;
  padding: 11px 12px;
  color: var(--white);
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(23, 33, 33, 0.26);
  font-weight: 800;
}

.crossword-clue-popup[hidden] {
  display: none;
}

.crossword-clues {
  order: 3;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.clue-group {
  min-width: 0;
}

.clue-group summary {
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 850;
  list-style-position: inside;
}

.crossword-clues ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.crossword-clues button {
  width: 100%;
  padding: 10px;
  color: var(--ink);
  background: #f8fbf8;
  border: 1px solid var(--line);
  text-align: left;
  line-height: 1.35;
}

.crossword-clues button span {
  color: var(--muted);
  font-weight: 800;
}

.crossword-clues button:hover,
.crossword-clues button:focus-visible,
.crossword-clues button.active {
  border-color: var(--ink);
  background: #e8f2ed;
  outline: none;
}

.crossword-stats {
  order: 4;
  margin-top: 22px;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crossword-stats h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid div {
  min-height: 78px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #f8fbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stats-grid strong {
  font-size: 1.25rem;
  line-height: 1.1;
}

.wordle-preview,
.search-preview,
.anagram-preview {
  width: min(360px, 100%);
  margin-top: 28px;
}

.search-preview {
  grid-template-columns: repeat(6, 1fr);
}

.search-preview span:nth-child(n+13):nth-child(-n+18) {
  background: #ffd6d2;
  border-color: var(--coral);
}

.anagram-preview {
  justify-content: flex-start;
}

.site-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
  color: var(--muted);
}

.site-footer a {
  color: var(--ink);
  font-weight: 800;
}

@media (max-width: 980px) {
  .intro-section {
    grid-template-columns: 1fr;
  }

  .puzzle-shell {
    grid-template-columns: 1fr;
  }

  .theme-choice {
    grid-template-columns: 1fr;
  }

  .crossword-layout {
    grid-template-columns: 1fr;
  }

  .crossword-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .crossword-meta {
    justify-content: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .crossword-clues {
    grid-template-columns: 1fr;
  }

  .intro-image {
    max-width: 420px;
  }

  .game-grid,
  .theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .crossword-app {
    display: flex;
    flex-direction: column;
    padding-top: 8px;
  }

  .crossword-layout {
    display: contents;
  }

  .crossword-board-panel {
    order: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
  }

  .crossword-board-panel .crossword-grid-wrap {
    order: 1;
  }

  .crossword-board-panel .crossword-toolbar {
    order: 2;
    margin: 12px 0 8px;
  }

  .crossword-board-panel .crossword-status {
    order: 3;
    margin: 0;
  }

  .crossword-topbar {
    order: 2;
    margin: 18px 0 16px;
  }

  .crossword-topbar h1 {
    font-size: clamp(1.9rem, 14vw, 3.2rem);
  }

  .crossword-clues {
    order: 3;
  }

  .crossword-stats {
    order: 4;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .intro-section {
    min-height: auto;
    padding-top: 28px;
  }

  .game-grid,
  .theme-grid {
    grid-template-columns: 1fr;
  }

  .game-card {
    min-height: 340px;
  }

  .featured-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .word-count-grid {
    grid-template-columns: 1fr;
  }

  .word-count-card {
    min-height: 160px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
