:root {
  --bg: #060914;
  --bg2: #0b1230;
  --ink: #eaf0ff;
  --ink-dim: rgba(234, 240, 255, .64);
  --ink-faint: rgba(234, 240, 255, .38);
  --teal: #36d6c3;
  --violet: #8b6cff;
  --coral: #ff7a6b;
  --gold: #ffd27a;
  --glass: rgba(150, 175, 255, .07);
  --glass-hi: rgba(170, 195, 255, .12);
  --line: rgba(200, 215, 255, .14);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --hud: calc(var(--sat) + 60px);
  --fw: min(70vw, 34vh, 320px);
  --fh: calc(var(--fw) * 1.4);
  --st-top: calc(var(--hud) + 3vh);
  --st-scale: 1;
  --ease: cubic-bezier(.22, .8, .24, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2) 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  position: fixed; inset: 0;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
canvas { display: block; }
[hidden] { display: none !important; }

/* ── Ambient background ── */
#nebula { position: fixed; inset: -20%; pointer-events: none; filter: blur(60px); opacity: .55; }
#nebula i { position: absolute; border-radius: 50%; width: 55vmax; height: 55vmax; mix-blend-mode: screen; animation: drift 26s ease-in-out infinite alternate; }
#nebula i:nth-child(1) { left: 5%; top: 8%; background: radial-gradient(circle, rgba(54, 214, 195, .38), transparent 62%); }
#nebula i:nth-child(2) { right: 0; top: 30%; background: radial-gradient(circle, rgba(139, 108, 255, .42), transparent 62%); animation-duration: 32s; animation-delay: -8s; }
#nebula i:nth-child(3) { left: 25%; bottom: 0; background: radial-gradient(circle, rgba(255, 122, 107, .26), transparent 62%); animation-duration: 38s; animation-delay: -15s; }
@keyframes drift { from { transform: translate3d(-4%, -3%, 0) scale(1); } to { transform: translate3d(5%, 4%, 0) scale(1.12); } }
#bg, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#fx { z-index: 50; }
#flash { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 40%, #fff 0%, rgba(200, 230, 255, .6) 30%, transparent 70%); }
body::after { /* vignette */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(140% 100% at 50% 45%, transparent 55%, rgba(0, 0, 4, .55) 100%);
}

/* ── HUD ── */
#hud {
  position: fixed; z-index: 40; left: 0; right: 0; top: 0;
  padding: calc(var(--sat) + 10px) 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
#logo {
  font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .18em;
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
#mute { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
#mute svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#mute .spk { fill: var(--ink); stroke: none; }
#mute .off { display: none; }
#mute[aria-pressed="true"] .on { display: none; }
#mute[aria-pressed="true"] .off { display: block; }
#progress {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 6px;
  border-radius: 22px; background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  opacity: 0; transform: translateY(-8px); transition: opacity .6s var(--ease), transform .6s var(--ease);
}
body[data-scene="lab"] #progress, body[data-scene="titration"] #progress, body[data-scene="reaction"] #progress { opacity: 1; transform: none; }
#progress svg { width: 32px; height: 32px; transform: rotate(-90deg); }
#progress circle { fill: none; stroke-width: 3; }
#progress .track { stroke: rgba(255, 255, 255, .1); }
#progress .bar { stroke: url(#none); stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 97.4; stroke-dashoffset: 97.4; transition: stroke-dashoffset 1.2s var(--ease), stroke 1.2s; filter: drop-shadow(0 0 4px rgba(54, 214, 195, .8)); }
#progress span { display: flex; flex-direction: column; line-height: 1.1; }
#progress b { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 500; }
#progress em { font-style: normal; font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ── Stage / flask ── */
#stage {
  position: fixed; z-index: 10; left: 50%; top: var(--st-top);
  width: var(--fw); height: var(--fh);
  transform: translateX(-50%) scale(var(--st-scale)); transform-origin: 50% 0;
  transition: top 1.1s var(--ease), transform 1.1s var(--ease), opacity 1s var(--ease), filter 1s var(--ease);
  opacity: 0; pointer-events: none;
}
body[data-scene="lab"] #stage, body[data-scene="titration"] #stage, body[data-scene="reaction"] #stage { opacity: 1; pointer-events: auto; }
body[data-scene="mission"] #stage { opacity: .0; --st-scale: .9; }
body[data-scene="report"] #stage, body[data-scene="gift"] #stage, body[data-scene="letter"] #stage { opacity: .22; filter: blur(6px); --st-scale: 1.15; }
#flask { position: absolute; inset: 0; border-radius: 30% 30% 12% 12%; }
#flask canvas { width: 100%; height: 100%; }
#flask .target-ring {
  position: absolute; left: 6%; right: 6%; top: 34%; bottom: 6%; border-radius: 40% 40% 18% 18%;
  pointer-events: none; opacity: 0; box-shadow: 0 0 0 2px rgba(54, 214, 195, .0), 0 0 40px rgba(54, 214, 195, .0);
  transition: opacity .4s;
}
body.selecting #flask .target-ring, body.drag-over #flask .target-ring { opacity: 1; animation: ring 1.4s ease-in-out infinite; }
@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 1px rgba(54, 214, 195, .35), 0 0 30px rgba(54, 214, 195, .25); }
  50% { box-shadow: 0 0 0 2px rgba(54, 214, 195, .75), 0 0 60px rgba(54, 214, 195, .45); }
}
body.shake #stage { animation: shake .09s linear infinite; }
@keyframes shake { 0% { translate: 0 0; } 25% { translate: 1.5px -1px; } 50% { translate: -1px 1.5px; } 75% { translate: 1px 1px; } }

/* Burette */
#burette {
  position: absolute; left: 50%; bottom: calc(100% - var(--fh) * .02); height: calc(var(--fh) * .34); aspect-ratio: 30 / 170;
  transform: translate(-50%, -40px); opacity: 0; transition: transform 1s var(--ease), opacity .8s; pointer-events: none;
}
#burette svg { width: 100%; height: 100%; overflow: visible; }
body[data-scene="titration"] #burette { opacity: 1; transform: translate(-50%, 0); }
body[data-scene="titration"] { --st-top: calc(var(--hud) + 104px + var(--fh) * .3); --st-scale: .84; }
body[data-scene="reaction"] { --st-top: calc(var(--hud) + 6vh); }

/* ── Vials ── */
#vials {
  position: fixed; z-index: 20; left: 12px; right: 12px; bottom: calc(var(--sab) + 14px);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  opacity: 0; transform: translateY(30px); pointer-events: none;
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
body[data-scene="lab"] #vials { opacity: 1; transform: none; }
body[data-scene="lab"] .vial { pointer-events: auto; }
body[data-scene="lab"].lab-done #vials, body[data-scene="lab"].lab-done .vial { opacity: 0; pointer-events: none; }
.vial {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 2px 8px; min-height: 132px; border-radius: 18px; touch-action: none;
  background: linear-gradient(180deg, rgba(160, 185, 255, .07), rgba(160, 185, 255, .02));
  border: 1px solid var(--line);
  transition: transform .45s var(--ease), background .4s, border-color .4s, opacity .5s;
}
.vial svg { width: 38px; height: 84px; overflow: visible; transition: transform .45s var(--ease), filter .45s; filter: drop-shadow(0 0 10px var(--c)); }
.vial .lbl { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.vial .vcode { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--ink-faint); }
.vial .name { font-size: 11px; line-height: 1.2; text-align: center; color: var(--ink-dim); font-weight: 500; max-width: 100%; overflow-wrap: normal; }
@media (max-width: 380px) { .vial .name { font-size: 10px; } }
.vial.selected { border-color: var(--c); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 20%, transparent), rgba(160, 185, 255, .02)); transform: translateY(-8px); }
.vial.selected svg { transform: translateY(-4px) rotate(-6deg); filter: drop-shadow(0 0 18px var(--c)); }
.vial.dragging { opacity: .25; }
.vial.used, body[data-scene="lab"] .vial.used { pointer-events: none; }
.vial.used svg { opacity: .3; filter: none; }
.vial.used .name { color: var(--ink-faint); }
.vial .check { position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; border-radius: 50%; background: var(--c); color: #061018; font-size: 11px; font-weight: 700; display: grid; place-items: center; transform: scale(0); transition: transform .5s var(--ease); }
.vial.used .check { transform: scale(1); }
.vial-ghost { position: fixed; z-index: 45; pointer-events: none; width: 38px; height: 84px; left: 0; top: 0; will-change: transform; }
.vial-ghost svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 16px var(--c)); }

/* ── Scenes ── */
.scene {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .8s var(--ease), visibility 0s linear .8s;
}
.scene.active { opacity: 1; visibility: visible; transition: opacity .8s var(--ease) .15s, visibility 0s; }
.scene.active > * { pointer-events: auto; }
.scene .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--hud) + 8px) 20px calc(var(--sab) + 24px); }

.btn {
  position: relative; min-height: 54px; padding: 0 28px; border-radius: 27px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 16px; font-weight: 600; letter-spacing: .01em;
  background: linear-gradient(135deg, rgba(54, 214, 195, .26), rgba(139, 108, 255, .3));
  border: 1px solid rgba(190, 210, 255, .28);
  box-shadow: 0 10px 40px -10px rgba(139, 108, 255, .6), inset 0 1px 0 rgba(255, 255, 255, .2);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  transition: transform .25s var(--ease), opacity .5s, box-shadow .4s;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: var(--glass); box-shadow: none; font-weight: 500; }
.btn.small { min-height: 44px; padding: 0 18px; font-size: 14px; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn.glow::before { content: ""; position: absolute; inset: -2px; border-radius: inherit; z-index: -1; background: linear-gradient(90deg, var(--teal), var(--violet), var(--coral), var(--teal)); background-size: 300% 100%; filter: blur(14px); opacity: .7; animation: glowflow 4s linear infinite; }
@keyframes glowflow { to { background-position: 300% 0; } }

.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--teal); }
.reveal { opacity: 0; transform: translateY(14px); filter: blur(6px); transition: opacity .9s var(--ease), transform .9s var(--ease), filter .9s var(--ease); }
.reveal.in { opacity: 1; transform: none; filter: none; }

.panel {
  width: min(100%, 440px); border-radius: 26px; padding: 26px 24px;
  background: linear-gradient(160deg, rgba(150, 175, 255, .11), rgba(150, 175, 255, .03));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(20px) saturate(1.2); backdrop-filter: blur(20px) saturate(1.2);
}

/* Intro */
#s-intro .panel { position: relative; overflow: hidden; }
#s-intro .panel::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, .015) 3px 4px); pointer-events: none; }
.proto-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.proto-head h1 { margin: 6px 0 0; font-size: 30px; font-weight: 650; letter-spacing: -.01em; }
.stamp { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--coral); border: 1.5px solid var(--coral); border-radius: 6px; padding: 5px 8px; transform: rotate(8deg) scale(1.6); opacity: 0; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1), opacity .2s; }
.stamp.in { transform: rotate(8deg) scale(1); opacity: .9; }
.rows { display: grid; gap: 12px; margin: 0 0 26px; }
.row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: baseline; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.row dt { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }
.row dd { margin: 0; font-size: 16px; line-height: 1.35; }
.row.status dd { display: flex; align-items: center; gap: 8px; color: var(--gold); }
.row.status dd::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
#s-intro .btn { width: 100%; }
.note { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--ink-faint); }

/* Mission */
#s-mission .lines { width: min(100%, 520px); display: grid; gap: 22px; }
#s-mission p { margin: 0; font-size: clamp(19px, 5vw, 26px); line-height: 1.45; font-weight: 450; letter-spacing: -.005em; }
#s-mission p:first-child { font-family: var(--serif); font-size: clamp(30px, 8vw, 42px); font-style: italic; }
#s-mission .actions { margin-top: 36px; }
.skip { position: absolute; right: 16px; bottom: calc(var(--sab) + 16px); font-size: 14px; color: var(--ink-faint); min-height: 44px; padding: 0 12px; }

/* Lab */
#s-lab:has(.toast.in) .hint { opacity: 0; }
.hint { position: absolute; left: 20px; right: 20px; top: calc(var(--st-top) + var(--fh) + 10px); text-align: center; font-size: 14px; color: var(--ink-dim); transition: opacity .4s; }
.toast {
  position: absolute; left: 14px; right: 14px; bottom: calc(var(--sab) + 174px); margin: 0 auto; max-width: 440px;
  padding: 16px 18px 16px 20px; border-radius: 20px; overflow: hidden;
  background: linear-gradient(150deg, rgba(20, 28, 60, .82), rgba(12, 16, 38, .78));
  border: 1px solid var(--line); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .8);
  opacity: 0; transform: translateY(20px) scale(.98); transition: opacity .6s var(--ease), transform .6s var(--ease);
  pointer-events: none;
}
.toast.in { opacity: 1; transform: none; }
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); box-shadow: 0 0 20px var(--c); }
.toast .t-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.toast b { font-size: 15px; font-weight: 650; color: var(--c); }
.toast small { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--ink-faint); text-transform: uppercase; white-space: nowrap; }
.toast p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink); }
#s-lab .done { position: absolute; left: 20px; right: 20px; bottom: calc(var(--sab) + 28px); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--ink-dim); font-size: 15px; }

/* Titration */
.t-top { position: absolute; left: 20px; right: 20px; top: calc(var(--hud) + 6px); text-align: center; }
.t-top h2 { margin: 6px 0 0; font-size: 20px; font-weight: 600; }
.t-bottom { position: absolute; left: 16px; right: 16px; bottom: calc(var(--sab) + 18px); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gauge { width: min(100%, 420px); }
.gauge .bar { position: relative; height: 14px; border-radius: 7px; background: linear-gradient(90deg, #3b5bdb, #36d6c3 35%, #c86bff 70%, #ff4f7b); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.gauge .zone { position: absolute; top: -6px; bottom: -6px; border-radius: 6px; border: 1.5px solid rgba(255, 255, 255, .85); box-shadow: 0 0 18px rgba(255, 255, 255, .35); }
.gauge .marker { position: absolute; top: -9px; width: 4px; height: 32px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 12px #fff; transition: left .25s var(--ease); }
.gauge .scale { display: flex; justify-content: space-between; margin-top: 8px; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); letter-spacing: .1em; }
.t-msg { min-height: 44px; max-width: 420px; text-align: center; font-size: 15px; line-height: 1.4; color: var(--ink); }
.t-hint { font-size: 14px; color: var(--ink-dim); text-align: center; max-width: 380px; margin: 8px auto 0; line-height: 1.4; }
.t-actions { display: flex; gap: 10px; width: min(100%, 420px); }
.t-actions .btn { flex: 1; white-space: nowrap; padding: 0 14px; }
#hold { flex: 1.6; }
#hold.active { transform: scale(.96); box-shadow: 0 0 50px -6px rgba(200, 107, 255, .9), inset 0 1px 0 rgba(255, 255, 255, .2); }

/* Reaction */
#s-reaction .r-bottom { position: absolute; left: 16px; right: 16px; bottom: calc(var(--sab) + 28px); display: flex; flex-direction: column; align-items: center; gap: 12px; }
#s-reaction .r-title { position: absolute; left: 16px; right: 16px; top: calc(var(--st-top) + var(--fh) + 8px); text-align: center; }
.r-title h2 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(34px, 9vw, 56px); letter-spacing: -.01em; background: linear-gradient(90deg, var(--teal), #c9b8ff, var(--coral)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.r-title p { margin: 8px 0 0; font-size: clamp(17px, 4.5vw, 22px); color: var(--ink); }
.status-line { font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-dim); }

/* Scrollable content scenes */
.scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: calc(var(--hud) + 10px) 18px calc(var(--sab) + 32px); display: flex; flex-direction: column; align-items: center; }
.scroll > * { flex-shrink: 0; }
.stack { width: min(100%, 460px); display: flex; flex-direction: column; gap: 14px; margin: auto 0; }
.stack h2 { margin: 4px 0 6px; font-size: 26px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.item { display: grid; gap: 4px; padding: 16px 18px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); }
.item small { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); }
.item b { font-size: 19px; font-weight: 650; }
.item p { margin: 2px 0 0; font-size: 15px; line-height: 1.45; color: var(--ink-dim); }
.item .meter { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); margin-top: 8px; overflow: hidden; }
.item .meter i { display: block; height: 100%; width: 0; border-radius: 2px; background: linear-gradient(90deg, var(--teal), var(--violet)); transition: width 1.6s var(--ease) .3s; }
.item.in .meter i { width: 100%; }
.conclusion { font-family: var(--serif); font-style: italic; font-size: 18px; line-height: 1.45; text-align: center; padding: 6px 8px; color: var(--ink); }

.element {
  align-self: center; position: relative; width: 156px; aspect-ratio: 1; border-radius: 18px; padding: 12px 14px;
  background: linear-gradient(150deg, rgba(54, 214, 195, .24), rgba(139, 108, 255, .28) 60%, rgba(255, 122, 107, .22));
  border: 1px solid rgba(220, 230, 255, .35); box-shadow: 0 0 50px -10px rgba(139, 108, 255, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
  display: flex; flex-direction: column; justify-content: space-between;
}
.element .z { font-family: var(--mono); font-size: 15px; }
.element .sym { font-size: 58px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.element .nm { font-size: 13px; font-weight: 600; }
.element .m { position: absolute; right: 14px; top: 12px; font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.element-note { text-align: center; font-size: 12px; color: var(--ink-faint); font-family: var(--mono); letter-spacing: .04em; margin-top: -4px; }

/* Gift */
#s-gift .center { gap: 26px; }
.capsule { position: relative; width: min(70vw, 300px); height: calc(min(70vw, 300px) * .42); }
.capsule .half { position: absolute; top: 0; bottom: 0; width: 50%; transition: transform 1.5s cubic-bezier(.6, 0, .2, 1); }
.capsule .l { left: 0; border-radius: 999px 0 0 999px; background: linear-gradient(170deg, #ff9a7f, #c3485f 70%, #7d2246); box-shadow: inset 0 6px 14px rgba(255, 255, 255, .35), inset 0 -10px 20px rgba(0, 0, 0, .35); }
.capsule .r { right: 0; border-radius: 0 999px 999px 0; background: linear-gradient(170deg, rgba(200, 220, 255, .35), rgba(120, 140, 220, .12)); border: 1px solid rgba(220, 230, 255, .4); border-left: 0; box-shadow: inset 0 6px 14px rgba(255, 255, 255, .25); overflow: hidden; }
.capsule .r::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle, #fff 1px, transparent 1.6px); background-size: 14px 14px; opacity: .45; animation: sparkle 3s linear infinite; }
@keyframes sparkle { to { background-position: 14px -28px; } }
.capsule .seal { position: absolute; left: 50%; top: -8px; bottom: -8px; width: 10px; margin-left: -5px; border-radius: 5px; background: linear-gradient(180deg, var(--gold), #b88a2c); box-shadow: 0 0 16px rgba(255, 210, 122, .7); transition: opacity .4s, transform .6s; }
.capsule .core { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; background: #fff; box-shadow: 0 0 40px 20px rgba(200, 220, 255, .8), 0 0 120px 40px rgba(139, 108, 255, .6); opacity: 0; transform: scale(.2); transition: opacity 1s, transform 1.5s var(--ease); }
.capsule.open .l { transform: translateX(-34%) rotate(-14deg); }
.capsule.open .r { transform: translateX(34%) rotate(14deg); }
.capsule.open .seal { opacity: 0; transform: scaleY(1.6); }
.capsule.open .core { opacity: 1; transform: scale(1); }
.capsule:not(.open) { animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.gift-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gift-card h2 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(26px, 7vw, 36px); line-height: 1.2; }
.gift-card p { margin: 0; font-size: 17px; line-height: 1.5; color: var(--ink-dim); max-width: 360px; }
.gift-card img { max-width: min(100%, 320px); border-radius: 18px; }
.code { font-family: var(--mono); font-size: 34px; letter-spacing: .35em; padding: 10px 6px 10px 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); }

/* Letter: Packungsbeilage */
.leaflet {
  width: min(100%, 460px); color: #1c1f2e; border-radius: 6px; padding: 26px 22px 28px;
  background: linear-gradient(180deg, #f6f2ea, #ece6da);
  box-shadow: 0 30px 80px -10px rgba(0, 0, 0, .7);
  transform-origin: 50% 0; animation: unfold 1.4s var(--ease) both;
  background-image: linear-gradient(180deg, transparent calc(33.3% - 1px), rgba(0, 0, 0, .06) 33.3%, transparent calc(33.3% + 1px), transparent calc(66.6% - 1px), rgba(0, 0, 0, .06) 66.6%, transparent calc(66.6% + 1px)), linear-gradient(180deg, #f6f2ea, #ece6da);
}
@keyframes unfold { from { transform: perspective(900px) rotateX(-70deg) scaleY(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.leaflet .lh { border-bottom: 2px solid #1c1f2e; padding-bottom: 12px; margin-bottom: 14px; }
.leaflet .lh small { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: #6a5d8f; }
.leaflet h2 { margin: 4px 0 2px; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.leaflet .sub { font-size: 13px; color: #555a6e; }
.leaflet h3 { margin: 14px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6a5d8f; }
.leaflet h3 span { font-family: var(--mono); margin-right: 6px; }
.leaflet p { margin: 0; font-size: 15px; line-height: 1.5; }
.leaflet .letter { margin-top: 20px; padding-top: 18px; border-top: 1px dashed rgba(0, 0, 0, .2); font-family: var(--serif); }
.leaflet .letter p { font-size: 17px; line-height: 1.55; margin-bottom: 10px; }
.leaflet .sig { font-style: italic; font-size: 22px; margin-top: 14px; }
.end-actions { width: min(100%, 460px); display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.media { width: min(100%, 460px); display: grid; gap: 10px; margin-top: 18px; }
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photos figure { margin: 0; border-radius: 14px; overflow: hidden; background: var(--glass); }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photos figcaption { font-size: 12px; padding: 6px 8px; color: var(--ink-dim); }
.song { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 24px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; background: var(--glass); }

.install-hint { width: min(100%, 460px); margin: 18px 0 0; text-align: center; font-size: 13px; line-height: 1.45; color: var(--ink-faint); }
#s-intro .archive { width: 100%; margin-top: 10px; }

/* Easter egg */
#egg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(4, 6, 16, .7); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: fadein .5s var(--ease); }
#egg .panel { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
#egg h3 { margin: 0; font-size: 20px; }
#egg p { margin: 0; color: var(--ink-dim); line-height: 1.5; }
@keyframes fadein { from { opacity: 0; } }

/* ── Desktop / landscape ── */
@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  :root { --fw: min(40vh, 360px); --hud: calc(var(--sat) + 72px); }
  #hud { padding: 20px 28px 0; }
  #vials {
    left: 50%; right: auto; bottom: auto; top: calc(var(--st-top) + var(--fh) * .42);
    width: calc(var(--fw) + 600px); transform: translate(-50%, 30px);
    grid-template-columns: 130px 130px 1fr 130px 130px; gap: 16px;
  }
  body[data-scene="lab"] #vials { transform: translate(-50%, 0); }
  .vial:nth-child(3) { grid-column: 4; }
  .vial { min-height: 170px; padding-top: 16px; }
  .vial svg { width: 46px; height: 100px; }
  .vial .name { font-size: 13px; }
  .toast { bottom: 40px; }
  body[data-scene="titration"] { --st-scale: .72; }
}
@media (max-height: 700px) and (max-aspect-ratio: 1/1) {
  .vial { min-height: 118px; padding-top: 8px; }
  .vial svg { height: 70px; }
  .toast { bottom: calc(var(--sab) + 152px); }
  body[data-scene="titration"] { --st-scale: .76; }
  .t-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #nebula i, .capsule:not(.open), .btn.glow::before, #flask .target-ring { animation: none !important; }
  .reveal { filter: none; transform: none; }
  body.shake #stage { animation: none; }
  .leaflet { animation-duration: .01s; }
}

/* ── 3D mode (js/lab3d.js) ── */
/* No CSS opacity on #gl: WebKit can stop compositing a WebGL canvas after opacity transitions; lab3d.js dims the scene itself */
#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; transform: translateZ(0); will-change: transform; }
.is3d #flask-canvas, .is3d #burette, .is3d #flask .target-ring { visibility: hidden; }
.is3d .vial, .is3d .vial.selected { background: none; border-color: transparent; }
.is3d .vial svg { opacity: 0; filter: none; }
.is3d .capsule > span { visibility: hidden; }
/* In 3D, #stage is only a layout anchor for the camera: never fade or blur it (WebKit then drops the WebGL layer under it) */
.is3d #stage { opacity: 1 !important; filter: none !important; transition: top 1.1s var(--ease), transform 1.1s var(--ease); }
