:root {
  color-scheme: light;
  --paper: #f8f6f0;
  --white: #fffdf8;
  --ink: #242128;
  --muted: #625c68;
  --line: #d9d3db;
  --accent: #643d9d;
  --accent-strong: #4d297f;
  --lavender: #e9def8;
  --current: #c9acec;
  --block: #2b2336;
  --success: #3f5b2d;
  --error: #9d2845;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 2; background: var(--white); padding: 12px; }
.skip-link:not(:focus) { clip-path: inset(50%); }

.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 70px;
  width: min(1080px, calc(100% - 64px));
  margin: auto;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 5px;
  text-decoration: none;
  font-size: 37px;
  line-height: 1;
  letter-spacing: -.08em;
  font-weight: 850;
}
.wordmark span { color: var(--accent); font-size: 25px; font-weight: 500; letter-spacing: 0; }
.game-nav { display: flex; gap: 25px; align-self: stretch; }
.game-nav :is(a, span) {
  display: grid;
  align-items: center;
  min-height: 44px;
  border-bottom: 2px solid transparent;
  font-size: .875rem;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
}
.game-nav a:hover, .game-nav [aria-current="page"] { color: var(--accent-strong); }
.game-nav [aria-current="page"] { border-color: var(--accent); }
.help-button {
  justify-self: end;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
}
.help-button:hover { color: var(--accent-strong); background: var(--lavender); }
.help-icon { display: inline-grid; place-items: center; width: 19px; height: 19px; border: 1px solid currentColor; border-radius: 50%; font-size: .75rem; }

.page { width: min(1080px, calc(100% - 64px)); margin: 0 auto; padding-bottom: 35px; }
.page:focus { outline: none; }
.book-note { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 15px; }
.book-note p { margin: 0 0 5px; }
.book-note a { color: var(--accent-strong); font-weight: 700; text-underline-offset: 3px; }
.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 49px 0 30px;
  border-bottom: 1px solid var(--ink);
}
.intro h1 {
  font: 700 clamp(2.75rem, 5.6vw, 5.35rem)/.99 Georgia, serif;
  letter-spacing: -.075em;
  margin: 0;
}
.intro h1 span { color: var(--accent); }
.intro p { color: var(--muted); font-size: 1.0625rem; line-height: 1.45; margin: 16px 0 0; }
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent-strong);
  font-size: .875rem;
  font-weight: 700;
}
.primary-button { background: var(--accent-strong); color: #fff; }
.primary-button:hover { background: var(--accent); border-color: var(--accent); }
.secondary-button { background: transparent; color: var(--accent-strong); }
.secondary-button:hover { background: var(--lavender); }
.edition-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; }
.edition-actions button { white-space: nowrap; }
.edition-actions span { font-size: 1.15rem; line-height: 1; }

.game-bar { display: flex; min-height: 54px; align-items: center; }
.tools { display: flex; align-items: center; gap: 5px; }
.tools button {
  min-height: 44px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
}
.tools button:hover:enabled { color: var(--accent-strong); background: var(--lavender); }

.game-layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; gap: clamp(25px, 4.4vw, 64px); }
.play-area { min-width: 0; }
.current-clue {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  min-height: 66px;
  align-items: stretch;
  border-radius: 6px;
  background: var(--lavender);
  color: #352447;
  margin-bottom: 12px;
}
.current-clue button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
  border-radius: 6px;
}
.current-clue button:hover { background: #ded0f0; }
.current-clue-copy { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 8px 4px; min-width: 0; }
#current-clue-name { font-size: .75rem; color: var(--accent-strong); font-weight: 800; }
#current-clue-text { font-size: .875rem; font-weight: 600; line-height: 1.27; }

.board {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 1px;
  padding: 2px;
  background: var(--block);
  border-radius: 2px;
}
.board-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; }
.square { display: grid; position: relative; min-width: 0; min-height: 0; }
.square-button {
  display: grid;
  place-items: center;
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  line-height: 1;
}
.square-button.is-entry { background: var(--lavender); }
.square-button.is-current {
  background: var(--current);
  box-shadow: inset 0 0 0 2px var(--accent-strong);
}
.square-button:focus-visible { outline-offset: -4px; }
.square-button.is-wrong .square-letter { color: var(--error); text-decoration: line-through; }
.square-button.is-revealed::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-top: 10px solid var(--accent);
  border-left: 10px solid transparent;
}
.square-number { position: absolute; top: 9%; left: 9%; font-size: clamp(.625rem, 1.05vw, .875rem); font-weight: 700; }
.square-letter { font-size: clamp(1.5rem, 3.5vw, 2.625rem); font-weight: 700; padding-top: 9%; }

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  min-height: 43px;
  padding: 10px 0 8px;
  font-size: .8125rem;
  line-height: 1.35;
  color: var(--muted);
}
#game-status[data-state="solved"] { font-weight: 750; color: var(--success); }
#game-status[data-state="error"] { color: var(--error); }
.status-feedback { min-width: 0; }
.game-metrics { display: flex; gap: 12px; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
#game-clock { color: var(--accent-strong); font-weight: 700; }
.results-link {
  display: block;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: underline;
}
.keyboard { display: none; gap: 5px; }
@media (pointer: coarse) {
  .keyboard { display: grid; }
}
.key-row { display: flex; justify-content: center; gap: 4px; }
.key-row:nth-child(2) { width: 90%; margin: auto; }
.key-row:last-child { width: 90%; margin: auto; }
.key {
  flex: 1;
  min-width: 0;
  min-height: 41px;
  padding: 0;
  border: 1px solid #d6cadf;
  border-radius: 4px;
  background: #efe8f2;
  font-weight: 700;
  line-height: 1;
}
.key:hover:enabled, .key:active:enabled { background: var(--current); }
.key-backspace { flex: 1.5; font-size: 1.14rem; }

.clues { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 2.1vw, 30px); }
.clues h2 {
  margin: 0;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--ink);
  font: 700 1.65rem/1.15 Georgia, serif;
  letter-spacing: -.04em;
}
.clue-list { margin: 5px 0 0; padding: 0; list-style: none; }
.clue-list li { border-bottom: 1px solid var(--line); }
.clue-button {
  display: grid;
  grid-template-columns: 1.3rem minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
  width: 100%;
  min-height: 52px;
  padding: 11px 7px 11px 9px;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  font-size: .9375rem;
  line-height: 1.38;
}
.clue-button:hover { background: #f2ebf8; }
.clue-button[aria-current="true"] { border-left-color: var(--accent); background: var(--lavender); }
.clue-number { color: var(--accent-strong); font-weight: 800; font-variant-numeric: tabular-nums; }

dialog {
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: min(450px, calc(100% - 32px));
  padding: 25px;
  box-shadow: 0 16px 48px #24183028;
}
dialog::backdrop { background: #29203277; }
dialog h2 { margin: 0 0 14px; font: 700 1.75rem/1.2 Georgia, serif; letter-spacing: -.04em; }
dialog p, dialog li { color: var(--muted); line-height: 1.5; }
dialog ul { padding-left: 20px; }
dialog li + li { margin-top: 7px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }

.results-dialog { overflow: hidden; text-align: center; max-height: calc(100dvh - 32px); overflow-y: auto; }
.results-dialog h2 { margin-bottom: 16px; font-size: clamp(1.8rem, 5vw, 2.45rem); }
.results-spark { display: block; margin-bottom: 6px; color: var(--accent); font-size: 2rem; line-height: 1; }
.solve-time, .solve-rankings { margin: 0; }
.solve-time { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--lavender); }
.solve-time dt, .solve-rankings dt { font-size: .8125rem; font-weight: 750; color: var(--muted); }
.solve-time dd, .solve-rankings dd { margin: 3px 0 0; color: var(--accent-strong); font-weight: 800; font-variant-numeric: tabular-nums; }
.solve-time dd { font-size: 2.45rem; line-height: 1.1; letter-spacing: -.07em; }
.solve-rankings { display: grid; grid-template-columns: 1fr 1fr; margin-top: 12px; gap: 8px; }
.solve-rankings > div { padding: 10px 5px; border: 1px solid var(--line); border-radius: 8px; }
.solve-rankings dd { font-size: clamp(1.075rem, 4vw, 1.35rem); }
.results-dialog p { font-size: .875rem; }
.results-dialog .dialog-actions { justify-content: center; }
.solve-note { margin: 0 0 14px; padding: 10px 13px; border-left: 3px solid var(--accent); background: var(--paper); text-align: left; }
.solve-note h3 { margin: 0 0 4px; color: var(--accent-strong); font-size: .8125rem; }
.solve-note p { margin: 0; }
#share-status { margin: 8px 0; }
#share-text { width: 100%; height: 6em; margin: 0 0 10px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.archive-dialog { padding: clamp(15px, 4vw, 25px); max-height: calc(100dvh - 32px); }
.archive-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-bottom: 10px; text-align: center; }
.archive-heading h3 { margin: 0; font-size: 1rem; }
.archive-heading button { min-width: 44px; padding: 2px; font-size: 1.3rem; }
.calendar-week, .archive-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.calendar-week { color: var(--muted); font-size: .688rem; font-weight: 700; }
.archive-days > * { display: grid; place-items: center; min-height: 44px; padding: 1px; font-size: .875rem; }
.archive-days > span { color: var(--muted); opacity: .48; }
.archive-days > button { position: relative; border: 1px solid transparent; border-radius: 6px; background: transparent; font-weight: 650; }
.archive-days > button:hover, .archive-days [aria-current] { background: var(--lavender); border-color: var(--accent); }
.archive-days [data-status="solved"]::after, .archive-days [data-status="in progress"]::after { position: absolute; right: 3px; top: 2px; color: var(--success); font-size: .7rem; }
.archive-days [data-status="solved"]::after { content: "✓"; }
.archive-days [data-status="in progress"]::after { content: "•"; color: var(--accent); }
.archive-legend { display: flex; justify-content: center; gap: 12px; margin: 6px 0 12px; font-size: .75rem; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti span {
  position: absolute;
  top: 28%;
  left: 50%;
  width: 8px;
  height: 6px;
  border-radius: 1px;
  opacity: 0;
  animation: confetti-scatter 1200ms var(--delay) both;
}
.confetti span:nth-child(3n) { border-radius: 50%; }
@keyframes confetti-scatter {
  0% { opacity: 1; transform: scale(.5); animation-timing-function: cubic-bezier(.05, .6, .3, 1); }
  38% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(var(--spin)); }
  100% { opacity: 0; transform: translate(var(--x), 230px) rotate(calc(var(--spin) * 1.8)); }
}
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
}

@media (max-width: 800px) {
  .game-layout { grid-template-columns: minmax(270px, 1fr) minmax(0, 1fr); gap: 24px; }
  .clues { grid-template-columns: 1fr; gap: 22px; }
}
@media (max-width: 620px) {
  .masthead-inner, .page { width: calc(100% - 32px); }
  .masthead-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 9px; min-height: 56px; }
  .wordmark { font-size: 28px; gap: 3px; }
  .wordmark span { font-size: 18px; }
  .game-nav { gap: 13px; justify-content: center; white-space: nowrap; }
  .game-nav :is(a, span) { font-size: .75rem; }
  .help-button { position: relative; padding: 0; }
  .help-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .intro { padding: 22px 0 14px; flex-wrap: wrap; gap: 10px; align-items: center; }
  .intro h1 { font-size: clamp(2.15rem, 7.5vw, 3.35rem); }
  .intro p { font-size: .875rem; margin: 7px 0 0; }
  .edition-actions { margin: 0; }
  .edition-actions button { padding: 5px 10px; gap: 6px; font-size: .8125rem; }
  .tools { gap: 0; }
  .tools button { font-size: .8125rem; padding: 0 6px; }
  .game-layout { grid-template-columns: 1fr; gap: 27px; }
  .play-area { width: min(100%, 400px); margin: auto; }
  .current-clue { min-height: 59px; margin-bottom: 9px; }
  .board { width: min(100%, 320px); margin: auto; }
  .square-letter { font-size: clamp(1.6rem, 8vw, 2.35rem); }
  .status-line { min-height: 34px; padding: 7px 0; }
  .keyboard { gap: 4px; }
  .key-row { gap: 3px; }
  .key { min-height: 37px; }
  .clues { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .clues h2 { font-size: 1.45rem; }
  .clue-button { min-height: 48px; padding-inline: 5px; grid-template-columns: 1.1rem minmax(0, 1fr); font-size: .875rem; }
}
@media (max-width: 360px) {
  .masthead-inner { gap: 3px; }
  .wordmark { font-size: 25px; }
  .game-nav { gap: 7px; }
  .game-nav :is(a, span) { font-size: .6875rem; }
  .tools button { padding-inline: 4px; font-size: .75rem; white-space: nowrap; }
}
