:root {
  --ink: #fbf5ea;
  --ink-soft: rgba(251, 245, 234, 0.74);
  --ink-faint: rgba(251, 245, 234, 0.45);
  --line: rgba(251, 245, 234, 0.22);
  --scrim: rgba(28, 18, 10, 0.5);
  --scrim-strong: rgba(24, 15, 8, 0.8);
  --accent: #e3b45a;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --tamil: 'Noto Serif Tamil', serif;
  --sans: 'Instrument Sans', system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  /* glass surfaces: a hairline ring and a soft drop, as shadows, not borders */
  --glass-edge: 0 0 0 1px rgba(251, 245, 234, 0.16), 0 8px 24px rgba(0, 0, 0, 0.22);
  --glass-edge-hover: 0 0 0 1px rgba(251, 245, 234, 0.42), 0 8px 24px rgba(0, 0, 0, 0.22);
  --gutter: clamp(16px, 2.6vw, 32px);
  /* type scale. Cormorant runs small, so serif reading text starts at 18px */
  --fs-label: 0.75rem;                          /* 12px  small uppercase labels */
  --fs-ui: 0.8125rem;                           /* 13px  buttons, hints, keys */
  --fs-tamil: 0.9375rem;                        /* 15px  Tamil names above titles */
  --fs-read: 1.125rem;                          /* 18px  serif lines, notes, captions */
  --fs-lead: 1.375rem;                          /* 22px  object names, coach */
  --fs-title: clamp(1.875rem, 3.4vw, 2.5rem);   /* place names */
  --fs-display: clamp(4rem, 11vw, 8.5rem);      /* the intro word */
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: #1b130c; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
/* only 500/600 of Cormorant are loaded; ask for them so nothing is synthesised */
.lede, .loading, #place .name, #place .line, #place .why, #hover .n, #caption .n, #caption .i, #coach, #gloss { font-weight: 500; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
/* The street view is on screen at once, as a picture (rendered from the same
   camera), and the live house fades in over it once its shaders are ready. */
body { background: #1b130c url('poster-wide.webp') center / cover no-repeat; }
@media (max-aspect-ratio: 1/1) { body { background-image: url('poster-tall.webp'); } }
/* the house fades in once its shaders are ready; the intro is already showing */
#scene { opacity: 0; transition: opacity 0.9s var(--ease); }
body.ready #scene { opacity: 1; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#fade { position: fixed; inset: 0; background: #120c07; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
#fade.on { opacity: 1; }

/* ── intro ─────────────────────────────────────────── */
#intro {
  position: fixed; inset: 0; display: grid; place-items: end start; padding: clamp(24px, 6vw, 88px);
  background: linear-gradient(180deg, rgba(20, 12, 6, 0) 30%, rgba(20, 12, 6, 0.78) 100%);
  transition: opacity 1.2s var(--ease), visibility 1.2s;
  z-index: 5;
}
#intro.gone { opacity: 0; visibility: hidden; }
/* the intro arrives line by line, 100 ms apart: it happens once, so it may take its time */
/* The intro reads straight away, while the house is still being built behind
   it; only the button waits. Its lines arrive 100 ms apart, once. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.intro-inner > * { animation: rise 0.9s var(--ease-out) both; }
.intro-inner > :nth-child(2) { animation-delay: 0.1s; }
.intro-inner > :nth-child(3) { animation-delay: 0.2s; }
.intro-inner > :nth-child(4) { animation-delay: 0.3s; }
.intro-inner > :nth-child(5) { animation-delay: 0.4s; }
#enter[disabled] { cursor: progress; color: var(--ink-soft); font-family: var(--serif); font-style: italic; font-size: var(--fs-read); box-shadow: 0 0 0 1px rgba(251, 245, 234, 0.2); background: transparent; }
#enter[disabled]:active { scale: none; }
.intro-inner { max-width: 30rem; }
/* the front page's sound switch: the house can be heard before you step in */
#intro-sound { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.9rem; padding: 0.5rem 0.2rem; min-height: 40px; font-size: var(--fs-ui); color: var(--ink-soft); transition: color 150ms var(--ease-out); }
#intro-sound svg { width: 1.15rem; height: 1.15rem; flex: none; }
#intro-sound svg path:not(:first-child) { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; opacity: 0.35; }
#intro-sound[aria-pressed="true"] { color: var(--ink); }
#intro-sound[aria-pressed="true"] svg path:not(:first-child) { opacity: 1; }
#intro-sound[aria-pressed="false"] .w1 { animation: wave 1.8s var(--ease) infinite; }
#intro-sound[aria-pressed="false"] .w2 { animation: wave 1.8s var(--ease) 0.25s infinite; }
@keyframes wave { 50% { opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) { #intro-sound .w1, #intro-sound .w2 { animation: none !important; } }
@media (hover: hover) { #intro-sound:hover { color: var(--ink); } }
#intro .ta { font-family: var(--tamil); font-size: var(--fs-tamil); color: var(--accent); }
#intro h1 { font-family: var(--serif); font-weight: 500; font-size: var(--fs-display); line-height: 0.9; letter-spacing: -0.01em; margin: 0.1em 0 0.25em; }
.lede { font-family: var(--serif); font-size: var(--fs-lead); line-height: 1.4; color: var(--ink-soft); max-width: 28ch; text-wrap: pretty; }
#enter {
  margin-top: 1.6rem; padding: 0.85rem 1.6rem; border-radius: 999px; box-shadow: 0 0 0 1px rgba(251, 245, 234, 0.5), 0 8px 24px rgba(0, 0, 0, 0.22);
  background: rgba(251, 245, 234, 0.08); backdrop-filter: blur(6px); font-size: var(--fs-ui);
}
/* tactile press on every button */
button { transition-property: color, background-color, box-shadow, scale; transition-duration: 150ms; transition-timing-function: var(--ease-out); }
button:active { scale: 0.96; }
.hint { margin-top: 0.8rem; font-size: var(--fs-ui); color: var(--ink-soft); }

/* ── overlay elements only exist once you are inside ── */
#place, #plan, #instrument, #hud { opacity: 0; transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out); pointer-events: none; }
/* once inside, the instruments come up in turn: plan, then time and season, then help */
.inside #instrument { transition-delay: 0.1s; }
.inside #hud { transition-delay: 0.2s; }
.inside #plan, .inside #instrument, .inside #hud { opacity: 1; pointer-events: auto; }

/* ── where you are: the term, then its meaning ───────── */
#place {
  position: fixed; left: var(--gutter); top: var(--gutter); max-width: min(22rem, calc(100vw - 120px));
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6), 0 0 2px rgba(0, 0, 0, 0.45);
  transform: translateY(-6px);
}
.inside #place.show { opacity: 1; transform: none; }
#place .ta { font-family: var(--tamil); font-size: var(--fs-tamil); color: var(--accent); }
#place .name { font-family: var(--serif); font-size: var(--fs-title); line-height: 1.1; letter-spacing: -0.005em; }
#place .en { font-size: var(--fs-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); margin-top: 0.15rem; }
/* once read, the line fades, then its row folds to nothing so the link sits under the title, not below a gap */
#place .line-wrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.6s var(--ease) 0.6s; }
#place.settled .line-wrap:has(.line:not(.keep)) { grid-template-rows: 0fr; }
#place .line-wrap > div { min-height: 0; overflow: hidden; }
#place .line { font-family: var(--serif); font-size: var(--fs-read); line-height: 1.45; padding-top: 0.55rem; max-width: 30ch; text-wrap: pretty; transition: opacity 1.2s var(--ease), transform 1.2s var(--ease), visibility 1.2s; }
#place.settled .line:not(.keep) { opacity: 0; transform: translateY(-4px); visibility: hidden; }
#place .why-btn {
  margin-top: 0.1rem; padding: 0.5rem 0; font-size: var(--fs-ui); color: var(--accent);
  pointer-events: auto; text-shadow: inherit; min-height: 40px;
}

#place .why {
  margin-top: 0.35rem; padding: 0.75rem 0.9rem; border-radius: 10px; background: var(--scrim); backdrop-filter: blur(8px);
  font-family: var(--serif); font-size: var(--fs-read); line-height: 1.5; text-shadow: none; max-width: 32ch; text-wrap: pretty;
}

/* ── pointing ──────────────────────────────────────── */
#hover {
  position: fixed; left: 0; top: 0; pointer-events: none; display: grid; gap: 1px;
  padding: 0.45rem 0.7rem; border-radius: 8px; background: var(--scrim-strong); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 120ms var(--ease-out);
}
#hover.show { opacity: 1; }
#hover .n { font-family: var(--serif); font-size: var(--fs-read); line-height: 1.2; white-space: nowrap; }
#hover .v { font-size: var(--fs-label); color: var(--ink-soft); white-space: nowrap; }

/* The note about an object sits on the side of the screen away from it, so
   it never covers the thing you just clicked. */
#caption {
  position: fixed; bottom: 88px; width: min(24rem, calc(50vw - 64px));
  transform: translateY(8px); padding: 0.8rem 1rem; border-radius: 12px; background: rgba(24, 15, 8, 0.72); backdrop-filter: blur(10px);
  pointer-events: none; opacity: 0; transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
/* in at 260 ms, out faster at 160 ms */
#caption.show { opacity: 1; transform: none; transition-duration: 260ms; }
#caption.side-left { left: calc(var(--gutter) + 166px); }
#caption.side-right { right: var(--gutter); }
#caption .n { font-family: var(--serif); font-size: var(--fs-read); line-height: 1.25; color: var(--accent); }
#caption .i { font-family: var(--serif); font-size: var(--fs-read); line-height: 1.5; margin-top: 0.2rem; text-wrap: pretty; }

#coach {
  position: fixed; left: 50%; top: 60%; transform: translate(-50%, 6px); text-align: center; pointer-events: none;
  font-family: var(--serif); font-size: var(--fs-lead); line-height: 1.3; font-style: italic; text-wrap: balance; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75);
  opacity: 0; transition: opacity 1s var(--ease), transform 1s var(--ease); max-width: calc(100vw - 32px);
}
#coach.show { opacity: 1; transform: translate(-50%, 0); }
/* a quiet line when you are near something waiting to be done, like an unlit lamp */
#near {
  position: fixed; left: 50%; top: 66%; transform: translate(-50%, 4px); pointer-events: none;
  font-family: var(--serif); font-style: italic; font-size: var(--fs-read); text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
  opacity: 0; transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
#near.show { opacity: 0.85; transform: translate(-50%, 0); }#coach small { display: block; font-family: var(--sans); font-style: normal; font-weight: 400; font-size: var(--fs-ui); color: var(--ink-soft); margin-top: 0.35rem; }

/* ── floor plan: an architect's locator, not a menu ──── */
#plan { position: fixed; left: max(var(--gutter), env(safe-area-inset-left)); bottom: max(var(--gutter), env(safe-area-inset-bottom)); width: 150px; }
#plan .pad { fill: transparent; stroke: none; cursor: pointer; }
#plan svg { width: 100%; height: auto; display: block; overflow: visible; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45)); }
#plan .plot { fill: rgba(24, 15, 8, 0.22); stroke: var(--line); stroke-width: 0.6; pointer-events: none; }
#plan .z { fill: rgba(24, 15, 8, 0.4); stroke: var(--line); stroke-width: 0.8; cursor: pointer; transition: fill 150ms var(--ease-out); }
#plan .z.locked { fill: rgba(10, 6, 3, 0.62); stroke-dasharray: 2 2; }
#plan .z.cur { fill: rgba(227, 180, 90, 0.42); stroke: var(--accent); }
#plan .z:focus-visible { outline: none; stroke: var(--accent); stroke-width: 2; }
#plan .up { fill: rgba(24, 15, 8, 0.25); stroke-dasharray: 2 2; }
#plan .sky { fill: rgba(170, 205, 235, 0.24); stroke: none; pointer-events: none; }
#plan .solid { fill: rgba(24, 15, 8, 0.6); stroke: var(--line); stroke-width: 0.6; pointer-events: none; }
#plan .me { fill: var(--ink); }
#plan .cone { fill: rgba(251, 245, 234, 0.3); pointer-events: none; }
#plan .here { font-size: var(--fs-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); margin-top: 0.4rem; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }

/* ── the instrument: time, season, sound ────────────── */
#instrument {
  position: fixed; left: 50%; bottom: var(--gutter); transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px 18px; flex-wrap: wrap; justify-content: center;
  padding: 2px 16px; border-radius: 999px; box-shadow: var(--glass-edge); background: var(--scrim); backdrop-filter: blur(10px);
  max-width: calc(100vw - 2 * var(--gutter) - 300px);
}
#instrument .grp { display: flex; align-items: center; gap: 2px; }
#instrument .lbl { font-size: var(--fs-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-right: 6px; }
#instrument button {
  position: relative; padding: 0.45rem 0.5rem; min-height: 40px; font-size: var(--fs-ui); color: var(--ink-soft); white-space: nowrap;
}
#instrument button[aria-checked='true'], #instrument #sound[aria-pressed='true'] { color: var(--ink); }
/* the fold-away handle exists only on phones */
#inst-toggle { display: none; }
#instrument button[aria-checked='true']::after {
  content: ''; position: absolute; left: 0.5rem; right: 0.5rem; bottom: 6px; height: 1px; background: var(--accent);
}
#gloss {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); white-space: nowrap;
  font-family: var(--serif); font-style: italic; font-size: var(--fs-read); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
  opacity: 0; transition: opacity 200ms var(--ease-out); pointer-events: none;
}
#gloss.show { opacity: 1; transition-duration: 300ms; }

/* ── help ──────────────────────────────────────────── */
#hud { position: fixed; right: max(var(--gutter), env(safe-area-inset-right)); top: max(var(--gutter), env(safe-area-inset-top)); }
/* keyboard walkers aim with the centre of the view */
#reticle { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.keyboard #reticle { opacity: 0.7; }
#hud button { min-height: 40px; min-width: 40px; border-radius: 999px; box-shadow: var(--glass-edge); background: var(--scrim); backdrop-filter: blur(6px); font-size: var(--fs-ui); }
#keys {
  position: fixed; right: var(--gutter); top: calc(var(--gutter) + 52px); padding: 0.8rem 1rem; border-radius: 10px;
  background: var(--scrim); backdrop-filter: blur(8px); font-size: var(--fs-ui); line-height: 1.7; color: var(--ink-soft);
  pointer-events: none; opacity: 0; transform: translateY(-4px); transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
#keys.show { opacity: 1; transform: none; transition-duration: 220ms; }
#keys b { display: inline-block; min-width: 4.6rem; color: var(--ink); font-weight: 500; }

/* ── the treasure hunt ─────────────────────────────── */
#hud { display: flex; gap: 8px; }
#hud #notes-btn { padding: 0 0.95rem; }
#hud #notes-btn[hidden] { display: none; }
#hunt-intro {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, 6px); width: max-content; max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
  font-family: var(--serif); font-weight: 500; font-style: italic; font-size: var(--fs-lead); line-height: 1.3; text-wrap: balance; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75);
  opacity: 0; transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
#hunt-intro.show { opacity: 1; transform: translate(-50%, 0); }
/* the riddle: a small card under the top-right buttons, folding to one line */
#hunt {
  position: fixed; right: max(var(--gutter), env(safe-area-inset-right)); top: calc(max(var(--gutter), env(safe-area-inset-top)) + 52px);
  width: min(19rem, calc(100vw - 2 * var(--gutter))); border-radius: 12px; background: var(--scrim); backdrop-filter: blur(10px); box-shadow: var(--glass-edge);
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out), visibility 0.5s, box-shadow 1.2s var(--ease);
}
#hunt.show { opacity: 1; visibility: visible; transform: none; }
/* near the answer the card edge warms: a feeling, not a pointer */
#hunt.near { box-shadow: 0 0 0 1px rgba(227, 180, 90, 0.6), 0 8px 24px rgba(0, 0, 0, 0.22); }
.notes-open #hunt, .keys-open #hunt { opacity: 0; visibility: hidden; }
#hunt .h-head { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0.7rem 1rem 0.35rem; min-height: 40px; text-align: left; }
#hunt .h-head:active { scale: none; }
#hunt .h-lbl { font-size: var(--fs-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
#hunt .h-count { font-size: var(--fs-label); letter-spacing: 0.08em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
#hunt .h-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.45s var(--ease); }
#hunt.folded .h-body { grid-template-rows: 0fr; }
#hunt .h-body > div { min-height: 0; overflow: hidden; padding: 0 1rem; }
#hunt .h-riddle { font-family: var(--serif); font-weight: 500; font-style: italic; font-size: var(--fs-read); line-height: 1.45; padding-top: 0.15rem; }
#hunt .h-hints { list-style: none; padding: 0; margin-top: 0.55rem; display: grid; gap: 0.4rem; counter-reset: h; }
#hunt .h-hints:empty { display: none; }
#hunt .h-hints li { counter-increment: h; font-size: var(--fs-ui); line-height: 1.5; color: var(--ink-soft); padding-left: 1.4rem; position: relative; text-wrap: pretty; animation: rise 0.5s var(--ease-out) both; }
#hunt .h-hints li::before { content: counter(h); position: absolute; left: 0; top: 0.08rem; width: 1rem; height: 1rem; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); font-size: 0.625rem; line-height: 1rem; text-align: center; color: var(--ink-faint); }
#hunt .h-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 0.35rem; padding-bottom: 0.45rem; }
#hunt .h-hint { padding: 0.5rem 0; min-height: 40px; font-size: var(--fs-ui); color: var(--accent); }
#hunt .h-hint[hidden] { display: none; }
#hunt .h-go { padding: 0.5rem 0.9rem; min-height: 36px; border-radius: 999px; font-size: var(--fs-ui); color: var(--ink); box-shadow: 0 0 0 1px var(--accent); }
#hunt .h-go[hidden] { display: none; }
#hunt .h-hints li.reveal { color: var(--ink); }
#hunt .h-hints li.reveal::before { content: '★'; box-shadow: none; color: var(--accent); }
#hunt .h-hints li.reveal b { font-weight: 500; color: var(--accent); }
#hunt .h-tries { font-size: var(--fs-label); line-height: 1.4; color: var(--ink-faint); margin-top: -0.2rem; padding-bottom: 0.5rem; }
#hunt .h-tries:empty { display: none; }
#hunt .h-worth { font-size: var(--fs-label); color: var(--ink-faint); font-variant-numeric: tabular-nums; margin-left: auto; }
/* the quiet lines open by folding their row, never by animating height */
#hunt .h-nope, #hunt .h-nudge { display: grid; grid-template-rows: 0fr; opacity: 0; }
#hunt .h-nope > span, #hunt .h-nudge > span { min-height: 0; overflow: hidden; }
/* the space below is inside the folding part, so a closed line leaves no gap */
#hunt .h-nope > span::after, #hunt .h-nudge > span::after { content: ''; display: block; height: 0.7rem; }
#hunt .h-nope { font-family: var(--serif); font-weight: 500; font-style: italic; font-size: var(--fs-read); color: var(--ink-soft); transition: opacity 0.4s var(--ease), grid-template-rows 0.4s var(--ease); }
#hunt .h-nope.show { grid-template-rows: 1fr; opacity: 1; }
/* after three quiet minutes: a gentle offer of a hint, once per riddle */
#hunt .h-nudge { font-size: var(--fs-ui); line-height: 1.5; color: var(--ink-soft); transition: opacity 0.8s var(--ease), grid-template-rows 0.8s var(--ease); }
#hunt.nudge .h-nudge { grid-template-rows: 1fr; opacity: 1; }
#hunt.nudge .h-hint { animation: offer 2.4s var(--ease) 3; }
@keyframes offer { 50% { color: var(--ink); } }
@media (prefers-reduced-motion: reduce) { #hunt.nudge .h-hint { animation: none; color: var(--ink); } }
/* found: a small note high in the view, never over the thing you found */
#found {
  position: fixed; left: 50%; top: 11%; transform: translate(-50%, -6px); width: min(25rem, calc(100vw - 32px)); text-align: center;
  padding: 1rem 1.3rem 1.05rem; border-radius: 14px; background: rgba(24, 15, 8, 0.66); backdrop-filter: blur(12px); box-shadow: var(--glass-edge);
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.7s var(--ease), transform 0.7s var(--ease), visibility 0.7s;
}
#found.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
#found .f-lbl { font-size: var(--fs-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
#found .f-term { font-family: var(--serif); font-weight: 500; font-size: var(--fs-title); line-height: 1.1; margin-top: 0.2rem; }
#found .f-def { font-family: var(--serif); font-weight: 500; font-size: var(--fs-read); line-height: 1.45; margin-top: 0.35rem; text-wrap: balance; }
#found .f-why { font-size: var(--fs-ui); line-height: 1.55; color: var(--ink-soft); margin-top: 0.6rem; text-wrap: pretty; }
#found .f-why span { display: block; font-size: var(--fs-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.1rem; }
#found .f-pts { font-size: var(--fs-ui); color: var(--accent); margin-top: 0.55rem; font-variant-numeric: tabular-nums; }
#found .f-pts:empty { display: none; }
#found .f-close { display: none; margin-top: 0.9rem; padding: 0.6rem 1.2rem; min-height: 40px; border-radius: 999px; box-shadow: 0 0 0 1px rgba(251, 245, 234, 0.4); font-size: var(--fs-ui); }
/* the ending stays until you choose to go on, so it can be read */
#found.end { top: 50%; transform: translate(-50%, -50%); pointer-events: auto; padding: 1.4rem 1.6rem 1.3rem; }
#found.end .f-close { display: inline-block; }
#found.end .f-def { display: grid; gap: 0.2rem; margin: 0.8rem auto 0; max-width: 15rem; font-family: var(--sans); font-weight: 400; font-size: var(--fs-ui); color: var(--ink-soft); }
#found.end .row { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
#found.end .row.total { color: var(--ink); padding-top: 0.3rem; margin-top: 0.2rem; box-shadow: 0 -1px 0 var(--line); }
#found.end .f-why { font-family: var(--serif); font-weight: 500; font-style: italic; font-size: var(--fs-read); color: var(--ink); margin-top: 1rem; }
/* house notes: what you have found, and a ? for each thing still waiting */
#notes {
  position: fixed; right: max(var(--gutter), env(safe-area-inset-right)); top: calc(max(var(--gutter), env(safe-area-inset-top)) + 52px);
  width: min(21rem, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 220px); overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem 1.1rem; border-radius: 12px; background: var(--scrim-strong); backdrop-filter: blur(12px); box-shadow: var(--glass-edge);
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), visibility 180ms;
}
#notes.show { opacity: 1; visibility: visible; transform: none; transition-duration: 240ms; }
#notes h2 { font-family: var(--serif); font-weight: 500; font-size: var(--fs-lead); line-height: 1.2; }
#notes header p { font-size: var(--fs-label); letter-spacing: 0.08em; color: var(--ink-soft); margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
#notes h3 { font-size: var(--fs-label); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin: 1rem 0 0.3rem; }
#notes ul { list-style: none; padding: 0; display: grid; gap: 0.1rem; }
#notes li { font-family: var(--serif); font-weight: 500; font-size: var(--fs-read); line-height: 1.4; }
#notes .mk { display: inline-block; width: 1.3rem; color: var(--accent); font-family: var(--sans); font-size: var(--fs-ui); }
#notes li.q { color: var(--ink-faint); padding: 0.35rem 0; }
#notes li.q .mk { color: var(--ink-faint); }
#notes summary { cursor: pointer; padding: 0.35rem 0; list-style: none; min-height: 32px; }
#notes summary::-webkit-details-marker { display: none; }
#notes details p { font-size: var(--fs-ui); font-family: var(--sans); font-weight: 400; line-height: 1.55; color: var(--ink-soft); margin: 0 0 0.4rem 1.3rem; text-wrap: pretty; }
#notes details .why span { display: block; font-size: var(--fs-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
#notes .bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 0.6rem; overflow: hidden; }
#notes .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transform-origin: left; transform: scaleX(var(--k, 0)); transition: transform 0.6s var(--ease-out); }
#notes h3 { display: flex; justify-content: space-between; align-items: baseline; }
#notes h3 .st { letter-spacing: 0.06em; text-transform: none; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
#notes section.done h3 .st { color: var(--accent); }
#notes .learn { font-size: var(--fs-label); color: var(--ink-faint); margin: -0.15rem 0 0.15rem; }
#notes section.locked h3, #notes section.locked h3 .st { color: var(--ink-faint); }
/* a room complete: the card that says what has opened */
#found.room .f-term { font-size: var(--fs-lead); }
/* "Show me": which way the answer is, at the edge of the view */
#guide { position: fixed; left: 50%; top: 50%; z-index: 4; pointer-events: none; transform: translate(-50%, -50%); opacity: 0; transition: opacity 0.4s var(--ease);
  display: grid; place-items: center; width: 64px; height: 64px; }
#guide.show { opacity: 1; }
#guide i { position: absolute; inset: 14px; border-radius: 50%; background: rgba(24, 15, 8, 0.6); box-shadow: 0 0 0 1.5px var(--accent); }
#guide i::after { content: ''; position: absolute; left: 100%; top: 50%; width: 10px; height: 14px; margin-top: -7px; margin-left: 3px; background: var(--accent); clip-path: polygon(0 0, 100% 50%, 0 100%); }
#guide i { transform: rotate(var(--a, 0rad)); }
#guide span { position: relative; font-size: var(--fs-label); color: var(--ink); font-variant-numeric: tabular-nums; }
#notes .again { margin-top: 1rem; padding: 0.5rem 0; min-height: 40px; font-size: var(--fs-ui); color: var(--ink-soft); }

@media (max-width: 900px) {
  #instrument { left: auto; right: var(--gutter); transform: none; border-radius: 14px; max-width: calc(100vw - 2 * var(--gutter) - 108px); gap: 0 10px; padding: 4px 8px; }
  #instrument .lbl { display: none; }
  #instrument button { padding: 0.4rem 0.35rem; font-size: var(--fs-label); }
  #gloss { left: auto; right: 0; transform: none; white-space: normal; width: min(80vw, 22rem); text-align: right; }
  #plan { width: 110px; }
  #caption, #caption.side-left, #caption.side-right { left: var(--gutter); right: var(--gutter); width: auto; bottom: 180px; }
}
/* ── phones ───────────────────────────────────────────
   Everything keeps to the edges and the middle of the view stays clear: the
   place name top left, help and notes top right, the plan bottom left, the
   time and season folded into one control bottom right, and the riddle as a
   one-line strip above them that opens when tapped. Every edge respects the
   notch and the home bar (safe-area insets). */
@media (max-width: 640px) {
  :root {
    --gutter: 14px;
    --fs-read: 1rem;                          /* 16px: Cormorant reads fine at this size on a phone */
    --fs-lead: 1.1875rem;                     /* 19px */
    --fs-title: 1.625rem;                     /* 26px */
    --fs-display: clamp(3.5rem, 19vw, 5rem);
    --top: max(var(--gutter), env(safe-area-inset-top));
    --bot: max(var(--gutter), env(safe-area-inset-bottom));
    --left: max(var(--gutter), env(safe-area-inset-left));
    --right: max(var(--gutter), env(safe-area-inset-right));
    --plan-w: 84px;
  }
  /* intro: smaller words, the button always on screen above the home bar */
  #intro { padding: 24px var(--right) calc(var(--bot) + 8px) var(--left); background: linear-gradient(180deg, rgba(20, 12, 6, 0) 25%, rgba(20, 12, 6, 0.85) 100%); }
  .intro-inner { max-width: 100%; }
  .lede { max-width: 30ch; line-height: 1.45; }
  #enter { margin-top: 1.2rem; padding: 0.8rem 1.5rem; min-height: 48px; font-size: var(--fs-ui); }
  #enter[disabled] { font-size: var(--fs-read); }
  .hint { margin-top: 0.6rem; }

  #place { left: var(--left); top: var(--top); max-width: calc(100vw - var(--left) - var(--right) - 110px); }
  #place .line { max-width: 26ch; padding-top: 0.4rem; }
  #place .why { max-width: none; }
  #hud { top: var(--top); right: var(--right); }
  #keys { right: var(--right); top: calc(var(--top) + 54px); left: auto; max-width: calc(100vw - 2 * var(--gutter)); }
  #keys b { min-width: 4rem; }

  /* the plan, small, bottom left; its label repeats the place name, so it goes */
  #plan { width: var(--plan-w); left: var(--left); bottom: var(--bot); }
  #plan .here { display: none; }

  /* time and season: one control showing what is set; tapped, the choices open above it */
  #instrument {
    left: auto; right: var(--right); bottom: var(--bot); transform: none;
    flex-direction: column; align-items: stretch; gap: 0; padding: 2px 6px; border-radius: 16px;
    max-width: calc(100vw - var(--left) - var(--right) - var(--plan-w) - 12px);
  }
  #instrument .grp[role='radiogroup'] { display: none; }
  #instrument.open .grp[role='radiogroup'] { display: flex; flex-wrap: wrap; justify-content: flex-start; padding: 2px 0; box-shadow: 0 1px 0 var(--line); }
  #instrument.open .grp[role='radiogroup'] .lbl { display: block; width: 100%; padding: 8px 8px 0; margin: 0; }
  #instrument .snd { justify-content: space-between; gap: 4px; }
  #inst-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink) !important; }
  #inst-toggle .chev { font-size: 0.625rem; color: var(--ink-soft); transition: rotate 200ms var(--ease-out); }
  #instrument.open #inst-toggle .chev { rotate: 180deg; }
  #instrument button { font-size: var(--fs-ui); padding: 0.4rem 0.55rem; min-height: 44px; }
  #gloss { right: 0; left: auto; width: min(calc(100vw - 2 * var(--gutter)), 20rem); text-align: right; white-space: normal; font-size: var(--fs-read); }
  #instrument.open #gloss { display: none; }
  /* the open choices and the riddle strip share the same space: one at a time */
  body:has(#instrument.open) #hunt { opacity: 0; visibility: hidden; }

  /* the riddle: a strip above the bottom row, opening upward */
  #hunt { top: auto; bottom: calc(var(--bot) + 112px); left: var(--left); right: var(--right); width: auto; }
  #hunt .h-head { padding: 0.55rem 0.9rem; }
  #hunt.folded .h-head { padding-bottom: 0.55rem; }
  #hunt .h-body > div { padding: 0 0.9rem; }
  #hunt .h-riddle { font-size: 1.0625rem; }
  #notes { top: calc(var(--top) + 54px); right: var(--right); max-height: calc(100dvh - var(--top) - var(--bot) - 190px); }

  /* a touched object's note sits above the riddle strip, full width */
  #caption, #caption.side-left, #caption.side-right { left: var(--left); right: var(--right); width: auto; bottom: calc(var(--bot) + 168px); }
  #coach { top: 42%; }
  #near { top: 50%; }
  #hunt-intro { top: 34%; }
  #found { top: calc(var(--top) + 64px); width: calc(100vw - 2 * var(--gutter)); padding: 0.9rem 1rem; }
  #found .f-def { text-wrap: pretty; }
}
/* phones on their side: little height, so the riddle goes back to the top right */
@media (max-height: 500px) and (orientation: landscape) {
  #hunt { top: calc(max(var(--gutter), env(safe-area-inset-top)) + 52px); bottom: auto; left: auto; width: min(18rem, 40vw); }
  #hunt .h-riddle { font-size: var(--fs-ui); }
  #place .line { display: none; }
  #plan { width: 80px; }
  #plan .here { display: none; }
  #caption, #caption.side-left, #caption.side-right { bottom: 70px; }
  #intro { padding: 16px max(24px, env(safe-area-inset-right)) 16px max(24px, env(safe-area-inset-left)); }
  #intro h1 { font-size: 3.5rem; }
  .lede { font-size: 1.0625rem; }
  #enter { margin-top: 0.8rem; }
}
/* hover only where a real pointer hovers, so taps never leave a stuck state */
@media (hover: hover) and (pointer: fine) {
  #enter:hover { background: rgba(251, 245, 234, 0.18); box-shadow: 0 0 0 1px var(--ink), 0 8px 24px rgba(0, 0, 0, 0.22); }
  #place .why-btn:hover, #instrument button:hover, #hunt .h-hint:hover, #notes .again:hover { color: var(--ink); }
  #found .f-close:hover { box-shadow: 0 0 0 1px var(--ink); }
  #hud button:hover { box-shadow: var(--glass-edge-hover); }
  #plan .z:hover { fill: rgba(251, 245, 234, 0.18); }
}
@media (pointer: coarse) {
  #instrument button, #hud button, #place .why-btn, #hunt .h-hint, #hunt .h-head { min-height: 44px; }
  #hud button { min-width: 44px; }
}
/* reduced motion: keep the fades that explain what changed, drop the movement */
@media (prefers-reduced-motion: reduce) {
  /* transforms still position things; they just stop animating */
  *, *::before, *::after { transition-property: opacity, color, background-color, box-shadow, fill !important; transition-delay: 0s !important; }
  button:active { scale: none; }
  @keyframes rise { from { opacity: 0; } }
}
