/* =========================================================
   星河情书 · Starlight Letter — a film in code
   Fixed-viewport, click-to-advance, no scrolling.
   ========================================================= */

@font-face {
  font-family: "WenKai";
  src: url("assets/wenkai-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "WenKai";
  src: url("assets/wenkai-medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #04040c;
  --bg-2: #070614;
  --text: #f3edfa;
  --muted: #a79dbd;
  --muted-2: #786f90;
  --gold: #f6d8a7;
  --rose: #ff8fb1;
  --rose-2: #ff5f8e;
  --violet: #a493ff;
  --line: rgba(255, 255, 255, 0.1);
  --line-2: rgba(255, 255, 255, 0.06);
  --grad: linear-gradient(100deg, #f8dcaa 0%, #ffa4c2 46%, #b3a2ff 100%);
  --serif: "WenKai", "Songti SC", "STSong", "SimSun", serif;
  --sans: "WenKai", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Courier New", "WenKai", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

::selection { background: rgba(255, 143, 177, 0.32); color: #fff; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
canvas { display: block; }
:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

.film {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: pointer;
}

/* ---------- scenes ---------- */

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.075);
  filter: blur(16px);
  transition:
    opacity 0.95s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 1.15s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.95s ease,
    visibility 0s linear 1s;
  will-change: opacity, transform, filter;
  overflow: hidden;
}
.scene.is-active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  filter: blur(0);
  z-index: 2;
  transition:
    opacity 0.95s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 1.15s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.95s ease,
    visibility 0s;
}
.scene:not(.is-active) { pointer-events: none; }

.scene-inner {
  position: relative;
  z-index: 3;
  width: min(1240px, 88vw);
  height: 100%;
  margin: 0 auto;
  padding: clamp(78px, 10vh, 112px) 0 clamp(84px, 11vh, 118px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.scene-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 30%, rgba(4, 4, 12, 0.5) 80%),
    linear-gradient(180deg, rgba(4, 4, 12, 0.45) 0%, transparent 26%, transparent 66%, var(--bg) 100%);
}

.scene-watermark {
  position: absolute;
  right: 4vw;
  bottom: 7vh;
  z-index: 1;
  font-family: var(--serif);
  font-size: clamp(8rem, 18vw, 16rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.022);
  pointer-events: none;
  user-select: none;
}

.scene-meta {
  position: absolute;
  left: 4vw;
  right: 4vw;
  bottom: 10.5vh;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.26);
  pointer-events: none;
}

/* ---------- shared type ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.34em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.86;
}
.eyebrow::before {
  content: "";
  width: 32px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
  opacity: 0.75;
}
.center .eyebrow { justify-content: center; }
.center .eyebrow::before { display: none; }

.scene-title {
  margin-top: clamp(12px, 2vh, 20px);
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 3.7vw, 3.4rem);
  line-height: 1.3;
  letter-spacing: 0.04em;
  color: #fbf7ff;
  text-shadow: 0 0 60px rgba(164, 147, 255, 0.15);
}
.scene-title .grad,
.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.scene-sub {
  margin-top: clamp(12px, 1.8vh, 18px);
  font-size: clamp(12px, 1.05vw, 14px);
  line-height: 2;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.scene-head.center {
  text-align: center;
  max-width: 780px;
  margin: 0 auto;
}
.scene-head.center .scene-title { margin-left: auto; margin-right: auto; }

.small-caption {
  margin-top: clamp(14px, 2.2vh, 22px);
  text-align: center;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.26);
}

/* ---------- scene entry animations ---------- */

.anim {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(9px);
  transition:
    opacity 1s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d, 0s),
    transform 1s cubic-bezier(0.19, 1, 0.22, 1) var(--d, 0s),
    filter 1s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d, 0s);
  will-change: opacity, transform;
}
.scene.is-active .anim { opacity: 1; transform: none; filter: blur(0); }

.hero-title .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}
.hero-title .line > span {
  display: block;
  transform: translateY(114%);
  opacity: 0;
  transition: transform 1.5s cubic-bezier(0.19, 1, 0.22, 1), opacity 1.1s ease;
}
.scene.is-active .hero-title .line > span { transform: translateY(0); opacity: 1; }
.scene.is-active .hero-title .line:nth-child(1) > span { transition-delay: 0.28s; }
.scene.is-active .hero-title .line:nth-child(2) > span { transition-delay: 0.46s; }

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  left: 0;
  width: 100%;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4vw;
  opacity: 0;
  transition: opacity 1s ease 0.5s;
  pointer-events: none;
}
body.loaded .hud { opacity: 1; }
.hud button { pointer-events: auto; }

.hud-top {
  top: 0;
  padding-top: clamp(18px, 3vh, 28px);
  background: linear-gradient(180deg, rgba(4, 4, 12, 0.7), transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.32em;
  color: rgba(244, 237, 250, 0.7);
  white-space: nowrap;
}
.brand-mark { color: var(--gold); font-size: 11px; }
.brand em {
  font-style: normal;
  font-size: 7px;
  letter-spacing: 0.26em;
  color: rgba(255, 255, 255, 0.24);
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.hud-top-right { display: flex; align-items: center; gap: clamp(12px, 2vw, 24px); }

.chapter-label {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.24em;
  color: rgba(246, 216, 167, 0.6);
  white-space: nowrap;
}

.sound-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 8, 22, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.24em;
  color: var(--muted);
  transition: border-color 0.4s, color 0.4s, background 0.4s;
}
.sound-btn:hover { border-color: rgba(246, 216, 167, 0.45); color: var(--gold); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.eq i {
  width: 2px;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  transition: height 0.3s;
}
.sound-btn.is-on { color: var(--gold); border-color: rgba(246, 216, 167, 0.35); }
.sound-btn.is-on .eq i { animation: eq 1.1s ease-in-out infinite; }
.sound-btn.is-on .eq i:nth-child(2) { animation-delay: 0.18s; }
.sound-btn.is-on .eq i:nth-child(3) { animation-delay: 0.36s; }
@keyframes eq {
  0%, 100% { height: 3px; }
  50% { height: 11px; }
}

.hud-bottom {
  bottom: 0;
  padding-bottom: clamp(16px, 2.6vh, 24px);
  background: linear-gradient(0deg, rgba(4, 4, 12, 0.62), transparent);
  gap: 18px;
}
.hud-bottom-left { display: flex; align-items: center; gap: 14px; }
.hud-arrow {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  transition: border-color 0.4s, color 0.4s, opacity 0.4s, transform 0.4s;
}
.hud-arrow:hover { border-color: rgba(246, 216, 167, 0.45); color: var(--gold); transform: translateX(-2px); }
.hud-arrow:disabled { opacity: 0.18; pointer-events: none; }

.scene-counter {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.34);
  white-space: nowrap;
}

.hud-track {
  flex: 1;
  max-width: 300px;
  height: 1px;
  margin: 0 10px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.hud-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--grad);
  transform: scaleX(0.1428);
  transform-origin: 0 50%;
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 0 12px rgba(255, 143, 177, 0.8);
}

.hud-bottom-right { display: flex; align-items: center; gap: 18px; }
.hud-hint {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.26);
  white-space: nowrap;
}
.next-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(243, 237, 250, 0.7);
  transition: border-color 0.4s, color 0.4s, background 0.4s, transform 0.4s;
}
.next-btn span { color: var(--gold); font-size: 11px; }
.next-btn:hover { border-color: rgba(246, 216, 167, 0.45); color: var(--gold); background: rgba(246, 216, 167, 0.05); transform: translateX(2px); }
.next-btn[hidden] { display: none; }

/* ---------- overlays ---------- */

.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 12;
  pointer-events: none;
}

.cursor-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 360px;
  height: 360px;
  margin: -180px 0 0 -180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 150, 190, 0.16), rgba(164, 147, 255, 0.08) 40%, transparent 66%);
  pointer-events: none;
  z-index: 18;
  opacity: 0;
  transition: opacity 0.8s ease;
  transform: translate3d(-50vw, -50vh, 0);
  will-change: transform;
  mix-blend-mode: screen;
}
body.has-pointer .cursor-glow { opacity: 1; }

.grain {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.warp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  pointer-events: none;
}

.fireworks-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}

/* =========================================================
   SCENE 01 · HERO
   ========================================================= */

.scene-hero { background: var(--bg); }
.hero-inner { justify-content: center; align-items: flex-start; padding-top: 11vh; padding-bottom: 12vh; }

.hero-title {
  margin-top: clamp(18px, 2.6vh, 30px);
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.6rem, 7.4vw, 6.5rem);
  line-height: 1.15;
  letter-spacing: 0.035em;
  text-shadow: 0 20px 80px rgba(30, 15, 70, 0.65);
}
.hero-sub {
  margin-top: clamp(18px, 2.4vh, 28px);
  font-size: clamp(12.5px, 1.15vw, 15px);
  line-height: 2.1;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.enter-hint {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-top: clamp(24px, 5vh, 52px);
  padding: 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  letter-spacing: 0.2em;
  transition: color 0.4s;
}
.enter-hint:hover { color: var(--gold); }
.hint-orbit {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(246, 216, 167, 0.34);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.hint-orbit::after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff3dc;
  box-shadow: 0 0 10px 2px rgba(255, 220, 170, 0.9);
  animation: hintPulse 2.2s ease-in-out infinite;
}
.hint-orbit i {
  position: absolute;
  inset: -1px;
  border: 1px solid rgba(246, 216, 167, 0.22);
  border-radius: 50%;
  animation: hintRing 3s ease-out infinite;
}
@keyframes hintPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.5); opacity: 1; }
}
@keyframes hintRing {
  0% { transform: scale(0.7); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* =========================================================
   SCENE 02 · CODE
   ========================================================= */

.scene-code {
  background:
    radial-gradient(1000px 620px at 12% 40%, rgba(100, 72, 220, 0.13), transparent 62%),
    radial-gradient(800px 520px at 92% 82%, rgba(200, 70, 130, 0.08), transparent 65%),
    var(--bg);
}

.code-inner { justify-content: center; }

.code-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 4vw;
}
.code-head .scene-sub { max-width: 340px; text-align: right; padding-bottom: 4px; }

.code-layout {
  flex: 1;
  min-height: 0;
  max-height: 51vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(16px, 2.6vw, 38px);
  margin-top: clamp(16px, 3vh, 30px);
}

.editor {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(12, 10, 26, 0.96), rgba(7, 6, 16, 0.98));
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.022);
  flex: 0 0 auto;
}
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; display: block; opacity: 0.8; }
.dots i:nth-child(1) { background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.editor-file { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.6); }
.editor-state { margin-left: auto; font-family: var(--mono); font-size: 8px; letter-spacing: 0.12em; color: rgba(255, 255, 255, 0.22); }

.code-lines {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 16px 14px;
  font-family: var(--mono);
  font-size: clamp(9.5px, 0.95vw, 12.5px);
  line-height: 1.88;
  letter-spacing: 0.01em;
  color: #d7d1e8;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.code-lines::-webkit-scrollbar { width: 5px; height: 5px; }
.code-lines::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.code-line { display: flex; white-space: pre; }
.ln {
  flex: 0 0 2.3em;
  text-align: right;
  padding-right: 1.1em;
  color: rgba(255, 255, 255, 0.16);
  user-select: none;
}
.line-code { flex: 1; }
.ch { opacity: 0; transition: opacity 0.08s linear; position: relative; }
.ch.on { opacity: 1; }
.ch.cursor::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 0.1em;
  width: 1px;
  height: 1.15em;
  background: var(--rose);
  box-shadow: 0 0 8px var(--rose);
  animation: blink 0.9s steps(1) infinite;
}
@keyframes blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.tok-kw { color: #ff9dbe; }
.tok-fn { color: #b9a8ff; }
.tok-num { color: #f6d8a7; }
.tok-str { color: #9ce0c7; }
.tok-cm { color: #6c6388; font-style: italic; }

.editor-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-top: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.32);
  flex: 0 0 auto;
}
.run-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6ee7a8;
  box-shadow: 0 0 8px rgba(110, 231, 168, 0.8);
  animation: corePulse 2s ease-in-out infinite;
}
@keyframes corePulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.4); opacity: 1; }
}
.editor-elapsed { margin-left: auto; color: rgba(255, 255, 255, 0.2); }

.heart-draw {
  position: relative;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(255, 126, 168, 0.12), transparent 62%),
    radial-gradient(ellipse at 50% 100%, rgba(123, 92, 255, 0.12), transparent 60%),
    #070611;
  box-shadow: 0 40px 100px -50px rgba(255, 95, 142, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.heart-draw canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.run-badge {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.38);
}
.run-badge i { width: 4px; height: 4px; border-radius: 50%; background: #6ee7a8; box-shadow: 0 0 7px #6ee7a8; }
.heart-caption {
  position: absolute;
  right: 16px;
  bottom: 16px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.26);
}
.heart-caption .hl { color: var(--rose); }

.scene-stats {
  display: flex;
  gap: clamp(28px, 5.5vw, 70px);
  margin-top: clamp(14px, 2.2vh, 24px);
  padding-top: clamp(12px, 1.8vh, 18px);
  border-top: 1px solid var(--line-2);
  flex: 0 0 auto;
}
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat strong {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.4rem, 2.3vw, 2rem);
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat strong em { font-style: normal; font-size: 0.4em; letter-spacing: 0.14em; }
.stat span { font-size: 10px; letter-spacing: 0.1em; color: var(--muted-2); }

/* =========================================================
   SCENE 03 · WORDS
   ========================================================= */

.scene-words {
  background:
    radial-gradient(ellipse 900px 600px at 50% 52%, rgba(73, 48, 145, 0.2), transparent 65%),
    var(--bg);
}
.words-glow {
  position: absolute;
  inset: 12% 16%;
  z-index: 1;
  background: radial-gradient(ellipse at center, rgba(255, 143, 177, 0.1), rgba(123, 92, 255, 0.06) 45%, transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
.words-head {
  position: absolute;
  top: 10.5vh;
  left: 0;
  right: 0;
  z-index: 4;
  text-align: center;
  padding: 0 6vw;
  pointer-events: none;
}
.words-head .scene-title { margin-top: 14px; }
.particle-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.particle-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.words-caption {
  position: absolute;
  bottom: 10.5vh;
  left: 0;
  right: 0;
  z-index: 4;
  text-align: center;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.26em;
  color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

/* =========================================================
   SCENE 04 · MEMORY
   ========================================================= */

.scene-memory {
  background:
    radial-gradient(1000px 620px at 90% 12%, rgba(104, 64, 160, 0.12), transparent 60%),
    radial-gradient(700px 500px at 6% 80%, rgba(255, 95, 142, 0.07), transparent 65%),
    var(--bg);
}

.memory-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 3vw;
  margin-bottom: clamp(18px, 3vh, 30px);
  flex: 0 0 auto;
}
.memory-count {
  font-family: var(--serif);
  font-size: clamp(2rem, 3.6vw, 3.2rem);
  line-height: 1;
  color: var(--gold);
  white-space: nowrap;
}
.memory-count em {
  font-style: normal;
  margin-left: 6px;
  font-size: 0.28em;
  letter-spacing: 0.12em;
  color: var(--muted-2);
}

.memory-deck {
  flex: 0 0 auto;
  min-height: 0;
  height: clamp(330px, 43vh, 420px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vw, 26px);
  margin-top: clamp(4px, 1vh, 12px);
  perspective: 1500px;
}

.memory-card {
  position: relative;
  flex: 1 1 0;
  max-width: 278px;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012) 60%);
  box-shadow: 0 30px 80px -50px rgba(0, 0, 0, 0.9);
  transform: rotateY(var(--ry, 0deg)) translateY(1.5vh) scale(0.9);
  opacity: 0.46;
  filter: blur(1.2px);
  transition:
    transform 1s cubic-bezier(0.19, 1, 0.22, 1),
    opacity 0.8s ease,
    filter 0.8s ease,
    border-color 0.5s,
    box-shadow 0.8s;
  transform-style: preserve-3d;
}
.memory-card.is-focus {
  transform: rotateY(0deg) translateY(-1vh) scale(1.02);
  opacity: 1;
  filter: blur(0);
  border-color: rgba(255, 157, 190, 0.32);
  box-shadow: 0 40px 100px -40px rgba(255, 95, 142, 0.38);
  z-index: 2;
}

.memory-art {
  position: relative;
  flex: 0 0 42%;
  min-height: 98px;
  overflow: hidden;
  background: #080713;
}
.memory-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform 1.4s cubic-bezier(0.2, 0.65, 0.2, 1); }
.memory-card.is-focus:hover .memory-art canvas { transform: scale(1.045); }
.memory-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(7, 6, 18, 0.78) 100%);
  pointer-events: none;
}
.memory-tag {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(5, 4, 14, 0.4);
  backdrop-filter: blur(10px);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.6);
}
.memory-tag i { width: 3.5px; height: 3.5px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 6px var(--rose); }

.memory-body {
  position: relative;
  flex: 1;
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.memory-index {
  position: absolute;
  right: 18px;
  top: 10px;
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.045);
  pointer-events: none;
}
.memory-body h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(18px, 1.55vw, 22px);
  letter-spacing: 0.16em;
  color: #f6efff;
}
.memory-body p {
  margin-top: 8px;
  font-size: clamp(10.5px, 0.82vw, 12px);
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.deck-hint {
  flex: 0 0 auto;
  margin-top: clamp(12px, 2vh, 20px);
  text-align: center;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.2);
}

/* =========================================================
   SCENE 05 · PULSE
   ========================================================= */

.scene-pulse {
  background:
    radial-gradient(900px 560px at 50% 52%, rgba(140, 39, 84, 0.14), transparent 65%),
    var(--bg);
}

.pulse-inner { justify-content: center; align-items: center; }

.ecg-wrap {
  position: relative;
  width: 100%;
  height: min(35vh, 310px);
  margin-top: clamp(22px, 4vh, 40px);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(8, 7, 20, 0.6);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6), 0 40px 100px -60px rgba(255, 95, 142, 0.4);
  flex: 0 0 auto;
}
.ecg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.032) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at 50% 50%, black 35%, transparent 88%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, black 35%, transparent 88%);
}
.ecg-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.bpm {
  position: absolute;
  top: 18px;
  right: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  pointer-events: none;
}
.bpm strong {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 3.2vw, 2.9rem);
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.bpm strong em {
  font-style: normal;
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--muted-2);
  -webkit-text-fill-color: var(--muted-2);
}
.bpm-note { font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.16em; color: rgba(255, 255, 255, 0.24); }

/* =========================================================
   SCENE 06 · GRAVITY
   ========================================================= */

.scene-heart {
  background:
    radial-gradient(700px 620px at 50% 56%, rgba(255, 95, 142, 0.12), transparent 66%),
    radial-gradient(900px 700px at 50% 40%, rgba(123, 92, 255, 0.1), transparent 70%),
    var(--bg);
}

.heart-inner { justify-content: center; align-items: center; }
.heart-stage {
  position: relative;
  width: min(54vh, 550px);
  max-width: 72vw;
  aspect-ratio: 1 / 1;
  margin-top: clamp(6px, 1.4vh, 14px);
  flex: 0 0 auto;
}
.heart-stage::before {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 126, 168, 0.14), rgba(123, 92, 255, 0.06) 50%, transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
.heart-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.heart-stage canvas:active { cursor: grabbing; }
.heart-hint {
  position: absolute;
  left: 50%;
  bottom: -2%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

/* =========================================================
   SCENE 07 · ASK
   ========================================================= */

.scene-ask { background: var(--bg); }
.scene-ask .scene-bg { z-index: 0; }
.finale-glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(255, 126, 168, 0.09), transparent 52%),
    radial-gradient(ellipse at 50% 100%, rgba(123, 92, 255, 0.12), transparent 60%);
}
.ask-inner { max-width: 1000px; align-items: center; justify-content: center; }

.ask-swap { display: grid; place-items: center; width: 100%; }
.ask-swap > * { grid-area: 1 / 1; width: 100%; }

.ask-copy {
  text-align: center;
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.65, 0.2, 1), visibility 0.9s;
}
.scene-ask.answered .ask-copy {
  opacity: 0;
  transform: translateY(-28px) scale(0.985);
  visibility: hidden;
  pointer-events: none;
}

.ask-title {
  margin-top: clamp(14px, 2.4vh, 22px);
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 4.5vw, 4rem);
  line-height: 1.38;
  letter-spacing: 0.035em;
  text-shadow: 0 10px 80px rgba(255, 95, 142, 0.18);
}
.ask-sub {
  margin-top: clamp(14px, 2.4vh, 24px);
  font-size: clamp(12px, 1.1vw, 14px);
  line-height: 2.05;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ask-actions {
  margin-top: clamp(24px, 4.4vh, 42px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.btn-yes {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 17px 42px;
  border-radius: 999px;
  background: var(--grad);
  color: #2a1020;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  box-shadow: 0 18px 60px -12px rgba(255, 126, 168, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.5s;
}
.btn-yes:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 24px 80px -10px rgba(255, 126, 168, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.btn-yes:active { transform: translateY(-1px) scale(0.99); }
.btn-yes-glow {
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  transform: rotate(18deg);
  animation: sheen 4.2s ease-in-out infinite;
  z-index: -1;
}
@keyframes sheen {
  0%, 55% { left: -60%; }
  85%, 100% { left: 130%; }
}
.btn-yes-text { position: relative; z-index: 2; }
.btn-yes-heart { position: relative; z-index: 2; font-size: 12px; color: #7d1f3f; animation: heartBeat 1.6s ease-in-out infinite; }
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.25); }
  24% { transform: scale(1); }
  36% { transform: scale(1.18); }
  48% { transform: scale(1); }
}

.btn-later {
  padding: 15px 26px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.4s, color 0.4s;
}
.btn-later:hover { border-color: rgba(246, 216, 167, 0.45); color: var(--gold); }

.ask-note {
  margin-top: clamp(14px, 2.4vh, 24px);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.26);
}

.answer-card {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
  padding: clamp(28px, 4vw, 50px) clamp(24px, 4vw, 58px);
  border: 1px solid rgba(246, 216, 167, 0.25);
  border-radius: 26px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 143, 177, 0.14), transparent 60%),
    rgba(10, 8, 22, 0.74);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 50px 120px -40px rgba(255, 95, 142, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(34px) scale(0.96);
  transition: opacity 1s ease 0.25s, transform 1s cubic-bezier(0.19, 1, 0.22, 1) 0.25s, visibility 1s;
  overflow: hidden;
}
.scene-ask.answered .answer-card {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.answer-kicker { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.34em; color: var(--gold); }
.answer-card h3 {
  margin-top: 14px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1.45;
  letter-spacing: 0.04em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.answer-body {
  margin-top: 16px;
  font-size: 13px;
  line-height: 2.05;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.answer-sign {
  margin-top: clamp(18px, 3vh, 30px);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  justify-content: flex-end;
}
.sign-line { flex: 0 0 42px; height: 1px; margin-top: 10px; background: linear-gradient(90deg, transparent, rgba(246, 216, 167, 0.5)); }
.answer-sign p { text-align: right; font-size: 11px; line-height: 1.9; letter-spacing: 0.05em; color: rgba(243, 237, 250, 0.7); }
.answer-sign em { font-style: normal; font-family: var(--mono); font-size: 8px; letter-spacing: 0.18em; color: var(--muted-2); }
.answer-heart {
  position: absolute;
  right: -18px;
  bottom: -34px;
  font-size: 140px;
  line-height: 1;
  color: rgba(255, 126, 168, 0.06);
  pointer-events: none;
  transform: rotate(-12deg);
}

.ask-foot {
  margin-top: clamp(16px, 3vh, 30px);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.22);
  text-align: center;
}

/* ---------- loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 7vw;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(48, 33, 89, 0.5), transparent 58%),
    radial-gradient(ellipse at 50% 100%, rgba(101, 35, 72, 0.28), transparent 60%),
    #03030a;
  transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 1.2s;
}
.loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-inner { position: relative; z-index: 2; max-width: 560px; text-align: center; }

.loader-glyph { position: relative; width: 74px; height: 74px; margin: 0 auto 34px; display: grid; place-items: center; }
.glyph-core {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff4dd;
  box-shadow: 0 0 18px 4px rgba(255, 224, 170, 0.9), 0 0 60px 16px rgba(255, 143, 177, 0.45);
  animation: loaderCore 2.6s ease-in-out infinite;
}
.glyph-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(246, 216, 167, 0.22);
  border-radius: 50%;
  animation: loaderRing 4s ease-out infinite;
}
.glyph-ring.r2 { animation-delay: 2s; }
@keyframes loaderRing {
  0% { transform: scale(0.25); opacity: 0; }
  30% { opacity: 0.55; }
  100% { transform: scale(1.15); opacity: 0; }
}
@keyframes loaderCore {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.45); opacity: 1; }
}

.sky-star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px rgba(255, 240, 210, 0.55);
  animation: twinkle 4s ease-in-out infinite;
}
.sky-star.s1 { top: 18%; left: 22%; animation-delay: 0.3s; }
.sky-star.s2 { top: 30%; left: 78%; animation-delay: 1.2s; }
.sky-star.s3 { top: 62%; left: 12%; animation-delay: 2.1s; }
.sky-star.s4 { top: 74%; left: 84%; animation-delay: 0.8s; }
.sky-star.s5 { top: 12%; left: 58%; animation-delay: 1.7s; }
.sky-star.s6 { top: 52%; left: 90%; animation-delay: 2.6s; }
@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.35); }
}

.loader-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 0.42em; color: rgba(246, 216, 167, 0.6); }
.loader-title {
  margin-top: 20px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  letter-spacing: 0.08em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.loader-sub { margin-top: 18px; font-size: 13px; line-height: 2.1; letter-spacing: 0.08em; color: var(--muted); }

.btn-ignite {
  position: relative;
  margin-top: 34px;
  padding: 16px 40px;
  border: 1px solid rgba(246, 216, 167, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  letter-spacing: 0.24em;
  color: #f8ecd9;
  overflow: hidden;
  transition: color 0.5s, border-color 0.5s, box-shadow 0.6s;
  isolation: isolate;
}
.btn-ignite span { position: relative; z-index: 2; }
.btn-ignite .btn-ignite-glow {
  position: absolute;
  inset: -2px;
  z-index: 1;
  border-radius: inherit;
  background: var(--grad);
  opacity: 0;
  transition: opacity 0.55s ease;
}
.btn-ignite:hover { color: #1b1020; border-color: transparent; box-shadow: 0 12px 60px rgba(255, 143, 177, 0.45); }
.btn-ignite:hover .btn-ignite-glow { opacity: 1; }

.loader-hint { margin-top: 20px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.18em; color: rgba(167, 157, 189, 0.55); }
.loader-foot {
  position: absolute;
  bottom: 26px;
  left: 0;
  width: 100%;
  text-align: center;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.2);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 10vw;
  background: #04040c;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  line-height: 2;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1024px) {
  .scene-inner { width: min(1100px, 90vw); }
  .brand em { display: none; }
  .memory-card { max-width: 240px; }
  .memory-body p { font-size: 10.5px; }
}

@media (max-width: 900px) {
  .scene-inner { width: calc(100% - 48px); padding-top: 10vh; padding-bottom: 10vh; }
  .hero-title { font-size: clamp(2.4rem, 10.5vw, 4.2rem); }
  .hero-inner { padding-top: 9vh; }
  .scene-watermark { font-size: 30vw; right: 2vw; bottom: 14vh; }

  .code-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .code-head .scene-sub { text-align: left; max-width: 100%; }
  .code-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 0.92fr;
    max-height: none;
    flex: 1;
    margin-top: 16px;
  }
  .scene-stats { display: none; }
  .code-lines { font-size: 9.5px; padding: 14px 12px; }
  .editor-status { display: none; }

  .memory-head { margin-bottom: 12px; }
  .memory-deck {
    position: relative;
    display: block;
    height: auto;
    flex: 1;
    min-height: 0;
    margin-top: 0;
  }
  .memory-card {
    position: absolute;
    inset: 0;
    max-width: none;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.94);
    filter: blur(8px);
    transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.19, 1, 0.22, 1), filter 0.8s ease, visibility 0s linear 0.9s;
  }
  .memory-card.is-focus {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    filter: blur(0);
    transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.19, 1, 0.22, 1), filter 0.8s ease, visibility 0s;
  }
  .memory-art { flex: 0 0 44%; }
  .memory-body { padding: 16px 20px; }
  .memory-body h3 { font-size: 20px; }
  .memory-body p { font-size: 12px; max-width: 34ch; }
  .deck-hint { margin-top: 10px; }

  .ecg-wrap { height: min(30vh, 280px); }
  .heart-stage { width: min(46vh, 440px); max-width: 74vw; }
  .ask-title { font-size: clamp(1.8rem, 6.4vw, 2.8rem); }
  .hud-hint { display: none; }
  .hud-track { max-width: 180px; }
  .hud-bottom { gap: 10px; }
  .scene-meta { bottom: 12.5vh; }
}

@media (max-width: 640px) {
  .scene-inner { width: calc(100% - 40px); padding-top: 9vh; padding-bottom: 9vh; }
  .hud { padding-left: 20px; padding-right: 20px; }
  .hud-top { padding-top: 16px; }
  .brand { font-size: 8px; letter-spacing: 0.24em; gap: 8px; }
  .brand-mark { font-size: 10px; }
  .chapter-label { display: none; }
  .sound-btn { padding: 8px 12px; gap: 0; }
  .sound-label { display: inline; font-size: 8px; letter-spacing: 0.14em; }
  .eq { display: none; }
  .hud-bottom { padding-bottom: 14px; gap: 8px; }
  .hud-bottom-left { gap: 8px; }
  .hud-arrow { width: 26px; height: 26px; font-size: 10px; }
  .scene-counter { font-size: 7.5px; }
  .hud-track { max-width: 70px; margin: 0 4px; }
  .next-btn { padding: 8px 12px; font-size: 9px; gap: 6px; }

  .eyebrow { font-size: 8px; letter-spacing: 0.26em; gap: 10px; }
  .eyebrow::before { width: 22px; }
  .scene-title { font-size: clamp(1.55rem, 6.6vw, 2.2rem); line-height: 1.36; }
  .scene-sub { font-size: 12px; line-height: 1.9; }
  .hero-title { font-size: clamp(2.15rem, 10.8vw, 3.2rem); letter-spacing: 0.01em; }
  .hero-sub { font-size: 12px; line-height: 1.95; }
  .enter-hint { margin-top: 28px; font-size: 10px; }
  .hint-orbit { width: 32px; height: 32px; }
  .scene-meta { display: none; }

  .code-head .scene-sub { display: none; }
  .code-layout { grid-template-rows: 1.05fr 0.9fr; gap: 10px; margin-top: 12px; }
  .editor-bar { padding: 8px 12px; }
  .code-lines { font-size: 8.5px; line-height: 1.8; padding: 10px 10px; }
  .ln { flex-basis: 2em; padding-right: 0.7em; }
  .editor-state, .editor-status { display: none; }
  .heart-draw { border-radius: 14px; }
  .heart-caption { display: none; }
  .run-badge { font-size: 7px; left: 12px; bottom: 12px; }
  .scene-watermark { display: none; }

  .words-head { top: 9.5vh; }
  .words-head .scene-title { font-size: clamp(1.5rem, 6.4vw, 2rem); }
  .words-caption { bottom: 10vh; font-size: 7px; letter-spacing: 0.18em; }

  .memory-head { align-items: center; }
  .memory-count { font-size: 1.9rem; }
  .memory-card { border-radius: 16px; }
  .memory-art { flex: 0 0 42%; }
  .memory-body { padding: 14px 18px; }
  .memory-body h3 { font-size: 19px; }
  .memory-body p { font-size: 11.5px; line-height: 1.85; }
  .deck-hint { font-size: 7px; }

  .ecg-wrap { height: 27vh; border-radius: 16px; margin-top: 16px; }
  .bpm { top: 12px; right: 14px; }
  .bpm strong { font-size: 1.8rem; }
  .bpm-note { font-size: 6.5px; }
  .small-caption { font-size: 7px; letter-spacing: 0.16em; }

  .heart-stage { width: 44vh; max-width: 82vw; }
  .heart-hint { font-size: 6.5px; letter-spacing: 0.14em; }

  .ask-title { font-size: clamp(1.6rem, 7.4vw, 2.2rem); }
  .ask-sub { font-size: 11.5px; }
  .ask-actions { flex-direction: column; gap: 12px; margin-top: 24px; }
  .btn-yes { width: min(270px, 100%); padding: 16px 26px; }
  .btn-later { width: min(190px, 100%); padding: 13px 22px; }
  .ask-note { margin-top: 16px; font-size: 7px; line-height: 1.9; }
  .ask-foot { font-size: 7px; }
  .answer-card { padding: 26px 22px; border-radius: 20px; }
  .answer-card h3 { font-size: 1.4rem; }
  .answer-body { font-size: 12px; }
  .answer-sign { margin-top: 16px; }

  .loader { padding: 8vw; }
  .loader-title { font-size: 2rem; }
  .loader-sub { font-size: 12px; }
  .btn-ignite { margin-top: 28px; padding: 15px 28px; font-size: 11px; }
  .loader-foot { font-size: 6.5px; letter-spacing: 0.2em; }
}

@media (max-height: 720px) {
  .scene-inner { padding-top: 9vh; padding-bottom: 9vh; }
  .hero-inner { padding-top: 8vh; }
  .hero-title { font-size: clamp(2.2rem, 6.4vw, 4.6rem); }
  .enter-hint { margin-top: 24px; }
  .scene-title { font-size: clamp(1.6rem, 3.1vw, 2.6rem); }
  .scene-stats { display: none; }
  .code-layout { max-height: 54vh; }
  .memory-deck { max-height: 50vh; }
  .ecg-wrap { height: min(31vh, 250px); }
  .heart-stage { width: min(48vh, 420px); }
  .ask-title { font-size: clamp(1.8rem, 3.8vw, 3rem); }
  .ask-note { display: none; }
  .words-caption { bottom: 9vh; }
}

@media (max-height: 600px) {
  .editor { display: none; }
  .code-layout { grid-template-rows: 1fr; }
  .memory-deck { max-height: 46vh; }
  .memory-body p { display: none; }
  .scene-head .scene-sub { display: none; }
  .ask-foot { display: none; }
}

@media (max-width: 900px) and (max-height: 700px) {
  .memory-art { flex: 0 0 34%; }
  .memory-body p { font-size: 10.5px; }
  .heart-stage { width: min(39vh, 330px); }
}

@media (hover: none) {
  .cursor-glow { display: none; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .scene { filter: none; transform: none; }
  .anim, .hero-title .line > span { opacity: 1 !important; transform: none !important; filter: none !important; }
  .scene.is-active { filter: none; transform: none; }
  .btn-yes-glow { display: none; }
}
