:root {
  color-scheme: dark;
  --ink: #f5e7cc;
  --muted: #dbcaab;
  --brass: #b79a5e;
  --line: #7b7151;
  --forest: #101d13;
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background: #101811;
}
.library-scene {
  position: fixed;
  left: 50%;
  top: 50%;
  width: max(100vw, 159.879svh);
  aspect-ratio: 1586 / 992;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: -1;
  background: linear-gradient(90deg, #08120b22, #08120b47 47%, #08120b15), url('candlelit-library.webp') center / cover no-repeat;
}
.library-scene i {
  position: absolute;
  left: var(--x);
  bottom: calc(100% - var(--y));
  width: var(--flame-width);
  height: var(--flame-height);
  transform: translateX(-50%);
}
.library-scene i::before,
.library-scene i::after {
  content: '';
  position: absolute;
  pointer-events: none;
}
.library-scene i::before {
  left: 50%;
  bottom: 45%;
  width: 1050%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, 50%);
  background: radial-gradient(circle, #ffba6195, #e48b2b35 30%, transparent 69%);
  mix-blend-mode: screen;
  animation: candlelight var(--speed) ease-in-out var(--phase) infinite;
}
.library-scene i::after {
  inset: 0;
  border-radius: 54% 46% 48% 52% / 73% 72% 28% 27%;
  background: radial-gradient(ellipse at 50% 71%, #fffef5 0 30%, #fff0ad 51%, #feb552 75%, #ed7c25 100%);
  box-shadow: 0 0 3px #ffca70, 0 0 7px #ff963374;
  transform-origin: 50% 100%;
  animation: candle-flame var(--speed) var(--phase) infinite;
}
@keyframes candle-flame {
  0%, 100% { transform: rotate(-3deg) scale(.94, 1.02); opacity: .96; }
  15% { transform: rotate(7deg) scale(1.12, .86); opacity: .89; }
  23% { transform: rotate(3deg) scale(.89, 1.14); opacity: 1; }
  37% { transform: rotate(-8deg) scale(.97, 1.05); opacity: .97; }
  51% { transform: rotate(2deg) scale(1.16, .77); opacity: .86; }
  61% { transform: rotate(-5deg) scale(.9, 1.19); opacity: 1; }
  75% { transform: rotate(5deg) scale(.96, 1.08); opacity: .97; }
  86% { transform: rotate(1deg) scale(1.08, .94); opacity: .91; }
}
@keyframes candlelight {
  0%, 100% { opacity: .36; }
  15% { opacity: .24; }
  23% { opacity: .48; }
  51% { opacity: .18; }
  61% { opacity: .55; }
  86% { opacity: .30; }
}
@media (prefers-reduced-motion: reduce) {
  .library-scene i::before { animation: none; opacity: .3; }
  .library-scene i::after { animation: none; }
}
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: min(90%, 1440px);
  margin: auto;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--brass);
}
.wordmark { color: inherit; font-size: clamp(28px, 3.25vw, 45px); letter-spacing: -.045em; text-decoration: none; }
main {
  width: min(80%, 1250px);
  margin: clamp(32px, 5vh, 68px) auto 48px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr);
  gap: clamp(24px, 4.8vw, 78px);
  align-items: center;
}
.intro { text-align: center; text-shadow: 0 2px 16px #000d; }
h1 { margin: 0; font-size: clamp(45px, 6.25vw, 96px); line-height: .91; font-weight: 600; letter-spacing: -.045em; }
h1 em { color: #e2cbab; }
.intro-rule { display: flex; align-items: center; gap: 12px; width: min(72%, 300px); margin: 23px auto 0; color: #bda17b; }
.intro-rule::before, .intro-rule::after { content: ''; height: 1px; background: currentColor; flex: 1; opacity: .75; }
.intro p { margin: 15px 0 0; color: var(--ink); font-size: clamp(19px, 2.25vw, 31px); font-weight: 600; }
.game {
  --paper-ink: #3a291e;
  --folio-bronze: #907855;
  --grain: url('folio-grain.png');
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 535px;
  padding: clamp(14px, 2.35vw, 32px);
  border: 1px solid #766a4c;
  border-radius: 22px;
  background: var(--grain), radial-gradient(ellipse at 38% 8%, #424431, #303328 56%, #282b22);
  box-shadow: 0 16px 54px #0009, inset 0 0 0 3px #181a12, inset 0 0 0 5px #544b37;
}
.game::before { content: ''; position: absolute; inset: 9px; z-index: -1; border: 1px solid #9d84665e; border-radius: 14px; pointer-events: none; }
button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #ffe6af; outline-offset: 3px; }
.board { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 4px solid #997f5d; border-radius: 13px; background: #8c795d; box-shadow: 0 3px 6px #0009, 0 0 0 1px #221a12; }
.cell { position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 0; padding: 0; min-width: 0; background: var(--grain), linear-gradient(140deg, #c9bba1, #c2b194); color: #27432d; font-size: clamp(19px, 3vw, 33px); font-weight: 700; line-height: 1; }
.cell.given { background: var(--grain), linear-gradient(140deg, #c2b094, #bba889); color: var(--paper-ink); }
.cell.peer { background: var(--grain), #b1b297; }
.cell.gold { background: var(--grain), linear-gradient(145deg, #b59673, #a98460); color: #3a2819; }
.cell.avert { background: var(--grain), #9b5850; color: #fff2e6; }
.cell.selected { box-shadow: inset 0 0 0 2px #486148; }
.cell.selected.avert { box-shadow: inset 0 0 0 2px #622b25; }
.cell:focus-visible { outline: 2px dashed #372d25; outline-offset: -5px; z-index: 1; }
.cell.avert:focus-visible { outline-color: #fff0cc; }
.cell.divider-x { border-right: 2px solid #705539; }
.cell.divider-y { border-bottom: 2px solid #705539; }
.number { position: absolute; left: 3px; top: 3px; color: #47301d; font: 700 10px/1 system-ui, sans-serif; }
.cell.avert .number { color: #fff2e6; }
.notes { display: grid; width: 86%; grid-template-columns: repeat(3, 1fr); font: 650 clamp(7px, 1.9vw, 11px)/1.04 system-ui, sans-serif; color: #344331; }
.notes span { min-height: 1em; }
.keys, .controls { display: grid; gap: clamp(3px, .65vw, 8px); margin-top: 10px; }
.keys { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.keys button, .controls button { min-height: 44px; min-width: 0; padding: 0 2px; border: 1px solid var(--folio-bronze); border-radius: 9px; font-weight: 700; box-shadow: inset 0 1px #f7e5c044, 0 2px 3px #0006; }
.keys button { background: var(--grain), linear-gradient(#ddc9aa, #c8af8a); color: var(--paper-ink); font-size: clamp(19px, 3.1vw, 30px); }
.controls button { background: var(--grain), linear-gradient(#434333, #303126); color: #f1e0c5; font-size: clamp(15px, 1.7vw, 20px); }
.controls button[aria-pressed=true], .controls .check { background: var(--grain), linear-gradient(#caae8d, #b5936d); color: #302017; }
.controls .check:disabled { opacity: .64; cursor: default; }
.keys button:not(:disabled):hover, .controls button:not(:disabled):hover { filter: brightness(1.09); }
.word { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px 9px; align-items: center; margin-top: 16px; }
.word strong { color: #eddbbf; font-size: clamp(17px, 1.7vw, 24px); font-weight: 600; font-style: italic; }
.word output { display: flex; gap: 4px; }
.word span { border: 1px solid #b09773; border-radius: 6px; display: grid; place-items: center; width: clamp(18px, 4.3vw, 29px); height: clamp(25px, 4vw, 34px); color: var(--paper-ink); background: var(--grain), #bdab8b; box-shadow: inset 0 1px 4px #39291977; font-size: clamp(16px, 2.2vw, 23px); font-weight: 700; }
.status { margin: 10px 0 0; font: 13px/1.4 system-ui, sans-serif; color: #e8d9be; }
.status:empty { display: none; }
@media (max-width: 720px) {
  .library-scene { top: 48px; width: 100vw; transform: translateX(-50%); mask-image: linear-gradient(#000 68%, transparent); }
  main { width: min(92%, 450px); grid-template-columns: minmax(0, 1fr); gap: 18px; margin: 23px auto 32px; }
  .intro { text-align: center; }
  h1 { font-size: clamp(33px, 9vw, 54px); }
  .hero-break { display: none; }
  .intro-rule { margin-top: 8px; }
  .intro p { margin-top: 8px; font-size: clamp(16px, 4.5vw, 21px); }
}

.wordmark { font-family: 'Explora', Georgia, serif; font-size: clamp(49px, 6vw, 77px); font-weight: 400; letter-spacing: 0; line-height: .85; }
.intro p { font-style: italic; font-size: clamp(19px, 2.4vw, 33px); line-height: 1.25; }
.rules-button {
  padding: 7px 13px;
  min-height: 44px;
  border: 1px solid #a38a60;
  border-radius: 7px;
  background: #26291ede;
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 700;
  white-space: nowrap;
}
.rules-dialog {
  width: min(91vw, 460px);
  max-height: calc(100dvh - 30px);
  padding: clamp(21px, 5vw, 34px);
  border: 1px solid #a78a64;
  border-radius: 17px;
  background: url('folio-grain.png'), #303328;
  color: #f5e7cc;
  box-shadow: 0 18px 65px #000a, inset 0 0 0 4px #24261c;
}
.rules-dialog::backdrop { background: #0f130caa; }
.rules-dialog h2 { margin: 0 0 10px; font-size: clamp(32px, 7vw, 44px); line-height: 1; }
.rules-dialog ol { margin: 0 0 17px; padding-left: 1.25em; font: 15px/1.5 system-ui, sans-serif; }
.rules-dialog li + li { margin-top: 7px; }
.rules-preference { display: flex; align-items: center; gap: 8px; min-height: 34px; font: 14px system-ui, sans-serif; }
.rules-preference input { width: 18px; height: 18px; accent-color: #c4a786; }
.rules-play { display: block; min-height: 44px; margin-top: 12px; padding: 6px 15px; border: 1px solid #ad8d66; border-radius: 8px; background: #c9af8b; color: #35251a; font-size: 21px; font-weight: 700; }
.puzzle-date { margin: 0 0 12px; color: #e8dbbf; text-align: center; font-size: clamp(16px, 1.7vw, 21px); font-weight: 700; }
.site-reading {
  display: block;
  width: min(90%, 740px);
  margin: 38px auto 24px;
  padding: clamp(20px, 4vw, 38px);
  border: 1px solid #8f795c;
  border-radius: 14px;
  background: #23281e;
  color: #f3e6cd;
  font: 16px/1.65 system-ui, sans-serif;
}
.site-reading h1, .site-reading h2 { font-family: 'Cormorant Garamond', Georgia, serif; line-height: 1.08; }
.site-reading h1 { font-size: clamp(38px, 7vw, 60px); letter-spacing: -.025em; }
.site-reading h2 { margin: 24px 0 6px; font-size: 28px; }
.site-reading h2:first-child { margin-top: 0; }
.site-reading p { margin: 10px 0 16px; }
.site-reading p:last-child { margin-bottom: 0; }
.site-reading a, .site-footer a, .site-header > a:not(.wordmark) { color: #f3dfbb; text-underline-offset: 3px; }
.site-footer { margin: 23px auto 0; padding: 0 12px 28px; text-align: center; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font: 15px system-ui, sans-serif; }

.cell, .keys button {
  font-family: 'STIX Two Text', Georgia, serif;
  font-weight: 600;
}
.cell { color: #12341e; }
.cell.given, .cell.gold { color: #281a12; }
.cell.avert { color: #fff5eb; }
@media (max-width: 720px) {
  .cell { font-size: clamp(20px, 5.6vw, 28px); }
  .number { font-size: 9px; }
}

/* Leave a separate top strip for the hidden-word number. */
.cell.gold .number { top: 1px; line-height: 1; }
.cell.gold .notes {
  position: absolute;
  inset: 12px 2px 1px;
  width: auto;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  place-items: center;
  font-size: 9px;
  line-height: 1;
}
.cell.gold .notes span { min-height: 0; }
@media (max-width: 720px) {
  .cell.gold .notes {
    top: 10px;
    font-size: clamp(6px, 1.6vw, 9px);
  }
}
