:root {
  color-scheme: dark;
  font-family: ui-rounded, 'Avenir Next', Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --night: #292a31;
  --panel: #39383b;
  --cream: #fff2d7;
  --muted: #d8cebd;
  --honey: #f2c96d;
  --amber: #d7953f;
  --bronze: #bd7952;
  --silver: #c5c9c5;
  --gold: #efc860;
  --sage: #a9c39f;
  --line: rgba(255, 242, 215, .2);
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--night); overflow-x: clip; -webkit-text-size-adjust: 100%; }
body { min-width: 320px; min-height: 100vh; min-height: 100dvh; margin: 0; color: var(--cream); background: radial-gradient(circle at 78% -5%, #5a4935 0, var(--night) 38rem); overflow-x: clip; }
button { min-height: 44px; border: 0; font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, .hub-link:focus-visible, .app:focus-visible { outline: 3px solid #fff0bd; outline-offset: 3px; }
button:disabled { cursor: default; }
.hub-link { display: inline-flex; min-height: 44px; align-items: center; color: var(--honey); font-size: .72rem; font-weight: 850; text-underline-offset: .18rem; }
.app { width: min(100%, 35rem); min-height: 100svh; margin: auto; padding: max(.75rem, env(safe-area-inset-top)) max(.55rem, env(safe-area-inset-right)) max(1.6rem, env(safe-area-inset-bottom)) max(.55rem, env(safe-area-inset-left)); }
header, .intro, .section-heading, .preview-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem; }
header { align-items: center; }
.eyebrow, .kicker { margin: 0 0 .2rem; color: var(--honey); font-size: .64rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 800 clamp(1.75rem, 8vw, 2.55rem)/.95 Georgia, serif; letter-spacing: -.04em; }
h1 em { display: block; color: var(--honey); font-weight: 400; }
h2 { margin-bottom: .18rem; font: 800 1.08rem/1.1 Georgia, serif; }
.lantern { display: grid; width: 48px; height: 48px; flex: 0 0 auto; place-items: center; color: #ffe59c; border: 1px solid #92734b; border-radius: 50% 50% 42% 42%; background: #554431; box-shadow: 0 0 22px rgba(242,201,109,.35); font-size: 1.35rem; }
.intro { align-items: end; margin: .8rem .2rem .55rem; }
.intro p { max-width: 15rem; margin-bottom: 0; color: var(--muted); font-size: .74rem; line-height: 1.3; }
.scores { flex: 0 0 auto; display: grid; gap: .05rem; text-align: right; font-size: .65rem; color: var(--muted); }
.scores strong { color: var(--honey); font-size: .92rem; }
.treasure-board, .word-builder, .completion, .found-panel { border: 1px solid var(--line); background: rgba(58,56,56,.92); box-shadow: 0 10px 26px rgba(10,10,12,.22); }
.treasure-board { margin-top: .55rem; padding: .62rem; border-radius: 1rem 1rem .35rem .35rem; }
.section-heading > span { color: var(--muted); font-size: .68rem; }
.treasures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .38rem; margin-top: .5rem; }
.treasure { min-width: 0; min-height: 126px; padding: .42rem .3rem; border: 1px solid currentColor; border-radius: .45rem .85rem .45rem .85rem; color: var(--bronze); background: #2e2d30; text-align: center; }
.treasure.silver { color: var(--silver); }
.treasure.gold { color: var(--gold); }
.treasure svg { display: block; width: 52px; height: 42px; margin: 0 auto .15rem; }
.chest-lid, .chest { fill: #5b4638; stroke: currentColor; stroke-width: 2; }
.band { fill: currentColor; opacity: .7; }
.lock { fill: #332920; stroke: currentColor; stroke-width: 2; }
.treasure text { fill: currentColor; font-size: 12px; font-weight: 900; }
.treasure strong { display: block; font-size: .62rem; letter-spacing: .11em; text-transform: uppercase; }
.treasure p { min-height: 2.55rem; margin: .25rem 0; color: var(--cream); font-size: .66rem; line-height: 1.25; overflow-wrap: anywhere; }
.treasure > span { display: inline-block; padding: .14rem .36rem; border-radius: 1rem; color: #28231c; background: currentColor; font-size: .58rem; font-weight: 900; text-transform: uppercase; }
.treasure.found { background: #4a4035; box-shadow: inset 0 0 20px rgba(242,201,109,.12); }
.treasure.found svg { filter: drop-shadow(0 0 7px currentColor); }
.word-builder { padding: .62rem; border-radius: .35rem 1rem 1rem 1rem; }
.preview-row { align-items: end; }
.preview-row > div { min-width: 0; flex: 1; }
.preview { min-height: 44px; padding: .48rem .55rem; border-bottom: 2px solid #a8844d; color: var(--cream); background: #29282c; font-size: 1.18rem; font-weight: 900; letter-spacing: .12em; text-align: center; overflow-wrap: anywhere; }
.preview.empty { color: #9d968b; font-size: .76rem; line-height: 1.6rem; }
.clear { min-width: 56px; color: var(--muted); border: 1px solid #716d68; border-radius: .55rem; background: transparent; font-size: .7rem; font-weight: 800; }
.letters { position: relative; width: 204px; height: 164px; margin: .35rem auto; }
.letter { position: absolute; display: grid; width: 48px; height: 48px; place-items: center; color: #3a2c19; border: 2px solid #f3cf7a; clip-path: polygon(25% 5%,75% 5%,100% 50%,75% 95%,25% 95%,0 50%); background: linear-gradient(145deg,#ffe8a7,#dca74f); box-shadow: 0 3px 6px rgba(0,0,0,.25); font-size: 1.1rem; font-weight: 900; }
.letter:active { transform: scale(.93); }
.letter.top { left:78px; top:0; }.letter.upper-right { left:121px; top:28px; }.letter.lower-right { left:121px; top:87px; }.letter.bottom { left:78px; top:116px; }.letter.lower-left { left:35px; top:87px; }.letter.upper-left { left:35px; top:28px; }
.letter.centre { left:76px; top:57px; width:52px; height:52px; color: #fff6dc; background: #9c6334; border-color: #ffd980; }
.letter.centre small { display: block; margin-top: -8px; font-size: .36rem; line-height: 1; letter-spacing: .05em; text-transform: uppercase; }
.controls { display: grid; grid-template-columns: .85fr 1.35fr; gap: .45rem; }
.controls button { min-height: 48px; border-radius: .7rem; font-size: .78rem; font-weight: 900; }
.delete { color: var(--cream); border: 1px solid #817a70; background: #56545a; }
.submit { color: #352919; background: var(--honey); box-shadow: inset 0 -4px 0 #a56e29, 0 4px 10px rgba(0,0,0,.22); }
.submit:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #a56e29; }
.controls button:disabled, .clear:disabled { opacity: .42; box-shadow: none; }
.message { min-height: 2.5rem; margin: .5rem 0 0; padding: .52rem .65rem; color: var(--muted); border-left: 4px solid #88765b; background: #2c2b2f; font-size: .72rem; line-height: 1.35; }
.message.good { border-color: var(--sage); color: #dcefd5; }
.message.bad { border-color: #d98c78; color: #ffd3c8; }
.message.treasure-message { border-color: var(--gold); color: #ffe7a2; }
.completion { margin-top: .55rem; padding: .75rem; border-color: rgba(239,200,96,.6); border-radius: 1rem; text-align: center; }
.completion > span { color: var(--gold); font-size: 1.4rem; }
.completion p { margin-bottom: 0; color: var(--muted); font-size: .76rem; }
.found-panel { margin-top: .55rem; padding: .7rem; border-radius: 1rem .35rem 1rem 1rem; }
.found-words { display: flex; flex-wrap: wrap; gap: .3rem; min-height: 34px; margin-top: .45rem; }
.found-words > span:not(.empty-list) { padding: .24rem .45rem; color: #3c2d19; border-radius: .35rem; background: #e5c275; font-size: .66rem; font-weight: 900; }
.empty-list { color: #aaa298; font-size: .72rem; }
.footer-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem; margin-top: .55rem; }
.footer-actions button { padding: .45rem; border-radius: .65rem; font-size: .72rem; font-weight: 850; }
.restart { color: var(--cream); border: 1px solid #817b73; background: transparent; }
.next { color: #2e2c26; background: var(--sage); }
.experiment-note { margin: .8rem .2rem 0; color: #aaa196; font-size: .64rem; text-align: center; }
.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; }
[hidden] { display: none !important; }

@media (max-width: 350px) {
  .app { padding-right: max(.4rem, env(safe-area-inset-right)); padding-left: max(.4rem, env(safe-area-inset-left)); }
  .treasure { padding-inline: .18rem; }
  .treasure p { font-size: .61rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .letter:active, .submit:active { transform: none; }
}
