/* The Wandering Stargazer — cozy cosmic: gold leaf on midnight blue, aged parchment, no neon. */

:root {
  --night: #0E1626;          /* deep midnight, the page */
  --night-2: #16223A;        /* raised night surfaces */
  --night-3: #1F2E4B;
  --gold: #D4AF6A;           /* gold leaf */
  --gold-bright: #F2D38C;
  --gold-dim: rgba(212, 175, 106, 0.35);
  --parchment: #F4EBD8;      /* aged paper */
  --parchment-2: #EADDC2;
  --ink: #2B2623;            /* ink on parchment */
  --ink-soft: #6E6458;
  --star-ink: #E9E2D3;       /* light text on night */
  --star-ink-soft: #A9B1C3;
  --rose: #C98B8B;           /* nebula rose */
  --teal: #5E8C8A;           /* nebula teal */
  --danger: #B5543F;

  --font-display: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --font-title: 'Cinzel', Georgia, serif;
  --font-body: 'Playfair Display', Georgia, serif;
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-hand: 'Caveat', 'Segoe Script', cursive;

  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --gutter: 16px;
  --topbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--star-ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

/* ---------- type ---------- */
.kicker { font-family: var(--font-title); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); margin: 0 0 .4rem; }
.title { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.05; margin: 0; color: var(--gold-bright); text-shadow: 0 2px 18px rgba(0,0,0,.5); }
.title-sm { font-family: var(--font-title); font-weight: 700; font-size: 1.35rem; margin: 0; color: var(--gold-bright); }
.subtitle { font-family: var(--font-body); font-style: italic; font-size: 1.15rem; margin: .3rem 0 0; color: var(--star-ink); }
.lede { font-family: var(--font-body); font-size: 1.05rem; color: var(--star-ink-soft); max-width: 34rem; margin: 1rem 0 1.4rem; }
.muted { color: var(--star-ink-soft); font-size: .92rem; margin: .2rem 0 .8rem; }
em { font-style: italic; opacity: .8; }

/* ---------- backdrop & screens ---------- */
#backdrop {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
  opacity: .35; filter: saturate(.9); transform: scale(1.03);
  transition: opacity .6s ease, background-image .6s ease;
}
.screen { position: fixed; inset: 0; z-index: 1; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .55rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--gold-dim); background: rgba(22, 34, 58, .8); color: var(--star-ink);
  cursor: pointer; font-weight: 500; letter-spacing: .02em; text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}
.btn:hover { border-color: var(--gold); background: var(--night-3); }
.btn:active { transform: translateY(1px); }
.btn-gold { background: linear-gradient(180deg, #E4C27E, #C59A4E); color: #1B1408; border-color: #E9CD8F; font-weight: 600; }
.btn-gold:hover { background: linear-gradient(180deg, #EFD08F, #CFA457); border-color: var(--gold-bright); }
.btn-big { min-height: 52px; padding: .75rem 1.6rem; font-size: 1.05rem; }
.btn-danger { border-color: rgba(181, 84, 63, .6); color: #F0B7A8; margin-top: .6rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--gold-dim);
  background: rgba(14, 22, 38, .7); color: var(--star-ink); cursor: pointer; font-size: 1.1rem;
  display: inline-grid; place-items: center;
}
.icon-btn:hover { border-color: var(--gold); }

.field { display: block; border: 0; padding: 0; margin: 0 0 1rem; }
.field > span, .field > legend { display: block; font-size: .9rem; color: var(--star-ink-soft); margin-bottom: .4rem; padding: 0; }
.field input[type="text"] {
  width: 100%; min-height: 44px; padding: .6rem .9rem; border-radius: 10px;
  border: 1px solid var(--gold-dim); background: rgba(14, 22, 38, .75); color: var(--star-ink);
}
.field input::placeholder, textarea::placeholder { color: #7D8699; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding: .4rem .9rem;
  border-radius: 999px; border: 1px solid var(--gold-dim); background: rgba(14, 22, 38, .6);
  font-size: .92rem; transition: all .2s ease;
}
.chip input:checked + span { border-color: var(--gold-bright); background: rgba(212, 175, 106, .18); color: var(--gold-bright); }
.chip input:focus-visible + span { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.center { text-align: center; justify-content: center; }
.range { display: flex; align-items: center; gap: .8rem; margin-top: .8rem; font-size: .9rem; color: var(--star-ink-soft); }
.range input { flex: 1; accent-color: var(--gold); }

/* ---------- welcome ---------- */
#welcome { overflow-y: auto; display: grid; place-items: center; padding: var(--gutter); }
.welcome-art {
  position: fixed; inset: 0; z-index: -1;
  background: url("../assets/bg/exterior.webp") center / cover no-repeat;
}
.welcome-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(14,22,38,.15) 0%, rgba(14,22,38,.75) 48%, rgba(14,22,38,.92) 100%); }
.welcome-card {
  position: relative; width: min(560px, 100%); margin-left: auto; margin-right: max(0px, 6vw);
  padding: clamp(1.2rem, 4vw, 2.4rem); border-radius: var(--radius);
  background: rgba(14, 22, 38, .72); border: 1px solid var(--gold-dim);
  box-shadow: var(--shadow); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.continue-line { font-family: var(--font-body); font-size: 1.05rem; color: var(--star-ink); margin: 0 0 1rem; }
@media (max-width: 760px) {
  .welcome-card { margin: 38vh 0 1rem; }
  .welcome-art { background-position: 30% center; }
  .welcome-art::after { background: linear-gradient(180deg, rgba(14,22,38,0) 0%, rgba(14,22,38,.55) 35%, rgba(14,22,38,.95) 60%); }
}

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  background: linear-gradient(180deg, rgba(14,22,38,.95), rgba(14,22,38,.6));
  border-bottom: 1px solid rgba(212,175,106,.18);
}
.topbar-title { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.brand { font-family: var(--font-title); font-weight: 700; color: var(--gold-bright); letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.pill { font-size: .78rem; padding: .25rem .65rem; border-radius: 999px; border: 1px solid var(--gold-dim); color: var(--gold); white-space: nowrap; }
.pill-quiet { color: var(--star-ink-soft); }
@media (max-width: 520px) { .brand { display: none; } }

/* ---------- star chart ---------- */
.chart-stage {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top));
  display: grid; place-items: center; padding: 12px;
  overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  --k: 1;
}
.chart-stage.is-zoomed { cursor: grab; }
.chart-stage.is-zoomed:active { cursor: grabbing; }
.chart-frame {
  position: relative; --ratio: calc(1356 / 762);
  width: min(100%, calc((100dvh - var(--topbar-h) - env(safe-area-inset-top) - 24px) * var(--ratio)));
  aspect-ratio: 1356 / 762;
  transform-origin: 50% 50%; will-change: transform;
}
.chart-frame.is-animating { transition: transform .35s cubic-bezier(.2, .7, .2, 1); }
.chart-frame.is-tall { --ratio: calc(763 / 1359); aspect-ratio: 763 / 1359; }
.chart-img {
  width: 100%; height: 100%; object-fit: fill; user-select: none; -webkit-user-drag: none; pointer-events: none;
  filter: drop-shadow(0 14px 30px rgba(0,0,0,.55));
  opacity: 0; transition: opacity .6s ease;
}
.chart-img.is-loaded { opacity: 1; }
.sky-canvas, .figure-layer, .pin-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pin-layer { pointer-events: none; }

/* the living sky's soft nebula: drifts on its own and moves a little less than the chart (parallax) */
.nebula-layer {
  position: absolute; inset: -12%; pointer-events: none; z-index: 1;
  background:
    radial-gradient(38% 30% at 28% 36%, rgba(201, 139, 139, .22), transparent 70%),
    radial-gradient(34% 28% at 72% 62%, rgba(94, 140, 138, .22), transparent 70%),
    radial-gradient(26% 22% at 58% 22%, rgba(242, 211, 140, .10), transparent 70%);
  mix-blend-mode: screen; opacity: .8;
}
.nebula-layer::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(30% 24% at 40% 70%, rgba(201, 139, 139, .14), transparent 70%);
  animation: nebula-drift 48s ease-in-out infinite alternate;
}
@keyframes nebula-drift { from { transform: translate(-3%, 2%); } to { transform: translate(4%, -3%); } }

/* constellations */
.figure-layer line { stroke: var(--gold-bright); stroke-width: 1.6px; stroke-linecap: round; vector-effect: non-scaling-stroke; fill: none; }
.figure-layer circle { fill: #FFE9B0; }
.figure-layer circle.home { fill: #8EC5FF; filter: drop-shadow(0 0 4px rgba(142, 197, 255, .9)); }
.figure.is-sealed line { filter: drop-shadow(0 0 3px rgba(242, 211, 140, .8)); }
.figure.is-ghost line { stroke: rgba(233, 226, 211, .28); stroke-width: 1px; stroke-dasharray: 3 5; }
.figure.is-ghost circle { fill: rgba(233, 226, 211, .35); }
.figure.is-drawing line {
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: ink-line .7s ease-out forwards;
  animation-delay: calc(.35s + var(--i) * .55s);
}
.figure.is-drawing circle { opacity: 0; animation: ink-dot .5s ease-out forwards; animation-delay: calc(.35s + var(--i) * .55s); }
@keyframes ink-line { to { stroke-dashoffset: 0; } }
@keyframes ink-dot { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }
.figure circle { transform-box: fill-box; transform-origin: center; }

/* zoom controls */
.zoom-controls {
  position: absolute; right: calc(var(--gutter) + env(safe-area-inset-right)); bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  z-index: 2; display: flex; flex-direction: column; gap: .5rem;
}
.zoom-controls .icon-btn { font-size: 1.3rem; line-height: 1; background: rgba(14, 22, 38, .85); }
.zoom-controls .icon-btn:disabled { opacity: .35; cursor: default; }
.zoom-hint {
  position: absolute; left: 50%; bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 2; margin: 0; padding: .45rem .9rem; border-radius: 999px; white-space: nowrap;
  background: rgba(14, 22, 38, .85); border: 1px solid var(--gold-dim); color: var(--star-ink-soft); font-size: .85rem;
  pointer-events: none; animation: hint-in .6s ease;
}
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (max-width: 520px) { .zoom-hint { font-size: .75rem; bottom: calc(var(--gutter) + 160px + env(safe-area-inset-bottom)); } }

.star-pin {
  position: absolute; transform: translate(-50%, -50%) scale(calc(1 / var(--k))); pointer-events: auto;
  width: 44px; height: 44px; border: 0; padding: 0; background: none; cursor: pointer;
  display: grid; place-items: center;
}
.star-pin .glyph {
  width: 18px; height: 18px; display: block;
  background: var(--gold-bright);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  filter: drop-shadow(0 0 6px rgba(242, 211, 140, .9));
  animation: twinkle 3.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.star-pin .label {
  position: absolute; top: 100%; left: 50%; transform: translate(-50%, -6px);
  font-family: var(--font-title); font-size: .7rem; letter-spacing: .08em; white-space: nowrap;
  color: var(--star-ink); text-shadow: 0 1px 4px #000, 0 0 10px #000; pointer-events: none;
}
.star-pin.is-locked { cursor: help; }
.star-pin.is-locked .glyph { background: #8A93A6; filter: none; opacity: .55; animation: none; transform: scale(.7); }
.star-pin.is-locked .label { opacity: .55; }
.star-pin.is-sealed .glyph { width: 22px; height: 22px; background: #FFE7A8; filter: drop-shadow(0 0 10px rgba(255, 220, 140, 1)); }
.star-pin.is-next .glyph { animation: beckon 1.8s ease-in-out infinite; }
.star-pin:hover .glyph, .star-pin:focus-visible .glyph { transform: scale(1.35); }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes beckon { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.45); } }
@media (max-width: 760px) { .star-pin .label { font-size: .62rem; } }

/* ---------- the stop (full sheet) ---------- */
dialog { color: inherit; }
dialog::backdrop { background: rgba(5, 9, 18, .7); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet {
  width: min(880px, 100vw); max-width: 100vw; height: min(100dvh, 980px); max-height: 100dvh;
  margin: auto; padding: 0; border: 1px solid var(--gold-dim); border-radius: var(--radius);
  background: var(--night); box-shadow: var(--shadow); overflow: hidden;
}
@media (max-width: 760px) { .sheet { border-radius: 0; border: 0; height: 100dvh; } }
.stop { height: 100%; overflow-y: auto; position: relative; overscroll-behavior: contain; }
.close-btn { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 2; }
.stop-hero { position: relative; margin: 0; }
.stop-hero img { width: 100%; aspect-ratio: 4 / 3; max-height: 62vh; object-fit: cover; }
.stop-hero figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2.2rem var(--gutter) 1rem;
  background: linear-gradient(180deg, rgba(14,22,38,0), rgba(14,22,38,.92) 60%);
}
.stop-hero .title-sm { font-size: clamp(1.4rem, 4vw, 2rem); }
.stop-body { padding: 1rem var(--gutter) 2.5rem; display: grid; gap: 1.6rem; }
.theme { font-family: var(--font-body); font-size: 1.25rem; font-style: italic; color: var(--parchment); margin: 0 0 .5rem; }
.light-note { color: var(--gold); margin: 0 0 .3rem; }
.constellation-note { color: var(--star-ink-soft); font-family: var(--font-body); font-style: italic; margin: 0 0 .6rem; }
.myths { margin: 0; padding-left: 1.1rem; color: var(--star-ink-soft); }
.myths li { margin: .2rem 0; }

#stopText {
  width: 100%; min-height: 200px; resize: vertical; padding: 1rem 1.1rem;
  border-radius: 10px; border: 1px solid #CDBB97;
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(110, 100, 88, .18) 31px 32px),
    var(--parchment);
  color: var(--ink); font-family: var(--font-hand); font-size: 1.45rem; line-height: 32px;
}
.save-hint { font-size: .8rem; color: var(--star-ink-soft); min-height: 1.2em; margin: .3rem 0 0; }

.sealed-box { display: flex; gap: 1rem; align-items: center; padding: .8rem; border-radius: 12px; background: var(--parchment); color: var(--ink); }
.sealed-box img { width: 96px; height: 96px; border-radius: 8px; flex-shrink: 0; }
.sealed-box .kicker { color: #8A6A2E; }
.keepsake-name { font-family: var(--font-title); font-weight: 700; font-size: 1.1rem; margin: 0; }

/* ---------- panels (settings, library, confirm) ---------- */
.panel {
  width: min(560px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 2 * var(--gutter));
  padding: 0; border: 1px solid var(--gold-dim); border-radius: var(--radius);
  background: var(--night-2); box-shadow: var(--shadow);
}
.panel-small { width: min(420px, calc(100vw - 2 * var(--gutter))); }
.panel-inner { padding: 1.2rem 1.3rem 1.4rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.panel-section { padding: .9rem 0; border-top: 1px solid rgba(212,175,106,.15); }
.panel-section h3 { font-family: var(--font-title); font-size: .95rem; letter-spacing: .06em; color: var(--gold); margin: 0 0 .6rem; }
.panel-foot { padding-top: .8rem; border-top: 1px solid rgba(212,175,106,.15); font-size: .8rem; }
.confirm-icon { font-size: 2rem; margin: 0 0 .3rem; }
#confirmBody { color: var(--star-ink-soft); }

.shelf { display: grid; gap: .6rem; }
.shelf details { border: 1px solid var(--gold-dim); border-radius: 10px; padding: .6rem .8rem; background: rgba(14,22,38,.5); }
.shelf summary { cursor: pointer; font-weight: 500; }
.shelf .vol-page { margin: .7rem 0 0; padding: .7rem .8rem; border-radius: 8px; background: var(--parchment); color: var(--ink); }
.shelf .vol-page h4 { font-family: var(--font-title); margin: 0 0 .3rem; font-size: .9rem; }
.shelf .vol-page p { font-family: var(--font-hand); font-size: 1.25rem; line-height: 1.3; margin: 0; white-space: pre-wrap; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  display: flex; gap: .6rem; align-items: center; max-width: calc(100vw - 2 * var(--gutter));
  padding: .7rem 1.1rem; border-radius: 999px; background: var(--parchment); color: var(--ink);
  box-shadow: var(--shadow); transition: all .35s ease; font-size: .95rem;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01s !important; }
}

/* ======================= rituals (F2) ======================= */
.ritual {
  position: absolute; inset: 0; z-index: 5; overflow-y: auto;
  display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top)) var(--gutter) calc(16px + env(safe-area-inset-bottom));
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(31, 46, 75, .55), transparent 70%),
    #080C16;
  opacity: 0; transition: opacity .45s ease;
}
.ritual.is-in { opacity: 1; }
.ritual.is-out { opacity: 0; pointer-events: none; }
.ritual-inner { width: min(520px, 100%); text-align: center; }
.ritual-title { font-family: var(--font-title); font-weight: 700; font-size: clamp(1.15rem, 3.6vw, 1.5rem); color: var(--gold-bright); margin: 0 0 1rem; }
.ritual-hint { font-family: var(--font-body); font-style: italic; color: var(--parchment); min-height: 3em; margin: 1rem auto .6rem; max-width: 30rem; }
.ritual-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }

/* --- the telescope --- */
.eyepiece-wrap {
  position: relative; width: min(340px, 78vw, 44dvh); aspect-ratio: 1; margin: 0 auto;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.eyepiece-wrap:active { cursor: grabbing; }
.focus-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.focus-ring .ring-body { fill: none; stroke: #8C6A34; stroke-width: 7; }
.focus-ring .ring-ticks { transform-origin: 50% 50%; transform-box: view-box; }
.focus-ring .ring-ticks line { stroke: #F2D38C; stroke-width: .5; opacity: .75; }
.focus-ring .ring-ticks line.long { stroke-width: .9; opacity: 1; }
.focus-ring .ring-mark { fill: #FFF1C9; }
.eyepiece {
  position: absolute; inset: 11%; border-radius: 50%; overflow: hidden;
  background: #05080F;
  box-shadow: inset 0 0 0 3px #3D2A12, inset 0 0 40px 18px rgba(0,0,0,.9), 0 0 0 2px #C99E58, 0 10px 40px rgba(0,0,0,.6);
}
.eyepiece img { width: 100%; height: 100%; object-fit: cover; transition: filter .12s linear, transform .12s linear; pointer-events: none; }
.eyepiece::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 60px 30px rgba(0,0,0,.75); pointer-events: none; }
.eyepiece-glint {
  position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%) scale(0); z-index: 1;
  background: radial-gradient(circle, rgba(255, 244, 214, .95) 0 6%, rgba(255, 233, 176, .35) 18%, transparent 60%);
  pointer-events: none; opacity: 0;
}
.ritual-focus.is-focused .eyepiece-glint { animation: glint 1.6s ease-out forwards; }
.ritual-focus.is-focused .eyepiece { box-shadow: inset 0 0 0 3px #3D2A12, inset 0 0 30px 10px rgba(0,0,0,.7), 0 0 0 2px #F2D38C, 0 0 40px rgba(242, 211, 140, .45); transition: box-shadow .8s ease; }
@keyframes glint { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0); } 35% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(2.4); } }

/* --- tracing the constellation --- */
.trace-sky {
  display: block; width: min(420px, 86vw, 50dvh); aspect-ratio: 1; margin: 0 auto; overflow: visible;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
  background: radial-gradient(circle at 50% 50%, rgba(31, 46, 75, .5), transparent 70%);
  border-radius: 50%;
}
.t-ghost line { stroke: rgba(233, 226, 211, .22); stroke-width: .5; stroke-dasharray: 1.2 1.8; stroke-linecap: round; }
.t-ink line { stroke: var(--gold-bright); stroke-width: .9; stroke-linecap: round; filter: drop-shadow(0 0 1.2px rgba(242, 211, 140, .9)); stroke-dasharray: 1; stroke-dashoffset: 1; animation: ink-line .35s ease-out forwards; }
.t-live { stroke: rgba(242, 211, 140, .75); stroke-width: .7; stroke-linecap: round; }
.t-star .core { fill: #D9D2C2; transition: fill .3s ease; }
.t-star .halo { fill: rgba(242, 211, 140, 0); transition: fill .3s ease; }
.t-star.is-lit .core { fill: #FFE9B0; }
.t-star.is-from .halo { fill: rgba(242, 211, 140, .35); }
.t-star.is-from .core { fill: #FFF1C9; }
.t-star.is-to .halo { fill: rgba(242, 211, 140, .25); animation: pulse-halo 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.t-star.is-home .core { fill: #8EC5FF; }
@keyframes pulse-halo { 0%, 100% { transform: scale(.7); opacity: .6; } 50% { transform: scale(1.25); opacity: 1; } }
.ritual-trace.is-sealed .t-star .halo { fill: rgba(242, 211, 140, .3); animation: flare 1.4s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes flare { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
@media (max-height: 640px) { .ritual-title { margin-bottom: .5rem; } .ritual-hint { min-height: 0; margin: .5rem auto; } }
@media (prefers-reduced-motion: reduce) {
  .t-ink line { stroke-dasharray: none; stroke-dashoffset: 0; }
  .eyepiece img { transition: none; }
}

/* ======================= the four movements (F3) ======================= */
.movement { padding-top: 1.4rem; border-top: 1px solid rgba(212, 175, 106, .18); }
.mv-title { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; font-family: var(--font-title); font-size: 1.05rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-bright); }
.mv-num { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--gold-dim); font-size: .8rem; letter-spacing: 0; color: var(--gold); }
.mv-lede { color: var(--star-ink-soft); margin: -.4rem 0 .8rem; font-size: .95rem; }

/* I · Arrive */
.encounter-img { border-radius: 10px; border: 1px solid var(--gold-dim); margin-bottom: 1rem; }
.encounter-text p { font-family: var(--font-body); font-size: 1.08rem; line-height: 1.7; color: var(--star-ink); margin: 0 0 .8rem; }
.encounter-text p:first-child::first-letter { font-family: var(--font-display); font-size: 2.6em; float: left; line-height: .9; margin: .08em .1em 0 0; color: var(--gold-bright); }
.keeper-sign { font-family: var(--font-hand); font-size: 1.35rem; color: var(--gold); text-align: right; margin: 0; }

/* II · Settle */
.seat-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.seat {
  display: grid; gap: .3rem; text-align: left; padding: .8rem .95rem; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--gold-dim); background: rgba(22, 34, 58, .7); color: var(--star-ink);
  transition: border-color .2s ease, background .2s ease, transform .15s ease;
}
.seat:hover { border-color: var(--gold); }
.seat.is-chosen { border-color: var(--gold-bright); background: linear-gradient(180deg, rgba(212, 175, 106, .26), rgba(31, 46, 75, .85)); box-shadow: 0 0 0 1px var(--gold-bright) inset; }
.seat-label { font-weight: 600; }
.seat-desc { font-size: .88rem; color: var(--star-ink-soft); }
.whisper { font-family: var(--font-body); font-style: italic; font-size: 1.02rem; line-height: 1.6; color: var(--parchment); margin: .9rem 0 0; padding-left: .9rem; border-left: 2px solid var(--gold-dim); }
.tea-box { margin-top: 1.1rem; }
.tea-reveal { display: flex; gap: 1rem; align-items: center; margin: 0; padding: .8rem; border-radius: 12px; background: var(--parchment); color: var(--ink); }
.tea-reveal img { width: 110px; height: 110px; border-radius: 8px; flex-shrink: 0; }
.tea-reveal figcaption { display: grid; gap: .3rem; }
.tea-reveal strong { font-family: var(--font-title); }
.tea-reveal span { font-family: var(--font-body); font-style: italic; font-size: .98rem; line-height: 1.5; }

/* III · Write */
.prompt-cards { display: grid; gap: .7rem; margin-bottom: 1rem; }
.prompt-card { padding: .85rem 1rem; border-radius: 12px; background: rgba(22, 34, 58, .75); border: 1px solid rgba(212, 175, 106, .22); }
.pc-kind { margin: 0 0 .3rem; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.pc-q { margin: 0 0 .5rem; font-family: var(--font-body); font-size: 1.08rem; line-height: 1.5; color: var(--star-ink); }
.pc-heart { border-color: rgba(242, 211, 140, .5); background: linear-gradient(180deg, rgba(212, 175, 106, .12), rgba(22, 34, 58, .75)); }
.pc-echo .pc-q { font-style: italic; }
.pc-actions { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.link-btn { background: none; border: 0; padding: .3rem 0; min-height: 36px; color: var(--gold-bright); cursor: pointer; font-size: .9rem; text-decoration: underline; text-decoration-color: var(--gold-dim); text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: var(--gold-bright); }
.write-tools { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.1rem; }
.page-label { display: block; margin-bottom: .4rem; }
#coinBtn.is-flipping { animation: coin-flip .8s ease-in-out; }
@keyframes coin-flip { 0% { transform: rotateY(0); } 100% { transform: rotateY(1080deg); } }
.is-new { animation: arrive-soft .6s ease-out; }
@keyframes arrive-soft { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* IV · Seal: the keepsake card turns over */
.keepsake-card { perspective: 1200px; }
.keepsake-inner {
  position: relative; display: block; width: 100%; min-height: 220px; padding: 0; border: 0; background: none; cursor: pointer;
  transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .2, 1); color: var(--ink); text-align: left;
}
.keepsake-card.is-flipped .keepsake-inner { transform: rotateY(180deg); }
.keepsake-face {
  position: absolute; inset: 0; display: grid; align-content: center; gap: .3rem; padding: 1rem 1rem 1rem 140px;
  border-radius: 14px; background: var(--parchment); border: 1px solid #CDBB97; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.keepsake-face.front img { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); width: 110px; height: 110px; border-radius: 8px; }
.keepsake-face.front .kicker { color: #8A6A2E; margin: 0; }
.keepsake-face .keepsake-name { font-family: var(--font-title); font-weight: 700; font-size: 1.1rem; }
.keepsake-desc { font-size: .92rem; color: var(--ink-soft); }
.keepsake-face.back { transform: rotateY(180deg); padding: 1.4rem; place-items: center; text-align: center; background: radial-gradient(circle at 50% 40%, #FBF4E4, var(--parchment-2)); }
.inscription { font-family: var(--font-hand); font-size: 1.6rem; line-height: 1.3; color: #3D2A12; }
.turn-hint { font-size: .78rem; color: #8A6A2E; }
@media (max-width: 520px) {
  .keepsake-inner { min-height: 300px; }
  .keepsake-face { padding: 128px 1rem 1rem; align-content: start; }
  .keepsake-face.front img { left: 50%; top: 1rem; transform: translateX(-50%); }
  .keepsake-face.back { padding: 1.2rem; align-content: center; }
}
@media (prefers-reduced-motion: reduce) { .keepsake-inner { transition: none; } }

/* story cards: prologue, halfway vow, closing letter */
.panel.story { width: min(640px, calc(100vw - 2 * var(--gutter))); background: var(--night-2); overflow: hidden; }
.story .panel-inner { text-align: center; max-height: calc(100dvh - 2 * var(--gutter)); overflow-y: auto; }
.story .title-sm { font-size: 1.5rem; margin-bottom: .2rem; }
.story-body { text-align: left; margin: 1.1rem 0; }
.story-body p { font-family: var(--font-body); font-size: 1.05rem; line-height: 1.7; margin: 0 0 .9rem; color: var(--star-ink); }
.story-write { text-align: left; margin-bottom: 1rem; }
.story-write textarea {
  width: 100%; min-height: 180px; resize: vertical; padding: 1rem 1.1rem; border-radius: 10px; border: 1px solid #CDBB97;
  background: repeating-linear-gradient(180deg, transparent 0 31px, rgba(110, 100, 88, .18) 31px 32px), var(--parchment);
  color: var(--ink); font-family: var(--font-hand); font-size: 1.45rem; line-height: 32px;
}
.story-actions { margin-top: .4rem; }

/* ======================= sound (F5) ======================= */
.sound-btn { position: absolute; left: calc(var(--gutter) + env(safe-area-inset-left)); bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); z-index: 2; background: rgba(14, 22, 38, .85); }
.sheet-sound { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 64px; z-index: 2; }
[data-sound-toggle][aria-pressed="true"] { border-color: var(--gold-bright); box-shadow: 0 0 12px rgba(242, 211, 140, .35); }
.mixer { display: grid; gap: .2rem; margin-top: .4rem; }
.mixer .range { margin-top: .3rem; }
.mixer .range span { min-width: 9.5rem; }
.small-note { font-size: .8rem; margin-top: .5rem; }

/* ======================= your observatory (F5) ======================= */
.obs-sheet { width: min(1100px, 100vw); height: min(100dvh, 860px); }
.obs { height: 100%; overflow-y: auto; position: relative; display: flex; flex-direction: column; }
.obs-head { padding: 1rem var(--gutter) .6rem; padding-right: 64px; }
.obs-head .muted { margin: .2rem 0 0; }
.obs-scroll { overflow-x: auto; overscroll-behavior-x: contain; padding: 0 var(--gutter); flex-shrink: 0; }
.obs-stage { position: relative; aspect-ratio: 1268 / 690; border-radius: 10px; overflow: hidden; border: 1px solid var(--gold-dim); flex-shrink: 0; }
.obs-stage > img { width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.obs-slots { position: absolute; inset: 0; }
.obs-slot {
  position: absolute; transform: translate(-50%, -50%) rotate(var(--tilt)); aspect-ratio: 1;
  min-width: 26px; padding: 0; border-radius: 4px; cursor: pointer;
  border: 1px dashed rgba(242, 211, 140, .0); background: transparent;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.obs-slot:not(.has-item) { border-color: rgba(242, 211, 140, .0); }
.obs-sheet .obs-slot:not(.has-item):hover, .obs-slot:not(.has-item):focus-visible { border-color: rgba(242, 211, 140, .7); background: rgba(242, 211, 140, .08); }
.obs-picking .obs-slot:not(.has-item) { border-color: rgba(242, 211, 140, .65); background: rgba(242, 211, 140, .10); animation: slot-glow 1.6s ease-in-out infinite; }
@keyframes slot-glow { 50% { box-shadow: 0 0 14px rgba(242, 211, 140, .55); } }
.obs-slot.has-item { border: 3px solid #F4EBD8; outline: 1px solid #B8924F; background: #F4EBD8; box-shadow: 0 4px 10px rgba(0,0,0,.55); }
.obs-slot img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.obs-slot.is-picked { transform: translate(-50%, -58%) rotate(0deg) scale(1.25); box-shadow: 0 0 0 2px var(--gold-bright), 0 10px 24px rgba(0,0,0,.6); z-index: 2; }
.obs-bar { padding: .8rem var(--gutter) 1.2rem; display: grid; gap: .8rem; }
@media (max-width: 700px) {
  .obs-stage { width: 760px; }   /* on a phone the room stays big enough to see the keepsakes; it scrolls sideways */
  .obs-head { padding-bottom: .4rem; }
}
.obs-tray { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .3rem; min-height: 40px; align-items: center; }
.obs-tray-item { display: grid; justify-items: center; gap: .25rem; flex: 0 0 auto; width: 86px; padding: .4rem; border-radius: 10px; cursor: pointer; border: 1px solid var(--gold-dim); background: rgba(22, 34, 58, .7); color: var(--star-ink); font-size: .7rem; text-align: center; line-height: 1.2; }
.obs-tray-item img { width: 56px; height: 56px; border-radius: 4px; }
.obs-tray-item.is-picked { border-color: var(--gold-bright); background: rgba(212, 175, 106, .2); }
.vol-print { margin-top: .6rem; }

/* ======================= the folio (print only) ======================= */
.print-root { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; }
  body.is-printing > *:not(.print-root) { display: none !important; }
  body.is-printing .print-root { display: block; color: #2B2623; font-family: 'Playfair Display', Georgia, serif; }
  .f-page { page-break-after: always; break-after: page; position: relative; }
  .f-page:last-child { page-break-after: auto; break-after: auto; }
  .f-kicker { font-family: 'Cinzel', serif; font-size: 8.5pt; letter-spacing: .16em; text-transform: uppercase; color: #8A6A2E; margin: 0 0 4pt; }
  .f-small { font-family: 'Outfit', sans-serif; font-size: 8.5pt; color: #6E6458; margin: 2pt 0; }
  .f-cover { text-align: center; padding-top: 6mm; }
  .f-cover-art { width: 100%; height: 118mm; object-fit: cover; border-radius: 3mm; margin-bottom: 10mm; }
  .f-cover h1 { font-family: 'Cinzel Decorative', 'Cinzel', serif; font-size: 30pt; margin: 0; color: #3D2A12; }
  .f-sub { font-style: italic; font-size: 15pt; margin: 2mm 0 8mm; }
  .f-vol { font-family: 'Cinzel', serif; font-size: 12pt; margin: 0 0 2mm; }
  .f-name { font-family: 'Caveat', cursive; font-size: 20pt; margin: 0 0 4mm; }
  .f-vow { font-style: italic; font-size: 12pt; margin: 6mm auto; max-width: 120mm; }
  .f-station { width: 100%; height: 78mm; object-fit: cover; border-radius: 3mm; margin-bottom: 5mm; }
  .f-star h2 { font-family: 'Cinzel', serif; font-size: 20pt; margin: 0; color: #3D2A12; }
  .f-theme { font-style: italic; font-size: 11.5pt; margin: 1mm 0 5mm; }
  .f-cols { display: grid; grid-template-columns: 46mm 1fr; gap: 7mm; }
  .f-figure { width: 42mm; height: 42mm; background: #0E1626; border-radius: 50%; padding: 3mm; margin-bottom: 2mm; }
  .f-figure line { stroke: #F2D38C; stroke-width: 1.4; stroke-linecap: round; }
  .f-figure circle { fill: #FFE9B0; }
  .f-question { font-size: 11.5pt; font-style: italic; border-left: 2px solid #C99E58; padding-left: 3mm; margin: 0 0 4mm; }
  .f-writing p { font-family: 'Caveat', cursive; font-size: 15pt; line-height: 1.25; margin: 0 0 3mm; white-space: pre-wrap; }
  .f-silent { color: #8A7F72; }
  .f-keepsake { display: flex; gap: 5mm; align-items: center; margin-top: 6mm; padding: 4mm; border: 1px solid #D8C7A2; border-radius: 3mm; background: #FAF4E6; break-inside: avoid; }
  .f-keepsake img { width: 26mm; height: 26mm; border-radius: 2mm; }
  .f-keepsake-name { font-family: 'Cinzel', serif; font-weight: 700; margin: 0 0 1mm; }
  .f-inscription { font-family: 'Caveat', cursive; font-size: 14pt; margin: 0; }
  .f-letter .f-society p { font-size: 11pt; line-height: 1.55; margin: 0 0 3mm; }
  .f-letter h3 { font-family: 'Cinzel', serif; font-size: 12pt; margin: 8mm 0 3mm; }
  .f-sky h2 { font-family: 'Cinzel', serif; font-size: 18pt; margin: 0 0 5mm; }
  .sky-print { position: relative; width: 100%; aspect-ratio: 1356 / 762; }
  .sky-print img { width: 100%; height: 100%; }
  .sky-print svg { position: absolute; inset: 0; width: 100%; height: 100%; }
  .sky-print line { stroke: #F2D38C; stroke-width: 2.4; stroke-linecap: round; }
  .sky-print circle { fill: #FFE9B0; }
}

/* the bridge from the Chronicler (F6) */
.bridge-field summary { cursor: pointer; color: var(--gold); font-size: .92rem; padding: .3rem 0; }
.bridge-field[open] summary { margin-bottom: .6rem; }
.code-input { flex: 1; min-width: 10rem; min-height: 44px; padding: .5rem .8rem; border-radius: 10px; border: 1px solid var(--gold-dim); background: rgba(14, 22, 38, .75); color: var(--star-ink); font-family: var(--font-ui); letter-spacing: .08em; text-transform: uppercase; }
#startCode { letter-spacing: .08em; text-transform: uppercase; }
