:root {
  --ink: #111111;
  --muted: #656565;
  --paper: #f7f5f0;
  --panel: #ffffff;
  --line: #d8d5ce;
  --yellow: #f7da21;
  --blue: #a7d8ff;
  --blue-soft: #dceeff;
  --wrong: #f5b8b8;
  --revealed: #2c6c9c;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  touch-action: manipulation;
}

.site-header {
  height: 60px;
  padding: 0 clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.button {
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    color 120ms ease;
}

@media (hover: hover) {
  .button:hover {
    border-color: var(--ink);
  }
}

.button:focus-visible,
.puzzle-card:focus-visible,
.cell:focus-visible,
.clue-button:focus-visible {
  outline: 3px solid #2674b8;
  outline-offset: 3px;
}

.button-quiet {
  border-color: var(--line);
  background: var(--panel);
}

.narrow-label {
  display: none;
}

.welcome {
  width: min(760px, calc(100% - 36px));
  min-height: calc(100vh - 60px);
  margin: 0 auto;
  padding: clamp(36px, 6vw, 64px) 0;
  display: grid;
  gap: 48px;
  align-content: start;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.puzzle-heading h1 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.045em;
}

.puzzle-library {
  display: grid;
  gap: 14px;
}

.library-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.library-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 5vw, 48px);
  letter-spacing: -0.04em;
}

.library-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.puzzle-cards {
  border-top: 1px solid var(--line);
  display: block;
}

.puzzle-card {
  width: 100%;
  min-height: 82px;
  padding: 16px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    box-shadow 120ms ease;
}

@media (hover: hover) {
  .puzzle-card:hover {
    background: var(--panel);
    box-shadow: inset 3px 0 0 var(--yellow);
  }
}

.puzzle-card-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.puzzle-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  line-height: 1.1;
}

.puzzle-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.puzzle-card-action {
  flex: none;
  font-size: 14px;
  font-weight: 700;
}

.puzzle-card-action::after {
  content: " →";
}

.solver {
  width: min(1500px, calc(100% - 36px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.puzzle-heading {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.puzzle-heading h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.05;
}

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

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

.timer {
  min-width: 76px;
  padding-right: 14px;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 700;
  text-align: right;
}

.solver-layout {
  display: grid;
  grid-template-columns: minmax(360px, 680px) minmax(420px, 1fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: start;
}

.board-column {
  width: 100%;
  min-width: 0;
}

.grid {
  --columns: 15;
  width: 100%;
  aspect-ratio: var(--columns) / var(--rows, 15);
  border: 3px solid var(--ink);
  background: var(--ink);
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 1px;
  user-select: none;
}

.grid:focus {
  outline: none;
}

.keyboard-input {
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  position: fixed;
  left: 0;
  bottom: 0;
  font-size: 16px;
  pointer-events: none;
}

.cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: white;
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  line-height: 1;
}

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

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

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

.cell.wrong {
  background: var(--wrong);
}

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

.cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  z-index: 1;
  font-size: clamp(6px, 1.05vw, 12px);
  font-weight: 600;
}

.letter {
  padding-top: 8%;
  font-size: clamp(13px, 2.65vw, 34px);
  font-weight: 500;
  text-transform: uppercase;
}

.current-clue {
  min-height: 64px;
  margin-top: 12px;
  padding: 14px 16px;
  border-left: 6px solid #4d9dd8;
  background: var(--blue-soft);
  display: flex;
  align-items: baseline;
  gap: 10px;
  line-height: 1.35;
}

.current-clue-number {
  flex: none;
  font-weight: 800;
}

.keyboard-help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.clues {
  max-height: min(800px, calc(100vh - 190px));
  padding-right: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
  overflow: auto;
  scrollbar-color: #a8a59f transparent;
}

.clue-section h2 {
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
}

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

.clue-button {
  width: 100%;
  padding: 9px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 4px;
  text-align: left;
  line-height: 1.35;
  cursor: pointer;
}

.clue-button:hover {
  background: #eceae5;
}

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

.clue-number {
  font-weight: 800;
  text-align: right;
}

.toast {
  max-width: min(420px, calc(100% - 32px));
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

@media (max-width: 1040px) {
  .solver-layout {
    grid-template-columns: minmax(0, 650px);
    justify-content: center;
  }

  .clues {
    max-height: none;
    padding-right: 0;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .site-header {
    height: calc(56px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  body.is-solving .site-header {
    display: none;
  }

  .brand {
    font-size: 16px;
  }

  .welcome {
    min-height: calc(100vh - 56px);
    padding: 28px 0 40px;
    gap: 36px;
  }

  .library-heading {
    align-items: baseline;
    flex-direction: row;
    gap: 12px;
  }

  .solver {
    width: 100%;
    min-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top)) 0
      max(48px, env(safe-area-inset-bottom));
  }

  .puzzle-heading {
    width: calc(100% - 28px);
    margin: 0 auto 12px;
    padding-bottom: 12px;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .puzzle-heading .eyebrow {
    display: none;
  }

  .puzzle-heading h1 {
    font-size: clamp(28px, 8vw, 38px);
    line-height: 1;
  }

  .byline {
    margin-top: 4px;
  }

  .puzzle-actions {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .puzzle-actions::-webkit-scrollbar {
    display: none;
  }

  .puzzle-actions .button {
    min-height: 40px;
    padding: 7px 9px;
    flex: none;
    font-size: 12px;
    white-space: nowrap;
  }

  .timer {
    min-width: 48px;
    margin: 0;
    padding: 0 2px;
    flex: none;
    font-size: 18px;
    text-align: left;
  }

  .solver-layout {
    display: block;
  }

  .board-column {
    display: flex;
    flex-direction: column;
  }

  .grid {
    border-width: 2px;
    order: 0;
  }

  .cell-number {
    top: 1px;
    left: 2px;
    font-size: clamp(6px, 1.8vw, 11px);
  }

  .letter {
    font-size: clamp(14px, 5.2vw, 31px);
  }

  .current-clue {
    min-height: 54px;
    margin: 0 0 10px;
    padding: 10px 14px;
    border-left: 0;
    border-top: 1px solid #b5d1e8;
    border-bottom: 1px solid #b5d1e8;
    position: sticky;
    top: 0;
    z-index: 6;
    order: -1;
  }

  .keyboard-help {
    display: none;
  }

  .clues {
    padding: 24px 14px 0;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 470px) {
  .site-header .button {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 12px;
  }

  .library-heading h1 {
    font-size: 34px;
  }

  .puzzle-card {
    min-height: 76px;
    padding: 14px 8px;
  }

  .puzzle-card h2 {
    font-size: 21px;
  }

  .puzzle-actions .button-quiet {
    padding-inline: 7px;
    font-size: 11px;
  }

  .wide-label {
    display: none;
  }

  .narrow-label {
    display: inline;
  }
}

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