:root {
  color-scheme: light;
  --paper: #faf8f4;
  --white: #fffefb;
  --ink: #22211f;
  --muted: #77716a;
  --rule: #ded9d0;
  --accent: #8e3651;
  --accent-soft: #f3e7eb;
  --word: #dceaf0;
  --selected: #f3d37e;
  --shade: #ded9d1;
  --error: #a52c35;
  --radius: 5px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.grid-row { display: contents; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html { min-width: 300px; background: var(--paper); }
body { margin: 0; color: var(--ink); line-height: 1.45; }
button, input, summary { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
button, summary { touch-action: manipulation; }
a { color: var(--accent); text-underline-offset: 3px; }
.page { width: min(1320px, 100%); margin: 0 auto; padding: 38px 44px 22px; }
.masthead {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid var(--ink);
}
.eyebrow {
  color: var(--accent); font-size: 10px; line-height: 1.4; font-weight: 700;
  text-transform: uppercase; letter-spacing: .2em; margin: 0 0 7px;
}
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 4vw, 54px); font-weight: 400; line-height: 1.1; letter-spacing: -.045em; margin: 0 0 10px; }
.header-meta { display: flex; align-items: center; gap: 20px; white-space: nowrap; padding-bottom: 2px; }
.time-button {
  background: none; border: 0; padding: 2px 0;
  font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
.time-button:hover { color: var(--accent); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(350px, 1fr); gap: 38px; align-items: start; }
.puzzle-panel { min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 5px; min-height: 32px; margin: 0 0 13px; flex-wrap: wrap; }
.toolbar > button, .toolbar summary {
  border: 0; border-radius: 4px; background: transparent; color: #57534f;
  font-size: 12px; line-height: 20px; padding: 6px 11px; text-align: center;
}
.toolbar > button:first-child { margin-left: -11px; }
.toolbar > button:hover:not(:disabled), .toolbar summary:hover { background: #eeebe5; color: var(--ink); }
.toolbar details { position: relative; }
.toolbar summary { list-style: none; cursor: pointer; }
.toolbar summary::-webkit-details-marker { display: none; }
.tool-menu summary::after { content: "⌄"; display: inline-block; margin-left: 5px; color: #827b73; transform: translateY(-1px); }
.menu-options, .help-content {
  position: absolute; top: calc(100% + 5px); left: 0; z-index: 25; min-width: 176px;
  background: var(--white); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 8px 28px #3025191a; padding: 5px;
}
.menu-options > button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  font-size: 13px; padding: 9px 10px; border-radius: 3px;
}
.menu-options > button:hover { background: var(--accent-soft); color: var(--accent); }
.help-content { left: auto; right: 0; width: 275px; padding: 15px 17px; font-size: 12px; color: #625c55; line-height: 1.65; }
.help-content p { margin: 0 0 9px; }
.help-content p:last-child { margin-bottom: 0; }
.help-content kbd {
  font-family: inherit; font-size: 11px; border: 1px solid var(--rule); border-bottom-width: 2px;
  border-radius: 3px; padding: 1px 4px; background: #f7f4ef; color: var(--ink);
}
.active-clue {
  min-height: 80px; display: flex; align-items: center; gap: 13px; padding: 14px 15px;
  background: #eeeae3; border-radius: 4px 4px 0 0; margin-bottom: 13px;
}
.clue-badge { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.current-clue-text { margin: 0; flex: 1; font-size: 16px; line-height: 1.45; font-family: Georgia, "Times New Roman", serif; }
.clue-nav { display: flex; gap: 1px; align-items: center; margin-left: auto; }
.clue-nav button {
  display: grid; place-items: center; width: 27px; height: 32px; padding: 0;
  border: 0; background: transparent; border-radius: 3px; font-size: 22px; color: #827b73;
}
.clue-nav button:hover { background: #dfd9cf; color: var(--ink); }
.board-wrap { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 1px;
  width: 100%; background: #22211f; border: 2px solid #22211f; container-type: inline-size;
  user-select: none; -webkit-user-select: none; overflow: hidden;
}
.cell, .block { aspect-ratio: 1; min-width: 0; min-height: 0; }
.cell {
  appearance: none; -webkit-appearance: none; display: block; position: relative;
  padding: 0; border: 0; border-radius: 0; background: var(--white); outline: none;
  color: var(--ink); font-weight: 500; overflow: hidden;
}
.block { background: #22211f; }
.cell .number { position: absolute; top: 1px; left: 3px; font-size: clamp(7px, 1.6cqw, 10px); line-height: 1.2; font-weight: 400; color: #3d3934; }
.cell .letter { display: flex; align-items: center; justify-content: center; height: 100%; padding-top: 6px; font-size: clamp(15px, 4.35cqw, 29px); line-height: 1; }
.cell.shaded { background: var(--shade); }
.cell .shade-dot { position: absolute; top: 4px; right: 4px; width: 3px; height: 3px; border-radius: 50%; background: #76674c; opacity: .6; }
.cell.in-word { background: var(--word); }
.cell.in-word.shaded { background: #c9d7dc; }
.cell.selected, .cell.selected.shaded { background: var(--selected); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }
.cell.incorrect .letter { color: var(--error); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cell.revealed .letter { color: #715078; }
.cell.revealed::after { position: absolute; bottom: 2px; right: 2px; content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-bottom: 4px solid #715078; }
.cell.pencilled .letter { color: #8a837b; font-style: italic; }
.typing-input {
  position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0;
  margin: 0; border: 0; opacity: 0; font-size: 16px; pointer-events: none;
}
.board-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; font-size: 10px; color: var(--muted); }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; background: var(--shade); border: 1px solid #c7c0b5; display: inline-block; flex-shrink: 0; }
#save-status { text-align: right; }
.clues-panel { min-width: 0; padding-top: 4px; }
.clue-tabs { display: none; }
.clue-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.clue-section { min-width: 0; }
.clue-section h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 22px; letter-spacing: -.02em; margin: 0; padding-bottom: 11px; border-bottom: 1px solid var(--ink); }
.clue-list {
  list-style: none; margin: 8px -7px 0; padding: 0 5px 0 0; max-height: min(690px, calc(100vh - 235px)); min-height: 440px;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #cec8be transparent; scroll-padding-top: 15px; scroll-padding-bottom: 15px;
}
.clue-list li { padding: 0; margin: 0 0 1px; }
.clue-item {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 2px; width: 100%;
  text-align: left; border: 0; border-left: 3px solid transparent; background: transparent;
  border-radius: 3px; padding: 8px 6px 8px 4px; font-size: 13px; line-height: 1.4;
}
.clue-number { font-weight: 700; font-size: 11px; padding-top: 1px; font-variant-numeric: tabular-nums; }
.clue-text { display: inline; }
.clue-length { font-size: 10px; color: #a39b92; margin-left: 4px; white-space: nowrap; }
.clue-item > .clue-length { grid-column: 2; margin-left: 0; }
.clue-item:hover { background: #f0ede7; }
.clue-item.active { background: var(--word); border-left-color: #83a9ba; }
.clue-item.crossing:not(.active) { border-left-color: #c5b17b; background: #f1eee5; }
.clue-item.complete:not(.active):not(.crossing) { color: #8d8881; }
.clue-item.complete .clue-number::after { content: "·"; margin-left: 3px; color: #8d8881; }
.mobile-keyboard { display: none; }
.message-strip { display: flex; align-items: center; gap: 20px; padding: 21px 0 5px; margin-top: 26px; border-top: 1px solid var(--rule); }
.message-label { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; max-width: 205px; }
.message-label strong { display: block; font-size: 12px; color: var(--ink); font-weight: 500; margin-bottom: 2px; }
.message-boxes { display: flex; gap: 5px; }
.message-letter { display: grid; place-items: center; width: 28px; height: 32px; border-bottom: 1px solid #c8bdab; background: #ece7dd; font-size: 17px; line-height: 1; font-weight: 500; }
.message-letter:nth-child(6) { margin-left: 8px; }
.toast {
  position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); z-index: 90;
  width: max-content; max-width: calc(100vw - 40px); border-radius: 5px; background: #272421;
  color: #fffdf9; box-shadow: 0 5px 18px #0002; padding: 12px 19px; text-align: center;
  font-size: 13px; pointer-events: none;
}
dialog {
  color: var(--ink); background: var(--white); border: 1px solid var(--rule); border-radius: 7px;
  width: min(440px, calc(100% - 36px)); padding: 0; box-shadow: 0 20px 80px #241b1933;
}
dialog::backdrop { background: #2f29296b; backdrop-filter: blur(2px); }
.dialog-content, .completion-content { padding: 30px; }
dialog h2 { font-family: Georgia, "Times New Roman", serif; font-size: 29px; font-weight: 400; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 13px; }
dialog p { font-size: 14px; color: #6d665e; line-height: 1.6; margin: 0 0 24px; }
.dialog-actions, .completion-actions { display: flex; justify-content: flex-end; gap: 9px; }
button.primary, button.secondary { border: 1px solid var(--rule); border-radius: 4px; padding: 9px 15px; font-size: 13px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #742a42; }
button.secondary { background: transparent; }
button.secondary:hover { background: #f1ede6; }
.completion-content { padding: 40px 30px 28px; text-align: center; }
.completion-content h2 { font-size: 38px; margin: 10px 0 15px; }
#completion-message { color: var(--accent); font-weight: 600; letter-spacing: .2em; font-size: 21px; margin-bottom: 20px; }
.completion-content .completion-actions { justify-content: center; }
.error-panel { max-width: 650px; padding: 28px; margin: 20px auto; background: #fff; border: 1px solid #d6bfc5; border-radius: 5px; }
.error-panel h2 { margin-top: 0; }
@media (min-width: 1450px) { .page { padding-top: 48px; } .masthead { margin-bottom: 30px; } }
@media (min-width: 821px) and (max-height: 900px) {
  .page { padding-top: 20px; }
  .masthead { padding-bottom: 14px; margin-bottom: 16px; }
  h1 { font-size: 40px; margin-bottom: 8px; }
  .workspace { grid-template-columns: minmax(360px, min(52%, calc(100dvh - 290px))) minmax(0, 1fr); }
  .active-clue { min-height: 66px; padding-top: 10px; padding-bottom: 10px; margin-bottom: 10px; }
  .toolbar { margin-bottom: 8px; }
  .clue-list { max-height: calc(100dvh - 220px); min-height: 300px; }
}
@media (max-width: 1050px) {
  .page { padding: 27px 27px 20px; }
  .workspace { grid-template-columns: minmax(0, 1.12fr) minmax(310px, 1fr); gap: 24px; }
  .clue-columns { gap: 13px; }
  .clue-item { font-size: 12px; grid-template-columns: 21px minmax(0, 1fr); }
  .active-clue { gap: 9px; padding: 12px; }
  .current-clue-text { font-size: 15px; }
  .header-meta { gap: 13px; }
}
@media (max-width: 820px) {
  .page { max-width: 620px; padding: 24px 22px 18px; }
  .masthead { align-items: start; padding-bottom: 20px; margin-bottom: 16px; }
  h1 { font-size: 43px; }
  .header-meta { flex-direction: column-reverse; align-items: flex-end; gap: 5px; padding-top: 6px; }
  .time-button { border: 0; padding: 0; font-size: 14px; }
  .workspace { display: block; }
  .toolbar { margin-bottom: 9px; }
  .active-clue { min-height: 72px; margin-bottom: 10px; }
  .current-clue-text { font-size: 16px; }
  .board-footer { font-size: 10px; }
  .clues-panel { margin-top: 27px; }
  .clue-tabs { display: flex; gap: 25px; border-bottom: 1px solid var(--rule); margin-bottom: 10px; }
  .clue-tabs button { background: transparent; padding: 0 0 9px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 21px; }
  .clue-tabs button.active, .clue-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
  .clue-columns { display: block; }
  .clue-section h2 { display: none; }
  .clue-list { max-height: 330px; min-height: 0; margin: 0 -5px; }
  .clue-item { grid-template-columns: 29px minmax(0, 1fr); padding: 9px 8px; font-size: 14px; }
  .clue-number { font-size: 12px; }
  .clue-item > .clue-length { display: none; }
  .clues-panel[data-mobile-direction="A"] .clue-section[data-direction="D"],
  .clues-panel[data-mobile-direction="D"] .clue-section[data-direction="A"] { display: none; }
  .message-strip { margin-top: 22px; padding-top: 20px; gap: 18px; }
  .message-label { font-size: 10px; }
  .message-letter { width: 25px; height: 29px; font-size: 16px; }
}
@media (max-width: 520px) {
  .page { padding: 20px 14px 16px; }
  .masthead { gap: 8px; margin-bottom: 9px; padding-bottom: 18px; }
  h1 { font-size: 36px; margin-bottom: 7px; }
  .eyebrow { font-size: 8px; letter-spacing: .18em; }
  .header-meta { gap: 5px; padding-top: 4px; }
  .time-button { font-size: 13px; }
  .toolbar { gap: 1px; margin-bottom: 8px; }
  .toolbar > button, .toolbar summary { padding: 5px 8px; font-size: 11px; }
  .toolbar > button:first-child { margin-left: -8px; }
  .active-clue { gap: 9px; padding: 11px 10px; min-height: 75px; }
  .current-clue-text { font-size: 15px; }
  .clue-badge { font-size: 11px; }
  .clue-nav button { width: 22px; font-size: 21px; }
  .cell .number { left: 2px; top: 1px; }
  .cell .letter { padding-top: 5px; }
  .cell .shade-dot { right: 2px; top: 3px; width: 2px; height: 2px; }
  .board-footer { margin-top: 9px; font-size: 9px; }
  .mobile-keyboard { display: block; padding: 14px 0 0; margin: 0 -5px; }
  .key-row { display: flex; justify-content: center; gap: 4px; margin-bottom: 5px; }
  .key-row button { flex: 1 1 0; max-width: 36px; height: 39px; padding: 0; border: 1px solid #d4cec5; border-bottom-width: 2px; border-radius: 4px; background: #fffefa; font-size: 14px; line-height: 1; }
  .key-row button:active { background: var(--selected); }
  .key-row button[data-key="Backspace"], .key-row button[data-key="Enter"], .key-row button[data-key="Tab"], .key-row button[data-key=" "] { flex-grow: 1.7; max-width: 64px; background: #e9e4dc; font-size: 12px; }
  .clues-panel { margin-top: 18px; }
  .clue-tabs { gap: 24px; }
  .clue-tabs button { font-size: 20px; }
  .message-strip { flex-direction: column; align-items: flex-start; gap: 10px; }
  .message-label { max-width: none; }
  .message-label strong { display: inline; margin-right: 6px; }
  .message-boxes { gap: 6px; }
  .message-letter { width: 27px; height: 31px; }
  .toast { bottom: 15px; font-size: 12px; }
  .dialog-content, .completion-content { padding: 25px 22px; }
}
@media (prefers-reduced-motion: no-preference) {
  .clue-item, .toolbar button, .toolbar summary { transition: background-color .12s ease; }
  dialog[open] { animation: arrive .18s ease-out; }
  @keyframes arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
}
@media print {
  html, body { background: white; }
  .page { padding: 0; }
  .masthead { margin-bottom: 12px; padding-bottom: 12px; }
  .header-meta, .toolbar, .active-clue, .mobile-keyboard, .board-footer, .toast, dialog, .clue-tabs { display: none !important; }
  .workspace { display: block; }
  .puzzle-panel { width: 62%; margin: 0 auto 20px; }
  .clue-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .clue-section { display: block !important; }
  .clue-section h2 { display: block; }
  .clue-list { max-height: none; min-height: 0; overflow: visible; }
  .clue-item { font-size: 11px; padding: 3px 0; break-inside: avoid; }
  .clue-item.active, .clue-item.crossing, .cell.selected, .cell.in-word { background: white; }
  .cell.shaded { background: #ded9d1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cell .letter { font-size: 24px; }
  .message-strip { break-inside: avoid; }
}
