: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;
  width: 100vw;
  height: 100dvh;
  min-height: 640px;
  overflow: hidden;
  background: #05050a;
}

.scene-bg,
.concept-skin,
.pulse-layer,
.glitch-veil,
.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.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/mountain-memory.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;
}

.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;
}

.pulse-layer.overdrive {
  animation: overdriveBg 620ms ease-in-out infinite 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);
  height: calc(100dvh - 78px);
  min-height: 560px;
  margin: 0 auto;
  padding: 9px clamp(10px, 2vw, 24px) clamp(10px, 2vw, 18px);
}

.scene-plate {
  justify-self: start;
  display: flex;
  align-items: center;
  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 {
  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;
}

.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;
}

.cutin-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  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: 0.88;
}

.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.16;
}

.decoy-info {
  position: absolute;
  top: 9px;
  left: 10px;
  z-index: 7;
  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);
  animation: decoyFlicker 2.6s steps(2) infinite;
}

.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;
  --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))) 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: 0.82;
}

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

.sprite.speaking {
  animation: talkBounce 540ms 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;
}

.sprite.overdrive {
  animation: overdriveSprite 620ms steps(2) infinite;
}

.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;
  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;
  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;
}

.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;
}

#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;
  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;
}

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

#logBody {
  max-height: 64vh;
  overflow: auto;
  padding: 15px;
}

#logBody p {
  margin: 0 0 14px;
  line-height: 1.72;
}

body.flash {
  animation: flash 420ms ease;
}

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.78;
  animation: glitchSlide 180ms linear infinite;
}

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

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))) 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))) 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))) 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))) 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))) 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))) rotate(-1deg); }
  48% { transform: translateX(calc(var(--x) + 13px)) translateY(calc(var(--base-y) + var(--stage-y))) scale(calc(var(--scale) * var(--stage-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))) 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))); 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))); 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 {
    height: calc(100dvh - 124px);
    min-height: 0;
    padding: 6px 8px 8px;
  }

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

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

  .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;
  }

  .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: 0.62;
  }

  .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;
  }

  .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;
  }
}
