:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --white: #fffefa;
  --ink: #241c31;
  --muted: #615a6b;
  --purple: #5a3294;
  --dark-purple: #41236d;
  --lilac: #e6d9f6;
  --line: #ded8e5;
  --lime: #dcecac;
  --error: #9a3038;
  --sans: "DM Sans", "Avenir Next", system-ui, sans-serif;
  --serif: "DM Serif Text", Georgia, serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.55 var(--sans); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
a { color: var(--purple); text-underline-offset: .17em; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
.skip { position: fixed; top: 12px; left: 12px; padding: .5rem 1rem; background: white; z-index: 2; transform: translateY(-160%); }
.skip:focus { transform: none; }

.top { border-bottom: 1px solid #e7e1db; }
.top-inner, .footer-inner { max-width: 1168px; margin: auto; padding: 0 32px; display: flex; justify-content: space-between; align-items: center; min-height: 73px; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 9px; font: bold 1.66rem/1 var(--sans); letter-spacing: -.085em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 33px; border-radius: 8px; background: var(--purple); color: white; font: bold 1.15rem/1 var(--mono); letter-spacing: 0; box-shadow: 0 2px 0 var(--dark-purple); }
.brand-dot { color: var(--purple); }
nav { display: flex; gap: 29px; }
nav a, .back-top { text-decoration: none; color: var(--muted); font-size: .9rem; font-weight: 650; }
nav a:hover, .back-top:hover, nav .jump-play { color: var(--purple); }
.top-cta { display: inline-flex; align-items: center; gap: 10px; border: 1px solid #d8c9e8; padding: 7px 13px; border-radius: 8px; font-weight: 700; font-size: .89rem; text-decoration: none; }
.top-cta:hover { background: var(--lilac); }

.hero { text-align: center; overflow: hidden; margin-inline: auto; }
.hero-inner { position: relative; max-width: 990px; margin-inline: auto; padding: 50px 20px 34px; }
h1, h2 { font-family: var(--serif); font-weight: 400; }
h1 { position: relative; margin: 0 0 16px; font-size: clamp(3.1rem, 7.4vw, 5.85rem); line-height: 1.03; letter-spacing: -.063em; }
h1 em { color: var(--purple); white-space: nowrap; }
.intro { position: relative; max-width: 520px; margin: 0 auto; color: var(--muted); font-size: 1.06rem; line-height: 1.55; text-wrap: pretty; }
.intro strong { color: var(--ink); font-weight: 750; }
.flourish { position: absolute; top: 63px; width: 100px; height: 114px; pointer-events: none; }
.flourish span { display: grid; place-items: center; position: absolute; width: 76px; height: 76px; border-radius: 17px; font: 700 2.65rem/1 var(--mono); }
.flourish i, .flourish b { position: absolute; font-style: normal; color: var(--purple); }
.flourish-left { left: 43px; }
.flourish-left span { top: 18px; left: 16px; transform: rotate(-14deg); background: var(--lilac); color: var(--dark-purple); box-shadow: 1px 5px 0 #c9b0e7; }
.flourish-left i { left: 0; bottom: 0; font-size: 1.55rem; }
.flourish-left b { top: -15px; left: 25px; font-size: 1.6rem; }
.flourish-right { right: 41px; }
.flourish-right span { top: 15px; left: 4px; transform: rotate(13deg); background: var(--lime); color: #34441b; box-shadow: 0 5px 0 #b7cb81; }
.flourish-right i { top: -10px; right: 0; font-size: 1.9rem; }
.flourish-right b { bottom: 2px; right: 4px; font-size: 2rem; }

.game { max-width: 710px; margin: 0 auto; border: 1px solid #ddd3e6; border-radius: 22px; background: var(--white); box-shadow: 0 5px 0 #e9e0ef, 0 16px 30px #48245c0b; overflow: hidden; scroll-margin-top: 16px; }
.game-head { padding: 17px 24px; display: flex; gap: 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid #e9e2ed; }
.game-head h2 { margin: 0; font-size: 1.95rem; letter-spacing: -.042em; line-height: 1.15; }
.game-head p { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }
.modes { flex: none; display: flex; background: #eee9f2; padding: 4px; border-radius: 10px; }
.modes button { border: 0; border-radius: 7px; background: transparent; color: #554c61; font-size: .85rem; font-weight: 750; min-height: 36px; padding: 4px 15px; }
.modes button[aria-pressed="true"] { color: var(--dark-purple); background: white; box-shadow: 0 1px 3px #3a21521b; }
.modes button:hover { color: var(--dark-purple); }
.game-body { padding: 17px 24px 12px; }
.theme { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 61px; border-radius: 11px; background: #efe8f7; padding: 8px 13px; }
.theme-text { display: flex; align-items: center; gap: 10px; min-width: 0; }
.theme-mark { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--lilac); color: var(--purple); font-size: 1.23rem; }
.kicker { display: block; color: var(--dark-purple); font: 700 .65rem/1.3 var(--mono); letter-spacing: .095em; }
.theme strong { display: block; color: var(--dark-purple); font-size: 1.06rem; line-height: 1.22; margin-top: 2px; }
.mistakes { display: grid; min-width: max-content; gap: 4px; justify-items: end; }
.pips { display: flex; gap: 5px; }
.pips i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid #7753a0; background: #7753a0; }
.pips i.spent { background: none; border-color: #a08ab6; }
.game-instruction { margin: 12px 0 8px; color: var(--muted); font-size: .89rem; }
.rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.word-row { display: flex; align-items: center; position: relative; min-height: 60px; width: 100%; text-align: left; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: white; padding: 7px 10px; }
.word-row[aria-pressed="true"] { background: #f7f1fe; border-color: #9270bc; box-shadow: inset 0 0 0 1px #9270bc; }
.word-row:not(:disabled):hover { border-color: var(--purple); }
.word-row.solved { border-color: #adc881; background: #f1f7e6; }
.word-row.revealed { border-color: #e3b5b5; background: #fcf2f0; }
.word-row.incorrect { animation: shake .23s ease-out; border-color: #c16067; }
.letters { flex: 1; display: flex; align-items: center; gap: 2px; font: 700 1.09rem/1 var(--mono); letter-spacing: .047em; }
.initial { display: grid; place-items: center; width: 30px; height: 32px; border-radius: 6px; background: #ede7f3; color: var(--purple); }
.word-row[aria-pressed="true"] .initial { background: var(--purple); color: white; }
.solved .initial { color: #354b19; background: #d9eab8; }
.revealed .initial { color: #842531; background: #f5d2d1; }
.row-glyph { color: #797181; font: 1.08rem/1 var(--sans); }
.solved .row-glyph { color: #496820; }
.revealed .row-glyph { color: var(--error); }
.keyboard { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 5px; margin-top: 13px; }
.key { border: 1px solid #e0d9e7; border-bottom-width: 2px; border-radius: 7px; background: #f1edf4; padding: 0; min-width: 0; min-height: 37px; color: var(--ink); font: 650 .93rem/1 var(--mono); }
.key:hover { color: var(--dark-purple); background: var(--lilac); border-color: #c1a6dd; }
.key:active { transform: translateY(1px); }
.key:disabled { background: #f8f6f7; color: #766d7e; }
.game-feedback { min-height: 42px; display: flex; justify-content: space-between; align-items: center; gap: 9px; }
.game-feedback p { color: var(--purple); font-size: .83rem; margin: 4px 0; }
.game-feedback p.error { color: var(--error); }
.hint { white-space: nowrap; margin-left: auto; color: var(--purple); background: none; border: 0; border-radius: 5px; font-size: .83rem; font-weight: 750; padding: 6px; min-height: 34px; }
.hint:hover { background: #f0e9f8; }
.result { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; margin: 0 0 9px; background: #f0e9f8; border-radius: 10px; }
.result strong { display: block; color: var(--dark-purple); font-size: 1.08rem; }
.result p { margin: 0; color: var(--muted); font-size: .84rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result button { border: 1px solid var(--purple); background: white; color: var(--purple); border-radius: 7px; font-weight: 750; font-size: .84rem; min-height: 38px; padding: 5px 10px; }
.result #next { color: white; background: var(--purple); }
.result button:hover { box-shadow: 0 0 0 2px #baa1d4; }
.notice { color: var(--muted); }

.reading { max-width: 710px; margin: 54px auto 65px; }
.reading section { scroll-margin-top: 25px; }
.reading section + section { margin-top: 42px; padding-top: 36px; border-top: 1px solid #e0d9e4; }
.reading h2 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 2.68rem); line-height: 1.13; letter-spacing: -.05em; }
.reading p, .reading li { color: var(--muted); }
.reading p { margin: 0 0 13px; }
.reading strong { color: var(--ink); }
.example { background: #efe8f7; padding: 14px 17px; border-radius: 12px; display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.example p { margin: 3px 0 0; }
.example-tiles { display: flex; gap: 10px; align-items: center; color: var(--ink); font: 700 .96rem var(--mono); }
.example-tiles span { display: inline-block; background: white; padding: 5px 8px 5px 5px; border-radius: 6px; }
.example-tiles b { display: inline-block; background: var(--lilac); color: var(--dark-purple); border-radius: 4px; padding: 3px 5px; margin-right: 2px; }
.example-tiles span:last-child b { background: var(--lime); color: #34441b; }
.example-tiles i { font-style: normal; }
.reading ol { padding-inline-start: 22px; margin-bottom: 0; }
.reading li { padding-left: 3px; margin-bottom: 7px; }
.sources { display: flex; gap: 7px 18px; flex-wrap: wrap; font-size: .86rem; }
details { border-bottom: 1px solid #ded7e2; }
summary { padding: 13px 0; font-weight: 750; cursor: pointer; }
summary::marker { color: var(--purple); }
footer { border-top: 1px solid #e1dbe4; }
.footer-inner { min-height: 85px; gap: 18px; }
.footer-inner p { color: var(--muted); text-align: center; font-size: .84rem; }
.back-top { white-space: nowrap; }
@keyframes shake { 33% { transform: translateX(-3px); } 66% { transform: translateX(3px); } }

@media (max-width: 860px) {
  .flourish-left { left: 14px; }
  .flourish-right { right: 14px; }
}
@media (max-width: 745px) {
  .game, .reading { margin-inline: 16px; }
  .flourish { display: none; }
}
@media (max-width: 520px) {
  .top-inner, .footer-inner { padding-inline: 16px; }
  .top-inner { min-height: 61px; }
  .top-cta { display: none; }
  nav { gap: 15px; }
  nav a { font-size: .82rem; }
  .hero-inner { padding-block: 35px 24px; }
  .intro { font-size: .94rem; }
  .game { border-radius: 16px; }
  .game-head, .game-body { padding: 13px; }
  .game-body { padding-bottom: 4px; }
  .game-head h2 { font-size: 1.6rem; }
  .game-head p { font-size: .73rem; }
  .modes button { padding-inline: 9px; }
  .word-row { padding-inline: 6px; min-height: 54px; }
  .letters { gap: 1px; font-size: .91rem; letter-spacing: 0; }
  .initial { width: 23px; height: 30px; }
  .row-glyph { margin-left: 3px; }
  .keyboard { grid-template-columns: repeat(9, minmax(0, 1fr)); }
  .key { min-height: 40px; }
  .reading { margin-top: 40px; }
  .footer-inner { flex-wrap: wrap; justify-content: center; padding-block: 14px; gap: 12px; }
  .footer-inner p { width: 100%; order: 1; margin: 0; }
}
@media (max-width: 360px) {
  .game, .reading { margin-inline: 10px; }
  nav { gap: 11px; }
  .theme strong { font-size: .93rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .word-row.incorrect { animation: none; }
}
