:root {
  color-scheme: dark;
  --ink: #fff8eb;
  --paper: #fff1d2;
  --muted: #d8cab7;
  --black: #04050a;
  --panel: rgba(6, 8, 14, 0.78);
  --deep: rgba(3, 4, 8, 0.92);
  --gold: #f3c76a;
  --cyan: #5ee6ff;
  --red: #ff4058;
  --green: #8be28b;
  --blue: #6b8cff;
  --violet: #b395ff;
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--black);
  color: var(--ink);
}

button {
  font: inherit;
}

.app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #05050a;
}

.scene-bg,
.concept-skin,
.pulse-layer,
.glitch-veil,
.suggestion-layer,
.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.scene-bg {
  z-index: 0;
  transition: filter 420ms ease, transform 420ms ease, opacity 420ms ease;
  transform: scale(1.025);
  filter: saturate(1.08) contrast(1.08) brightness(0.86);
}

.scene-bg.school {
  background:
    linear-gradient(180deg, rgba(5, 8, 13, 0.06), rgba(3, 4, 8, 0.72)),
    url("/assets/backgrounds/school.png") center / cover;
}

.scene-bg.clinic {
  background:
    linear-gradient(180deg, rgba(7, 10, 13, 0.08), rgba(3, 4, 8, 0.74)),
    url("/assets/backgrounds/clinic.png") center / cover;
}

.scene-bg.mansion {
  background:
    linear-gradient(180deg, rgba(9, 7, 13, 0.08), rgba(3, 4, 8, 0.76)),
    url("/assets/backgrounds/mansion.png") center / cover;
}

.scene-bg.event {
  background:
    linear-gradient(180deg, rgba(11, 8, 16, 0.08), rgba(3, 4, 8, 0.72)),
    url("/assets/backgrounds/event.png") center / cover;
}

.scene-bg.iwato,
.scene-bg.core {
  background:
    linear-gradient(180deg, rgba(5, 4, 7, 0.04), rgba(2, 2, 5, 0.74)),
    url("/assets/backgrounds/iwato-recode.png") center / cover;
}

.scene-bg.mountain {
  background:
    linear-gradient(180deg, rgba(3, 8, 16, 0.04), rgba(2, 3, 8, 0.78)),
    url("/assets/backgrounds/mugen-yamamiya.webp") center / cover;
}

.scene-bg.gorge-day {
  background:
    linear-gradient(180deg, rgba(4, 12, 14, 0.05), rgba(2, 5, 8, 0.58)),
    url("/assets/backgrounds/sealed-gorge-bridge.png") center / cover;
}

.scene-bg.gorge-road {
  background:
    linear-gradient(180deg, rgba(4, 8, 13, 0.03), rgba(1, 3, 7, 0.66)),
    url("/assets/backgrounds/sealed-gorge-approach.png") center / cover;
}

.scene-bg.gorge-night {
  background:
    linear-gradient(180deg, rgba(3, 6, 12, 0.05), rgba(1, 2, 6, 0.64)),
    url("/assets/backgrounds/sealed-gorge-night.png") center / cover;
}

.scene-bg.tunnel {
  background:
    linear-gradient(180deg, rgba(3, 8, 11, 0.12), rgba(1, 2, 5, 0.80)),
    url("/assets/backgrounds/last-line-tunnel.png") center / cover;
}

.scene-bg.settlement {
  background:
    linear-gradient(180deg, rgba(12, 8, 4, 0.04), rgba(2, 3, 7, 0.76)),
    url("/assets/backgrounds/kiregi-settlement.png") center / cover;
}

.scene-bg.ending {
  background:
    linear-gradient(180deg, rgba(3, 4, 8, 0.10), rgba(3, 4, 8, 0.70)),
    url("/assets/dizark-modern-cast.png") center / cover;
}

.concept-skin {
  z-index: 1;
  opacity: 0.22;
  mix-blend-mode: screen;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.8), transparent 16%, transparent 84%, rgba(0,0,0,0.82)),
    url("/assets/concepts/concept-c_boxbottom-core.png") center / cover;
}

.concept-skin.concept-a {
  opacity: 0.20;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.78), transparent 18%, transparent 82%, rgba(0,0,0,0.84)),
    url("/assets/concepts/concept-a_glass-relic.png") center / cover;
}

.concept-skin.concept-b {
  opacity: 0.26;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.75), transparent 18%, transparent 82%, rgba(0,0,0,0.78)),
    url("/assets/concepts/concept-b_retro-busstop.png") center / cover;
}

.concept-skin.concept-c {
  opacity: 0.24;
}

.scene-bg.gorge-day + .concept-skin,
.scene-bg.gorge-road + .concept-skin,
.scene-bg.gorge-night + .concept-skin {
  opacity: 0.09;
}

.pulse-layer {
  z-index: 2;
  opacity: 0.64;
  background:
    radial-gradient(circle at 50% 45%, rgba(243, 199, 106, 0.22), transparent 19rem),
    radial-gradient(circle at 15% 24%, rgba(94, 230, 255, 0.14), transparent 16rem),
    radial-gradient(circle at 86% 78%, rgba(255, 64, 88, 0.14), transparent 18rem);
  mix-blend-mode: screen;
}

body.effect-burst .pulse-layer.overdrive {
  animation: overdriveBg 600ms ease-in-out 2 alternate;
}

.glitch-veil {
  z-index: 3;
  opacity: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 64, 88, 0.18) 0 2px, transparent 2px 34px),
    linear-gradient(180deg, transparent, rgba(94, 230, 255, 0.08), transparent);
  mix-blend-mode: screen;
  transition: opacity 260ms ease;
}

.suggestion-layer {
  z-index: 6;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 64, 88, 0.18), transparent),
    repeating-linear-gradient(115deg, transparent 0 22px, rgba(94, 230, 255, 0.08) 22px 23px);
  mix-blend-mode: screen;
  transition: opacity 220ms ease;
}

body.has-suggestion .suggestion-layer {
  opacity: 0.38;
}

.scanline {
  z-index: 4;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 50% 110%, rgba(0,0,0,0.88), transparent 36rem);
  mix-blend-mode: screen;
}

.top-ui {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(10px, 1.8vw, 18px) clamp(12px, 3vw, 30px) 0;
}

.title-block p {
  margin: 0 0 4px;
  color: var(--cyan);
  font: 900 13px/1.1 ui-monospace, Consolas, monospace;
}

.audio-readout {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(330px, 44vw);
  margin-top: 8px;
  overflow: hidden;
  color: rgba(255, 248, 235, 0.68);
  font: 700 11px/1.2 ui-monospace, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(255, 248, 235, 0.42);
  border-radius: 50%;
  background: rgba(255, 248, 235, 0.22);
}

.audio-dot.active {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 12px rgba(139, 226, 139, 0.80);
}

.audio-dot.fallback {
  border-color: var(--red);
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 64, 88, 0.72);
}

h1 {
  margin: 0;
  font-size: clamp(27px, 4.1vw, 58px);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow:
    2px 2px 0 #050508,
    7px 7px 0 rgba(255, 64, 88, 0.25),
    0 0 22px rgba(243, 199, 106, 0.24);
}

.top-buttons {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.top-buttons button,
.sub-button,
.next-button,
.choice-list button,
.log-dialog button {
  min-height: 40px;
  border: 1px solid rgba(255, 248, 235, 0.28);
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(243,199,106,0.17), transparent 36%),
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04)),
    rgba(6, 8, 14, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 0 18px rgba(94, 230, 255, 0.06);
  cursor: pointer;
}

.top-buttons button {
  min-width: 72px;
  padding: 0 11px;
}

#localeButton {
  min-width: 48px;
  color: var(--cyan);
  font-family: ui-monospace, Consolas, monospace;
}

.top-buttons button:disabled,
.next-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.adv-screen {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(100vw, 1240px);
  min-height: 0;
  margin: 0 auto;
  padding: 9px clamp(10px, 2vw, 24px) clamp(10px, 2vw, 18px);
}

.scene-plate {
  justify-self: start;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  max-width: calc(100vw - 84px);
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid rgba(243, 199, 106, 0.46);
  border-left: 5px solid var(--gold);
  background:
    linear-gradient(90deg, rgba(243,199,106,0.14), transparent),
    rgba(3, 5, 10, 0.70);
  box-shadow: 0 0 28px rgba(243, 199, 106, 0.14);
  backdrop-filter: blur(12px);
}

.scene-plate span,
.scene-plate strong,
.scene-plate time,
.scene-plate small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-plate span {
  color: var(--muted);
  font-size: 15px;
}

.scene-plate strong {
  color: var(--gold);
  font-size: 15px;
}

.scene-plate time,
.scene-plate small {
  color: rgba(255, 248, 235, 0.72);
  font: 700 10px/1.2 ui-monospace, Consolas, monospace;
}

.scene-plate small {
  max-width: min(44vw, 420px);
}

.glyph-rail {
  position: absolute;
  top: 56px;
  right: clamp(5px, 1vw, 14px);
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(2, 25px);
  gap: 5px;
  width: 56px;
  max-height: calc(100% - 176px);
  overflow: hidden;
  padding: 7px 5px;
  border: 1px solid rgba(94, 230, 255, 0.26);
  background:
    linear-gradient(180deg, rgba(94,230,255,0.13), transparent),
    rgba(2, 5, 9, 0.62);
  backdrop-filter: blur(10px);
}

.glyph {
  position: relative;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(255, 248, 235, 0.18);
  color: rgba(255, 248, 235, 0.48);
  font: 900 13px/1 ui-monospace, Consolas, monospace;
}

.glyph::after {
  content: attr(data-code);
  position: absolute;
  right: 120%;
  top: 50%;
  display: none;
  padding: 3px 6px;
  color: var(--ink);
  background: rgba(3, 4, 8, 0.9);
  border: 1px solid rgba(243, 199, 106, 0.35);
  transform: translateY(-50%);
  white-space: nowrap;
}

.glyph:hover::after {
  display: block;
}

.glyph.active {
  border-color: var(--gold);
  color: var(--paper);
  background:
    radial-gradient(circle, rgba(243,199,106,0.42), transparent 62%),
    rgba(255, 64, 88, 0.10);
  box-shadow: 0 0 18px rgba(243,199,106,0.26);
  animation: glyphPulse 1.4s ease-in-out infinite alternate;
}

.stage {
  position: relative;
  min-height: 290px;
  overflow: hidden;
}

.scene-transition {
  position: absolute;
  top: 9px;
  left: 12px;
  z-index: 6;
  max-width: min(760px, calc(100% - 96px));
  margin: 0;
  padding: 8px 11px;
  border-left: 3px solid rgba(243,199,106,.72);
  color: rgba(255,248,235,.9);
  background: linear-gradient(90deg, rgba(3,6,11,.88), rgba(3,6,11,.5), transparent);
  font-size: 12px;
  line-height: 1.65;
  text-shadow: 0 1px 8px #000;
  pointer-events: none;
  animation: sceneTransitionIn 540ms ease both;
}

.scene-transition[hidden] { display: none; }

@keyframes sceneTransitionIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.cutin-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 340ms ease, filter 340ms ease;
}

.cutin-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(2, 3, 8, 0.82), transparent 42%, rgba(2, 3, 8, 0.28)),
    linear-gradient(0deg, rgba(2, 3, 8, 0.62), transparent 46%);
}

.cutin-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  filter: saturate(1.05) contrast(1.08);
  transform: scale(1.04);
  transition: transform 4s ease;
}

.cutin-layer.show {
  opacity: 1;
}

.cutin-layer.show img {
  transform: scale(1);
}

.cutin-caption {
  position: absolute;
  left: 16px;
  bottom: 13px;
  z-index: 2;
  color: var(--cyan);
  font: 900 12px/1 ui-monospace, Consolas, monospace;
  text-shadow: 0 0 12px rgba(94, 230, 255, 0.78);
}

.stage.has-cutin .sprite,
.stage.has-cutin .aura,
.stage.has-cutin .dizark-sigil {
  opacity: 0;
}

.decoy-info {
  position: absolute;
  top: 9px;
  left: 10px;
  z-index: 2;
  display: grid;
  gap: 3px;
  width: min(260px, 37vw);
  padding: 8px 10px;
  border: 1px solid rgba(94, 230, 255, 0.20);
  background: rgba(3, 5, 10, 0.46);
  color: rgba(216, 202, 183, 0.62);
  font: 700 10px/1.28 ui-monospace, Consolas, monospace;
  pointer-events: none;
  opacity: 0.72;
  transform: skewX(-4deg);
}

.decoy-info b {
  color: rgba(94, 230, 255, 0.86);
  font-size: 11px;
}

.decoy-info em {
  color: rgba(243, 199, 106, 0.72);
  font-style: normal;
}

.decoy-info.decay {
  border-color: rgba(255, 64, 88, 0.44);
  color: rgba(255, 165, 167, 0.74);
}

.aura {
  position: absolute;
  left: 50%;
  bottom: -4%;
  width: min(64vw, 650px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle, rgba(243,199,106,0.20), rgba(94,230,255,0.12) 43%, transparent 70%);
  filter: blur(10px);
  animation: auraIdle 3.2s ease-in-out infinite alternate;
}

.dizark-sigil {
  position: absolute;
  left: 50%;
  bottom: 2%;
  width: min(56vw, 550px);
  aspect-ratio: 1;
  border: 1px solid rgba(243, 199, 106, 0.42);
  border-radius: 50%;
  transform: translateX(-50%);
  animation: sigilSpin 22s linear infinite;
}

.dizark-sigil::before,
.dizark-sigil::after {
  content: "";
  position: absolute;
  inset: 13%;
  border: 1px dashed rgba(94, 230, 255, 0.25);
  border-radius: 50%;
}

.dizark-sigil::after {
  inset: 28%;
  border-color: rgba(255, 64, 88, 0.24);
  animation: sigilSpin 12s linear infinite reverse;
}

.sprite {
  --x: -50%;
  --base-y: 0px;
  --scale: 1;
  --stage-scale: 1;
  --character-scale: 1;
  --stage-y: 0px;
  --rot: 0deg;
  position: absolute;
  bottom: 0;
  z-index: 3;
  opacity: 0;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 28px 24px rgba(0,0,0,0.78));
  transition: opacity 180ms ease, filter 180ms ease;
  user-select: none;
  pointer-events: none;
  transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(var(--rot));
  mask-image:
    linear-gradient(90deg, transparent 0%, #000 13%, #000 87%, transparent 100%),
    linear-gradient(180deg, transparent 0%, #000 5%, #000 98%, transparent 100%);
  mask-composite: intersect;
}

.sprite.main {
  left: 50%;
  width: min(38vw, 370px);
  min-width: 230px;
  height: 100%;
  z-index: 5;
}

.sprite.side {
  width: min(29vw, 300px);
  min-width: 190px;
  height: 94%;
  z-index: 4;
  --scale: 0.92;
}

.stage[data-layout="duo"] .sprite.main {
  width: min(43vw, 430px);
  height: 104%;
  --stage-scale: 1.04;
  --stage-y: 4px;
}

.stage[data-layout="duo"] .sprite.side {
  width: min(35vw, 365px);
  height: 100%;
  --stage-scale: 1.05;
  --stage-y: 2px;
}

.stage[data-layout="trio"] .sprite.main {
  width: min(37vw, 390px);
  height: 104%;
  --stage-scale: 1.08;
  --stage-y: 4px;
}

.stage[data-layout="trio"] .sprite.side {
  width: min(31vw, 335px);
  height: 98%;
  --stage-scale: 1.05;
}

.sprite[data-character="kurumi"],
.sprite[data-character="himeko"] {
  --stage-scale: 1.08;
}

.sprite[data-character="mikage"],
.sprite[data-character="rikka"] {
  --stage-scale: 1.10;
}

.sprite.left {
  left: 29%;
}

.sprite.right {
  left: 71%;
}

.stage.trio .sprite.left {
  left: 24%;
}

.stage.trio .sprite.right {
  left: 76%;
}

.sprite.active {
  opacity: 1;
}

.sprite.side.active {
  opacity: 1;
}

.sprite.idol {
  animation: idolIdle 7.4s ease-in-out infinite;
}

.sprite.speaking {
  animation: talkBounce 1.35s ease-in-out infinite;
  filter: drop-shadow(0 30px 24px rgba(0,0,0,0.78)) brightness(1.11);
}

.sprite.smile {
  filter: drop-shadow(0 30px 24px rgba(0,0,0,0.78)) brightness(1.13) saturate(1.12);
}

.sprite.stern {
  filter: drop-shadow(0 30px 24px rgba(0,0,0,0.78)) contrast(1.11) saturate(1.08);
}

.sprite.soft {
  filter: drop-shadow(0 30px 24px rgba(0,0,0,0.78)) brightness(1.07) saturate(0.94);
}

.sprite.anxious,
.sprite.shock {
  filter: drop-shadow(0 30px 24px rgba(0,0,0,0.78)) saturate(1.55) hue-rotate(-12deg);
}

.sprite.aura {
  filter: drop-shadow(0 0 28px rgba(94,230,255,0.55)) brightness(1.08);
}

.sprite.shock {
  animation: shock 340ms linear 1;
}

body.effect-burst .sprite.overdrive {
  animation: overdriveSprite 600ms steps(2) 2;
}

.pose-front { --scale: 1; --rot: 0deg; }
.pose-smile { --scale: 1.02; --rot: -0.2deg; }
.pose-anxious { --scale: 0.98; --rot: 0.4deg; }
.pose-pain { --scale: 0.96; --rot: -1.2deg; --base-y: 9px; }
.pose-resolve { --scale: 1.04; --rot: 0deg; }
.pose-side-glance { --scale: 0.99; --rot: 0.8deg; }
.pose-laugh-weak { --scale: 1.01; --rot: -0.6deg; }
.pose-dark-aura { --scale: 1.04; --rot: 0.2deg; }
.pose-collapse { --scale: 0.92; --rot: -2deg; --base-y: 20px; }
.pose-true-self { --scale: 1.06; --rot: 0deg; }
.pose-stern { --scale: 1.01; --rot: 0.2deg; }
.pose-soft { --scale: 1; --rot: -0.3deg; }
.pose-record { --scale: 1.01; --rot: 0.7deg; }
.pose-idol { --scale: 1.04; --rot: -0.5deg; }
.pose-freeze { --scale: 0.99; --rot: 0deg; }
.pose-guard { --scale: 1.02; --rot: 0.3deg; }
.pose-labyrinth { --scale: 1.03; --rot: 0.8deg; }

.closeup {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0;
  object-fit: cover;
  object-position: center 18%;
  filter: saturate(0.94) contrast(1.10);
  mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
  pointer-events: none;
  transition: opacity 220ms ease;
}

.closeup.show {
  opacity: 0.34;
}

.message-window {
  position: relative;
  z-index: 15;
  border: 1px solid rgba(255, 248, 235, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(243,199,106,0.18), transparent 22%),
    linear-gradient(180deg, rgba(16, 20, 30, 0.88), rgba(4, 5, 10, 0.97));
  box-shadow:
    0 18px 48px rgba(0,0,0,0.62),
    inset 0 0 0 1px rgba(255,255,255,0.07),
    inset 0 0 26px rgba(94,230,255,0.06);
  backdrop-filter: blur(16px);
}

.message-window::before,
.message-window::after {
  content: "";
  position: absolute;
  pointer-events: none;
  width: 72px;
  height: 22px;
  border-color: var(--gold);
  opacity: 0.78;
}

.message-window::before {
  left: 8px;
  top: 8px;
  border-left: 2px solid;
  border-top: 2px solid;
}

.message-window::after {
  right: 8px;
  bottom: 8px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.speaker-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 42px;
  padding: 14px 20px 0;
}

.speaker-line span {
  font-size: clamp(23px, 2.9vw, 32px);
  font-weight: 900;
  text-shadow: 0 0 15px rgba(243,199,106,0.24);
}

.speaker-line b {
  color: var(--cyan);
  font-size: 15px;
  font-weight: 900;
}

.speaker-type {
  color: rgba(216, 202, 183, 0.84);
  border: 1px solid rgba(216, 202, 183, 0.38);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
}

.message-window[data-line-kind="narration"] {
  border-color: rgba(94, 230, 255, 0.46);
  background:
    linear-gradient(135deg, rgba(94, 230, 255, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(11, 22, 34, 0.92), rgba(4, 8, 14, 0.98));
}

.message-window[data-line-kind="narration"] .speaker-line span,
.message-window[data-line-kind="narration"] .speaker-type {
  color: var(--cyan);
}

.message-window[data-line-kind="narration"] .speaker-type {
  border-color: rgba(94, 230, 255, 0.55);
}

.message-window[data-line-kind="monologue"] {
  border-color: rgba(243, 199, 106, 0.58);
}

.message-window[data-line-kind="monologue"] .speaker-type {
  color: var(--gold);
  border-color: rgba(243, 199, 106, 0.56);
}

.message-window[data-line-kind="system"] .speaker-type {
  color: #ff5268;
  border-color: rgba(255, 82, 104, 0.6);
}


.character-note {
  min-height: 30px;
  padding: 3px 20px 0;
  overflow: hidden;
  color: rgba(216, 202, 183, 0.80);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.reading-guide {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 22px;
  padding: 2px 20px 1px;
  overflow-x: auto;
  overflow-y: hidden;
  color: rgba(230, 241, 242, 0.86);
  font-size: 12.5px;
  line-height: 1.35;
  scrollbar-width: none;
}

.reading-guide::-webkit-scrollbar {
  display: none;
}

.reading-guide[hidden] {
  display: none;
}

.reading-guide b {
  flex: 0 0 auto;
  color: var(--cyan);
  font: 900 10.5px/1 ui-monospace, Consolas, monospace;
}

.reading-guide span {
  flex: 0 0 auto;
  white-space: nowrap;
}

#dialogueText {
  min-height: 112px;
  margin: 0;
  padding: 10px 20px 4px;
  color: var(--ink);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.65;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

#dialogueText .char {
  display: inline-block;
  opacity: 0;
  filter: blur(5px);
  transform: translateY(0.35em);
  animation: textRise 260ms ease forwards;
}

#dialogueText .suggest {
  color: #ff5268;
  text-shadow: 0 0 10px rgba(255, 64, 88, 0.72);
}

#dialogueText .bug {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(94, 230, 255, 0.7);
}

#dialogueText.instant .char {
  opacity: 1;
  filter: none;
  transform: none;
  animation: none;
}

.choice-list {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  padding: 8px 20px 0;
}

.choice-list button {
  width: 100%;
  min-height: 47px;
  padding: 9px 14px 9px 18px;
  border-left: 5px solid var(--cyan);
  text-align: left;
  font-weight: 800;
  line-height: 1.35;
}

.choice-list button::before {
  content: "◇ ";
  color: var(--gold);
}

.choice-char {
  display: inline;
}

.choice-char.suggest {
  color: #ff5268;
  text-shadow: 0 0 8px rgba(255, 64, 88, 0.72);
}

.choice-char.bug {
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(94, 230, 255, 0.62);
}

.choice-list button.has-choice-suggestion {
  border-left-color: var(--red);
  box-shadow:
    inset 0 0 0 1px rgba(255, 64, 88, 0.12),
    0 0 18px rgba(255, 64, 88, 0.12);
}

.choice-list button:hover,
.choice-list button:focus-visible {
  border-color: var(--gold);
  background:
    linear-gradient(90deg, rgba(243, 199, 106, 0.24), transparent),
    rgba(255,255,255,0.10);
}

.command-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 20px 16px;
}

.sub-button {
  min-width: 62px;
  color: var(--muted);
}

.next-button {
  min-width: 130px;
  padding: 0 20px;
  border-color: rgba(243, 199, 106, 0.62);
  background:
    linear-gradient(180deg, rgba(243, 199, 106, 0.26), rgba(255, 64, 88, 0.18)),
    rgba(20, 12, 16, 0.86);
  font-weight: 900;
}

.status-row {
  position: relative;
  z-index: 16;
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding-top: 8px;
}

.status-row span {
  min-width: 76px;
  padding: 4px 9px;
  border: 1px solid rgba(255, 248, 235, 0.20);
  background: rgba(0,0,0,0.38);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.status-row b {
  color: var(--ink);
  font-size: 16px;
}

.log-dialog {
  width: min(780px, calc(100vw - 20px));
  border: 1px solid rgba(255, 248, 235, 0.30);
  border-radius: 8px;
  background: #101722;
  color: var(--ink);
  padding: 0;
}

.log-dialog::backdrop {
  background: rgba(0,0,0,0.68);
}

.log-dialog form {
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(760px, calc(100dvh - 28px));
}

.log-dialog header {
  display: flex;
  justify-content: space-between;
  padding: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}

#logBody {
  min-height: 0;
  max-height: 66vh;
  overflow: auto;
  padding: 15px;
}

#logBody .log-entry {
  padding: 12px 0 14px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}

#logBody .log-entry header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
}

#logBody .log-entry header span {
  padding: 3px 6px;
  color: var(--cyan);
  border: 1px solid rgba(94,230,255,.28);
  font: 800 9px/1 ui-monospace, Consolas, monospace;
}

#logBody .log-entry.choice {
  padding-left: 12px;
  border-left: 3px solid var(--gold);
}

#logBody .log-entry.choice header strong { color: var(--gold); }

#logBody .log-entry p,
#logBody .log-empty {
  margin: 6px 0 0;
  line-height: 1.72;
}

.log-dialog footer {
  display: flex;
  justify-content: flex-start;
  padding: 10px 13px;
  border-top: 1px solid rgba(255,255,255,.14);
}

.log-close-button { min-width: 120px; }

body.impact-shake .stage {
  animation: impact-shake 440ms cubic-bezier(.22,.7,.3,1) both;
}

body.shockwave .glitch-veil {
  opacity: 0.72;
  animation: glitchSlide 280ms linear 2;
}

body.flag-a .pulse-layer {
  background:
    radial-gradient(circle at 50% 45%, rgba(255,64,88,0.25), transparent 19rem),
    radial-gradient(circle at 15% 24%, rgba(94,230,255,0.12), transparent 16rem);
}

body.flag-b .glitch-veil,
body.flag-r .glitch-veil,
body.flag-x .glitch-veil {
  opacity: 0.35;
}

body.deep-glitch .glitch-veil {
  opacity: 0.45;
}

body.effect-burst.deep-glitch .concept-skin {
  animation: conceptTear 1.2s steps(2) 1;
}

body.deep-glitch .message-window {
  box-shadow:
    0 18px 48px rgba(0,0,0,0.72),
    inset 0 0 0 1px rgba(255,255,255,0.08),
    inset 0 0 34px rgba(255,64,88,0.16),
    0 0 42px rgba(94,230,255,0.16);
}

body.flag-e .scene-bg {
  filter: saturate(0.72) contrast(1.1) brightness(0.76);
}

body.flag-k .scene-bg {
  filter: saturate(1.1) contrast(1.18) brightness(0.62);
}

body.flag-g .dizark-sigil {
  box-shadow: 0 0 42px rgba(243,199,106,0.34);
}

@keyframes idolIdle {
  0%, 100% {
    transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(calc(var(--rot) - 0.16deg));
  }
  50% {
    transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y) - 8px)) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(calc(var(--rot) + 0.20deg));
  }
}

@keyframes talkBounce {
  0%, 100% {
    transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(var(--rot));
  }
  50% {
    transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y) - 6px)) scale(calc((var(--scale) + 0.012) * var(--stage-scale) * var(--character-scale))) rotate(var(--rot));
  }
}

@keyframes shock {
  0%, 100% { transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(var(--rot)); }
  22% { transform: translateX(calc(var(--x) - 16px)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(-1deg); }
  48% { transform: translateX(calc(var(--x) + 13px)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(1deg); }
  72% { transform: translateX(calc(var(--x) - 8px)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))) rotate(-0.7deg); }
}

@keyframes overdriveSprite {
  0% { transform: translateX(var(--x)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))); opacity: 1; }
  50% { transform: translateX(calc(var(--x) + 6px)) translateY(calc(var(--base-y) + var(--stage-y) - 3px)) scale(calc(var(--scale) * var(--stage-scale) * var(--character-scale))); opacity: 0.70; }
}

@keyframes auraIdle {
  from { opacity: 0.45; transform: translateX(-50%) scale(0.94); }
  to { opacity: 0.86; transform: translateX(-50%) scale(1.05); }
}

@keyframes sigilSpin {
  to { transform: translateX(-50%) rotate(360deg); }
}

@keyframes overdriveBg {
  from { opacity: 0.38; filter: hue-rotate(0deg) saturate(1); }
  to { opacity: 0.88; filter: hue-rotate(-18deg) saturate(1.8); }
}

@keyframes glyphPulse {
  from { transform: scale(0.96); }
  to { transform: scale(1.05); }
}

@keyframes flash {
  42% { filter: brightness(1.7); }
}

@keyframes glitchSlide {
  0% { transform: translateX(0); }
  25% { transform: translateX(-12px); }
  50% { transform: translateX(9px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

@keyframes conceptTear {
  0% { filter: hue-rotate(0deg) saturate(1); transform: translateX(0); }
  33% { filter: hue-rotate(22deg) saturate(1.6); transform: translateX(-8px); }
  66% { filter: hue-rotate(-18deg) saturate(1.8); transform: translateX(6px); }
  100% { filter: hue-rotate(0deg) saturate(1); transform: translateX(0); }
}

@keyframes decoyFlicker {
  0%, 100% { opacity: 0.72; transform: skewX(-4deg) translateX(0); }
  17% { opacity: 0.46; transform: skewX(-4deg) translateX(2px); }
  18% { opacity: 0.88; transform: skewX(-4deg) translateX(-3px); }
  67% { opacity: 0.58; transform: skewX(-4deg) translateX(1px); }
}

@keyframes textRise {
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

.archive-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(720px, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid rgba(94, 230, 255, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(94, 230, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(9, 14, 24, 0.98), rgba(3, 5, 11, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.76), inset 0 0 0 1px rgba(255,255,255,0.06);
}

.archive-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(5px);
}

.archive-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: inherit;
}

.archive-dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 15px 17px;
  border-bottom: 1px solid rgba(255, 248, 235, 0.16);
}

.archive-dialog header div {
  display: grid;
  gap: 3px;
}

.archive-dialog header strong {
  color: var(--gold);
  font: 900 18px/1 ui-monospace, Consolas, monospace;
}

.archive-dialog header span {
  color: var(--muted);
  font-size: 12px;
}

.archive-dialog header button {
  min-width: 64px;
  min-height: 34px;
}

.archive-body {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 14px 17px 20px;
}

.trace-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 13px;
  padding: 12px;
  border-left: 3px solid rgba(94, 230, 255, 0.52);
  background: rgba(255, 255, 255, 0.035);
}

.trace-card.locked {
  opacity: 0.48;
  filter: saturate(0.35);
}

.trace-code {
  min-width: 76px;
  color: var(--cyan);
  font: 900 11px/1.2 ui-monospace, Consolas, monospace;
}

.trace-card h2,
.trace-card p {
  margin: 0;
}

.trace-card h2 {
  color: var(--paper);
  font-size: 16px;
}

.trace-card p {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.trace-tags {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.trace-tags span {
  padding: 3px 6px;
  border: 1px solid rgba(243, 199, 106, 0.32);
  color: rgba(243, 199, 106, 0.92);
  font: 800 10px/1 ui-monospace, Consolas, monospace;
}

body.deep-glitch .trace-card:nth-child(even) {
  border-left-color: var(--red);
}

@media (max-width: 720px) {
  .app {
    min-height: 100dvh;
  }

  .top-ui {
    padding: 8px 9px 0;
  }

  .title-block p {
    font-size: 11px;
  }

  .audio-readout {
    max-width: 215px;
    margin-top: 5px;
    font-size: 9px;
  }

  h1 {
    font-size: 25px;
  }

  .top-buttons {
    gap: 5px;
    max-width: 228px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .top-buttons button {
    min-width: 42px;
    min-height: 32px;
    padding: 0 7px;
    font-size: 12px;
  }

  .archive-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .archive-dialog header {
    padding: 12px;
  }

  .archive-body {
    padding: 10px 12px 14px;
  }

  .trace-card {
    gap: 8px 10px;
    padding: 10px;
  }

  .trace-card p,
  .trace-tags {
    grid-column: 1 / -1;
  }

  .adv-screen {
    min-height: 0;
    padding: 6px 8px 8px;
  }

  .scene-plate {
    max-width: calc(100vw - 72px);
    min-height: 32px;
    padding: 4px 9px;
    gap: 3px 8px;
  }

  .scene-plate span,
  .scene-plate strong {
    font-size: 12px;
  }

  .scene-plate time { font-size: 9px; }
  .scene-plate small {
    flex-basis: 100%;
    max-width: calc(100vw - 94px);
    font-size: 9px;
  }

  .glyph-rail {
    top: 46px;
    right: 5px;
    grid-template-columns: repeat(1, 22px);
    width: 32px;
    max-height: calc(100% - 154px);
    gap: 4px;
    padding: 5px 4px;
  }

  .glyph {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .stage {
    min-height: 210px;
  }

  .scene-transition {
    top: 5px;
    left: 7px;
    max-width: calc(100% - 48px);
    padding: 6px 8px;
    font-size: 10px;
    line-height: 1.5;
  }

  .cutin-caption {
    left: 9px;
    bottom: 7px;
    font-size: 9px;
  }

  .stage[data-layout="duo"] .sprite.main,
  .stage[data-layout="trio"] .sprite.main {
    width: 56vw;
    --stage-scale: 1.03;
  }

  .stage[data-layout="duo"] .sprite.side,
  .stage[data-layout="trio"] .sprite.side {
    width: 42vw;
    --stage-scale: 1.02;
  }

  .decoy-info {
    top: 5px;
    left: 4px;
    width: 174px;
    padding: 5px 6px;
    font-size: 8px;
  }

  .decoy-info b {
    font-size: 9px;
  }

  .sprite.main {
    width: 56vw;
    min-width: 214px;
  }

  .sprite.side {
    width: 42vw;
    min-width: 160px;
    height: 88%;
    opacity: 0;
  }

  .sprite.left,
  .stage.trio .sprite.left {
    left: 21%;
  }

  .sprite.right,
  .stage.trio .sprite.right {
    left: 79%;
  }

  .sprite.side.active {
    opacity: 1;
  }

  .aura,
  .dizark-sigil {
    width: 78vw;
  }

  .speaker-line {
    min-height: 36px;
    padding: 10px 14px 0;
  }

  .speaker-line span {
    font-size: 21px;
  }

  .speaker-line b {
    font-size: 13px;
  }

  .speaker-type {
    padding: 3px 6px;
    font-size: 8px;
  }

  .character-note {
    min-height: 25px;
    padding: 2px 14px 0;
    font-size: 11px;
    line-height: 1.28;
  }

  #dialogueText {
    min-height: 90px;
    padding: 7px 14px 2px;
    font-size: 16.5px;
    line-height: 1.52;
  }

  .choice-list {
    gap: 6px;
    padding: 6px 14px 0;
  }

  .choice-list button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .command-row {
    padding: 8px 14px 12px;
  }

  .sub-button {
    min-width: 52px;
    min-height: 34px;
    font-size: 12px;
  }

  .next-button {
    min-width: 96px;
    min-height: 34px;
  }

  .status-row {
    gap: 5px;
    padding-top: 5px;
  }

  .status-row span {
    min-width: 54px;
    padding: 3px 5px;
    font-size: 11px;
  }

  .status-row b {
    font-size: 14px;
  }
}

/* v16: return-route interface, normalized character art, and mobile one-screen layout */
* {
  letter-spacing: 0 !important;
}

.scene-bg.festival {
  background:
    linear-gradient(180deg, rgba(4, 8, 13, 0.03), rgba(2, 3, 7, 0.73)),
    url("/assets/backgrounds/return-fire-festival.png") center / cover;
}

.scene-bg.mugen-satomiya {
  background:
    linear-gradient(180deg, rgba(3, 9, 14, 0.02), rgba(2, 4, 8, 0.58)),
    url("/assets/backgrounds/mugen-satomiya.webp") center / cover;
}

.scene-bg.mugen-yamamiya {
  background:
    linear-gradient(180deg, rgba(2, 7, 8, 0.03), rgba(1, 3, 5, 0.62)),
    url("/assets/backgrounds/mugen-yamamiya.webp") center / cover;
}

.scene-bg.mugen-okumiya {
  background:
    linear-gradient(180deg, rgba(3, 8, 15, 0.02), rgba(1, 3, 7, 0.52)),
    url("/assets/backgrounds/mugen-okumiya.webp") center / cover;
}

.scene-bg.festival-prep {
  background:
    linear-gradient(180deg, rgba(8, 14, 13, 0.02), rgba(3, 6, 9, 0.48)),
    url("/assets/backgrounds/festival-preparation.png") center / cover;
}

.scene-bg.festival-night {
  background:
    linear-gradient(180deg, rgba(2, 5, 12, 0.05), rgba(1, 2, 7, 0.67)),
    url("/assets/backgrounds/festival-night-stage.png") center / cover;
}

.scene-bg.festival-river {
  background:
    linear-gradient(180deg, rgba(5, 10, 14, 0.01), rgba(2, 5, 9, 0.48)),
    url("/assets/backgrounds/festival-river-dawn.png") center / cover;
}

.top-buttons button,
.sub-button,
.next-button,
.choice-list button,
.log-dialog button,
.archive-dialog button,
.cast-dialog button,
.song-overlay button {
  position: relative;
  border-radius: 3px;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

#soundButton[aria-pressed="true"] {
  color: #fff4bc;
  border-color: rgba(243, 199, 106, 0.74);
  box-shadow: inset 0 0 18px rgba(243, 199, 106, 0.16), 0 0 16px rgba(243, 199, 106, 0.18);
}

.scene-plate {
  flex-wrap: wrap;
}

.ending-badge {
  padding: 4px 8px;
  border: 1px solid rgba(255, 248, 235, 0.5);
  color: #fff8eb;
  background: rgba(4, 5, 10, 0.74);
  font: 900 11px/1 ui-monospace, Consolas, monospace;
}

.ending-badge[data-ending-class="TRUE END"],
.ending-badge[data-ending-class="GOOD END"] {
  color: #fff0a8;
  border-color: rgba(243, 199, 106, 0.86);
  box-shadow: 0 0 18px rgba(243, 199, 106, 0.24);
}

.ending-badge[data-ending-class="BAD END"] {
  color: #ff8a98;
  border-color: rgba(255, 64, 88, 0.75);
}

.stage {
  min-height: 260px;
}

.sprite,
.sprite.main,
.sprite.side,
.stage[data-layout="duo"] .sprite.main,
.stage[data-layout="duo"] .sprite.side,
.stage[data-layout="trio"] .sprite.main,
.stage[data-layout="trio"] .sprite.side {
  width: min(36vw, 390px);
  min-width: 0;
  height: 100%;
  --scale: 1;
  --stage-scale: 1;
  --stage-y: 0px;
  object-fit: contain;
  object-position: bottom center;
  mask-image: none;
}

.sprite.side,
.stage[data-layout="duo"] .sprite.side,
.stage[data-layout="trio"] .sprite.side {
  opacity: 0;
}

.stage[data-layout="duo"] .sprite.side.active,
.stage[data-layout="trio"] .sprite.side.active {
  opacity: 1;
}

.stage[data-layout="duo"] .sprite.left {
  left: 34%;
}

.stage[data-layout="duo"] .sprite.main {
  left: 66%;
}

.stage[data-layout="trio"] .sprite,
.stage[data-layout="trio"] .sprite.main,
.stage[data-layout="trio"] .sprite.side {
  width: min(31vw, 340px);
}

.stage[data-layout="trio"] .sprite.left {
  left: 22%;
}

.stage[data-layout="trio"] .sprite.main {
  left: 50%;
}

.stage[data-layout="trio"] .sprite.right {
  left: 78%;
}

.sprite[data-character="kurumi"],
.sprite[data-character="himeko"],
.sprite[data-character="mikage"],
.sprite[data-character="rikka"] {
  --stage-scale: 1;
}

.stage.has-closeup .sprite {
  opacity: 0.12;
  filter: blur(1px) brightness(0.72);
}

.stage[data-layout="duo"].has-closeup .sprite.side.active,
.stage[data-layout="trio"].has-closeup .sprite.side.active {
  opacity: 0.12;
}

.closeup {
  inset: auto 0 0 auto;
  width: min(68%, 760px);
  height: 108%;
  object-fit: contain;
  object-position: right bottom;
  mask-image: linear-gradient(90deg, transparent 0%, #000 18%, #000 100%);
  transform: translateX(5%);
  z-index: 9;
}

.closeup.show {
  opacity: 0.88;
}

.stage.non-character .aura,
.stage.non-character .dizark-sigil {
  opacity: 0.14;
}

.sprite,
.sprite.main,
.sprite.side {
  filter: brightness(.86) saturate(.92) contrast(1.04) drop-shadow(0 28px 24px rgba(0,0,0,.82));
}

.sprite.side.active {
  opacity: 1;
  filter: brightness(.78) saturate(.84) contrast(1.05) drop-shadow(0 24px 22px rgba(0,0,0,.84));
}

.sprite.speaking {
  filter: brightness(.97) saturate(.98) contrast(1.04) drop-shadow(0 30px 26px rgba(0,0,0,.84));
}

.sprite.shock {
  filter: brightness(.9) saturate(1.24) contrast(1.08) hue-rotate(-7deg) drop-shadow(0 30px 26px rgba(0,0,0,.86));
}

.stage.choice-mode {
  isolation: isolate;
}

.stage.choice-mode .decoy-info {
  z-index: 1;
  opacity: .16;
}

.stage.choice-mode .sprite.presentation-bust {
  bottom: -46%;
  left: 50%;
  z-index: 5;
  width: min(58vw, 560px);
  height: 150%;
  opacity: .74;
  object-position: center top;
  filter: brightness(.76) saturate(.86) contrast(1.05) drop-shadow(0 22px 24px rgba(0,0,0,.86));
}

.stage.choice-mode.choice-crowded .sprite.presentation-bust {
  bottom: -108px;
  width: min(44vw, 340px);
  height: 238px;
  opacity: .58;
}

.stage.choice-mode.choice-crowded .decoy-info {
  display: none;
}

.speaker-name {
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-left: 3px solid var(--gold);
  color: var(--paper);
  background: linear-gradient(90deg, rgba(243, 199, 106, 0.17), transparent);
  font-size: clamp(22px, 2.9vw, 31px);
  font-weight: 900;
  cursor: pointer;
}

.speaker-name:disabled {
  border-left-color: var(--cyan);
  color: var(--cyan);
  cursor: default;
}

.speaker-name ruby {
  ruby-position: over;
  ruby-align: center;
}

.speaker-name rt {
  color: var(--cyan);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
}

#abilityName ruby {
  ruby-position: over;
  ruby-align: center;
}

#abilityName rt {
  color: rgba(243, 199, 106, 0.86);
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1;
}

.message-window {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, auto) auto auto;
  max-height: min(45dvh, 410px);
  overflow: hidden;
  cursor: pointer;
}

.message-window[data-line-kind="narration"] .character-note,
.message-window[data-line-kind="system"] .character-note {
  display: none;
}

.message-window[data-line-kind="narration"] #dialogueText {
  color: #e6f8ff;
}

.message-window[data-line-kind="monologue"] #dialogueText {
  color: #fff0c7;
  font-style: italic;
}

.message-window[data-line-kind="system"] {
  border-color: rgba(255, 64, 88, 0.58);
  background:
    linear-gradient(100deg, rgba(255, 64, 88, 0.13), transparent 40%),
    linear-gradient(180deg, rgba(16, 7, 14, 0.94), rgba(4, 4, 9, 0.98));
}

#dialogueText {
  overflow-y: auto;
  scrollbar-width: thin;
}

.choice-list {
  max-height: min(27dvh, 250px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.choice-list button.locked-choice {
  border-left-color: rgba(216, 202, 183, 0.28);
  color: rgba(216, 202, 183, 0.58);
  filter: saturate(0.45);
}

.choice-list button.locked-choice::before {
  content: "⌬ ";
  color: rgba(255, 64, 88, 0.72);
}

.command-row {
  align-items: center;
}

.tap-hint {
  flex: 1;
  min-width: 0;
  color: rgba(216, 202, 183, 0.68);
  font-size: 12px;
  text-align: right;
}

.next-button {
  min-width: 48px;
  width: 48px;
  padding: 0;
  font-size: 18px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
}

.danger-button {
  color: #ff9aa6 !important;
  border-color: rgba(255, 64, 88, 0.45) !important;
}

.cast-dialog {
  width: min(960px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid rgba(243, 199, 106, 0.5);
  border-radius: 6px;
  background:
    linear-gradient(130deg, rgba(243, 199, 106, 0.1), transparent 36%),
    #080c14;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.78);
}

.cast-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.cast-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: inherit;
}

.cast-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 248, 235, 0.14);
}

.cast-dialog header div {
  display: grid;
  gap: 3px;
}

.cast-dialog header strong {
  color: var(--gold);
  font-size: 18px;
}

.cast-dialog header span {
  color: var(--muted);
  font-size: 12px;
}

.cast-dialog header > button {
  min-width: 64px;
  min-height: 36px;
}

.cast-book {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  min-height: 0;
}

.cast-list {
  display: grid;
  grid-auto-rows: minmax(70px, 1fr);
  gap: 1px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.06);
}

.cast-list button {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 70px;
  padding: 4px 8px;
  border: 0;
  border-left: 3px solid transparent;
  color: var(--muted);
  background: #080d16;
  text-align: left;
}

.cast-list button.active {
  border-left-color: var(--gold);
  color: var(--ink);
  background: linear-gradient(90deg, rgba(243, 199, 106, 0.18), #0a101b);
}

.cast-list button:disabled {
  opacity: 0.38;
}

.cast-list img,
.profile-lock {
  width: 48px;
  height: 62px;
  object-fit: contain;
  object-position: center top;
}

.profile-lock {
  display: grid;
  place-items: center;
  color: var(--red);
  font: 900 20px/1 ui-monospace, Consolas, monospace;
}

.cast-detail {
  display: grid;
  grid-template-columns: minmax(230px, 38%) minmax(0, 1fr);
  min-height: 0;
  overflow-y: auto;
}

.cast-portrait {
  position: sticky;
  top: 0;
  align-self: start;
  height: min(650px, calc(100dvh - 110px));
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(94, 230, 255, 0.05), rgba(255, 64, 88, 0.06)),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(255,255,255,0.025) 31px 32px);
  padding: 0;
  border: 0;
  color: var(--ink);
  cursor: zoom-in;
}

.cast-portrait span {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(94, 230, 255, 0.46);
  background: rgba(3, 5, 11, 0.78);
  color: var(--cyan);
  font: 800 11px/1 ui-monospace, Consolas, monospace;
}

.cast-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 25px 24px rgba(0,0,0,0.7));
}

.cast-copy {
  padding: 22px 22px 28px;
}

.cast-reading {
  color: var(--cyan);
  font-size: 12px;
}

.cast-copy h2 {
  margin: 3px 0 4px;
  color: var(--paper);
  font-size: clamp(26px, 4vw, 42px);
}

.cast-role {
  margin: 0 0 14px !important;
  color: var(--gold) !important;
  font-weight: 800;
}

.cast-copy > strong {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-left: 3px solid var(--red);
  color: var(--cyan);
  background: rgba(255, 255, 255, 0.04);
}

.cast-copy p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.cast-copy .cast-note {
  padding-top: 11px;
  border-top: 1px solid rgba(255,255,255,0.12);
  color: rgba(216, 202, 183, 0.76);
  font-size: 13px;
}

.relation-grid {
  display: grid;
  gap: 7px;
  margin: 17px 0;
}

.relation-meter {
  display: grid;
  grid-template-columns: 82px minmax(80px, 1fr) 28px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.relation-meter i {
  height: 5px;
  overflow: hidden;
  background: rgba(255,255,255,0.1);
}

.relation-meter i b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--red));
}

.relation-meter strong {
  color: var(--paper);
  font: 800 11px/1 ui-monospace, Consolas, monospace;
}

.expression-record {
  display: grid;
  grid-template-columns: repeat(5, minmax(52px, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.expression-record > button {
  display: grid;
  grid-template-rows: 72px auto;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.24);
  padding: 0;
  color: inherit;
  cursor: pointer;
}

.expression-record img,
.expression-record i {
  width: 100%;
  height: 72px;
  object-fit: contain;
  overflow: hidden;
}

.expression-record i {
  display: grid;
  place-items: center;
  color: rgba(216, 202, 183, 0.35);
  font-style: normal;
}

.expression-record b {
  padding: 4px 2px;
  overflow: hidden;
  color: rgba(216, 202, 183, 0.65);
  font-size: 9px;
  text-align: center;
  text-overflow: ellipsis;
}

.expression-record .known {
  border-color: rgba(94, 230, 255, 0.28);
}

.expression-record .known:hover,
.expression-record .known.active {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(243,199,106,.34), 0 0 16px rgba(243,199,106,.12);
}

.expression-record button:disabled {
  cursor: default;
  opacity: .62;
}

.trace-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: rgba(94, 230, 255, 0.2);
}

.trace-summary > div {
  padding: 12px;
  background: #090f19;
}

.trace-summary span,
.trace-summary p {
  color: var(--muted);
  font-size: 11px;
}

.trace-summary strong {
  display: block;
  margin: 4px 0;
  color: var(--gold);
  font: 900 24px/1 ui-monospace, Consolas, monospace;
}

.trace-summary p {
  margin: 0;
}

.trace-relations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.trace-relation {
  padding: 10px;
  border-left: 2px solid rgba(243, 199, 106, 0.4);
  background: rgba(255,255,255,0.03);
}

.trace-relation h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 8px;
  font-size: 12px;
}

.trace-relation h3 span {
  color: var(--cyan);
  font-family: ui-monospace, Consolas, monospace;
}

.trace-card blockquote {
  grid-column: 2;
  margin: 0;
  padding: 7px 9px;
  border-left: 2px solid rgba(255, 64, 88, 0.48);
  color: rgba(255, 184, 190, 0.82);
  background: rgba(255, 64, 88, 0.05);
  font-size: 12px;
  line-height: 1.55;
}

.song-overlay {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(720px, calc(100vw - 24px));
  min-height: 76px;
  padding: 12px 14px 12px 18px;
  border: 1px solid rgba(243, 199, 106, 0.66);
  background:
    linear-gradient(90deg, rgba(255, 64, 88, 0.12), transparent 46%),
    rgba(4, 6, 12, 0.95);
  box-shadow: 0 20px 55px rgba(0,0,0,0.68), inset 0 0 22px rgba(94,230,255,0.05);
  transform: translateX(-50%);
}

.song-overlay[hidden] {
  display: none;
}

.song-overlay > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.song-overlay span {
  color: var(--cyan);
  font: 900 10px/1 ui-monospace, Consolas, monospace;
}

.song-overlay strong {
  color: var(--paper);
  font-size: 19px;
}

.song-overlay p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.song-overlay button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,0.28);
  color: var(--ink);
  background: rgba(255,255,255,0.06);
}

@media (max-width: 720px) {
  .top-ui {
    min-height: 98px;
  }

  .audio-readout {
    font-size: 10px;
  }

  .decoy-info {
    width: 190px;
    font-size: 10px;
    line-height: 1.35;
  }

  .decoy-info b {
    font-size: 11px;
  }

  .stage[data-layout="duo"] .decoy-info,
  .stage[data-layout="trio"] .decoy-info {
    z-index: 2;
    width: min(44vw, 170px);
    opacity: 0.38;
    transform: none;
  }

  .top-buttons {
    max-width: 246px;
  }

  .top-buttons button {
    min-width: 44px;
    min-height: 34px;
    padding: 0 6px;
    font-size: 11px;
  }

  #castButton,
  #archiveButton {
    min-width: 55px;
  }

  .adv-screen {
    grid-template-rows: auto minmax(150px, 1fr) auto auto;
  }

  .stage {
    min-height: 150px;
  }

  .sprite,
  .sprite.main,
  .sprite.side,
  .stage[data-layout="duo"] .sprite.main,
  .stage[data-layout="duo"] .sprite.side {
    width: 48vw;
  }

  .stage[data-layout="trio"] .sprite,
  .stage[data-layout="trio"] .sprite.main,
  .stage[data-layout="trio"] .sprite.side {
    width: 40vw;
  }

  .stage[data-layout="duo"] .sprite.left {
    left: 31%;
  }

  .stage[data-layout="duo"] .sprite.main {
    left: 69%;
  }

  .stage[data-layout="trio"] .sprite.left {
    left: 17%;
  }

  .stage[data-layout="trio"] .sprite.main {
    left: 50%;
  }

  .stage[data-layout="trio"] .sprite.right {
    left: 83%;
  }

  .closeup {
    width: 78%;
    height: 112%;
  }

  .message-window {
    max-height: min(47dvh, 360px);
  }

  .message-window:has(.choice-list:not(:empty)) {
    max-height: min(55dvh, 440px);
  }

  .scene-bg.gorge-day {
    background-position: center, 72% center;
  }

  .speaker-line {
    align-items: center;
    gap: 6px;
    padding: 8px 11px 0;
  }

  .speaker-name {
    min-height: 30px;
    padding: 0 7px;
    font-size: 20px;
  }

  .speaker-name rt {
    font-size: 9px;
  }

  #abilityName rt {
    font-size: 8px;
  }

  .speaker-type {
    font-size: 9px;
  }

  .character-note {
    padding: 2px 11px 0;
    font-size: 12px;
  }

  .reading-guide {
    min-height: 21px;
    gap: 6px;
    padding: 2px 11px 1px;
    font-size: 12px;
  }

  .reading-guide b {
    font-size: 10px;
  }

  #dialogueText {
    min-height: 80px;
    max-height: 22dvh;
    padding: 6px 11px 2px;
    font-size: 17px;
    line-height: 1.5;
  }

  .choice-list {
    max-height: 26dvh;
    padding: 6px 11px 0;
  }

  .choice-list button {
    min-height: 44px;
    font-size: 14px;
  }

  .command-row {
    gap: 6px;
    padding: 7px 11px 10px;
  }

  .tap-hint {
    font-size: 10px;
  }

  .next-button {
    min-width: 42px;
    width: 42px;
  }

  .cast-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  .cast-dialog header {
    padding: 10px;
  }

  .cast-dialog header span {
    display: none;
  }

  .cast-book {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .cast-list button {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 2px;
    padding: 3px;
    font-size: 11px;
  }

  .cast-list img,
  .profile-lock {
    width: 46px;
    height: 48px;
  }

  .cast-detail {
    display: block;
  }

  .cast-portrait {
    position: relative;
    height: 190px;
  }

  .cast-copy {
    padding: 13px;
  }

  .cast-copy h2 {
    font-size: 28px;
  }

  .cast-copy p {
    font-size: 14px;
    line-height: 1.62;
  }

  .expression-record {
    grid-template-columns: repeat(5, minmax(40px, 1fr));
  }

  .expression-record > button {
    grid-template-rows: 52px auto;
  }

  .expression-record img,
  .expression-record i {
    height: 52px;
  }

  .trace-relations {
    grid-template-columns: 1fr;
  }

  .trace-card blockquote {
    grid-column: 1 / -1;
  }

  .song-overlay {
    bottom: 8px;
    gap: 8px;
    width: calc(100vw - 14px);
    min-height: 68px;
    padding: 10px;
  }

  .song-overlay strong {
    font-size: 16px;
  }

  .song-overlay p {
    max-width: 54vw;
    font-size: 11px;
  }

  .song-overlay button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 11px;
  }
}

@media (max-height: 700px) and (max-width: 720px) {
  .top-ui {
    min-height: 82px;
  }

  .title-block h1 {
    font-size: 21px;
  }

  .audio-readout {
    display: none;
  }

  .adv-screen {
    grid-template-rows: auto minmax(112px, 1fr) auto auto;
  }

  .stage {
    min-height: 112px;
  }

  .message-window {
    max-height: 49dvh;
  }

  #dialogueText {
    min-height: 68px;
    max-height: 20dvh;
  }

  .character-note {
    display: none;
  }

  .status-row {
    min-height: 25px;
  }
}

/* Short landscape screens need separate art and reading columns. */
@media (max-height: 540px) and (min-width: 721px) {
  .top-ui { padding: 6px 12px 0; }
  .title-block h1 { font-size: 28px; }
  .audio-readout { display: none; }
  .adv-screen {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 5px 8px;
    padding: 5px 12px 8px;
  }
  .adv-screen > .scene-plate { grid-column: 1 / -1; }
  .adv-screen > .stage { min-height: 0; }
  .adv-screen > .message-window {
    min-height: 0;
    max-height: none;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  }
  .adv-screen > .message-window:has(.choice-list:not(:empty)) {
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  }
  .adv-screen .character-note { display: none; }
  .adv-screen .speaker-line { grid-row: 1; }
  .adv-screen .reading-guide { grid-row: 3; }
  .adv-screen #dialogueText { grid-row: 4; }
  .adv-screen .choice-list { grid-row: 5; }
  .adv-screen .command-row { grid-row: 6; }
  .adv-screen #dialogueText { min-height: 0; font-size: 16px; padding: 5px 12px; }
  .adv-screen .message-window:has(.choice-list:not(:empty)) #dialogueText { display: none; }
  .adv-screen .choice-list { min-height: 0; max-height: none; }
  .adv-screen .speaker-line { padding: 5px 12px 0; min-height: 34px; }
  .adv-screen .speaker-name { font-size: 22px; }
  .adv-screen .reading-guide { padding: 3px 12px; font-size: 9px; }
  .adv-screen .command-row { padding: 4px 12px 6px; }
  .adv-screen > .status-row { grid-column: 1 / -1; padding-top: 0; }
}

/* Bookmark slots */
.bookmark-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid rgba(243, 199, 106, 0.58);
  color: var(--paper);
  background: rgba(5, 7, 13, 0.98);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.78), inset 0 0 36px rgba(94, 230, 255, 0.04);
}

.bookmark-dialog::backdrop {
  background: rgba(0, 2, 8, 0.82);
  backdrop-filter: blur(8px);
}

.bookmark-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 26px);
}

.bookmark-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(90deg, rgba(255, 64, 88, 0.1), transparent 56%);
}

.bookmark-dialog header div {
  display: grid;
  gap: 3px;
}

.bookmark-dialog header strong {
  font-size: 20px;
}

.bookmark-dialog header span {
  color: var(--muted);
  font-size: 12px;
}

.bookmark-dialog button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
}

.bookmark-slots {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 14px;
}

.bookmark-slot {
  position: relative;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 122px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 3px solid var(--cyan);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.025);
}

.bookmark-slot.empty {
  border-left-color: rgba(255, 255, 255, 0.24);
}

.bookmark-index {
  display: grid;
  place-content: center;
  gap: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--cyan);
  text-align: center;
  font: 900 12px/1.2 ui-monospace, Consolas, monospace;
}

.bookmark-index b {
  color: var(--paper);
  font-size: 28px;
}

.bookmark-copy {
  display: grid;
  align-content: center;
  gap: 6px;
  min-width: 0;
  padding: 14px 16px;
}

.bookmark-copy strong {
  overflow: hidden;
  font-size: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bookmark-copy p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.bookmark-copy small {
  color: rgba(243, 199, 106, 0.86);
  font: 800 11px/1.4 ui-monospace, Consolas, monospace;
}

.bookmark-actions {
  display: grid;
  grid-template-rows: 1fr 1fr;
  width: 92px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.bookmark-actions button {
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bookmark-actions .load-bookmark {
  color: #061017;
  background: var(--cyan);
}

.bookmark-actions button:disabled {
  color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.02);
}

.bookmark-notice {
  min-height: 42px;
  margin: 0;
  padding: 11px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--cyan);
  font-size: 12px;
}

/* Full-screen OP, insert song and ending cinematics */
.song-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #02040a;
  box-shadow: none;
  transform: none;
  isolation: isolate;
}

.song-overlay[hidden] {
  display: none;
}

.song-backdrop {
  position: absolute;
  inset: -3%;
  z-index: -5;
  background-position: center;
  background-size: cover;
  filter: saturate(0.82) contrast(1.08) brightness(0.66);
  transform: scale(1.06);
  animation: cinematic-drift 12s ease-in-out infinite alternate;
  transition: opacity 1.1s ease, background-image 0.2s linear;
}

.song-backdrop-alt {
  z-index: -4;
  opacity: 0;
  mix-blend-mode: screen;
  animation-direction: alternate-reverse;
}

.song-overlay.frame-shift .song-backdrop-alt {
  opacity: 0.2;
}

.song-character {
  --mv-rest-x: 0%;
  position: absolute;
  bottom: -5%;
  z-index: -2;
  display: none;
  width: min(48vw, 690px);
  height: 94%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 24px 36px rgba(0, 0, 0, 0.74));
  animation: cinematic-character 6s ease-in-out infinite alternate;
}

.song-character[src] {
  display: block;
}

/* Empty slots must stay hidden even when waiting/duo layouts enable characters. */
.song-overlay .song-character:not([src]),
.song-overlay .song-character[src=""],
.song-overlay .song-item:not([src]),
.song-overlay .song-item[src=""] {
  display: none !important;
}

.song-character-a {
  left: 4%;
}

.song-character-b {
  right: 2%;
  animation-delay: -2.4s;
}

.song-film {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 32, 66, 0.12), transparent 22%, transparent 75%, rgba(38, 211, 255, 0.1)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, rgba(0, 0, 0, 0.05), transparent 55%, rgba(0, 0, 0, 0.84));
}

.song-film::before,
.song-film::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background: linear-gradient(105deg, transparent 0 44%, rgba(255, 255, 255, 0.14) 44.2% 44.4%, transparent 44.6% 100%);
  transform: translateX(-14%);
  animation: cinematic-scan 7s linear infinite;
}

.song-film::after {
  opacity: 0.12;
  animation-delay: -3.5s;
  animation-duration: 4.2s;
}

.song-copy {
  position: absolute;
  left: 7%;
  bottom: 9%;
  z-index: 3;
  display: grid;
  gap: 8px;
  width: min(720px, 78vw);
  text-shadow: 0 3px 22px rgba(0, 0, 0, 0.95);
}

.song-copy span {
  color: var(--cyan);
  font: 900 12px/1 ui-monospace, Consolas, monospace;
}

.song-copy strong {
  color: #fff;
  font-size: 44px;
  line-height: 1.08;
}

.song-copy p {
  min-height: 2em;
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 18px;
  line-height: 1.7;
  white-space: normal;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.song-overlay.lyric-shift .song-copy p {
  opacity: 0;
  transform: translateY(8px);
}

.song-controls {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 5;
  display: flex;
  gap: 8px;
}

.song-overlay > .song-controls {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.song-controls button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  color: #fff;
  background: rgba(3, 5, 11, 0.68);
  backdrop-filter: blur(8px);
}

#songPlayButton {
  border-color: rgba(94, 230, 255, 0.72);
  color: var(--cyan);
}

.song-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--cyan));
  transform: scaleX(0);
  transform-origin: left;
}

.song-overlay.playing .song-progress {
  animation: cinematic-progress var(--song-duration, 90s) linear forwards;
}

.song-overlay[data-song="insert"] .song-backdrop {
  inset: 0;
  filter: saturate(0.94) contrast(1.05) brightness(0.74);
  transform: scale(1.02);
}

.song-overlay[data-song="insert"] .song-copy {
  width: min(640px, 72vw);
}

.song-overlay[data-song="ed"] .song-copy {
  right: 5%;
  bottom: 6%;
  left: auto;
  width: min(440px, 44vw);
  text-align: right;
}

.staff-roll {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: 4;
  width: min(560px, calc(100vw - 48px));
  color: #fff;
  text-align: center;
  text-shadow: 0 3px 18px #000;
  transform: translateX(-50%);
}

.staff-roll:not([hidden]) {
  display: block;
  animation: staff-roll var(--song-duration, 108s) linear forwards;
}

.staff-roll h2 {
  margin: 24px 0 70px;
  font-size: 36px;
}

.staff-roll p {
  margin: 0 0 46px;
  color: rgba(255, 255, 255, 0.78);
  font: 800 12px/1.6 ui-monospace, Consolas, monospace;
}

.staff-roll dl {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 22px 28px;
  margin: 0 0 82px;
  text-align: left;
}

.staff-roll dt {
  color: var(--cyan);
  text-align: right;
}

.staff-roll dd {
  margin: 0;
}

.song-overlay[data-song="ed"] .song-copy {
  opacity: 0.55;
}

@keyframes cinematic-drift {
  from { transform: scale(1.06) translate3d(-0.8%, -0.3%, 0); }
  to { transform: scale(1.12) translate3d(0.9%, 0.6%, 0); }
}

@keyframes cinematic-character {
  from { transform: translate3d(0, 0, 0) rotate(-0.25deg); }
  to { transform: translate3d(0, -1.2%, 0) rotate(0.3deg); }
}

@keyframes cinematic-scan {
  from { transform: translateX(-55%); }
  to { transform: translateX(55%); }
}

@keyframes cinematic-progress {
  to { transform: scaleX(1); }
}

@keyframes staff-roll {
  from { transform: translate(-50%, 0); }
  to { transform: translate(-50%, -185%); }
}

/* Character art viewer and reduced character motion */
.portrait-viewer {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 68%, rgba(94, 230, 255, 0.12), transparent 42%),
    rgba(2, 4, 9, 0.96);
  cursor: zoom-out;
}

.portrait-viewer[hidden] { display: none; }

.portrait-viewer::before {
  content: "FULL CHARACTER RECORD";
  position: absolute;
  top: 24px;
  left: 24px;
  color: rgba(94, 230, 255, 0.56);
  font: 800 11px/1 ui-monospace, Consolas, monospace;
}

.portrait-viewer img {
  width: min(82vw, 720px);
  height: 94dvh;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 30px 38px rgba(0, 0, 0, 0.82));
  animation: portrait-arrive 700ms cubic-bezier(.2,.8,.2,1) both;
}

.portrait-viewer-caption {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-right: 3px solid var(--red);
  background: rgba(3, 5, 11, 0.78);
  text-align: right;
}

.portrait-viewer-caption span { color: var(--cyan); font-size: 12px; }
.portrait-viewer-caption strong { color: #fff; font-size: 24px; }
.portrait-viewer-caption small { color: var(--muted); font-size: 10px; }

body.motion-off .sprite,
body.motion-off .aura,
body.motion-off .dizark-sigil,
body.motion-off .dizark-sigil::after,
body.motion-off .closeup {
  animation: none !important;
  transition-duration: 0.01ms !important;
}

/* Timeline-driven music video language */
.song-item {
  position: absolute;
  top: 8%;
  left: 50%;
  z-index: -1;
  display: none;
  width: min(48vw, 620px);
  height: 72%;
  object-fit: contain;
  opacity: 0.36;
  transform: translateX(-50%);
  filter: contrast(1.12) saturate(0.82) drop-shadow(0 0 30px rgba(94, 230, 255, 0.32));
  mix-blend-mode: screen;
}

.song-item[src] { display: block; animation: song-item-drift 8s ease-in-out infinite alternate; }

.song-copy em {
  color: rgba(243, 199, 106, 0.92);
  font: 800 10px/1.2 ui-monospace, Consolas, monospace;
  font-style: normal;
  letter-spacing: 0;
}

.song-copy > i {
  position: absolute;
  right: -4vw;
  bottom: -1.5em;
  z-index: -1;
  width: 120%;
  overflow: hidden;
  color: rgba(255, 64, 88, 0.13);
  font: 900 clamp(26px, 5vw, 76px)/1 sans-serif;
  font-style: normal;
  white-space: nowrap;
  pointer-events: none;
}

.song-overlay.cue-enter .song-copy p {
  animation: lyric-reveal 1.05s cubic-bezier(.2,.8,.2,1) both;
}

.song-overlay.cue-enter .song-character-a { animation: character-cue-a 6.5s ease-out both; }
.song-overlay.cue-enter .song-character-b { animation: character-cue-b 6.5s ease-out both; }

.song-overlay[data-shot="close"] .song-character,
.song-overlay[data-shot="impact"] .song-character {
  width: min(72vw, 940px);
  height: 108%;
  bottom: -10%;
}

.song-overlay[data-shot="close"] .song-character-a,
.song-overlay[data-shot="impact"] .song-character-a { left: 18%; }
.song-overlay[data-shot="duo"] .song-character { width: min(54vw, 760px); height: 102%; }
.song-overlay[data-shot="impact"] .song-film { animation: pv-impact 900ms steps(2) both; }
.song-overlay[data-shot="symbol"] .song-item { opacity: 0.62; width: min(66vw, 880px); }

.song-overlay[data-effect="chorus"] .song-copy p,
.song-overlay[data-effect="surge"] .song-copy p {
  color: #fff;
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 900;
  text-shadow: 0 0 26px rgba(255, 64, 88, 0.52), 0 4px 18px #000;
}

.song-overlay[data-effect="fracture"] .song-copy p,
.song-overlay[data-effect="shock"] .song-copy p {
  text-shadow: -3px 0 rgba(255, 64, 88, 0.75), 3px 0 rgba(94, 230, 255, 0.72), 0 4px 18px #000;
}

.song-overlay[data-effect="void"] .song-backdrop { filter: grayscale(0.8) contrast(1.35) brightness(0.38); }
.song-overlay[data-effect="afterglow"] .song-backdrop { filter: saturate(0.9) contrast(1.02) brightness(0.82); }
.song-overlay[data-effect="light"] .song-film { background-color: rgba(243, 199, 106, 0.08); }

@keyframes portrait-arrive {
  from { opacity: 0; transform: translateY(3%) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes lyric-reveal {
  0% { opacity: 0; filter: blur(12px); transform: translateY(18px) skewX(-4deg); }
  45% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; }
}

@keyframes character-cue-a {
  from { opacity: 0; transform: translateX(-5%) scale(1.06); filter: blur(6px) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  18% { opacity: 1; filter: blur(0) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  to { opacity: 1; transform: translateX(1%) scale(1); }
}

@keyframes character-cue-b {
  from { opacity: 0; transform: translateX(5%) scale(1.06); filter: blur(6px) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  18% { opacity: 1; filter: blur(0) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  to { opacity: 1; transform: translateX(-1%) scale(1); }
}

@keyframes song-item-drift {
  from { transform: translateX(-50%) translateY(-1%) rotate(-0.7deg) scale(0.96); }
  to { transform: translateX(-50%) translateY(1%) rotate(0.7deg) scale(1.04); }
}

@keyframes pv-impact {
  0%, 100% { opacity: 1; filter: none; }
  18% { opacity: 0.35; filter: invert(1) contrast(2); }
  28% { opacity: 1; transform: translateX(8px); }
  38% { transform: translateX(-5px); }
}

@media (max-width: 720px) {
  .portrait-viewer img {
    width: 100vw;
    height: 91dvh;
  }

  .portrait-viewer-caption {
    right: 10px;
    bottom: max(12px, env(safe-area-inset-bottom));
    padding: 9px 10px;
  }

  .portrait-viewer-caption strong { font-size: 19px; }

  .song-copy {
    bottom: max(38px, env(safe-area-inset-bottom));
    gap: 5px;
  }

  .song-copy strong { font-size: 27px; }
  .song-copy p { font-size: 16px; line-height: 1.5; }
  .song-overlay[data-effect="chorus"] .song-copy p,
  .song-overlay[data-effect="surge"] .song-copy p { font-size: 20px; }
  .song-overlay[data-shot="close"] .song-character,
  .song-overlay[data-shot="impact"] .song-character { width: 112vw; height: 92%; left: -6%; }
  .song-item { width: 88vw; height: 62%; opacity: 0.28; }
  .song-copy > i { right: 0; width: 100%; font-size: 36px; }
}

@media (max-width: 720px) {
  .top-buttons {
    max-width: 292px;
  }

  .bookmark-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  .bookmark-dialog form {
    max-height: calc(100dvh - 14px);
  }

  .bookmark-dialog header {
    padding: 11px;
  }

  .bookmark-dialog header span {
    display: none;
  }

  .bookmark-slots {
    gap: 8px;
    padding: 8px;
  }

  .bookmark-slot {
    grid-template-columns: 54px minmax(0, 1fr) 72px;
    min-height: 112px;
  }

  .bookmark-index b {
    font-size: 22px;
  }

  .bookmark-copy {
    padding: 10px;
  }

  .bookmark-copy strong {
    font-size: 14px;
  }

  .bookmark-copy p {
    font-size: 12px;
  }

  .bookmark-actions {
    width: 72px;
  }

  .song-copy {
    right: 18px;
    bottom: max(28px, env(safe-area-inset-bottom));
    left: 18px;
    width: auto;
  }

  .song-copy strong {
    font-size: 30px;
  }

  .song-copy p {
    font-size: 15px;
  }

  .song-character {
    width: 92vw;
    max-width: none;
    height: 86%;
    opacity: 0.82;
  }

  .song-overlay .song-character-a {
    right: auto;
    left: 4%;
  }

  .song-overlay .song-character-b {
    display: none;
  }

  .song-overlay[data-song="insert"] .song-backdrop {
    background-position: 54% center;
  }

  .song-overlay[data-song="insert"] .song-copy,
  .song-overlay[data-song="ed"] .song-copy {
    right: 18px;
    left: 18px;
    width: auto;
    text-align: left;
  }

  .staff-roll h2 {
    margin-bottom: 54px;
    font-size: 28px;
  }

  .staff-roll dl {
    grid-template-columns: 1fr;
    gap: 5px;
    text-align: center;
  }

  .staff-roll dt {
    margin-top: 18px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .song-backdrop,
  .song-character,
  .song-film::before,
  .song-film::after {
    animation: none;
  }
}

/* Compact command bar */
.top-ui {
  min-height: 70px;
  align-items: flex-start;
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  white-space: nowrap;
}

.top-buttons {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 6px;
}

.top-buttons button {
  min-width: 58px;
  min-height: 38px;
  padding: 0 10px;
  white-space: nowrap;
}

.top-buttons .settings-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  color: var(--cyan);
  font-size: 21px;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: clamp(10px, 2.5vw, 30px);
  z-index: 70;
  width: min(370px, calc(100vw - 20px));
  border: 1px solid rgba(94, 230, 255, 0.42);
  border-top: 3px solid var(--cyan);
  background:
    linear-gradient(135deg, rgba(94, 230, 255, 0.09), transparent 42%),
    rgba(4, 7, 13, 0.97);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), inset 0 0 30px rgba(94, 230, 255, 0.04);
  backdrop-filter: blur(18px);
}

.settings-panel[hidden] { display: none; }

.settings-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-panel > header div { display: grid; gap: 3px; }
.settings-panel > header span { color: var(--cyan); font: 800 9px/1 ui-monospace, Consolas, monospace; }
.settings-panel > header strong { color: var(--paper); font-size: 15px; }
.settings-panel > header button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.settings-grid button {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 11px;
  border: 0;
  color: var(--ink);
  background: #080d16;
  text-align: left;
  cursor: pointer;
}

.settings-grid button:hover,
.settings-grid button[aria-pressed="true"] {
  background: linear-gradient(90deg, rgba(94, 230, 255, 0.13), #080d16);
}

.settings-grid button i {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid rgba(243, 199, 106, 0.38);
  color: var(--gold);
  font: 900 15px/1 ui-monospace, Consolas, monospace;
  font-style: normal;
}

.settings-grid button span { font-size: 13px; font-weight: 800; }
.settings-grid button b { color: var(--cyan); font: 800 9px/1 ui-monospace, Consolas, monospace; }

.settings-grid .reset-setting { grid-column: 1 / -1; }
.settings-grid .reset-setting i,
.settings-grid .reset-setting b { color: #ff9aa6; }

.confirm-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid rgba(255,64,88,.5);
  border-radius: 6px;
  color: var(--ink);
  background: #090d15;
}

.confirm-dialog::backdrop {
  background: rgba(0,0,0,.76);
  backdrop-filter: blur(5px);
}

.confirm-dialog form {
  display: grid;
  gap: 13px;
  padding: 22px;
}

.confirm-dialog form > span { color: #ff788b; font: 800 10px/1 ui-monospace, Consolas, monospace; }
.confirm-dialog form > strong { color: var(--paper); font-size: 23px; }
.confirm-dialog form > p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.confirm-dialog form > div { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-dialog button { min-height: 42px; padding: 8px 14px; }

.loading-gate {
  position: fixed;
  top: max(76px, 10svh);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  gap: 7px;
  color: #fff;
  background: rgba(2, 4, 9, .88);
  pointer-events: none;
}

.loading-gate[hidden] {
  display: none;
}

.loading-gate i {
  width: 20px;
  flex: 0 0 20px;
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--cyan);
  border-right-color: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(94,230,255,.24);
  animation: loading-gate-spin 820ms linear infinite;
}

.loading-gate span {
  color: var(--cyan);
  font: 900 11px/1 ui-monospace, Consolas, monospace;
}

.loading-gate b {
  padding: 6px 10px;
  border-left: 2px solid var(--gold);
  color: var(--paper);
  background: rgba(2,4,9,.78);
  font-size: 13px;
}

#nextButton.input-queued {
  box-shadow: 0 0 0 2px var(--cyan);
}

@keyframes loading-gate-spin {
  to { transform: rotate(360deg); }
}

/* Song MV: a stable logo, clean cuts and a guaranteed lyric safe area. */
.song-overlay {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #020307;
}

.song-overlay > .song-brand {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  z-index: 7;
  display: grid;
  gap: 0;
  width: max-content;
  padding: 7px 18px 8px 14px;
  border-left: 4px solid var(--red);
  background: linear-gradient(90deg, rgba(2, 3, 7, 0.76), rgba(2, 3, 7, 0));
  pointer-events: none;
}

.song-brand::after {
  content: "";
  position: absolute;
  right: -72px;
  bottom: 0;
  width: 120px;
  height: 1px;
  background: linear-gradient(90deg, var(--cyan), transparent);
}

.song-brand span {
  color: var(--paper);
  font: 900 clamp(12px, 1.3vw, 18px)/1 sans-serif;
}

.song-brand strong {
  color: #fff;
  font: 950 clamp(34px, 5.8vw, 82px)/0.82 "Arial Black", "Yu Gothic UI", sans-serif;
  text-shadow: 3px 0 rgba(255, 64, 88, 0.48), -2px 0 rgba(94, 230, 255, 0.32), 0 10px 28px #000;
}

.song-brand i {
  margin-top: 8px;
  color: rgba(94, 230, 255, 0.74);
  font: 800 8px/1 ui-monospace, Consolas, monospace;
  font-style: normal;
}

.song-overlay > .song-frame-code {
  position: absolute;
  top: max(82px, calc(env(safe-area-inset-top) + 64px));
  right: max(24px, env(safe-area-inset-right));
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 174px;
  color: rgba(255, 255, 255, 0.64);
  font: 800 9px/1 ui-monospace, Consolas, monospace;
}

.song-frame-code span { color: var(--red); }
.song-frame-code i { flex: 1; height: 1px; background: rgba(255, 255, 255, 0.26); }
.song-frame-code b { color: var(--cyan); font-weight: 800; }

.song-backdrop,
.song-backdrop-alt {
  inset: -7%;
  opacity: 0;
  background-position: center;
  background-size: cover;
  mix-blend-mode: normal;
  filter: saturate(0.9) contrast(1.1) brightness(0.64);
  transition: opacity 850ms cubic-bezier(.2,.75,.2,1);
  animation: none;
}

.song-overlay[data-bg-layer="0"] .song-backdrop,
.song-overlay[data-bg-layer="1"] .song-backdrop-alt { opacity: 1; }
.song-overlay[data-bg-layer="0"] .song-backdrop-alt,
.song-overlay[data-bg-layer="1"] .song-backdrop { opacity: 0; }

.song-overlay.cue-enter[data-camera="push"] .song-backdrop,
.song-overlay.cue-enter[data-camera="push"] .song-backdrop-alt { animation: mv-camera-push 7s ease-out both; }
.song-overlay.cue-enter[data-camera="pull"] .song-backdrop,
.song-overlay.cue-enter[data-camera="pull"] .song-backdrop-alt { animation: mv-camera-pull 8s ease-out both; }
.song-overlay.cue-enter[data-camera="pan-left"] .song-backdrop,
.song-overlay.cue-enter[data-camera="pan-left"] .song-backdrop-alt { animation: mv-camera-left 8s ease-out both; }
.song-overlay.cue-enter[data-camera="pan-right"] .song-backdrop,
.song-overlay.cue-enter[data-camera="pan-right"] .song-backdrop-alt,
.song-overlay.cue-enter[data-camera="drift-right"] .song-backdrop,
.song-overlay.cue-enter[data-camera="drift-right"] .song-backdrop-alt { animation: mv-camera-right 8s ease-out both; }
.song-overlay.cue-enter[data-camera="drift-left"] .song-backdrop,
.song-overlay.cue-enter[data-camera="drift-left"] .song-backdrop-alt { animation: mv-camera-left 9s ease-out both; }
.song-overlay.cue-enter[data-camera="tilt"] .song-backdrop,
.song-overlay.cue-enter[data-camera="tilt"] .song-backdrop-alt { animation: mv-camera-tilt 8s ease-out both; }
.song-overlay.cue-enter[data-camera="whip"] .song-backdrop,
.song-overlay.cue-enter[data-camera="whip"] .song-backdrop-alt { animation: mv-camera-whip 900ms cubic-bezier(.15,.8,.25,1) both; }
.song-overlay.cue-enter[data-camera="surge"] .song-backdrop,
.song-overlay.cue-enter[data-camera="surge"] .song-backdrop-alt { animation: mv-camera-surge 5.5s ease-out both; }
.song-overlay.cue-enter[data-camera="orbit"] .song-backdrop,
.song-overlay.cue-enter[data-camera="orbit"] .song-backdrop-alt { animation: mv-camera-orbit 8s ease-out both; }

.song-character {
  z-index: -1;
  max-width: none;
  opacity: 1;
  object-fit: contain;
  object-position: center bottom;
  transform-origin: center bottom;
}

.song-character[data-art="bust"] {
  width: min(64vw, 900px);
  height: 92dvh;
  bottom: -7dvh;
}

.song-character[data-art="full"] {
  width: min(48vw, 680px);
  height: 96dvh;
  bottom: -3dvh;
}

.song-overlay[data-shot="hero"] .song-character-a,
.song-overlay[data-shot="bust-left"] .song-character-a { left: 5vw; right: auto; }
.song-overlay[data-shot="bust-right"] .song-character-a { right: 4vw; left: auto; }
.song-overlay[data-shot="impact"] .song-character-a { --mv-rest-x: -50%; left: 50%; right: auto; width: min(76vw, 1040px); transform: translateX(-50%); }
.song-overlay[data-shot="duo"] .song-character { width: min(55vw, 760px); height: 91dvh; bottom: -7dvh; }
.song-overlay[data-shot="duo"] .song-character-a { left: -1vw; right: auto; }
.song-overlay[data-shot="duo"] .song-character-b { right: -1vw; left: auto; }

.song-item {
  top: 18%;
  left: 50%;
  z-index: -1;
  width: min(44vw, 610px);
  height: 54%;
  opacity: 0.68;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.24);
  filter: saturate(0.82) contrast(1.14) drop-shadow(0 22px 38px rgba(0,0,0,.68));
  mix-blend-mode: normal;
  clip-path: polygon(7% 0, 100% 0, 93% 100%, 0 100%);
}

.song-overlay[data-shot="detail"] .song-item { width: min(58vw, 820px); height: 62%; opacity: 0.82; }

.song-film {
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(255, 32, 66, 0.10), transparent 24%, transparent 78%, rgba(38, 211, 255, 0.08)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(0,0,0,.12), transparent 48%, rgba(0,0,0,.92));
}

.song-copy,
.song-overlay[data-song="insert"] .song-copy,
.song-overlay[data-song="ed"] .song-copy {
  right: auto;
  bottom: max(42px, calc(env(safe-area-inset-bottom) + 28px));
  left: 6vw;
  z-index: 6;
  display: grid;
  gap: 5px;
  width: min(88vw, 1080px);
  max-width: calc(100vw - 12vw);
  opacity: 1;
  text-align: left;
  pointer-events: none;
}

.song-copy span { font-size: 9px; }
.song-copy strong { color: var(--gold); font-size: clamp(14px, 1.5vw, 20px); }
.song-copy em { font-size: 9px; }

.song-copy p,
.song-overlay[data-effect="chorus"] .song-copy p,
.song-overlay[data-effect="surge"] .song-copy p {
  width: fit-content;
  max-width: min(900px, 86vw);
  min-height: 2.5em;
  margin: 2px 0 0;
  overflow: visible;
  color: #fff;
  font-size: clamp(21px, 3vw, 38px);
  font-weight: 900;
  line-height: 1.32;
  white-space: normal;
  text-wrap: balance;
  text-overflow: clip;
  text-shadow: 0 3px 4px #000, 0 0 28px rgba(0,0,0,.9);
}

.song-lyric-accent {
  position: relative;
  display: inline;
  padding: 0;
  color: #fff1b8;
  background: none;
  text-shadow:
    0 3px 4px #000,
    0 0 14px rgba(243, 199, 106, .86),
    0 0 34px rgba(255, 64, 88, .4);
}

.song-lyric-accent::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--red), #fff1b8 58%, var(--cyan));
  box-shadow: 0 0 12px rgba(243, 199, 106, .75);
  transform-origin: left;
}

.song-overlay.cue-enter .song-copy p {
  animation: song-lyric-arrive 760ms cubic-bezier(.18,.82,.24,1) both;
}

.song-overlay.cue-enter .song-lyric-accent {
  animation: song-accent-arrive 980ms 120ms cubic-bezier(.18,.82,.24,1) both;
}

.song-overlay.cue-enter .song-lyric-accent::after {
  animation: song-accent-line 820ms 260ms cubic-bezier(.18,.82,.24,1) both;
}

.song-overlay[data-lyric-align="right"] .song-copy {
  right: 6vw;
  left: auto;
  justify-items: end;
  text-align: right;
}
.song-overlay[data-lyric-align="center"] .song-copy {
  right: 6vw;
  left: 6vw;
  width: auto;
  justify-items: center;
  text-align: center;
}

.song-copy > i {
  right: 0;
  bottom: 0;
  width: 100%;
  color: rgba(255, 64, 88, 0.11);
  font-size: clamp(28px, 5vw, 70px);
  text-align: inherit;
  transform: translateY(0.35em);
}

.song-overlay[data-effect="chorus"] .song-copy p { text-shadow: 4px 0 rgba(255,64,88,.52), -3px 0 rgba(94,230,255,.42), 0 5px 24px #000; }
.song-overlay[data-effect="fracture"] .song-copy p,
.song-overlay[data-effect="shock"] .song-copy p { animation-name: lyric-fracture; }
.song-overlay[data-effect="afterglow"] .song-copy p { color: #fff8e4; text-shadow: 0 0 24px rgba(243,199,106,.5), 0 4px 20px #000; }
.song-overlay[data-effect="void"] .song-copy p { font-weight: 700; color: rgba(255,255,255,.82); }

.song-controls { z-index: 9; }
.staff-roll { z-index: 4; }

.song-overlay[data-song="ed"] .song-copy {
  z-index: 8;
  width: min(78vw, 880px);
  max-width: min(78vw, 880px);
  padding: 13px 18px 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-left: 4px solid var(--gold);
  background:
    linear-gradient(90deg, rgba(1,2,6,.9), rgba(1,2,6,.78) 72%, rgba(1,2,6,.58));
  box-shadow: 0 16px 46px rgba(0,0,0,.58), inset 0 0 0 1px rgba(255,255,255,.035);
  backdrop-filter: blur(7px);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.song-overlay[data-song="ed"][data-lyric-align="right"] .song-copy {
  right: 6vw;
  left: auto;
}

.song-overlay[data-song="ed"][data-lyric-align="center"] .song-copy {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

@keyframes mv-camera-push { from { transform: scale(1.04); } to { transform: scale(1.16); } }
@keyframes mv-camera-pull { from { transform: scale(1.17); } to { transform: scale(1.05); } }
@keyframes mv-camera-left { from { transform: scale(1.13) translateX(3%); } to { transform: scale(1.13) translateX(-3%); } }
@keyframes mv-camera-right { from { transform: scale(1.13) translateX(-3%); } to { transform: scale(1.13) translateX(3%); } }
@keyframes mv-camera-tilt { from { transform: scale(1.13) rotate(-.7deg); } to { transform: scale(1.08) rotate(.7deg); } }
@keyframes mv-camera-whip { 0% { transform: scale(1.2) translateX(-7%); filter: blur(9px) saturate(1.4); } 55% { filter: blur(0) saturate(1); } 100% { transform: scale(1.1); } }
@keyframes mv-camera-surge { 0% { transform: scale(1.04); filter: brightness(.7) saturate(.7); } 18% { filter: brightness(1.06) saturate(1.25); } 100% { transform: scale(1.17); } }
@keyframes mv-camera-orbit { from { transform: scale(1.12) translate(-2%, 1%) rotate(-.4deg); } to { transform: scale(1.12) translate(2%, -1%) rotate(.4deg); } }
@keyframes lyric-fracture { 0% { opacity: 0; transform: translateX(-18px) skewX(-9deg); filter: blur(6px); } 24% { opacity: 1; transform: translateX(7px) skewX(3deg); filter: none; } 38% { transform: translateX(-3px); } 100% { transform: none; } }
@keyframes song-lyric-arrive {
  from { opacity: 0; transform: translateY(18px); filter: blur(8px); }
  55% { filter: blur(0); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes song-accent-arrive {
  from { color: #fff; filter: brightness(2.2) blur(2px); }
  to { color: #fff1b8; filter: none; }
}

@keyframes impact-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  12% { transform: translate3d(-12px, 4px, 0); }
  24% { transform: translate3d(10px, -5px, 0); }
  38% { transform: translate3d(-7px, -2px, 0); }
  54% { transform: translate3d(6px, 3px, 0); }
  72% { transform: translate3d(-3px, 1px, 0); }
}

@keyframes impact-flash {
  0% { opacity: 0; }
  9% { opacity: 0.92; }
  19% { opacity: 0.08; }
  29% { opacity: 0.64; background: #ff304f; }
  44% { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes song-accent-line {
  from { opacity: 0; transform: scaleX(0); }
  to { opacity: 1; transform: scaleX(1); }
}
@keyframes character-cue-a {
  from { opacity: 0; transform: translateX(var(--mv-rest-x)) translateX(-5%) scale(1.08); filter: blur(7px) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  18% { opacity: 1; filter: blur(0) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  to { opacity: 1; transform: translateX(var(--mv-rest-x)) translateX(1%) scale(1); }
}
@keyframes character-cue-b {
  from { opacity: 0; transform: translateX(5%) scale(1.08); filter: blur(7px) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  18% { opacity: 1; filter: blur(0) drop-shadow(0 24px 36px rgba(0,0,0,.74)); }
  to { opacity: 1; transform: translateX(-1%) scale(1); }
}

@media (max-width: 720px) {
  .app { min-height: 0; }
  .top-ui {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
    min-height: 66px;
    padding: 7px 8px 0;
  }
  .title-block p { margin-bottom: 2px; font-size: 9px; }
  .title-block h1 { font-size: clamp(17px, 5.2vw, 22px); line-height: 1; }
  .audio-readout { display: none; }
  .top-buttons { align-items: flex-start; max-width: none; gap: 3px; }
  .top-buttons button { min-width: 43px; min-height: 34px; padding: 0 6px; font-size: 11px; }
  .top-buttons #skipButton { min-width: 55px; }
  .top-buttons #bookmarkButton { min-width: 48px; }
  .top-buttons .settings-button { width: 35px; min-width: 35px; font-size: 18px; }
  .settings-panel { top: 51px; right: 7px; width: min(350px, calc(100vw - 14px)); }
  .settings-panel > header { padding: 9px 9px 8px 11px; }
  .settings-grid button { min-height: 52px; padding: 6px 9px; }
  .stage.choice-mode { min-height: 132px; }
  .stage.choice-mode .sprite.presentation-bust {
    bottom: -104px;
    left: 50%;
    width: min(76vw, 330px);
    height: 244px;
    opacity: .64;
  }
  .stage.choice-mode.choice-crowded { min-height: 100px; }
  .stage.choice-mode.choice-crowded .sprite.presentation-bust {
    bottom: -114px;
    width: min(62vw, 270px);
    height: 214px;
    opacity: .5;
  }

  .song-overlay > .song-brand {
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    padding: 5px 12px 6px 9px;
  }
  .song-brand strong { font-size: clamp(32px, 12vw, 48px); }
  .song-brand span { font-size: 11px; }
  .song-brand i { margin-top: 5px; font-size: 6px; }
  .song-overlay > .song-frame-code { top: max(84px, calc(env(safe-area-inset-top) + 72px)); right: 12px; width: 118px; font-size: 7px; }
  .song-controls { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  .song-controls button { min-height: 36px; padding: 0 9px; font-size: 11px; }

  .song-character[data-art="bust"] { width: 118vw; height: 80dvh; bottom: 5dvh; }
  .song-character[data-art="full"] { width: 88vw; height: 79dvh; bottom: 6dvh; }
  .song-overlay[data-shot="hero"] .song-character-a,
  .song-overlay[data-shot="bust-left"] .song-character-a { left: -18vw; }
  .song-overlay[data-shot="bust-right"] .song-character-a { right: -18vw; left: auto; }
  .song-overlay[data-shot="impact"] .song-character-a { left: 50%; width: 132vw; }
  .song-overlay[data-shot="duo"] .song-character { display: block; width: 89vw; height: 75dvh; bottom: 8dvh; opacity: .92; }
  .song-overlay[data-shot="duo"] .song-character-a { left: -28vw; }
  .song-overlay[data-shot="duo"] .song-character-b { right: -28vw; left: auto; }
  .song-item,
  .song-overlay[data-shot="detail"] .song-item { top: 20%; width: 88vw; height: 52%; opacity: .72; }

  .song-copy,
  .song-overlay[data-song="insert"] .song-copy,
  .song-overlay[data-song="ed"] .song-copy {
    right: auto;
    bottom: max(66px, calc(env(safe-area-inset-bottom) + 48px));
    left: 14px;
    gap: 3px;
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    text-align: left;
  }
  .song-overlay[data-lyric-align="right"] .song-copy,
  .song-overlay[data-lyric-align="center"] .song-copy { right: 14px; left: 14px; width: auto; }
  .song-copy span { font-size: 7px; }
  .song-copy strong { font-size: 13px; }
  .song-copy em { font-size: 7px; }
  .song-copy p,
  .song-overlay[data-effect="chorus"] .song-copy p,
  .song-overlay[data-effect="surge"] .song-copy p {
    max-width: calc(100vw - 28px);
    min-height: 2.8em;
    font-size: clamp(18px, 5.2vw, 22px);
    line-height: 1.38;
  }
  .song-copy > i { display: none; }
  .song-overlay[data-song="ed"] .song-copy,
  .song-overlay[data-song="ed"][data-lyric-align="right"] .song-copy,
  .song-overlay[data-song="ed"][data-lyric-align="center"] .song-copy {
    right: 10px;
    bottom: max(62px, calc(env(safe-area-inset-bottom) + 44px));
    left: 10px;
    width: auto;
    max-width: none;
    padding: 10px 12px 12px;
    transform: none;
  }
}

@media (max-width: 420px) {
  .title-block h1 { font-size: 17px; }
  .top-buttons button { min-width: 40px; padding: 0 5px; }
  .top-buttons #skipButton { min-width: 52px; }
  .top-buttons #bookmarkButton { min-width: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .song-backdrop,
  .song-backdrop-alt,
  .song-character,
  .song-item,
  .song-copy p,
  .song-film::before,
  .song-film::after { animation: none !important; }
}

/* Visual integrity and cinematic transition pass v34 */
.message-window[data-line-kind="dialogue"][data-character-line="true"] #dialogueText::before,
.message-window[data-line-kind="dialogue"][data-character-line="true"] #dialogueText::after {
  content: none;
}

.stage.has-closeup .sprite,
.stage[data-layout="duo"].has-closeup .sprite.side.active,
.stage[data-layout="trio"].has-closeup .sprite.side.active {
  opacity: 0 !important;
  visibility: hidden;
  animation: none !important;
}

.closeup {
  --closeup-scale: 1;
  --closeup-x: 5%;
  inset: auto 0 -2% auto;
  z-index: 12;
  width: min(82%, 920px);
  height: 112%;
  opacity: 0;
  object-fit: contain;
  object-position: right bottom;
  mask-image: none;
  transform: translateX(var(--closeup-x)) scale(var(--closeup-scale));
  transform-origin: right bottom;
  filter: brightness(.89) saturate(.94) contrast(1.08) drop-shadow(0 28px 28px rgba(0,0,0,.78));
  transition: opacity 180ms ease, filter 260ms ease;
}

.closeup.show { opacity: 1; }
.closeup[data-character="yuto"] { --closeup-scale: 1.12; --closeup-x: 8%; }
.closeup[data-character="kurumi"] { --closeup-scale: 1.02; --closeup-x: 4%; }
.closeup[data-character="serin"] { --closeup-scale: 1.06; --closeup-x: 5%; }
.closeup[data-character="ayami"] { --closeup-scale: 1.01; --closeup-x: 4%; }
.closeup[data-character="himeko"] { --closeup-scale: 1.15; --closeup-x: 8%; }
.closeup[data-character="iwana"] { --closeup-scale: 1.04; --closeup-x: 5%; }
.closeup[data-character="mikage"] { --closeup-scale: 1.01; --closeup-x: 3%; }
.closeup[data-character="rikka"] { --closeup-scale: 1; --closeup-x: 4%; }
.closeup[data-character="dizark"] { --closeup-scale: 1.08; --closeup-x: 6%; }
.stage.choice-mode .sprite.presentation-bust {
  z-index: 12;
  opacity: 1;
  filter: brightness(.88) saturate(.94) contrast(1.08) drop-shadow(0 22px 24px rgba(0,0,0,.86));
}

.stage.choice-mode.choice-crowded .sprite.presentation-bust {
  display: none;
}

/* Character alpha contract: transparent canvas, fully opaque subject. */
.stage:not(.has-cutin):not(.has-closeup) .sprite.active,
.stage[data-layout="duo"]:not(.has-cutin):not(.has-closeup) .sprite.side.active,
.stage[data-layout="trio"]:not(.has-cutin):not(.has-closeup) .sprite.side.active,
.stage.choice-mode:not(.choice-crowded) .sprite.presentation-bust.active {
  opacity: 1 !important;
  visibility: visible;
}

.stage.has-cutin .sprite,
.stage.has-closeup .sprite,
.stage[data-layout="duo"].has-cutin .sprite.side.active,
.stage[data-layout="trio"].has-cutin .sprite.side.active,
.stage[data-layout="duo"].has-closeup .sprite.side.active,
.stage[data-layout="trio"].has-closeup .sprite.side.active {
  opacity: 0 !important;
  visibility: hidden;
  animation: none !important;
}

.transition-fx {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: none;
  pointer-events: none;
  transform-origin: center;
}

.transition-fx.active { display: block; }
.transition-fx[data-transition="fade-black"].active { background: #020307; animation: scene-fade-through 760ms ease-out both; }
.transition-fx[data-transition="fade-white"].active { background: #f8f6ef; animation: scene-fade-through 700ms ease-out both; }
.transition-fx[data-transition="wipe-left"].active { background: linear-gradient(90deg, #04050a 0 48%, rgba(94,230,255,.28) 50%, transparent 54%); animation: scene-wipe-left 720ms cubic-bezier(.5,0,.2,1) both; }
.transition-fx[data-transition="wipe-right"].active { background: linear-gradient(270deg, #04050a 0 48%, rgba(255,64,88,.24) 50%, transparent 54%); animation: scene-wipe-right 720ms cubic-bezier(.5,0,.2,1) both; }
.transition-fx[data-transition="bands"].active { background: repeating-linear-gradient(0deg, rgba(3,5,10,.96) 0 7%, rgba(94,230,255,.34) 7% 8%, transparent 8% 15%); mix-blend-mode: screen; animation: scene-bands 640ms steps(7) both; }
.transition-fx[data-transition="bloom"].active { background: radial-gradient(circle at 50% 48%, rgba(255,255,255,.92), rgba(94,230,255,.28) 22%, transparent 56%); mix-blend-mode: screen; animation: scene-bloom 780ms ease-out both; }
.transition-fx[data-transition="glitch"].active { background: repeating-linear-gradient(90deg, transparent 0 7vw, rgba(255,64,88,.28) 7vw 8vw, transparent 8vw 13vw), repeating-linear-gradient(0deg, rgba(94,230,255,.18) 0 2px, transparent 2px 9px); mix-blend-mode: screen; animation: scene-glitch 560ms steps(5) both; }
.transition-fx[data-transition="zoom"].active { background: rgba(2,3,7,.78); backdrop-filter: blur(10px); animation: scene-zoom 720ms ease-out both; }
.transition-fx[data-transition="burn"].active { background: radial-gradient(circle at 42% 54%, transparent 0 14%, rgba(255,224,143,.76) 19%, rgba(255,73,32,.62) 23%, #120307 42%, transparent 66%); mix-blend-mode: screen; animation: scene-burn 820ms ease-out both; }
.transition-fx[data-transition="cross-blur"].active { background: rgba(94,230,255,.08); backdrop-filter: blur(12px); animation: song-cross-blur 820ms ease-out both; }

.song-backdrop,
.song-backdrop-alt { z-index: 0; }

.song-item {
  z-index: 1;
  opacity: .72;
}

.song-character {
  z-index: 2;
  opacity: 1;
  mix-blend-mode: normal;
  filter: brightness(.9) saturate(.96) contrast(1.06) drop-shadow(0 24px 36px rgba(0,0,0,.78));
}

.song-film { z-index: 3; }

.song-overlay[data-shot="detail"] .song-character,
.song-overlay[data-shot="symbol"] .song-character {
  display: none !important;
}

.song-overlay[data-shot="detail"] .song-item,
.song-overlay[data-shot="symbol"] .song-item {
  z-index: 2;
  opacity: 1;
}

.song-transition {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
}

.song-overlay.cue-enter[data-transition="fade-black"] .song-transition { background: #020307; animation: song-fade-through 820ms ease-out both; }
.song-overlay.cue-enter[data-transition="fade-white"] .song-transition { background: #fffdf5; mix-blend-mode: screen; animation: song-fade-through 760ms ease-out both; }
.song-overlay.cue-enter[data-transition="wipe-left"] .song-transition { background: linear-gradient(90deg, #020307 0 47%, rgba(94,230,255,.4) 50%, transparent 54%); animation: scene-wipe-left 760ms cubic-bezier(.5,0,.2,1) both; }
.song-overlay.cue-enter[data-transition="wipe-right"] .song-transition { background: linear-gradient(270deg, #020307 0 47%, rgba(255,64,88,.38) 50%, transparent 54%); animation: scene-wipe-right 760ms cubic-bezier(.5,0,.2,1) both; }
.song-overlay.cue-enter[data-transition="bands"] .song-transition { background: repeating-linear-gradient(0deg, rgba(4,5,10,.94) 0 6%, rgba(94,230,255,.32) 6% 7%, transparent 7% 13%); mix-blend-mode: screen; animation: scene-bands 650ms steps(7) both; }
.song-overlay.cue-enter[data-transition="bloom"] .song-transition { background: radial-gradient(circle, rgba(255,255,255,.88), rgba(94,230,255,.24) 26%, transparent 64%); mix-blend-mode: screen; animation: scene-bloom 900ms ease-out both; }
.song-overlay.cue-enter[data-transition="glitch"] .song-transition { background: repeating-linear-gradient(90deg, transparent 0 9vw, rgba(255,64,88,.32) 9vw 10vw, transparent 10vw 16vw), repeating-linear-gradient(0deg, rgba(94,230,255,.2) 0 2px, transparent 2px 8px); mix-blend-mode: screen; animation: scene-glitch 620ms steps(6) both; }
.song-overlay.cue-enter[data-transition="signal-corrupt"] .song-transition {
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 28, 77, .38), transparent 33% 61%, rgba(41, 224, 255, .34)),
    repeating-linear-gradient(0deg, rgba(2, 4, 10, .92) 0 5px, rgba(94, 230, 255, .34) 5px 7px, transparent 7px 17px);
  mix-blend-mode: screen;
  animation: song-signal-corrupt 1180ms steps(10, end) both;
}

.song-overlay.cue-enter[data-transition="signal-corrupt"] .song-transition::before,
.song-overlay.cue-enter[data-transition="signal-corrupt"] .song-transition::after {
  content: "";
  position: absolute;
  inset: -8%;
  pointer-events: none;
}

.song-overlay.cue-enter[data-transition="signal-corrupt"] .song-transition::before {
  background:
    linear-gradient(90deg, rgba(255, 19, 70, .54), transparent 28% 70%, rgba(45, 227, 255, .5)),
    repeating-linear-gradient(90deg, transparent 0 12vw, rgba(255,255,255,.16) 12vw 12.6vw, transparent 12.6vw 19vw);
  clip-path: polygon(0 7%,100% 7%,100% 15%,0 15%,0 31%,100% 31%,100% 43%,0 43%,0 61%,100% 61%,100% 68%,0 68%,0 82%,100% 82%,100% 94%,0 94%);
  mix-blend-mode: color-dodge;
  animation: song-signal-slices 1180ms steps(9, end) both;
}

.song-overlay.cue-enter[data-transition="signal-corrupt"] .song-transition::after {
  background:
    linear-gradient(180deg, transparent 0 23%, rgba(2,3,8,.94) 23% 28%, transparent 28% 54%, rgba(255,255,255,.2) 54% 55%, transparent 55%),
    repeating-linear-gradient(90deg, rgba(255,64,88,.18) 0 1px, transparent 1px 11px, rgba(94,230,255,.16) 11px 12px, transparent 12px 23px);
  mix-blend-mode: hard-light;
  animation: song-signal-tear 1180ms steps(8, end) both;
}

.song-overlay.cue-enter[data-transition="signal-corrupt"] > .song-brand,
.song-overlay.cue-enter[data-transition="signal-corrupt"] > .song-frame-code {
  animation: song-signal-label 1180ms steps(8, end) both;
}
.song-overlay.cue-enter[data-transition="zoom"] .song-transition { background: rgba(2,3,7,.58); backdrop-filter: blur(9px); animation: scene-zoom 760ms ease-out both; }
.song-overlay.cue-enter[data-transition="burn"] .song-transition { background: radial-gradient(circle at 45% 55%, transparent 0 16%, rgba(255,231,162,.8) 21%, rgba(255,64,33,.62) 25%, #130307 44%, transparent 68%); mix-blend-mode: screen; animation: scene-burn 900ms ease-out both; }
.song-overlay.cue-enter[data-transition="cross-blur"] .song-transition { background: rgba(94,230,255,.08); backdrop-filter: blur(12px); animation: song-cross-blur 920ms ease-out both; }

.song-overlay.waiting {
  background: #03050b;
}

.song-overlay.waiting .song-backdrop,
.song-overlay.waiting .song-backdrop-alt {
  filter: saturate(.94) contrast(1.12) brightness(.54);
}

.song-overlay.waiting .song-character {
  display: block;
  height: 96dvh;
  opacity: 1;
  animation: cover-character-idle 8s ease-in-out infinite alternate;
}

.song-overlay.waiting .song-character-a {
  left: -1vw;
  width: min(49vw, 720px);
}

.song-overlay.waiting .song-character-b {
  right: -1vw;
  width: min(55vw, 780px);
  animation-delay: -4s;
}

.song-overlay.waiting .song-copy {
  right: auto;
  bottom: max(54px, calc(env(safe-area-inset-bottom) + 38px));
  left: 6vw;
  width: min(760px, 72vw);
  padding: 12px 16px 14px;
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, rgba(2,3,8,.82), rgba(2,3,8,.16));
}

.song-overlay.waiting .song-copy p {
  color: #fff;
  font-size: clamp(18px, 2.2vw, 30px);
  text-shadow: 0 4px 16px #000;
}

@keyframes scene-fade-through { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes scene-wipe-left { 0% { opacity: 1; transform: translateX(-110%); } 58% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(108%); } }
@keyframes scene-wipe-right { 0% { opacity: 1; transform: translateX(110%); } 58% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(-108%); } }
@keyframes scene-bands { 0% { opacity: 0; transform: translateY(-12%); } 28% { opacity: .9; } 100% { opacity: 0; transform: translateY(18%); } }
@keyframes scene-bloom { 0% { opacity: 0; transform: scale(.7); } 38% { opacity: 1; } 100% { opacity: 0; transform: scale(1.45); } }
@keyframes scene-glitch { 0% { opacity: 0; transform: translateX(0); } 18% { opacity: .9; transform: translateX(-12px); } 38% { transform: translateX(14px); } 62% { opacity: .55; transform: translateX(-5px); } 100% { opacity: 0; transform: translateX(0); } }
@keyframes song-signal-corrupt {
  0% { opacity: 0; transform: translateX(0); backdrop-filter: hue-rotate(0deg) saturate(1) contrast(1); }
  8% { opacity: .96; transform: translateX(-14px); backdrop-filter: invert(.84) hue-rotate(142deg) saturate(2.7) contrast(1.7); }
  17% { opacity: .42; transform: translateX(10px); backdrop-filter: hue-rotate(-48deg) saturate(2.35) contrast(1.55); }
  27% { opacity: .86; transform: translateX(-7px); backdrop-filter: invert(.2) hue-rotate(78deg) saturate(2.15) contrast(1.48); }
  41% { opacity: .3; transform: translateX(13px); backdrop-filter: hue-rotate(-28deg) saturate(1.9) contrast(1.38); }
  57% { opacity: .74; transform: translateX(-5px); backdrop-filter: invert(.7) hue-rotate(168deg) saturate(2.4) contrast(1.6); }
  73% { opacity: .26; transform: translateX(4px); backdrop-filter: hue-rotate(-14deg) saturate(1.55) contrast(1.28); }
  100% { opacity: 0; transform: translateX(0); backdrop-filter: hue-rotate(0deg) saturate(1) contrast(1); }
}
@keyframes song-signal-slices {
  0% { opacity: 0; transform: translateX(0) skewX(0); }
  12% { opacity: .88; transform: translateX(9%) skewX(-4deg); }
  26% { opacity: .34; transform: translateX(-7%) skewX(3deg); }
  45% { opacity: .76; transform: translateX(4%) skewX(-2deg); }
  66% { opacity: .28; transform: translateX(-3%) skewX(1deg); }
  100% { opacity: 0; transform: translateX(0) skewX(0); }
}
@keyframes song-signal-tear {
  0% { opacity: 0; transform: translateY(-4%); }
  10% { opacity: .92; transform: translateY(2%); }
  24% { opacity: .18; transform: translateY(-1%); }
  39% { opacity: .8; transform: translateY(5%); }
  58% { opacity: .25; transform: translateY(-3%); }
  100% { opacity: 0; transform: translateY(0); }
}
@keyframes song-signal-label {
  0%, 100% { filter: none; transform: translateX(0); }
  10% { filter: drop-shadow(-7px 0 rgba(255,64,88,.9)) drop-shadow(7px 0 rgba(94,230,255,.86)); transform: translateX(-4px); }
  22% { filter: invert(.9) contrast(1.7); transform: translateX(5px); }
  39% { filter: drop-shadow(5px 0 rgba(255,64,88,.72)) drop-shadow(-5px 0 rgba(94,230,255,.74)); transform: translateX(-2px); }
  63% { filter: hue-rotate(156deg) saturate(1.8); transform: translateX(2px); }
}
@keyframes scene-zoom { 0% { opacity: 0; transform: scale(1.18); } 34% { opacity: .86; } 100% { opacity: 0; transform: scale(.94); } }
@keyframes scene-burn { 0% { opacity: 0; transform: scale(.72) rotate(-2deg); } 36% { opacity: .96; } 100% { opacity: 0; transform: scale(1.42) rotate(2deg); } }
@keyframes song-fade-through { 0% { opacity: 0; } 28% { opacity: .92; } 100% { opacity: 0; } }
@keyframes song-cross-blur { 0% { opacity: 0; } 34% { opacity: .72; } 100% { opacity: 0; backdrop-filter: blur(0); } }
@keyframes cover-character-idle { from { transform: translateY(1%) scale(1.01); } to { transform: translateY(-1.2%) scale(1.025); } }

@media (max-width: 700px) {
  .closeup {
    right: -7vw;
    width: 112vw;
    height: 103%;
    transform-origin: right bottom;
  }

  .song-overlay.waiting .song-character {
    bottom: 7dvh;
    height: 72dvh;
  }

  .song-overlay.waiting .song-character-a {
    left: -25vw;
    width: 92vw;
  }

  .song-overlay.waiting .song-character-b {
    right: -26vw;
    width: 98vw;
  }

  .song-overlay.waiting .song-copy {
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 58px));
    left: 14px;
    width: calc(100vw - 28px);
  }
}

/* Mikage's bonus performance is one opaque portrait-safe illustration.
   Never add a transparent sprite or an extra cut-in over this frame. */
.song-overlay[data-song="edBonusMikage"] .song-backdrop,
.song-overlay[data-song="edBonusMikage"] .song-backdrop-alt {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: #02040a;
  filter: brightness(.82) saturate(1.08) contrast(1.08);
}

.song-overlay[data-song="edBonusMikage"] .song-character,
.song-overlay[data-song="edBonusMikage"] .song-item {
  display: none !important;
}

.song-overlay[data-song="edBonusMikage"] .song-copy {
  z-index: 22;
}

.song-overlay[data-song="edBonusMikage"] .song-copy p {
  color: #fff8e4;
  text-shadow: 0 0 18px rgba(255,64,88,.68), 0 3px 18px #000;
}

.song-overlay[data-song="edBonusMikage"] .song-lyric-accent {
  color: #ffb4c0;
  text-shadow: 0 0 14px rgba(255,64,88,.9);
}

@media (max-width: 700px) {
  .song-overlay[data-song="edBonusMikage"] .song-copy,
  .song-overlay[data-song="edBonusMikage"][data-lyric-align="center"] .song-copy {
    right: 10px;
    bottom: max(62px, calc(env(safe-area-inset-bottom) + 44px));
    left: 10px;
    width: auto;
    max-width: none;
    padding: 10px 12px 12px;
    text-align: center;
  }

  .song-overlay[data-song="edBonusMikage"] .song-copy p {
    font-size: clamp(19px, 5.4vw, 25px);
    line-height: 1.34;
  }
}

body.motion-off .transition-fx,
body.motion-off .song-transition,
body.motion-off .song-overlay.waiting .song-character {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .transition-fx,
  .song-transition {
    display: none !important;
  }

  .song-overlay.waiting .song-character {
    animation: none !important;
  }
}

/* Core completion pass: opaque story art, poster cover, and collection archives */
.stage.has-cutin .sprite,
.stage.has-cutin .closeup,
.stage.has-cutin .aura,
.stage.has-cutin .dizark-sigil,
.stage.has-cutin .decoy-info,
.stage.has-closeup .sprite,
.stage.has-closeup .decoy-info {
  visibility: hidden;
  opacity: 0 !important;
}

.cutin-layer {
  z-index: 14;
  background: transparent;
}

.cutin-layer::before {
  background: linear-gradient(0deg, rgba(2, 3, 8, .5), transparent 22%);
}

.cutin-layer.show {
  opacity: 1;
}

.cutin-layer img {
  display: block;
  filter: none;
  object-fit: contain;
  object-position: center center;
  transform: none;
  background: transparent;
}

.cutin-layer.portrait-source img {
  object-position: center center;
}

.closeup {
  z-index: 13;
  mix-blend-mode: normal;
}

.closeup.show {
  visibility: visible;
  opacity: 1 !important;
}

.stage[data-layout="duo"] .sprite,
.stage[data-layout="trio"] .sprite,
.sprite[data-character] {
  --stage-scale: 1;
}

.stage.choice-mode:not(.choice-crowded) .sprite.presentation-bust {
  bottom: -7%;
  left: 50%;
  z-index: 12;
  display: block;
  width: min(70vw, 680px);
  height: 118%;
  opacity: 1;
  object-position: center 14%;
  filter: brightness(.9) saturate(.96) contrast(1.07) drop-shadow(0 24px 26px rgba(0,0,0,.86));
}

.stage.choice-mode.choice-crowded .sprite.presentation-bust {
  display: none !important;
}

.song-lyric-line {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.song-overlay[data-shot="cinematic"] .song-character,
.song-overlay[data-shot="cinematic"] .song-item {
  display: none !important;
}

.song-overlay[data-shot="cinematic"] .song-backdrop,
.song-overlay[data-shot="cinematic"] .song-backdrop-alt {
  opacity: 1;
  filter: brightness(.76) saturate(1.02) contrast(1.08);
}

/* The secret ending's five new vertical illustrations are complete opaque cuts.
   Contain them so the desktop layout never crops a face or the grounded feet. */
.song-overlay[data-art-format="portrait-cutin"] .song-backdrop,
.song-overlay[data-art-format="portrait-cutin"] .song-backdrop-alt {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: rgba(3, 5, 12, .96);
}

.song-cover-cast {
  position: absolute;
  inset: 8dvh 0 0;
  z-index: 2;
  display: block;
  overflow: hidden;
  pointer-events: none;
}

.song-cover-cast[hidden] {
  display: none;
}

.song-cover-cast::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  background: linear-gradient(90deg, rgba(2,4,10,.36), transparent 25% 76%, rgba(2,4,10,.28)), linear-gradient(0deg, rgba(2,4,10,.94), transparent 37%);
  pointer-events: none;
}

.song-cover-member {
  position: absolute;
  bottom: -2dvh;
  left: var(--cover-x);
  z-index: var(--cover-depth);
  width: auto;
  height: var(--cover-height);
  max-width: none;
  opacity: 1;
  object-fit: contain;
  object-position: center bottom;
  filter: brightness(.84) saturate(.94) contrast(1.08) drop-shadow(0 22px 22px rgba(0,0,0,.82));
  transform: translateX(-50%);
  transform-origin: center bottom;
  animation: cover-cast-idle 8.5s ease-in-out var(--cover-delay) infinite alternate;
}

.song-cover-member.cover-yuto {
  filter: brightness(.95) saturate(1.02) contrast(1.08) drop-shadow(0 28px 30px rgba(0,0,0,.88));
}

.song-overlay.waiting .song-backdrop,
.song-overlay.waiting .song-backdrop-alt {
  filter: saturate(1.04) contrast(1.1) brightness(.7);
}

.song-overlay.waiting .song-copy {
  z-index: 7;
}

@keyframes cover-cast-idle {
  from { transform: translateX(-50%) translateY(0) scale(1); }
  to { transform: translateX(-50%) translateY(-1.2%) scale(1.012); }
}

.collection-dialog {
  width: min(1060px, calc(100vw - 32px));
  max-width: none;
  max-height: min(90dvh, 900px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(243,199,106,.62);
  border-radius: 4px;
  background: rgba(5, 8, 16, .98);
  color: var(--paper);
  box-shadow: 0 28px 90px rgba(0,0,0,.82), inset 0 0 0 1px rgba(94,230,255,.08);
}

.collection-dialog::backdrop {
  background: rgba(1, 2, 7, .82);
  backdrop-filter: blur(8px);
}

.collection-dialog > form {
  display: flex;
  flex-direction: column;
  max-height: min(90dvh, 900px);
  min-height: 0;
}

.collection-dialog header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid rgba(94,230,255,.18);
  background: linear-gradient(90deg, rgba(94,230,255,.08), transparent 44%);
}

.collection-dialog header div {
  display: grid;
  gap: 3px;
}

.collection-dialog header strong {
  color: var(--gold);
  font-size: 20px;
}

.collection-dialog header span {
  color: rgba(216,226,234,.64);
  font: 800 10px/1.2 ui-monospace, Consolas, monospace;
}

.collection-dialog header button,
.collection-filters button {
  min-height: 38px;
  border: 1px solid rgba(94,230,255,.34);
  border-radius: 2px;
  background: rgba(12,18,30,.9);
  color: var(--paper);
}

.collection-filters {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  padding: 10px 14px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.collection-filters button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  font-size: 11px;
}

.collection-filters button.active {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: inset 0 -2px var(--gold);
}

.gallery-body {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
}

.gallery-tile {
  display: grid;
  grid-template-rows: auto minmax(48px, auto);
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(94,230,255,.2);
  border-radius: 3px;
  background: #080d17;
  color: var(--paper);
  text-align: left;
}

.gallery-tile:not(:disabled):hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.gallery-tile.locked {
  opacity: .46;
}

.gallery-thumb {
  display: grid;
  aspect-ratio: 16 / 10;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(94,230,255,.06), rgba(255,64,88,.04));
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-thumb i {
  color: rgba(94,230,255,.4);
  font: 900 32px/1 ui-monospace, Consolas, monospace;
}

.gallery-meta {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 9px 10px 11px;
}

.gallery-meta small {
  color: var(--cyan);
  font: 800 8px/1 ui-monospace, Consolas, monospace;
}

.gallery-meta strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.gallery-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(1,2,7,.96);
  cursor: zoom-out;
}

.gallery-viewer[hidden] {
  display: none;
}

.gallery-viewer img {
  width: min(92vw, 1440px);
  height: min(82dvh, 920px);
  object-fit: contain;
  filter: drop-shadow(0 24px 52px rgba(0,0,0,.86));
}

.gallery-viewer div {
  position: fixed;
  right: 5vw;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: 3px;
  padding: 9px 12px;
  border-right: 2px solid var(--gold);
  background: rgba(2,4,10,.74);
}

.gallery-viewer span,
.gallery-viewer small {
  color: var(--cyan);
  font: 800 9px/1.2 ui-monospace, Consolas, monospace;
}

.gallery-viewer strong {
  font-size: 16px;
}

.jukebox-now {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.3fr);
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.jukebox-now div {
  display: grid;
  gap: 4px;
}

.jukebox-now span {
  color: var(--cyan);
  font: 900 9px/1 ui-monospace, Consolas, monospace;
}

.jukebox-now audio {
  width: 100%;
  height: 38px;
}

.jukebox-body {
  display: grid;
  gap: 6px;
  min-height: 0;
  padding: 12px 14px 16px;
  overflow-y: auto;
}

.jukebox-track {
  display: grid;
  grid-template-columns: 38px 74px minmax(0, 1fr) 32px;
  align-items: center;
  min-height: 48px;
  border: 1px solid rgba(94,230,255,.18);
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(94,230,255,.06), rgba(10,14,24,.94) 30%);
  color: var(--paper);
  text-align: left;
}

.jukebox-track > span,
.jukebox-track > i,
.jukebox-track > b {
  color: var(--cyan);
  font: 800 9px/1 ui-monospace, Consolas, monospace;
  font-style: normal;
  text-align: center;
}

.jukebox-track strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jukebox-track.locked {
  opacity: .42;
}

.jukebox-track:not(:disabled):hover {
  border-color: var(--gold);
}

@media (max-width: 700px) {
  .stage.choice-mode:not(.choice-crowded) .sprite.presentation-bust {
    bottom: -5%;
    width: 102vw;
    height: 122%;
    object-position: center 12%;
  }

  .song-cover-cast {
    top: 13dvh;
  }

  .song-cover-member {
    bottom: 5dvh;
    height: var(--cover-mobile-height);
  }

  .song-overlay.waiting .song-copy {
    background: linear-gradient(90deg, rgba(2,3,8,.88), rgba(2,3,8,.3));
  }

  .collection-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 20px);
  }

  .collection-dialog > form {
    max-height: calc(100dvh - 20px);
  }

  .collection-dialog header {
    padding: 11px 12px;
  }

  .collection-dialog header strong {
    font-size: 17px;
  }

  .gallery-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 9px;
  }

  .gallery-meta {
    padding: 7px 8px 9px;
  }

  .gallery-meta strong {
    font-size: 11px;
  }

  .gallery-viewer div {
    right: 14px;
    left: 14px;
    justify-items: start;
  }

  .jukebox-now {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px 12px;
  }

  .jukebox-body {
    padding: 9px;
  }

  .jukebox-track {
    grid-template-columns: 30px 52px minmax(0, 1fr) 26px;
    min-height: 46px;
    padding: 0 4px;
  }
}

body.motion-off .song-cover-member {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .song-cover-member {
    animation: none !important;
  }
}

/* Package cover, archive hub, and first-introduction readability pass. */
.character-note[hidden] {
  display: none !important;
}

.message-window[data-character-introduction="true"] .character-note {
  min-height: 0;
  padding-bottom: 3px;
}

.settings-controls {
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 12px;
  font-size: 12px;
}
.gallery-toolbar label { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.gallery-toolbar input { width: 18px; height: 18px; accent-color: var(--cyan); }
.gallery-toolbar button { padding: 8px 12px; }
.gallery-empty { grid-column: 1 / -1; padding: 24px 0; color: var(--paper); }
.collection-filters small { color: var(--gold); font-size: 10px; white-space: nowrap; }

/* Static clues survive reduced stimulation; audio-timed credits/progress remain intact. */
body.low-stimulus :is(.scene-bg, .concept-skin, .pulse-layer, .glitch-veil, .stage,
  .decoy-info, .sprite, .aura, .dizark-sigil, .closeup, .glyph,
  .song-backdrop, .song-backdrop-alt, .song-character, .song-item,
  .song-cover-member, .song-film, .song-brand, .song-frame-code,
  .song-copy p, .song-lyric-accent),
body.low-stimulus :is(.song-film, .song-lyric-accent, .dizark-sigil)::before,
body.low-stimulus :is(.song-film, .song-lyric-accent, .dizark-sigil)::after {
  animation: none !important;
  transition: none !important;
}
body.low-stimulus :is(.transition-fx, .song-transition) { display: none !important; }
body.low-stimulus #dialogueText .char {
  animation: none !important;
  opacity: 1;
  filter: none;
  transform: none;
}

.collection-hub {
  border-bottom: 1px solid rgba(255,255,255,.1);
  background:
    linear-gradient(110deg, rgba(94,230,255,.08), transparent 42%),
    #080d16;
}

.collection-hub > header {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 10px 12px 8px;
}

.collection-hub > header span {
  color: var(--cyan);
  font: 900 9px/1 ui-monospace, Consolas, monospace;
  letter-spacing: .04em;
}

.collection-hub > header strong {
  color: var(--gold);
  font-size: 13px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: rgba(94,230,255,.16);
}

.collection-grid button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 11px;
  border: 0;
  color: var(--ink);
  background: rgba(5,10,18,.96);
  text-align: left;
  cursor: pointer;
}

.collection-grid button:hover {
  background: linear-gradient(90deg, rgba(243,199,106,.16), rgba(5,10,18,.96));
}

.collection-grid button i {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(243,199,106,.42);
  color: var(--gold);
  font: 900 15px/1 ui-monospace, Consolas, monospace;
  font-style: normal;
}

.collection-grid button span {
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
}

.collection-grid button b {
  color: var(--cyan);
  font: 800 9px/1 ui-monospace, Consolas, monospace;
}

.settings-actions .reset-setting {
  min-height: 49px;
}

.cast-copy .expression-record {
  margin: 7px 0 13px;
}

.cast-copy .cast-role + .expression-record {
  border-top: 1px solid rgba(255,255,255,.07);
  padding-top: 8px;
}

.stage[data-layout="trio"] .sprite.main {
  width: min(44vw, 460px);
  height: 108%;
}

.stage[data-layout="trio"] .sprite.side {
  width: min(31vw, 340px);
  height: 96%;
}

.stage.trio .sprite.left { left: 21%; }
.stage.trio .sprite.right { left: 79%; }

.stage.choice-mode:not(.choice-crowded) {
  min-height: 188px;
}

.stage.choice-mode:not(.choice-crowded) .sprite.presentation-bust {
  bottom: -13%;
  width: min(82vw, 760px);
  height: 132%;
  object-position: center 10%;
}

.song-cover-cast {
  inset: 7dvh 0 0;
  overflow: hidden;
}

.song-cover-member {
  bottom: 1dvh;
  max-width: 28vw;
  filter: brightness(.92) saturate(1.01) contrast(1.08) drop-shadow(0 24px 26px rgba(0,0,0,.86));
}

.song-cover-member.cover-lead {
  filter: brightness(1) saturate(1.04) contrast(1.08) drop-shadow(0 28px 32px rgba(0,0,0,.9));
}

.song-overlay.waiting .song-copy {
  right: auto;
  bottom: max(48px, calc(env(safe-area-inset-bottom) + 26px));
  left: 50%;
  z-index: 24;
  align-items: center;
  justify-items: center;
  width: min(86vw, 700px);
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(94,230,255,.58);
  border-bottom: 1px solid rgba(255,64,88,.42);
  background: linear-gradient(90deg, rgba(2,4,10,.8), rgba(2,4,10,.3), rgba(2,4,10,.8));
  text-align: center;
  transform: translateX(-50%);
}

.song-overlay.waiting .song-copy p {
  min-height: 0;
  font-size: clamp(21px, 3.2vw, 34px);
  line-height: 1.24;
  text-wrap: balance;
}

.song-lyric-line {
  line-break: strict;
  word-break: keep-all;
}

.gallery-body {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  padding: 16px;
}

.gallery-tile {
  grid-template-rows: auto minmax(58px, auto);
  min-height: 0;
}

.gallery-thumb {
  aspect-ratio: 5 / 4;
  padding: 7px;
}

.gallery-thumb img {
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.48));
}

@media (max-width: 700px) {
  .collection-grid button {
    min-height: 54px;
    padding: 7px 9px;
  }

  .collection-hub > header {
    padding: 9px 10px 7px;
  }

  .stage[data-layout="trio"] .sprite.main {
    width: 54vw;
    min-width: 0;
    height: 107%;
  }

  .stage[data-layout="trio"] .sprite.side {
    width: 38vw;
    min-width: 0;
    height: 94%;
  }

  .stage.trio .sprite.left { left: 18%; }
  .stage.trio .sprite.right { left: 82%; }

  .stage.choice-mode:not(.choice-crowded) {
    min-height: 214px;
  }

  .stage.choice-mode:not(.choice-crowded) .sprite.presentation-bust {
    bottom: -18%;
    width: 118vw;
    height: 142%;
  }

  .song-cover-cast {
    inset: 11dvh 0 13dvh;
  }

  .song-cover-member {
    bottom: 0;
    max-width: 42vw;
  }

  .song-cover-member.cover-edge {
    display: none;
  }

  .song-overlay.waiting .song-copy {
    bottom: max(45px, calc(env(safe-area-inset-bottom) + 25px));
    width: calc(100vw - 28px);
    padding: 8px 10px 10px;
  }

  .song-overlay.waiting .song-copy p,
  .song-copy p,
  .song-overlay[data-effect="chorus"] .song-copy p,
  .song-overlay[data-effect="surge"] .song-copy p {
    font-size: clamp(20px, 5.8vw, 25px);
    line-height: 1.33;
  }

  .gallery-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .gallery-thumb {
    aspect-ratio: 4 / 5;
    padding: 8px;
  }

  .gallery-meta {
    padding: 9px 10px 11px;
  }

  .gallery-meta strong {
    font-size: 12px;
  }
}

/* Final responsive presentation calibration: a common ground plane, legible lyrics, and a true package cover. */
.sprite {
  --ground-offset: 0%;
  bottom: var(--ground-offset);
  transform-origin: center bottom;
}

.stage[data-layout="duo"] .sprite,
.stage[data-layout="duo"] .sprite.main,
.stage[data-layout="duo"] .sprite.side {
  width: min(40vw, 420px);
  height: 100%;
  --stage-scale: 1;
  --stage-y: 0px;
}

.stage[data-layout="duo"] .sprite.left { left: 31%; }
.stage[data-layout="duo"] .sprite.main { left: 69%; }

.stage[data-layout="trio"] .sprite,
.stage[data-layout="trio"] .sprite.main,
.stage[data-layout="trio"] .sprite.side {
  width: min(32vw, 350px);
  height: 100%;
  --stage-scale: 1;
  --stage-y: 0px;
}

.stage[data-layout="trio"] .sprite.left { left: 21%; }
.stage[data-layout="trio"] .sprite.main { left: 50%; }
.stage[data-layout="trio"] .sprite.right { left: 79%; }

.song-copy p,
.song-overlay[data-effect="chorus"] .song-copy p,
.song-overlay[data-effect="surge"] .song-copy p {
  max-width: min(920px, calc(100vw - 12vw));
  padding: 7px 14px 10px;
  border-left: 4px solid var(--cyan);
  border-bottom: 1px solid rgba(255, 255, 255, .28);
  background: linear-gradient(90deg, rgba(1, 3, 10, .84), rgba(1, 3, 10, .52) 78%, transparent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .36), inset 0 -1px rgba(94, 230, 255, .16);
  color: #fff;
  font-size: clamp(28px, 3.7vw, 48px);
  font-weight: 900;
  line-height: 1.24;
  letter-spacing: 0;
}

.song-lyric-line {
  text-wrap: balance;
}

.song-overlay.waiting .song-copy p {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: clamp(19px, 2.6vw, 28px);
  line-height: 1.25;
}

.song-cover-cast {
  inset: 5dvh 0 7dvh;
}

.song-cover-cast::after {
  z-index: 1;
}

.song-cover-member {
  bottom: var(--cover-bottom, 0);
  z-index: calc(var(--cover-depth) + 2);
  max-width: none;
  transform-origin: center bottom;
}

.song-cover-member.cover-back {
  opacity: .9;
  filter: brightness(.78) saturate(.88) contrast(1.05) drop-shadow(0 20px 22px rgba(0,0,0,.82));
}

.song-cover-member.cover-front {
  filter: brightness(.98) saturate(1.02) contrast(1.08) drop-shadow(0 28px 30px rgba(0,0,0,.9));
}

.song-cover-member.cover-lead {
  filter: brightness(1.04) saturate(1.05) contrast(1.1) drop-shadow(0 30px 34px rgba(0,0,0,.92));
}

.gallery-dialog {
  width: min(1180px, calc(100vw - 24px));
}

.gallery-body {
  grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
  gap: 16px;
  padding: 18px;
}

.gallery-tile {
  grid-template-rows: auto minmax(66px, auto);
}

.gallery-thumb {
  aspect-ratio: 4 / 5;
  padding: 10px;
}

.gallery-meta {
  padding: 11px 13px 13px;
}

.gallery-meta strong {
  font-size: 14px;
}

@media (max-width: 700px) {
  .stage[data-layout="duo"] .sprite,
  .stage[data-layout="duo"] .sprite.main,
  .stage[data-layout="duo"] .sprite.side {
    width: 48vw;
  }

  .stage[data-layout="duo"] .sprite.left { left: 28%; }
  .stage[data-layout="duo"] .sprite.main { left: 72%; }

  .stage[data-layout="trio"] .sprite,
  .stage[data-layout="trio"] .sprite.main,
  .stage[data-layout="trio"] .sprite.side {
    width: 43vw;
    height: 100%;
  }

  .stage[data-layout="trio"] .sprite.left { left: 17%; }
  .stage[data-layout="trio"] .sprite.main { left: 50%; }
  .stage[data-layout="trio"] .sprite.right { left: 83%; }

  .song-cover-cast {
    inset: 10dvh 0 13dvh;
  }

  .song-cover-member,
  .song-cover-member.cover-edge {
    display: block;
    bottom: var(--cover-mobile-bottom, 0);
    max-width: none;
  }

  .song-copy,
  .song-overlay[data-song="insert"] .song-copy,
  .song-overlay[data-song="ed"] .song-copy {
    right: 14px;
    left: 14px;
    width: auto;
    max-width: none;
  }

  .song-copy p,
  .song-overlay[data-effect="chorus"] .song-copy p,
  .song-overlay[data-effect="surge"] .song-copy p {
    width: auto;
    max-width: 100%;
    padding: 8px 11px 10px;
    border-left-width: 4px;
    font-size: clamp(28px, 7.7vw, 36px);
    line-height: 1.2;
  }

  .song-overlay.waiting .song-copy p {
    padding: 0;
    font-size: clamp(19px, 5.4vw, 25px);
  }

  .gallery-dialog {
    width: calc(100vw - 12px);
  }

  .gallery-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 13px;
  }

  .gallery-thumb {
    aspect-ratio: 5 / 6;
    padding: 12px;
  }

  .gallery-meta {
    padding: 11px 13px 14px;
  }

  .gallery-meta strong {
    font-size: 15px;
  }
}

/* Release presentation contract: package cover, readable lyrics, archive scale and common stage ground. */
.song-overlay.waiting::before {
  content: "";
  position: absolute;
  inset: -6%;
  z-index: -6;
  background: var(--opening-cover) center / cover no-repeat;
  filter: blur(28px) brightness(.3) saturate(.9);
  transform: scale(1.08);
}

.song-overlay.waiting .song-backdrop,
.song-overlay.waiting .song-backdrop-alt {
  inset: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: brightness(.9) saturate(1.02) contrast(1.04);
  transform: none;
  animation: none;
}

.song-overlay.waiting > .song-brand {
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  width: auto;
  padding: 7px 14px 8px 11px;
  border-left: 4px solid var(--red);
  background: linear-gradient(90deg, rgba(2, 4, 10, .82), rgba(2, 4, 10, .18));
  transform: none;
}

.song-overlay.waiting .song-brand strong,
.song-overlay.waiting .song-brand i {
  display: none;
}

.song-overlay.waiting .song-brand span {
  color: #fff;
  font: 950 clamp(18px, 2.4vw, 28px)/1.08 "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  letter-spacing: 0;
  text-shadow: 2px 0 rgba(255, 64, 88, .56), -1px 0 rgba(94, 230, 255, .42), 0 6px 18px #000;
}

.song-overlay:not(.waiting) .song-copy,
.song-overlay:not(.waiting)[data-song="insert"] .song-copy,
.song-overlay:not(.waiting)[data-song="ed"] .song-copy {
  z-index: 30;
}

.song-overlay:not(.waiting) .song-copy p,
.song-overlay:not(.waiting)[data-effect="chorus"] .song-copy p,
.song-overlay:not(.waiting)[data-effect="surge"] .song-copy p {
  padding: 10px 18px 13px;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, .28);
  border-left: 5px solid var(--cyan);
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(1, 3, 10, .92), rgba(1, 3, 10, .66) 82%, rgba(1, 3, 10, .24));
  box-shadow: 0 14px 38px rgba(0, 0, 0, .56), inset 0 0 24px rgba(94, 230, 255, .07), 0 0 18px rgba(94, 230, 255, .1);
  color: #fff;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.22;
  letter-spacing: 0;
  text-shadow: 0 3px 5px #000, 0 0 10px rgba(255, 255, 255, .26), 0 0 30px rgba(94, 230, 255, .18);
  -webkit-text-stroke: .25px rgba(255, 255, 255, .32);
}

.song-overlay .song-copy p .song-lyric-line {
  width: 100%;
  overflow: visible;
  overflow-wrap: normal;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-break: strict;
  word-break: keep-all;
}

.gallery-dialog {
  width: min(980px, calc(100vw - 24px));
}

.gallery-body {
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  justify-items: stretch;
  gap: 11px;
  padding: 14px;
}

.gallery-tile {
  grid-template-rows: minmax(138px, 22dvh) minmax(54px, auto);
  width: 100%;
  height: auto;
}

.gallery-thumb {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 4 / 3;
  padding: 6px;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .54));
}

.gallery-meta {
  padding: 8px 9px 10px;
}

.gallery-meta strong {
  font-size: 12px;
}

.stage:not(.has-cutin):not(.has-closeup) .sprite.active {
  opacity: 1;
}

.stage[data-layout="duo"] .sprite,
.stage[data-layout="trio"] .sprite {
  bottom: var(--ground-offset, 0%);
  height: 100%;
  object-position: center bottom;
  transform-origin: center bottom;
}

/* Keep every full-body asset inside a visible ground-safe zone. The reduced
   height also lowers the crown, so adding foot clearance never hides faces
   behind the scene plate. Bust-ups and dedicated cut-ins are excluded. */
.stage:not(.has-cutin):not(.has-closeup) .sprite.presentation-full {
  bottom: max(var(--ground-offset, 0%), 8px);
  height: calc(100% - clamp(10px, 3.8%, 18px));
}

@media (max-width: 700px) {
  .song-overlay.waiting::before {
    display: none;
  }

  .song-overlay.waiting .song-backdrop,
  .song-overlay.waiting .song-backdrop-alt {
    background-size: cover;
  }

  .song-overlay.waiting > .song-brand {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    max-width: calc(100vw - 132px);
    padding: 6px 10px 7px 9px;
  }

  .song-overlay.waiting .song-brand span {
    font-size: clamp(17px, 5vw, 22px);
  }

  .song-overlay:not(.waiting) .song-copy,
  .song-overlay:not(.waiting)[data-song="insert"] .song-copy,
  .song-overlay:not(.waiting)[data-song="ed"] .song-copy {
    right: 10px;
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 42px));
    left: 10px;
    width: auto;
    max-width: none;
  }

  .song-overlay:not(.waiting) .song-copy p,
  .song-overlay:not(.waiting)[data-effect="chorus"] .song-copy p,
  .song-overlay:not(.waiting)[data-effect="surge"] .song-copy p {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px 12px;
    font-size: clamp(32px, 9vw, 42px);
    line-height: 1.2;
  }

  .song-overlay.waiting .song-copy p {
    font-size: clamp(21px, 6vw, 27px);
  }

  .gallery-dialog {
    width: calc(100vw - 10px);
    max-height: 94dvh;
  }

  .gallery-dialog > form {
    max-height: 94dvh;
  }

  .gallery-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
  }

  .gallery-tile {
    grid-template-rows: minmax(126px, 21dvh) minmax(48px, auto);
    width: 100%;
  }

  .gallery-thumb {
    aspect-ratio: 4 / 3;
    padding: 4px;
  }

  .gallery-meta {
    padding: 7px 8px 9px;
  }

  .gallery-meta strong {
    font-size: 11px;
  }

  .stage[data-layout="duo"] .sprite,
  .stage[data-layout="duo"] .sprite.main,
  .stage[data-layout="duo"] .sprite.side {
    width: 48vw;
    height: 100%;
  }

  .stage[data-layout="trio"] .sprite,
  .stage[data-layout="trio"] .sprite.main,
  .stage[data-layout="trio"] .sprite.side {
    width: 43vw;
    height: 100%;
  }
}

/* Permanent MV contract: lyrics only while sung, open typography for OP/insert,
   and a protected panel only where the ED staff roll crosses behind it. */
.song-overlay[data-has-lyric="false"] .song-copy p,
.song-overlay[data-has-lyric="false"] .song-copy > i {
  display: none;
}

.song-overlay:not(.waiting)[data-lyric-frame="open"] .song-copy p,
.song-overlay:not(.waiting)[data-lyric-frame="open"][data-effect="chorus"] .song-copy p,
.song-overlay:not(.waiting)[data-lyric-frame="open"][data-effect="surge"] .song-copy p {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-shadow:
    0 4px 5px rgba(0, 0, 0, .96),
    0 0 12px rgba(0, 0, 0, .9),
    0 0 22px rgba(94, 230, 255, .3);
}

.song-overlay:not(.waiting)[data-lyric-frame="staff-protected"] .song-copy p {
  padding: 11px 16px 14px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-left: 5px solid var(--cyan);
  background: rgba(1, 3, 10, .86);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .72), inset 0 0 22px rgba(94, 230, 255, .06);
}

.song-overlay:not(.waiting) .song-character[data-art="full"] {
  bottom: max(4dvh, 44px);
  height: min(86dvh, calc(100dvh - 118px));
  object-fit: contain;
  object-position: center bottom;
}

@media (max-width: 700px) {
  .song-overlay:not(.waiting) .song-copy p,
  .song-overlay:not(.waiting)[data-effect="chorus"] .song-copy p,
  .song-overlay:not(.waiting)[data-effect="surge"] .song-copy p {
    font-size: clamp(25px, 7.1vw, 34px);
    line-height: 1.24;
  }

  .song-overlay:not(.waiting)[data-lyric-frame="open"] .song-copy p {
    padding: 0 4px;
  }

  .song-overlay:not(.waiting) .song-character[data-art="full"] {
    bottom: max(9dvh, 72px);
    width: 94vw;
    height: min(78dvh, calc(100dvh - 154px));
  }
}

/* Final MV ground contract: full-body art stays on-screen from hair to shoes. */
.song-overlay:not(.waiting) .song-character[data-art="full"] {
  bottom: max(2.2dvh, 18px);
  height: min(91dvh, calc(100dvh - 78px));
  object-fit: contain;
  object-position: center bottom;
}

.song-overlay:not(.waiting)[data-shot="duo"] .song-character[data-art="full"] {
  bottom: max(2.2dvh, 18px);
  width: min(53vw, 760px);
  height: min(86dvh, calc(100dvh - 86px));
}

.song-overlay[data-ending-mode="secret"] .staff-roll dt {
  color: #ffcf75;
}

.song-overlay[data-ending-mode="secret"] .staff-roll dd {
  color: #f4fbff;
}

.song-overlay[data-ending-mode="secret"] .staff-roll h2 {
  text-shadow: 3px 0 rgba(255, 64, 88, .52), -3px 0 rgba(94, 230, 255, .46), 0 8px 28px #000;
}

.song-overlay[data-ending-mode="secret"] .song-copy {
  z-index: 8;
  width: min(74vw, 820px);
  max-width: min(74vw, 820px);
}

@media (max-width: 700px) {
  .song-overlay:not(.waiting) .song-character[data-art="full"] {
    bottom: max(2.4dvh, 18px);
    width: 98vw;
    height: min(86dvh, calc(100dvh - 92px));
  }

  .song-overlay:not(.waiting)[data-shot="duo"] .song-character[data-art="full"] {
    bottom: max(2.4dvh, 18px);
    width: 91vw;
    height: min(82dvh, calc(100dvh - 104px));
  }

  .song-overlay[data-ending-mode="secret"] .song-copy,
  .song-overlay[data-ending-mode="secret"][data-lyric-align="right"] .song-copy,
  .song-overlay[data-ending-mode="secret"][data-lyric-align="center"] .song-copy {
    right: 14px;
    bottom: max(5dvh, 34px);
    left: 14px;
    width: auto;
    max-width: none;
    transform: none;
  }

  .song-overlay[data-ending-mode="secret"] .staff-roll {
    width: calc(100vw - 52px);
  }

  .gallery-body {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
  }

  .gallery-tile {
    grid-template-rows: minmax(84px, 13dvh) 44px;
  }

  .gallery-thumb {
    padding: 3px;
  }

  .gallery-meta {
    min-width: 0;
    padding: 5px 5px 6px;
  }

  .gallery-meta small {
    overflow: hidden;
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .gallery-meta strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.22;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}

@media (max-width: 350px) {
  .gallery-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Character visual invariant: an integrated illustration owns the frame.
   Never leave a faint standing sprite behind it. Responsive companion art
   supplies the reviewed crop, so story CGs may fill each viewport. */
.stage.has-cutin .sprite,
.stage.has-cutin .closeup,
.stage.has-cutin .aura,
.stage.has-cutin .dizark-sigil,
.stage.has-cutin .decoy-info,
.stage.has-closeup .sprite,
.stage.has-closeup .decoy-info {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

.cutin-layer {
  z-index: 30;
  /* Illustration fill contract: story CGs own the stage and use their
     reviewed object-position instead of shrinking into transparent margins. */
  background: transparent;
}

.cutin-layer.show {
  opacity: 1;
}

.cutin-layer img,
.cutin-layer.portrait-source img {
  object-fit: cover;
  transform: scale(1.01);
  background: transparent;
}

/* Character CG framing contract: keep every face below the upper information
   band. The lower body may leave the stage when a portrait must be cropped. */
.cutin-layer.face-safe img {
  object-position: center 20%;
  transform-origin: center top;
}

.closeup {
  z-index: 29;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  mask-image: none;
  mix-blend-mode: normal;
  /* Bust-up alpha contract: keep the cutout canvas transparent while the
     character itself remains fully opaque above the scene background. */
  background: transparent;
  transform: none;
}

.closeup.show {
  opacity: 1 !important;
}

/* Keep full-body shoe soles above the stage floor without changing the
   character-specific height relationship used by duo/trio scenes. */
.stage:not(.has-cutin):not(.has-closeup) .sprite.presentation-full {
  bottom: max(var(--ground-offset, 0%), 12px);
  object-position: center bottom;
}

@media (max-width: 700px) {
  .cutin-layer.portrait-source img {
    object-fit: cover;
  }
}

/* The opening cover is a single poster composition. Contain it instead of
   cropping the outer cast on narrow screens; the poster already carries the
   title treatment, so the live brand does not duplicate the logo. */
.song-overlay.waiting[data-shot="cover-poster"] .song-backdrop,
.song-overlay.waiting[data-shot="cover-poster"] .song-backdrop-alt {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: #02040a;
  transform: none;
}

.song-overlay.waiting[data-shot="cover-poster"] > .song-brand {
  display: none;
}

.song-overlay.waiting[data-shot="cover-poster"] .song-copy > i {
  display: none;
}

@media (max-width: 700px) {
  .song-overlay.waiting[data-shot="cover-poster"] .song-controls {
    right: max(8px, env(safe-area-inset-right));
    gap: 4px;
  }

  .song-overlay.waiting[data-shot="cover-poster"] .song-controls button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 10px;
    white-space: nowrap;
  }
}

/* Final lyric-fit contract: semantic rows may wrap, but no sung text may leave
   the visual safe area or be hidden behind an ending credit roll. */
.song-overlay:not(.waiting) .song-copy,
.song-overlay:not(.waiting) .song-copy p,
.song-overlay:not(.waiting) .song-lyric-line {
  min-width: 0;
  box-sizing: border-box;
  max-width: 100%;
}

.song-overlay:not(.waiting) .song-copy p {
  white-space: normal;
  overflow: visible;
}

.song-overlay:not(.waiting) .song-copy p .song-lyric-line {
  display: block;
  width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-break: strict;
}

.song-overlay:not(.waiting) .song-copy p .song-lyric-accent {
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .song-overlay:not(.waiting) .song-copy,
  .song-overlay:not(.waiting)[data-song="insert"] .song-copy,
  .song-overlay:not(.waiting)[data-song="ed"] .song-copy,
  .song-overlay:not(.waiting)[data-lyric-align="right"] .song-copy,
  .song-overlay:not(.waiting)[data-lyric-align="center"] .song-copy,
  .song-overlay[data-ending-mode="secret"] .song-copy,
  .song-overlay[data-ending-mode="bonus"] .song-copy {
    right: max(34px, env(safe-area-inset-right)) !important;
    left: max(34px, env(safe-area-inset-left)) !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
  }

  .song-overlay:not(.waiting) .song-copy p,
  .song-overlay:not(.waiting)[data-effect="chorus"] .song-copy p,
  .song-overlay:not(.waiting)[data-effect="surge"] .song-copy p {
    width: 100% !important;
    max-width: 100% !important;
    font-size: clamp(25px, 6.4vw, 31px);
    line-height: 1.2;
  }

  .song-overlay:not(.waiting)[data-lyric-frame="staff-protected"] .song-copy p {
    padding: 9px 11px 11px;
  }
}

/* Collection signals stay separate from the story's deliberate corruption. */
.choice-discovery {
  display: block;
  margin-top: 5px;
  color: #a7bbc2;
  font: 600 11px/1.4 ui-monospace, Consolas, monospace;
  white-space: normal;
  overflow-wrap: anywhere;
}
.choice-list button[data-discovery="new"] { border-left: 3px solid #69d8ba; }
.choice-list button[data-discovery="target"] { border-left: 3px solid #f2ce77; }
.choice-list button[data-discovery="ahead"],
.choice-list button[data-discovery="possible"] { border-left: 3px dashed #69d8ba; }
[data-discovery="new"] .choice-discovery,
[data-discovery="ahead"] .choice-discovery,
[data-discovery="possible"] .choice-discovery { color: #8ce8ce; }
[data-discovery="target"] .choice-discovery { color: #f2ce77; }
#collectionTargetStatus {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
  color: #f2ce77;
  font-size: 11px;
}
#collectionTargetStatus[hidden] { display: none; }
.command-row .tap-hint[hidden] { display: none; }
#collectionTargetStatus button { width: 32px; height: 32px; padding: 0; flex: 0 0 32px; }
.gallery-tile { grid-template-rows: minmax(84px, 13dvh) minmax(64px, auto); }
.gallery-tile.locked, .jukebox-track.locked { opacity: 1; }
.gallery-tile.locked .gallery-thumb { opacity: .5; }
.collection-source {
  display: block;
  margin-top: 4px;
  color: #b9d3d7;
  font: 500 10px/1.4 ui-monospace, Consolas, monospace;
  white-space: normal;
  overflow-wrap: anywhere;
}
.jukebox-entry { display: flex; gap: 5px; min-width: 0; }
.jukebox-entry .jukebox-track { flex: 1; min-width: 0; }
.jukebox-track .collection-source { grid-column: 2 / 5; text-align: left; padding-bottom: 5px; }
.jukebox-track strong { white-space: normal; overflow-wrap: anywhere; }
.song-replay { flex: 0 0 54px; padding: 4px; font-size: 11px; }
.collection-hint-dialog { width: min(620px, calc(100vw - 24px)); }
.collection-hint-dialog form { max-height: 80dvh; overflow: auto; }
.collection-hint-body { padding: 0 16px 16px; }
.collection-hint-body section { padding: 14px 0; border-bottom: 1px solid #33454e; }
.collection-hint-body strong { font-size: 13px; overflow-wrap: anywhere; }
.collection-hint-body p { font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.collection-hint-body .collection-route { color: #b9d3d7; }
.collection-hint-body button { min-height: 40px; }
.cast-list .collection-source { grid-column: 1 / -1; margin: 0; text-align: center; }
.expression-record .collection-source { margin: 0; padding: 2px; font-size: 8px; text-align: center; }
.gallery-tile:focus-visible, .jukebox-track:focus-visible, .song-replay:focus-visible {
  outline: 2px solid #f2ce77;
  outline-offset: 2px;
}
