:root {
  --paper: #fbfaf7;
  --ink: #1c2321;
  --muted: #6d746f;
  --line: #d9ddd8;
  --cell-line: #3e4641;
  --accent: #176b57;
  --accent-soft: #d9eee7;
  --word: #edf5f1;
  --focus: #f6c85f;
  --error: #c94c4c;
  --shadow: 0 18px 45px rgba(27, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
}

button {
  font: inherit;
}

.site-header {
  height: 66px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.96);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: "Fraunces", serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 9px 9px 9px 2px;
  background: var(--accent);
  color: white;
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button span {
  width: 19px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}

.text-button,
.pill-button,
.primary-button {
  border: 0;
  cursor: pointer;
  font-weight: 600;
}

.text-button {
  padding: 9px 4px;
  background: transparent;
  color: var(--ink);
}

.pill-button {
  padding: 10px 17px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
}

main {
  width: min(1180px, calc(100% - 48px));
  margin: 34px auto 60px;
}

.game-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
.modal h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  letter-spacing: -0.045em;
}

h1 {
  font-size: clamp(42px, 7vw, 68px);
  line-height: 0.96;
}

.byline {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.byline span {
  padding: 0 4px;
}

.game-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer {
  min-width: 66px;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tool-button {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.tool-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.pause-icon {
  width: 10px;
  height: 13px;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}

.check-icon,
.reveal-icon {
  font-size: 17px;
  font-weight: 700;
}

.rule {
  height: 1px;
  margin: 26px 0 34px;
  background: var(--line);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(360px, 500px) 1fr;
  gap: clamp(40px, 6vw, 82px);
  align-items: start;
}

.board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--puzzle-cols, 7), 1fr);
  grid-template-rows: repeat(var(--puzzle-rows, 7), 1fr);
  border: 2px solid var(--cell-line);
  background: var(--cell-line);
  gap: 1px;
  user-select: none;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

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

.cell.in-word {
  background: var(--word);
}

.cell.selected {
  background: var(--focus);
}

.cell.error .letter {
  color: var(--error);
}

.cell.revealed::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.number {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: clamp(8px, 1.2vw, 11px);
  font-weight: 600;
  line-height: 1;
}

.letter {
  margin-top: 5%;
  font-size: clamp(22px, 5vw, 40px);
  font-weight: 500;
  line-height: 1;
  text-transform: uppercase;
}

.clues-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
}

.clue-column h2 {
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  font-family: "Fraunces", serif;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.clue-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.clue {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 7px;
  padding: 8px 8px 8px 5px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.35;
}

.clue:hover {
  background: #f0f1ee;
}

.clue.active {
  background: var(--accent-soft);
}

.clue-number {
  font-weight: 700;
}

.mobile-clue {
  display: none;
}

.keyboard {
  display: none;
}

.about-section {
  background: var(--accent-soft);
  border-top: 1px solid var(--line);
  margin-top: 48px;
}

.about-inner {
  width: min(760px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 52px;
}

.about-inner h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--ink);
}

.about-inner p {
  font-size: 0.975rem;
  line-height: 1.75;
  color: var(--ink);
  margin: 0 0 14px;
}

.about-inner p:last-child {
  margin-bottom: 0;
}

.about-inner a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.site-footer p {
  margin: 3px 0;
}

.toast {
  position: fixed;
  top: 82px;
  left: 50%;
  z-index: 10;
  transform: translate(-50%, -20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  font-size: 14px;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 31, 28, 0.42);
  backdrop-filter: blur(3px);
}

.hidden {
  display: none !important;
}

.modal {
  position: relative;
  width: min(430px, 100%);
  padding: 38px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 26px;
}

.modal h2 {
  font-size: 38px;
}

.modal > p:not(.eyebrow) {
  color: var(--muted);
}

.result-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 25px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.result-card div {
  display: grid;
  gap: 4px;
  padding: 15px;
}

.result-card div + div {
  border-left: 1px solid var(--line);
}

.result-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-card strong {
  font-size: 20px;
}

.primary-button {
  width: 100%;
  padding: 13px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
}

@media (max-width: 850px) {
  .game-layout {
    grid-template-columns: minmax(0, 560px);
    justify-content: center;
  }

  .clues-panel {
    display: none;
  }

  .mobile-clue {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 13px;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    font-size: 14px;
  }

  .keyboard {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    margin-top: 18px;
  }

  .key {
    min-height: 42px;
    border: 0;
    border-radius: 5px;
    background: #e3e6e2;
    color: var(--ink);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
  }

  .key.wide {
    grid-column: span 2;
    font-size: 16px;
  }
}

@media (max-width: 620px) {
  .site-header {
    height: 56px;
    padding: 0 12px;
  }

  .brand {
    font-size: 21px;
  }

  .brand-mark {
    width: 25px;
    height: 25px;
    font-size: 14px;
  }

  .text-button {
    display: none;
  }

  .pill-button {
    padding: 7px 11px;
    font-size: 12px;
  }

  main {
    width: min(100% - 24px, 500px);
    margin-top: 22px;
  }

  .site-footer {
    width: min(100% - 24px, 500px);
    padding-bottom: 24px;
  }

  .game-heading {
    align-items: start;
  }

  h1 {
    font-size: 45px;
  }

  .byline {
    margin-top: 9px;
    font-size: 12px;
  }

  .game-tools {
    gap: 5px;
  }

  .timer {
    min-width: 52px;
    font-size: 14px;
  }

  .tool-button {
    width: 32px;
    height: 32px;
  }

  .rule {
    margin: 20px 0;
  }

  .letter {
    font-size: clamp(20px, 8vw, 34px);
  }
}
