/* main.css - full-screen visual-novel layout + game UI.
 *
 * The game is a full-screen "stage": a scenario background fills the viewport,
 * a character portrait stands on stage, the Good Angel floats as a guide, and a
 * dialog box at the bottom tells the story and presents choices, like a
 * dialog/visual-novel game. A HUD across the top shows progress + goodness score.
 */

/* ── App frame (full screen) ───────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

/* ── Background layers (crossfade) ─────────────────────────────────────── */
#bg { position: absolute; inset: 0; z-index: 0; }
.bg-layer {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity var(--bg-crossfade) ease;
}
.bg-layer.is-visible { opacity: 1; }
/* Scenario art now reads as a real backdrop (not a faint tint). A dark
   vignette at the bottom keeps the dialog box text readable over any art. */
.bg-layer.has-image::before {
  content: "";
  position: absolute; inset: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  opacity: 0.95;
  /* Darker than the raw art, so every scenario sits at the same brightness
     instead of each PNG's own exposure. */
  filter: brightness(0.4) contrast(1.05);
}
.bg-layer::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 22%),
    linear-gradient(0deg, rgba(6,12,10,0.86) 0%, rgba(6,12,10,0.35) 34%, rgba(6,12,10,0) 60%),
    /* Flat cool-blue wash over the whole scene: a little bluer + a little
       darker, applied evenly (a flat overlay reads as a colour grade -
       predictably "bluer" - where hue-rotate would shift skin/wood/green
       tones unpredictably). */
    linear-gradient(rgba(14, 28, 58, 0.72), rgba(14, 28, 58, 0.72));
}

/* Slow parallax drift for life. */
@keyframes bgDrift { 0%,100% { transform: scale(1.06) translate(0,0); } 50% { transform: scale(1.06) translate(-1.4%, -1%); } }
.bg-layer { animation: bgDrift 26s var(--ease-in-out) infinite; }

/* ── Scene root ────────────────────────────────────────────────────────── */
#scene-root { position: absolute; inset: 0; z-index: 1; display: flex; }
.scene { width: 100%; }

/* ── Visual-novel game layer ───────────────────────────────────────────── */
.vn {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  width: 100%;
}

/* ── HUD (top bar) ─────────────────────────────────────────────────────── */
.hud {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 10px;
}
.hud-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hud-panel {
  display: flex; align-items: center; gap: 10px;
  background: rgba(8, 16, 13, 0.78);
  border: 2px solid var(--panel-border);
  border-radius: var(--r-sm);
  padding: 7px 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
}
.ep {
  font-size: 13px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--paper-soft); white-space: nowrap;
}
.hud-chip {
  font-size: 13px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #08110d; padding: 7px 18px;
  background: var(--tc, var(--accent)); white-space: nowrap;
  clip-path: var(--clip-tab);
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.35));
}
.dots { display: flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 0; background: rgba(255,255,255,.3); }
.dot.on { background: #fff; }
.dot.done { background: rgba(255,255,255,.75); }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 18px; font-weight: 800; color: #fff; white-space: nowrap;
}
.pill .gem { font-size: 19px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }

/* ── Stage (where characters live) ─────────────────────────────────────── */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* Good Angel - a floating guide bubble, top area of the stage. */
.angel {
  position: absolute; top: 6px; left: 18px; right: 18px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(8, 16, 13, 0.55); border: 2px solid var(--glass-border);
  border-radius: var(--r-sm); padding: 10px 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  max-width: 520px;
  box-shadow: var(--shadow-1);
}
.angel-avatar { position: relative; width: 58px; height: 58px; flex-shrink: 0; }
.angel-img { width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,.35)); }
.angel-face {
  position: absolute; bottom: -3px; right: -6px; font-size: 23px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
}
.angel-line {
  font-size: 16px; color: rgba(255,255,255,.95); font-style: italic;
  line-height: 1.5; min-height: 1.5em;
}

/* Focus dim - covers the stage, the HUD band above it and the backdrop art.
   When a character talks (.vn.focused) everything behind it blurs + darkens,
   leaving only the talking portrait and the dialog box in focus.
   (Blur/darkness are transitioned directly; transitioning `opacity` on a
   backdrop-filter element leaves the blur visible in some browsers.) */
.focus-dim {
  /* bottom overshoots on purpose, all the way past the dialog box: while a
     character talks the dialog fades to near-invisible (see .vn.charline
     .dialog below), and without this the strip behind it stayed at normal
     brightness instead of dimming with the rest of the stage. #app clips the
     overshoot so this never shows past the real screen edge. */
  position: absolute; left: 0; right: 0; top: -140px; bottom: -100vh;
  z-index: 3; pointer-events: none;
  background: rgba(3, 9, 7, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background .5s ease, backdrop-filter .5s ease, -webkit-backdrop-filter .5s ease;
}
.vn.focused .focus-dim {
  background: rgba(3, 9, 7, 0.55);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

/* Story illustration - big, CENTER STAGE, rising from behind the dialog box.
   The container spans the full stage width and flex-centers the art, so the
   character always stands in the middle of the screen. */
.portrait {
  z-index: 4; /* above the focus dim: the scene art stays sharp */
  position: absolute; left: 0; right: 0; bottom: 0;
  height: min(100%, 900px);
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.45));
  transition: opacity .45s ease;
}
.portrait.portrait-empty { opacity: 0; }
.portrait::before {
  content: "";
  position: absolute; left: 50%; bottom: 2%; transform: translateX(-50%);
  width: min(80%, 620px); height: 60%;
  background: radial-gradient(ellipse at center, var(--tc, rgba(255,255,255,.5)) 0%, transparent 68%);
  opacity: .34; filter: blur(14px); z-index: -1;
}
.portrait-img { height: 100%; width: auto; max-width: 100%; object-fit: contain; }

@media (max-width: 620px) {
  .portrait { height: min(94%, 640px); opacity: .98; }
  .portrait.portrait-empty { opacity: 0; }
}

/* ── Speech bubble - character lines come FROM the character ─────────────
   The character stands centre stage, so the bubble hangs directly above
   them with a tail pointing DOWN at their head, comic-book style. */
.speech {
  position: absolute; z-index: 5;
  /* `bottom` is set per-beat from JS (positionSpeech) so the bubble hangs just
     above the speaking character's head; this is only the pre-JS fallback. */
  left: 50%; bottom: 40%;
  width: min(560px, calc(100% - 32px));
  background: rgba(9, 17, 14, 0.96);
  border: 2px solid var(--tc, var(--accent));
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  padding: 24px 20px 62px;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity .35s ease, transform .35s var(--ease-out);
}
.vn.charline .speech { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
/* tail pointing down, at the character (border triangle + fill triangle) */
.speech::before {
  content: ""; position: absolute; left: 50%; margin-left: -15px; bottom: -19px;
  border-left: 15px solid transparent; border-right: 15px solid transparent;
  border-top: 19px solid var(--tc, var(--accent));
}
.speech::after {
  content: ""; position: absolute; left: 50%; margin-left: -11px; bottom: -14px;
  border-left: 11px solid transparent; border-right: 11px solid transparent;
  border-top: 15px solid rgba(9, 17, 14, 0.96);
}
.speech-name {
  position: absolute; top: -17px; left: 12px;
  background: var(--tc, var(--accent)); color: #08110d;
  font-size: 16px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 7px 24px;
  clip-path: var(--clip-tab);
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.4));
}
.speech-text {
  font-size: 22px; color: #fff; line-height: 1.55; min-height: 1.55em;
}
.speech .ok-btn { position: absolute; right: 12px; bottom: 10px; }

/* While a character talks, the narrator box recedes into the blur. */
.dialog { transition: opacity .4s ease, transform .4s ease, filter .4s ease; }
.vn.charline .dialog { opacity: .12; transform: translateY(10px); filter: blur(3px); pointer-events: none; }

/* Mobile: same centered layout, just tighter and clear of the skip button. */
@media (max-width: 620px) {
  .speech { width: calc(100% - 24px); padding: 18px 16px 56px; }
  .speech-text { font-size: 18px; }
}

/* On narrow screens the virtue tag chip is dropped so the goodness score
   always stays on screen; the tag still reads in the dialog + outcome. */
@media (max-width: 600px) {
  .hud { padding-left: 12px; padding-right: 12px; }
  .hud-chip { display: none; }
  .angel { left: 12px; right: 12px; }
}

/* ── Dialog box (bottom) ───────────────────────────────────────────────── */
.dialog {
  flex: 0 0 auto;
  position: relative;
  z-index: 6; /* above the focus dim */
  margin: 0 14px max(14px, env(safe-area-inset-bottom));
  max-height: 70dvh;
  display: flex; flex-direction: column;
  background: rgba(10, 18, 15, 0.92);
  border: 2px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.dialog-inner {
  display: flex; flex-direction: column; min-height: 0;
  padding: 16px 20px 18px;
  overflow-y: auto;
}
.nameplate {
  position: absolute; top: -17px; left: 18px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--tc, var(--accent));
  color: #08110d; font-weight: 800; font-size: 16px;
  letter-spacing: .07em; text-transform: uppercase;
  padding: 7px 24px;
  clip-path: var(--clip-tab);
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.4));
}
.nameplate .np-emoji { font-size: 17px; }
.nameplate { transition: transform .3s var(--ease-out), box-shadow .3s; }
.vn.focused .nameplate { transform: scale(1.07); box-shadow: 0 0 22px var(--tc, var(--accent)), 0 4px 14px rgba(0,0,0,0.4); }

/* OK button - advances to the next dialog beat during the story. */
.ok-btn {
  position: absolute; right: 14px; bottom: 12px; z-index: 2;
  display: none; align-items: center; gap: 8px;
  background: var(--tc, var(--accent)); color: #08110d;
  font-size: 17px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  padding: 12px 28px; border-radius: 0;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.ok-btn.show { display: inline-flex; }
.ok-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5); }
.ok-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5); }

/* Skip button - jumps past the story straight to the choices. Lives on the
   stage (top-right), above the focus dim so it stays usable mid-story. */
.skip-btn {
  position: absolute; top: 10px; right: 14px; z-index: 8;
  display: none; align-items: center;
  background: rgba(8, 16, 13, 0.9); color: var(--paper-soft);
  border: 2px solid var(--panel-border);
  font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 9px 16px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-1);
  transition: color .15s, border-color .15s;
}
.vn.storying .skip-btn { display: inline-flex; }
.skip-btn:hover { color: #fff; border-color: rgba(255,255,255,.5); }
@media (max-width: 620px) {
  /* Pushed down further than desktop so it clears the music button, which
     also moves to its own mobile spot below the HUD (see .music-widget). */
  .skip-btn { top: 118px; }
}

/* Reserve room for the OK button while the story is playing. */
.dialog-inner { transition: padding-bottom .3s ease; }
.vn.storying .dialog-inner { padding-bottom: 68px; }

.content-area { position: relative; display: flex; min-height: 0; }
.phase { display: flex; flex-direction: column; width: 100%; min-height: 0; }
/* The CURRENT scenario is always the LAST-appended phase; any earlier phase still
   in the DOM (fading out, or a stray leftover from a fast/edge transition) is
   pulled OUT of flow and overlaid, so two scenarios can NEVER sit side by side in
   the flex row and squash/merge together. This keys off DOM order rather than a
   transient animation class, so it holds no matter how the swap is timed - the
   permanent fix. A lone phase is itself the last child, so this never applies to
   the normal single-phase case and that layout is left exactly as-is (no jam). */
.content-area > .phase:not(:last-child) {
  position: absolute; inset: 0; pointer-events: none;
}

/* Narration / dialogue text */
.ctext {
  font-size: 20px; color: var(--paper); line-height: 1.6;
  min-height: 1.6em; margin-top: 4px;
}
.eyebrow {
  font-size: 14px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px;
}

.eyebrow.choose { margin-top: 18px; margin-bottom: 0; }

/* ── Scenario title card (start of every moment) ───────────────────────── */
.scene-card {
  position: absolute; inset: 0; z-index: 9;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 24px; cursor: pointer;
  background: rgba(4, 10, 8, 0.78);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.sc-kicker {
  font-size: 15px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
}
.sc-title {
  font-size: clamp(36px, 7vw, 56px); font-weight: 800; color: #fff;
  letter-spacing: -.01em; text-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.sc-tag {
  font-size: 15px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #08110d; padding: 8px 20px; border-radius: var(--r-pill);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.sc-hint { margin-top: 12px; font-size: 14px; color: rgba(255,255,255,.6); letter-spacing: .05em; }
.anote {
  font-size: 15px; font-style: italic; margin-top: 12px; padding: 12px 15px;
  background: rgba(255, 205, 90, 0.14); border: 1px solid rgba(255, 205, 90, 0.4);
  border-radius: var(--r-sm); color: #FFE39A; line-height: 1.5;
}

/* ── In-scenario thought box (first choice screen) ─────────────────────── */
.thoughtbox { margin-top: 16px; }
.thought-q {
  font-size: 14px; font-weight: 700; letter-spacing: .04em;
  color: var(--paper-soft); margin-bottom: 7px;
  display: flex; align-items: center; gap: 6px;
}
.thought-input {
  width: 100%; background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.16); border-radius: var(--r-sm);
  color: #fff; font-size: 16px; padding: 11px 13px; line-height: 1.5;
  resize: none; font-family: inherit;
}
.thought-input::placeholder { color: rgba(255,255,255,.4); }
.thought-input:focus {
  outline: none; border-color: var(--tc, var(--accent)); background: rgba(255,255,255,.12);
}

/* ── Choices (game menu) ───────────────────────────────────────────────── */
.choices { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }
.choices.locked { pointer-events: none; }
.btn {
  position: relative; overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-left: 6px solid var(--accent, #7CE0BC);
  border-radius: 0; padding: 16px 18px; font-size: 18px; color: var(--paper);
  text-align: left; line-height: 1.45; display: flex; align-items: center; gap: 13px;
  transition: transform .14s var(--ease-out), box-shadow .14s var(--ease-out),
              background .14s, border-color .14s;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--accent, #7CE0BC);
  transform: translateX(4px);
  box-shadow: var(--shadow-hard);
}
.btn:active { transform: translateX(4px) scale(.99); }
.ltr {
  width: 34px; height: 34px; border-radius: 0; display: flex;
  align-items: center; justify-content: center; font-size: 17px; font-weight: 800;
  flex-shrink: 0; color: #fff;
}
.btn-label { flex: 1; }

/* ── Outcome result banner ─────────────────────────────────────────────── */
.ocard { border-radius: var(--r-md); padding: 17px 19px; margin-top: 2px; }
.oicon { font-size: 40px; margin-bottom: 6px; }
.otitle { font-size: 21px; font-weight: 800; margin-bottom: 8px; }
.otxt { font-size: 17px; line-height: 1.6; margin-bottom: 11px; min-height: 1.6em; }
.vtag {
  display: inline-block; font-size: 13px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; padding: 6px 14px; border-radius: var(--r-pill);
}

/* ── Reflection box ────────────────────────────────────────────────────── */
.rbox { background: rgba(255,255,255,.95); border-radius: var(--r-md); padding: 15px 17px; margin-top: 12px; }
.rq { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; line-height: 1.5; }
.rsub { font-size: 15px; color: #555; margin-bottom: 10px; line-height: 1.5; }
.rinput {
  width: 100%; border: 1px solid #ddd; border-radius: var(--r-sm); padding: 10px 13px;
  font-size: 16px; color: var(--ink); background: #fff; resize: none; line-height: 1.5;
}
.rinput:focus { outline: 2px solid #9FE1CB; border-color: transparent; }
.rskip { font-size: 14px; color: #888; cursor: pointer; text-decoration: underline; margin-top: 8px; display: inline-block; }
.rskip:hover { color: #555; }
/* Shown under the reflection field until the player writes something. */
.rreq { font-size: 13px; font-weight: 700; color: #B26A00; margin-top: 9px; }

/* ── Action row ────────────────────────────────────────────────────────── */
.rowbtns { display: flex; gap: 10px; margin-top: 16px; }
.gbtn {
  flex: 1; background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.24);
  border-radius: 0; padding: 14px; font-size: 15px; font-weight: 700; color: #fff;
  text-transform: uppercase; letter-spacing: .04em;
  transition: background .15s, transform .15s;
}
.gbtn:hover { background: rgba(255,255,255,.18); }
.gbtn:active { transform: scale(.97); }
.nbtn {
  flex: 2; background: #fff; border-radius: 0; padding: 15px;
  font-size: 17px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  box-shadow: var(--shadow-2);
  transition: transform .15s, box-shadow .15s;
}
.nbtn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 rgba(0,0,0,.4); }
.nbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0,0,0,.4); }
/* Disabled until the reflection is written (required to advance). */
.nbtn:disabled { opacity: .5; cursor: not-allowed; box-shadow: var(--shadow-2); transform: none; }
.nbtn:disabled:hover { transform: none; box-shadow: var(--shadow-2); }

/* Tap-to-continue hint (shown while narration types / waits) */
.tap-hint {
  align-self: flex-end; margin-top: 10px;
  font-size: 13px; color: var(--paper-soft); letter-spacing: .04em;
  display: inline-flex; align-items: center; gap: 5px;
}
.tap-hint .caret { display: inline-block; }

/* ── Title screen (full screen) ────────────────────────────────────────── */
.title-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; height: 100dvh; padding: 32px; width: 100%;
}
.title-inner { max-width: 460px; display: flex; flex-direction: column; align-items: center; }
.title-logo-wrap { margin-bottom: 18px; }
.title-logo { width: 150px; height: 150px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0,0,0,.4)); }
.tgame { font-size: 14px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.75); margin-bottom: 10px; }
.tepi { font-size: 42px; font-weight: 900; color: #fff; margin-bottom: 10px; min-height: 1.2em; text-transform: uppercase; letter-spacing: .04em; text-shadow: 4px 4px 0 rgba(0,0,0,.4); }
.tsub { font-size: 18px; color: rgba(255,255,255,.85); line-height: 1.65; margin-bottom: 30px; }
.title-cta { margin-bottom: 4px; }
.sbtn {
  background: #fff; border-radius: 0;
  padding: 18px 44px; font-size: 18px; font-weight: 800; color: #12613f;
  text-transform: uppercase; letter-spacing: .08em;
  border: 3px solid #0e3f2a;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.45);
}
.tnote { font-size: 14px; color: rgba(255,255,255,.55); margin-top: 16px; }

/* ── Brand footer (Game Goodness lockup: title + final) ─────────────────── */
.brand-footer {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-align: center;
}
.brand-logo {
  width: clamp(140px, 44vw, 188px); height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
  opacity: .97;
}
.brand-note {
  font-size: 12.5px; font-weight: 700; letter-spacing: .05em;
  color: rgba(255, 255, 255, .62);
}
/* Title: pin the lockup to the bottom of the screen, clear of the content. */
.title-screen { position: relative; }
.brand-footer-fixed {
  position: absolute; left: 0; right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
}
/* Final: the lockup closes out the results, sitting under the card. */
.final-inner .brand-footer { margin-top: 22px; margin-bottom: 4px; }

/* ── Student form (between title and game) ─────────────────────────────── */
.form-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100dvh; width: 100%; padding: 24px 16px; overflow-y: auto;
}
.form-card {
  width: 100%; max-width: 440px;
  background: rgba(10, 18, 15, 0.92);
  border: 2px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 26px 24px;
}
.form-title { font-size: 26px; font-weight: 800; color: #fff; margin-bottom: 6px; }
.form-sub { font-size: 15px; color: rgba(255,255,255,.75); line-height: 1.6; margin-bottom: 18px; }
.fld { display: block; margin-bottom: 14px; }
.fld-label {
  display: block; font-size: 13px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 6px;
}
.finput {
  width: 100%; background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.18); border-radius: var(--r-sm);
  color: #fff; font-size: 17px; padding: 12px 14px;
}
.finput::placeholder { color: rgba(255,255,255,.4); }
.finput:focus { outline: none; border-color: var(--accent); background: rgba(255,255,255,.12); }
select.finput option { color: #111; background: #fff; }
.form-err { min-height: 20px; font-size: 14px; color: #FFB4A2; margin: 2px 0 10px; }
.form-card .sbtn { width: 100%; animation: none; }
.form-note { font-size: 12.5px; color: rgba(255,255,255,.5); margin-top: 12px; text-align: center; line-height: 1.5; }

/* ── Final screen (full screen) ────────────────────────────────────────── */
.final-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  height: 100dvh; width: 100%; padding: 24px 18px; overflow-y: auto;
}
/* margin:auto centres the card when it fits, but (unlike justify-content:center)
   lets the top stay reachable and scroll into view when it's taller than the
   viewport. Only this window scrolls; the backdrop is a separate fixed layer. */
.final-inner { width: 100%; max-width: 500px; margin: auto 0; }
.final-head { text-align: center; margin-bottom: 12px; }
.final-head .ep { color: rgba(255,255,255,.7); }
.fcard { background: rgba(255,255,255,.98); border-radius: var(--r-xl); padding: 26px 22px; text-align: center; box-shadow: var(--shadow-card); }
.fring { width: 104px; height: 104px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 16px; }
.fnum { font-size: 33px; font-weight: 800; }
.flbl { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }
.ftitle { font-size: 26px; font-weight: 800; margin-bottom: 9px; color: var(--ink); min-height: 1.2em; }
.ftxt { font-size: 16px; color: #555; line-height: 1.7; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; min-height: 32px; }
.chip { font-size: 14px; font-weight: 700; padding: 6px 15px; border-radius: var(--r-pill); background: #D4EDDA; color: #155724; }
.dbox { background: #F0FBF5; border: 1px solid #9FE1CB; border-radius: var(--r-md); padding: 15px 17px; margin-bottom: 16px; text-align: left; }
.dtitle { font-size: 13px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: #0F6E56; margin-bottom: 10px; }
.dq { font-size: 15px; color: #085041; line-height: 1.6; margin-bottom: 8px; padding-left: 17px; position: relative; }
.dq::before { content: "•"; position: absolute; left: 0; color: #1D9E75; }
.rbtn { width: 100%; border-radius: var(--r-md); padding: 16px; font-size: 17px; font-weight: 800; transition: transform .15s; margin-bottom: 8px; }
.rbtn:hover { transform: translateY(-2px); }
.rbtn:active { transform: scale(.98); }
.fnote { font-size: 12.5px; color: #aaa; margin-top: 6px; }

/* ── End-screen report: the kid's choices + thoughts, per moment ─────────── */
.jbox { background: #F7FBFF; border: 1px solid #C7DEF3; border-radius: var(--r-md); padding: 15px 17px; margin-bottom: 12px; text-align: left; }
.jentry { padding: 10px 0; border-bottom: 1px solid #E4EEF8; }
.jentry:last-child { border-bottom: 0; padding-bottom: 2px; }
.jhead { font-size: 14px; font-weight: 800; color: #14406e; margin-bottom: 4px; }
.jchoice { font-size: 13.5px; color: #1c3d5a; line-height: 1.5; }
.jvirt { font-size: 13px; color: #185FA5; margin: 2px 0; }
.jthought { font-size: 13.5px; color: #37474f; line-height: 1.5; margin-top: 3px; }
.jthought b { color: #14406e; }
.dlbtn { width: 100%; border-radius: var(--r-md); padding: 13px; font-size: 15px; font-weight: 800; color: #14406e; background: #E6F1FB; border: 1px solid #9FC4E8; transition: transform .15s; margin-bottom: 16px; }
.dlbtn:hover { transform: translateY(-2px); }
.dlbtn:active { transform: scale(.98); }

/* ── Music widget (global, floats above everything, every screen) ───────── */
.music-widget {
  /* Sits below the in-game HUD's top-right score pill AND the "Skip story"
     button (both also claim the top-right corner while a story plays)
     instead of on top of either, on every screen. */
  position: fixed; top: max(122px, calc(env(safe-area-inset-top) + 112px)); right: max(14px, env(safe-area-inset-right));
  z-index: 999; /* above scene-card (9), dialog (6), focus-dim (3) - every screen, always */
}
.music-btn {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 16, 13, 0.78); border: 2px solid var(--panel-border);
  border-radius: 50%;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
  font-size: 19px;
  transition: transform .14s var(--ease-out), box-shadow .14s var(--ease-out), border-color .14s;
}
.music-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-2); }
.music-btn.active { border-color: var(--accent); }
.music-icon { filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); line-height: 1; }

.music-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 220px;
  background: rgba(10, 18, 15, 0.94);
  border: 2px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 14px 16px;
  opacity: 0; transform: translateY(-8px) scale(.97);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s var(--ease-out);
}
.music-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.music-title-row {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.music-title {
  font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--paper-soft);
}
.music-info-btn {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.3);
  color: var(--paper-soft); font-size: 12px; font-weight: 800; font-style: italic;
  font-family: Georgia, serif;
  transition: border-color .14s, color .14s;
}
.music-info-btn:hover { border-color: var(--accent); color: var(--paper); }
.music-credits {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.14);
  display: none;
}
.music-credits.open { display: block; }
.music-credits-title {
  font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 5px;
}
.music-credits-line { font-size: 12.5px; color: var(--paper-soft); line-height: 1.5; }
.music-mute {
  width: 100%; padding: 9px; margin-bottom: 12px;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.16);
  border-radius: var(--r-sm); color: var(--paper);
  font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  transition: background .14s, border-color .14s;
}
.music-mute:hover { background: rgba(255,255,255,.14); border-color: var(--accent); }
.music-row { display: flex; align-items: center; gap: 10px; }
.music-lbl { font-size: 12.5px; color: var(--paper-soft); white-space: nowrap; }
.music-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); outline: none;
}
.music-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.music-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--accent); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
@media (max-width: 620px) {
  /* Same breakpoint as .skip-btn's mobile shift, with enough gap between
     them so the two never sit edge-to-edge (they did before this fix). */
  .music-widget { top: max(70px, calc(env(safe-area-inset-top) + 60px)); right: 10px; }
  .music-btn { width: 38px; height: 38px; font-size: 17px; }
  .music-panel { width: min(200px, calc(100vw - 20px)); padding: 12px 14px; }
}

/* ── Wider screens: keep the dialog readable, not stretched ─────────────── */
@media (min-width: 760px) {
  .dialog { margin-left: auto; margin-right: auto; width: min(860px, calc(100% - 28px)); }
  .hud { padding-left: max(18px, calc((100% - 860px) / 2)); padding-right: max(18px, calc((100% - 860px) / 2)); }
}
