:root { --ink: #e9ecf4; --dim: #9aa6c2; --night: #05070f; --gold: #f3d79a; color-scheme: dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { font-family: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
button { font: inherit; color: inherit; }

.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(220, 228, 255, .16); background: rgba(14, 20, 38, .55);
  display: grid; place-items: center; cursor: pointer; padding: 0; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: transform .15s ease, background .2s ease; }
.round svg { width: 22px; height: 22px; }
.round:active { transform: scale(.93); }
.round.big { width: 72px; height: 72px; background: rgba(243, 215, 154, .14); border-color: rgba(243, 215, 154, .45); color: var(--gold); }
.round.big svg { width: 32px; height: 32px; }
.round:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* the HUD: the Sleepy Pines corners (both top corners, 60 x 60 + safe area on the platform, 0 elsewhere) stay clear */
#hud { position: fixed; top: 0; left: 0; right: 0; height: 56px; pointer-events: none;
  padding-top: env(safe-area-inset-top); }
#hud[hidden], #title[hidden], #done[hidden], #mapbtn[hidden], #stick[hidden] { display: none; }
#home { position: absolute; top: calc(6px + env(safe-area-inset-top)); left: calc(8px + var(--sp-home-w, 0px)); pointer-events: auto; }
#mid { position: absolute; top: calc(6px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); height: 44px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px 0 8px; border-radius: 22px; background: rgba(8, 12, 26, .42); }
#lvl { font-weight: 700; font-size: 19px; letter-spacing: .04em; min-width: 1.2em; text-align: center; color: var(--ink); }
#stars { display: flex; gap: 4px; }
.star { width: 15px; height: 15px; }
.star path { fill: rgba(200, 210, 240, .18); transition: fill .4s ease; }
.star.got path { fill: var(--gold); }
#pieces { display: flex; gap: 3px; margin-left: 4px; }
#pieces:empty { display: none; }
.scrap { width: 15px; height: 15px; }
.scrap path { fill: rgba(232, 220, 188, .16); transition: fill .4s ease; }
.scrap.got path { fill: #e8dcbc; }

/* the title: the live maze plays behind a quiet lowercase wordmark */
#title { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(76px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom)); pointer-events: none;
  transition: opacity .7s ease; }
#title.out { opacity: 0; }
#mark { margin: 0; font-weight: 300; font-size: clamp(34px, 10vw, 58px); letter-spacing: .32em; text-indent: .32em; color: #eef1fa;
  text-shadow: 0 0 24px rgba(190, 210, 255, .35), 0 2px 10px rgba(0, 0, 0, .6); }
#mark span { display: inline-block; animation: breathe 7s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .82; } 50% { opacity: 1; } }
#tbtns { display: flex; gap: 18px; align-items: center; pointer-events: auto; }
#tsmall { display: flex; gap: 12px; align-items: center; pointer-events: auto; }
#tlvl { font-size: 15px; letter-spacing: .14em; color: var(--dim); }
#snd.off #sndWave { opacity: 0; }

/* the stick: a faint ring resting bottom left; under your thumb wherever you hold the left side */
#stick { position: fixed; left: calc(78px + env(safe-area-inset-left)); top: calc(100% - 92px - env(safe-area-inset-bottom)); width: 112px; height: 112px;
  margin: -56px 0 0 -56px; border-radius: 50%; border: 1px solid rgba(243, 215, 154, .2); background: radial-gradient(circle, rgba(243, 215, 154, .06), rgba(14, 20, 38, .2) 70%);
  pointer-events: none; opacity: .55; transition: opacity .3s ease; }
#stick.on { opacity: 1; transition: none; }
#sknob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%;
  background: rgba(243, 215, 154, .16); border: 1px solid rgba(243, 215, 154, .45); transition: transform .2s ease; }
#stick.on #sknob { transition: none; background: rgba(243, 215, 154, .24); }
#mapbtn { position: fixed; right: calc(18px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom));
  background: rgba(14, 20, 38, .6); border-color: rgba(220, 228, 255, .14); color: rgba(200, 210, 235, .38); transition: color .4s ease, border-color .4s ease, background .4s ease, box-shadow .4s ease; }
#mapbtn:active { transform: scale(.93); }
#mapbtn.ready { color: #f1e6c6; border-color: rgba(214, 226, 255, .7); background: rgba(70, 86, 130, .5); box-shadow: 0 0 28px rgba(190, 210, 255, .45); animation: moonready 2.6s ease-in-out infinite; }
@keyframes moonready { 50% { box-shadow: 0 0 40px rgba(190, 210, 255, .7); } }
#mapbtn.nope { animation: nope .35s ease; }
@keyframes nope { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* what the wood tells you: a line of text that rises softly above the pad */
#note { position: fixed; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); width: min(86vw, 420px);
  text-align: center; font-size: 16px; line-height: 1.45; color: #efe6cf; text-shadow: 0 1px 8px rgba(0, 0, 0, .9), 0 0 2px rgba(0, 0, 0, .8);
  opacity: 0; transition: opacity 1.1s ease, transform 1.1s ease; pointer-events: none; }
#note.in { opacity: 1; transform: translate(-50%, 0); }

/* the end of a wood */
#done { position: fixed; left: 50%; bottom: calc(10vh + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 16px; animation: rise .8s ease both; }
#doneStars { display: flex; gap: 10px; }
#doneStars .star { width: 30px; height: 30px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

#veil { position: fixed; inset: 0; background: var(--night); opacity: 1; pointer-events: none; transition: opacity .6s ease; }
#veil.clear { opacity: 0; }

@media (prefers-reduced-motion: reduce) { #mark span { animation: none; } #done { animation: none; } }

body.reading #stick, body.reading #note { opacity: 0; }

/* the old pine: the level select, scrolled up and down */
#grove { position: fixed; inset: 0; z-index: 30; background: #070b16; }
#grove.in { animation: groveIn .5s ease; }
@keyframes groveIn { from { opacity: 0; } }
#gscroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
#gin { position: relative; margin: 0 auto; }
#gart, #gpath { position: absolute; left: 0; top: 0; display: block; }
#gback { position: fixed; left: calc(14px + env(safe-area-inset-left)); top: calc(14px + env(safe-area-inset-top)); z-index: 2; }
.gnode { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 1px solid rgba(255, 214, 150, .5); background: radial-gradient(circle at 40% 35%, #4a3a22, #1e170e 75%); color: #f3d79a; font-weight: 600; font-size: 15px; line-height: 1; display: grid; place-items: center; box-shadow: 0 0 14px rgba(255, 190, 100, .25); cursor: pointer; padding: 0; }
.gnode .n { pointer-events: none; }
.gnode .pips { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 3px); display: flex; gap: 3px; pointer-events: none; }
.gnode .pips i { width: 6px; height: 6px; border-radius: 50%; background: rgba(243, 215, 154, .22); }
.gnode .pips i.got { background: #f3d79a; box-shadow: 0 0 5px rgba(255, 210, 130, .8); }
.gnode.locked { background: rgba(14, 20, 34, .85); border-color: rgba(190, 205, 235, .18); color: rgba(190, 205, 235, .35); box-shadow: none; cursor: default; }
.gnode.cur { width: 54px; height: 54px; margin: -27px 0 0 -27px; background: radial-gradient(circle at 40% 35%, #ffe2a4, #d99a3c 70%); color: #2a1d0c; border-color: #fff0c8; box-shadow: 0 0 24px rgba(255, 200, 110, .8); animation: curGlow 2.4s ease-in-out infinite; font-size: 17px; }
@keyframes curGlow { 50% { box-shadow: 0 0 40px rgba(255, 210, 130, 1); } }
.gnode.tip { background: transparent; border: 0; box-shadow: none; }
.gnode.tip svg { width: 40px; height: 40px; fill: rgba(243, 215, 154, .35); filter: drop-shadow(0 0 6px rgba(255, 220, 150, .4)); }
.gnode.tip.cur svg, .gnode.tip.done svg { fill: #ffe7a8; filter: drop-shadow(0 0 14px rgba(255, 220, 150, 1)); }
.gnode.tip.cur { animation: none; }

#planks { display: flex; gap: 3px; margin-left: 4px; }
#planks:empty { display: none; }
.plank { width: 16px; height: 16px; }
.plank path:first-child { fill: #c9a06a; }
.plank path:last-child { stroke: #5a4026; }

/* the satchel and its keepsakes */
#satchel { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: 10px; padding: 9px 18px 9px 14px; border-radius: 26px; border: 1px solid rgba(243, 215, 154, .4); background: rgba(20, 16, 10, .82); color: #f3d79a; font: inherit; font-size: 16px; box-shadow: 0 0 18px rgba(0, 0, 0, .5); }
#satchel .bag { width: 22px; height: 22px; fill: #c9a06a; }
#satchel span { display: flex; align-items: center; gap: 4px; }
#satchel span svg, #kbal svg, .kc svg { width: 15px; height: 15px; fill: #f3d79a; }
#keeps { position: fixed; inset: 0; z-index: 3; background: rgba(4, 6, 12, .6); display: flex; align-items: flex-end; justify-content: center; }
#keepsin { width: min(460px, 100%); max-height: 78vh; overflow-y: auto; margin: 0 10px calc(10px + env(safe-area-inset-bottom)); padding: 14px; border-radius: 22px; background: #15110b; border: 1px solid rgba(243, 215, 154, .25); color: #f3d79a; animation: groveIn .3s ease; }
#khead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#kbal { display: flex; align-items: center; gap: 6px; font-size: 20px; padding-left: 4px; }
#kbal svg { width: 20px; height: 20px; }
#klist { display: grid; gap: 8px; }
.keep { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; border: 1px solid rgba(243, 215, 154, .14); background: rgba(243, 215, 154, .04); color: inherit; font: inherit; text-align: left; opacity: .55; }
.keep.can { opacity: 1; border-color: rgba(243, 215, 154, .5); background: rgba(243, 215, 154, .1); cursor: pointer; }
.keep.own { opacity: 1; border-color: rgba(160, 220, 170, .35); }
.keep .ki { width: 34px; height: 34px; fill: #e6c27a; stroke: #e6c27a; }
.keep .kt { display: grid; gap: 2px; }
.keep .kt b { font-weight: 600; font-size: 16px; }
.keep .kt i { font-style: normal; font-size: 13px; opacity: .75; line-height: 1.3; }
.keep .kc { display: flex; align-items: center; gap: 3px; font-size: 15px; white-space: nowrap; }
.keep.own .kc { color: #a8dcb0; }
.keep.own .kc svg { width: 20px; height: 20px; fill: none; stroke: #a8dcb0; }
#keeps[hidden], #satchel[hidden] { display: none; }
#khead { position: sticky; top: -14px; z-index: 1; margin: -14px -14px 10px; padding: 14px 14px 8px; background: #15110b; }

/* reading: the world dims and softens round the paper */
#mapveil { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .7s ease; background: radial-gradient(ellipse 70% 62% at 50% 54%, rgba(0,0,0,0) 45%, rgba(2,4,10,.55) 80%, rgba(2,4,10,.82)); }
body.reading #mapveil { opacity: 1; }

#gfx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#gscroll { z-index: 0; }
#gnodes { position: absolute; inset: 0; z-index: 2; }
.gnode { width: 52px; height: 52px; margin: -26px 0 0 -26px; font-size: 17px; }
.gnode.cur { width: 66px; height: 66px; margin: -33px 0 0 -33px; font-size: 20px; }
.gnode .me { position: absolute; left: 50%; bottom: 100%; width: 26px; height: 34px; transform: translate(-50%, -4px); pointer-events: none; animation: meBob 2.4s ease-in-out infinite; }
.gnode .me svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 6px rgba(255, 210, 130, .6)); }
@keyframes meBob { 50% { transform: translate(-50%, -8px); } }
.gnode.tip svg { width: 52px; height: 52px; }
