:root {
  --ink: #4b3340;
  --ink-soft: #7d6471;
  --ink-faint: rgba(75, 51, 64, 0.5);
  --cream: #fffaf5;
  --milk: #fffdfb;
  --pink: #ff9dbb;
  --pink-deep: #ef6d99;
  --pink-soft: #ffe3ec;
  --pink-glow: rgba(239, 109, 153, 0.24);
  --sky: #9fd4ef;
  --sky-soft: #e7f6ff;
  --lav: #c9b9f4;
  --line: rgba(255, 255, 255, 0.7);
  --glass: rgba(255, 250, 252, 0.72);
  --glass-strong: rgba(255, 253, 252, 0.9);
  --shadow: rgba(160, 89, 121, 0.18);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  --round: "YouYuan", "幼圆", "Yuanti SC", "Microsoft YaHei", sans-serif;
  --dialogue-size: clamp(17px, 1.52vw, 22px);
  --dialogue-font: var(--sans);
}

:root[data-font-size="small"] {
  --dialogue-size: clamp(15px, 1.3vw, 19px);
}

:root[data-font-size="large"] {
  --dialogue-size: clamp(20px, 1.82vw, 27px);
}

:root[data-font-style="yuanti"] {
  --dialogue-font: var(--round);
}

:root[data-font-style="serif"] {
  --dialogue-font: var(--serif);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #f8edf2;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
}

button:focus-visible {
  outline: 2px solid var(--pink-deep);
  outline-offset: 3px;
}

::selection {
  background: var(--pink-soft);
  color: var(--ink);
}

/* ---------- Start screen ---------- */

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(20px, 4vw, 56px);
  background-size: cover;
  background-position: center;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

#start-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-position: center center;
  background-size: cover;
  transform: scale(1.12);
  transform-origin: center center;
  pointer-events: none;
}

.start-veil {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 255, 255, 0.85), transparent 38%),
    radial-gradient(circle at 86% 18%, rgba(255, 190, 214, 0.46), transparent 40%),
    radial-gradient(circle at 76% 82%, rgba(159, 212, 239, 0.4), transparent 42%),
    linear-gradient(102deg, rgba(255, 250, 245, 0.97) 0%, rgba(255, 248, 247, 0.9) 42%, rgba(255, 244, 249, 0.45) 72%, rgba(255, 248, 252, 0.2) 100%);
  backdrop-filter: saturate(115%);
  -webkit-backdrop-filter: saturate(115%);
}

.start-veil::before,
.start-veil::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
  pointer-events: none;
}

.start-veil::before {
  width: 34vw;
  height: 34vw;
  right: -12vw;
  top: -14vw;
  background: radial-gradient(circle, rgba(255, 157, 187, 0.32), transparent 68%);
}

.start-veil::after {
  width: 28vw;
  height: 28vw;
  left: 34%;
  bottom: -18vw;
  background: radial-gradient(circle, rgba(159, 212, 239, 0.3), transparent 68%);
}

.start-content {
  position: relative;
  z-index: 2;
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.62fr);
  align-items: center;
  gap: clamp(32px, 5vw, 76px);
  animation: riseIn 1.05s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.start-copy {
  position: relative;
  min-width: 0;
}

.start-kicker {
  margin: 0 0 18px;
  color: var(--pink-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.38em;
}

.start-content h1 {
  margin: 0;
  color: #4f3240;
  font-family: var(--serif);
  font-size: clamp(46px, 6.6vw, 92px);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: 0.03em;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.5), 0 20px 50px rgba(175, 99, 132, 0.13);
}

.start-content h1 span {
  display: inline-block;
  margin-top: 6px;
  color: #765362;
  font-size: 0.46em;
  letter-spacing: 0.11em;
}

.start-sub {
  margin: 28px 0 24px;
  max-width: 540px;
  color: rgba(75, 51, 64, 0.68);
  font-family: var(--serif);
  font-size: clamp(14px, 1.3vw, 18px);
  line-height: 2;
  letter-spacing: 0.055em;
}

.start-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.16em;
  box-shadow: 0 10px 30px rgba(193, 121, 150, 0.1);
}

.start-ribbon span {
  color: var(--pink-deep);
}

.start-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(18px, 2.2vw, 28px);
  border: 1.5px solid rgba(255, 255, 255, 0.82);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.64), rgba(255, 246, 250, 0.5)),
    radial-gradient(circle at 90% 0%, rgba(255, 157, 187, 0.22), transparent 45%);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  box-shadow:
    0 30px 80px rgba(151, 80, 112, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.start-actions::before,
.start-actions::after {
  position: absolute;
  color: rgba(239, 109, 153, 0.55);
  font-size: 20px;
  pointer-events: none;
}

.start-actions::before {
  content: "♡";
  top: 12px;
  right: 16px;
}

.start-actions::after {
  content: "✿";
  bottom: 12px;
  left: 16px;
}

.start-actions-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 8px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
}

.start-actions-title em {
  color: var(--pink-deep);
  font-size: 16px;
  font-style: normal;
  letter-spacing: 0;
}

.title-btn {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(165, 93, 124, 0.08);
  transition: transform 0.22s ease, background 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.title-btn:hover,
.title-btn:focus-visible {
  transform: translateY(-2px) scale(1.025);
  border-color: rgba(255, 255, 255, 0.96);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 14px 32px rgba(165, 93, 124, 0.16);
}

.title-btn:active {
  transform: translateY(0) scale(0.99);
}

.title-btn.is-primary {
  border-color: rgba(255, 255, 255, 0.88);
  background:
    linear-gradient(135deg, rgba(255, 183, 205, 0.98), rgba(247, 128, 168, 0.94)),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.55), transparent 50%);
  color: #4e1d32;
  box-shadow: 0 16px 38px rgba(239, 109, 153, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.title-btn.is-primary:hover {
  background:
    linear-gradient(135deg, rgba(255, 192, 212, 1), rgba(250, 137, 176, 0.98)),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.6), transparent 50%);
  box-shadow: 0 18px 44px rgba(239, 109, 153, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.title-btn-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.56);
  color: var(--pink-deep);
  font-size: 17px;
  line-height: 1;
}

.title-btn.is-primary .title-btn-icon {
  background: rgba(255, 255, 255, 0.4);
  color: #6d2442;
}

.title-btn-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.title-btn-copy strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.title-btn-copy small {
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.title-btn.is-primary .title-btn-copy small {
  color: rgba(78, 29, 50, 0.7);
}

.title-btn-mark {
  color: rgba(239, 109, 153, 0.65);
  font-size: 14px;
  text-align: right;
}

.title-btn.is-primary .title-btn-mark {
  color: rgba(109, 36, 66, 0.6);
}

.start-actions-note {
  margin: 8px 0 0;
  color: rgba(125, 100, 113, 0.62);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-align: center;
}

.start-note {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: rgba(75, 51, 64, 0.48);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-align: center;
}

.start-deco {
  position: absolute;
  z-index: 1;
  color: rgba(239, 109, 153, 0.38);
  pointer-events: none;
  animation: floatDeco 7s ease-in-out infinite;
}

.start-deco-a {
  top: 12%;
  left: 6%;
  font-size: clamp(30px, 4vw, 64px);
}

.start-deco-b {
  top: 18%;
  right: 8%;
  color: rgba(159, 212, 239, 0.55);
  font-size: clamp(24px, 3.2vw, 48px);
  animation-delay: -2.4s;
}

.start-deco-c {
  bottom: 16%;
  left: 10%;
  color: rgba(201, 185, 244, 0.55);
  font-size: clamp(20px, 2.6vw, 38px);
  animation-delay: -4.1s;
}

.start-deco-d {
  bottom: 11%;
  right: 14%;
  font-size: clamp(26px, 3.5vw, 52px);
  animation-delay: -1.2s;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatDeco {
  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }
  50% {
    transform: translateY(-14px) rotate(7deg);
  }
}

/* ---------- Stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #17121a;
  user-select: none;
  cursor: pointer;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.1);
  transform-origin: center center;
  transition: opacity 1.1s ease;
}

.bg-layer.active {
  opacity: 1;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 36%, rgba(47, 28, 40, 0.16) 80%, rgba(39, 24, 34, 0.36) 100%),
    linear-gradient(180deg, rgba(54, 32, 46, 0.18) 0%, transparent 24%, transparent 62%, rgba(54, 32, 46, 0.32) 100%);
  transition: box-shadow 0.4s ease;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.08;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.25) 0.5px, transparent 0.6px),
    radial-gradient(rgba(0, 0, 0, 0.24) 0.5px, transparent 0.6px);
  background-position: 0 0, 5px 7px;
  background-size: 9px 9px, 11px 11px;
}

.watermark-cover {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 18%;
  height: 12%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 100% 100%, rgba(30, 18, 26, 0.9) 0%, rgba(30, 18, 26, 0.62) 42%, rgba(30, 18, 26, 0) 78%),
    linear-gradient(315deg, rgba(30, 18, 26, 0.5) 0%, rgba(30, 18, 26, 0) 66%);
  backdrop-filter: blur(7px) saturate(90%);
  -webkit-backdrop-filter: blur(7px) saturate(90%);
  -webkit-mask-image: radial-gradient(ellipse at 100% 100%, #000 0%, #000 48%, transparent 82%);
  mask-image: radial-gradient(ellipse at 100% 100%, #000 0%, #000 48%, transparent 82%);
}

/* ---------- Sprite ---------- */

.sprite-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.sprite-wrap {
  position: relative;
  width: 100%;
  height: 75vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}

.sprite {
  display: block;
  width: auto;
  height: 75vh;
  max-width: 100%;
  object-fit: contain;
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  transition: opacity 0.32s ease, transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}

.sprite.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sprite.is-hidden {
  opacity: 0;
  transform: translateY(16px) scale(0.985);
}

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

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 2.6vh, 28px) clamp(18px, 3.6vw, 48px);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 17px 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 251, 252, 0.68);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: 0 10px 28px rgba(111, 62, 83, 0.14);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffc1d5, #f47aa5);
  color: #641e3b;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.brand-text {
  color: rgba(75, 51, 64, 0.8);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.16em;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: auto;
}

.hud-hint {
  padding: 8px 13px;
  border: 1px dashed rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(75, 51, 64, 0.58);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.progress {
  padding: 8px 15px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  background: rgba(255, 251, 252, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(75, 51, 64, 0.68);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.sound-btn {
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 251, 252, 0.64);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(75, 51, 64, 0.78);
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sound-btn:hover {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(255, 180, 204, 0.78);
  color: var(--ink);
  transform: scale(1.04);
}

.sound-btn.is-muted {
  opacity: 0.55;
  text-decoration: line-through;
}

/* ---------- Dialogue ---------- */

.dialogue {
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 2.8vh, 32px);
  z-index: 50;
  width: min(1120px, calc(100% - 48px));
  min-height: 192px;
  padding: 34px clamp(26px, 3.4vw, 48px) 30px;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 253, 252, 0.9), rgba(255, 245, 249, 0.84)),
    radial-gradient(circle at 10% 0%, rgba(255, 173, 199, 0.3), transparent 48%);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow:
    0 24px 70px rgba(68, 37, 53, 0.25),
    0 3px 0 rgba(255, 255, 255, 0.38) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transform: translateX(-50%);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.dialogue::before {
  content: "";
  position: absolute;
  top: 0;
  left: 34px;
  right: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(239, 109, 153, 0.5), rgba(159, 212, 239, 0.5), transparent);
}

.dialogue::after {
  content: "♡";
  position: absolute;
  right: 24px;
  top: -15px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd8e5, #ffb1c9);
  color: #9b3e60;
  font-size: 13px;
  box-shadow: 0 5px 14px rgba(216, 111, 149, 0.2);
}

.speaker-wrap {
  position: absolute;
  top: -17px;
  left: clamp(26px, 3.4vw, 48px);
}

.speaker {
  display: inline-block;
  padding: 7px 20px 8px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 168, 196, 0.98), rgba(242, 117, 158, 0.95));
  color: #fffafb;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 8px rgba(120, 36, 68, 0.28);
  box-shadow: 0 8px 24px rgba(239, 109, 153, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.speaker:empty {
  display: none;
}

.dialogue-text {
  margin: 0;
  min-height: 3.8em;
  color: var(--ink);
  font-family: var(--dialogue-font);
  font-size: var(--dialogue-size);
  line-height: 1.92;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  white-space: pre-wrap;
}

.dialogue.is-narration .dialogue-text {
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.dialogue.is-narration {
  background:
    linear-gradient(135deg, rgba(255, 253, 252, 0.9), rgba(242, 249, 255, 0.85)),
    radial-gradient(circle at 88% 100%, rgba(159, 212, 239, 0.25), transparent 48%);
}

.next-hint {
  position: absolute;
  right: clamp(24px, 3.2vw, 46px);
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(75, 51, 64, 0.46);
  font-size: 11px;
  letter-spacing: 0.16em;
  transition: opacity 0.25s ease;
}

.next-hint.is-hidden {
  opacity: 0;
}

.next-hint i {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--pink-deep);
  border-bottom: 1.5px solid var(--pink-deep);
  transform: rotate(45deg);
  animation: nudge 1.4s ease-in-out infinite;
}

@keyframes nudge {
  0%,
  100% {
    opacity: 0.5;
    transform: translateY(-2px) rotate(45deg);
  }
  50% {
    opacity: 1;
    transform: translateY(3px) rotate(45deg);
  }
}

#stage.chapter-mode .dialogue {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(16px);
}

#stage.is-title-mode .dialogue,
#stage.is-title-mode .hud,
#stage.is-title-mode .game-menu,
#stage.is-title-mode .sprite-stage {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: none;
}

/* ---------- Chapter card ---------- */

.chapter-overlay {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8vw;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.94), rgba(255, 244, 249, 0.84) 42%, rgba(231, 246, 255, 0.74) 100%),
    rgba(255, 249, 252, 0.72);
  backdrop-filter: blur(15px) saturate(120%);
  -webkit-backdrop-filter: blur(15px) saturate(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.chapter-overlay::before,
.chapter-overlay::after {
  position: absolute;
  color: rgba(239, 109, 153, 0.32);
  font-size: clamp(26px, 4vw, 58px);
  pointer-events: none;
}

.chapter-overlay::before {
  content: "✿";
  top: 18%;
  left: 16%;
}

.chapter-overlay::after {
  content: "♡";
  right: 17%;
  bottom: 20%;
}

.chapter-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.chapter-line {
  width: 1px;
  height: 54px;
  margin-bottom: 24px;
  background: linear-gradient(180deg, transparent, var(--pink-deep));
  animation: lineGrow 0.9s ease both;
}

.chapter-kicker {
  margin: 0 0 14px;
  color: var(--pink-deep);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.52em;
  text-indent: 0.52em;
  animation: riseIn 0.7s 0.1s ease both;
}

.chapter-title {
  margin: 0;
  color: #4a2d3c;
  font-family: var(--serif);
  font-size: clamp(30px, 4.6vw, 62px);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55), 0 18px 44px rgba(141, 70, 101, 0.14);
  animation: riseIn 0.8s 0.18s ease both;
}

.chapter-tip {
  margin: 40px 0 0;
  color: rgba(75, 51, 64, 0.44);
  font-size: 11px;
  letter-spacing: 0.28em;
  animation: fadePulse 2s 0.5s ease-in-out infinite both;
}

@keyframes lineGrow {
  from {
    transform: scaleY(0);
    transform-origin: top;
  }
  to {
    transform: scaleY(1);
    transform-origin: top;
  }
}

@keyframes fadePulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.9;
  }
}

/* ---------- End card ---------- */

.end-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8vw;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 186, 208, 0.4), transparent 46%),
    linear-gradient(135deg, rgba(255, 251, 247, 0.96), rgba(255, 241, 247, 0.94));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 1.2s ease, visibility 1.2s ease;
}

.end-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.end-kicker {
  margin: 0 0 10px;
  color: rgba(194, 83, 122, 0.72);
  font-size: 12px;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
}

.end-overlay h2 {
  margin: 0;
  color: #f187aa;
  font-family: var(--serif);
  font-size: clamp(64px, 10vw, 138px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65), 0 20px 60px rgba(239, 109, 153, 0.2);
}

.end-text {
  margin: 22px 0 36px;
  color: rgba(75, 51, 64, 0.64);
  font-family: var(--serif);
  font-size: clamp(14px, 1.4vw, 18px);
  letter-spacing: 0.1em;
  text-align: center;
}

#restart-btn {
  padding: 12px 38px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 178, 202, 0.88), rgba(244, 126, 165, 0.82));
  color: #4e1d32;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(239, 109, 153, 0.22);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

#restart-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: linear-gradient(135deg, rgba(255, 190, 210, 0.98), rgba(247, 139, 175, 0.94));
  box-shadow: 0 16px 38px rgba(239, 109, 153, 0.3);
}

/* ---------- Highlight effects ---------- */

.fx-flash {
  position: absolute;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 220, 235, 0.64) 24%, rgba(255, 153, 187, 0.18) 48%, transparent 72%);
}

#stage.fx-shock .fx-flash {
  animation: shockFlash 0.85s ease-out both;
}

#stage.fx-shock .sprite-stage {
  animation: shockShake 0.55s ease both;
}

#stage.fx-shock .vignette {
  box-shadow: inset 0 0 180px rgba(255, 120, 164, 0.48);
}

@keyframes shockFlash {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  32% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
  }
}

@keyframes shockShake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  15% {
    transform: translate(-7px, 3px);
  }
  30% {
    transform: translate(6px, -4px);
  }
  45% {
    transform: translate(-5px, -2px);
  }
  60% {
    transform: translate(4px, 3px);
  }
  75% {
    transform: translate(-2px, 1px);
  }
}

.heart-burst {
  position: absolute;
  inset: 0;
  z-index: 91;
  pointer-events: none;
  overflow: hidden;
}

.heart-burst span {
  position: absolute;
  left: 50%;
  top: 52%;
  color: #f477a2;
  font-size: var(--size, 24px);
  text-shadow: 0 0 18px rgba(255, 110, 160, 0.8);
  animation: heartRise 1.45s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes heartRise {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(0, 30px) scale(0.25) rotate(0deg);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--dx, 0px), -240px) scale(1.15) rotate(var(--rot, 0deg));
  }
}

/* ---------- Game menu ---------- */

.game-menu {
  position: absolute;
  top: clamp(84px, 11vh, 112px);
  right: clamp(14px, 2vw, 28px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  background: rgba(255, 251, 252, 0.58);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    0 16px 42px rgba(66, 36, 51, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: default;
}

.menu-btn {
  min-width: 58px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: rgba(75, 51, 64, 0.7);
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(255, 188, 208, 0.55);
  color: var(--ink);
  outline: none;
  transform: scale(1.04);
}

.menu-btn:active {
  transform: scale(0.97);
}

.menu-btn.is-active {
  border-color: rgba(255, 255, 255, 0.8);
  background: linear-gradient(135deg, rgba(255, 176, 200, 0.96), rgba(246, 128, 166, 0.9));
  color: #4b1830;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(239, 109, 153, 0.22);
}

/* ---------- Save / load archive ---------- */

.save-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(65, 40, 55, 0.32);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  cursor: default;
}

.save-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.save-panel {
  width: min(580px, 100%);
  max-height: min(82vh, 720px);
  overflow-y: auto;
  padding: clamp(22px, 3vw, 34px);
  border: 1.5px solid rgba(255, 255, 255, 0.88);
  border-radius: 28px;
  background:
    linear-gradient(140deg, rgba(255, 253, 252, 0.97), rgba(255, 242, 248, 0.94) 56%, rgba(237, 248, 255, 0.92)),
    radial-gradient(circle at 10% 0%, rgba(255, 167, 196, 0.22), transparent 44%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 34px 100px rgba(66, 34, 50, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.save-overlay.is-visible .save-panel {
  transform: translateY(0) scale(1);
}

.save-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.save-kicker {
  margin: 0 0 6px;
  color: var(--pink-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.38em;
}

.save-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.save-close,
.ui-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.44);
  color: rgba(75, 51, 64, 0.64);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.save-close:hover,
.save-close:focus-visible,
.ui-close:hover,
.ui-close:focus-visible {
  background: rgba(255, 224, 234, 0.92);
  border-color: rgba(255, 174, 199, 0.72);
  color: var(--ink);
  outline: none;
  transform: rotate(8deg) scale(1.06);
}

.save-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.save-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.save-slot:hover:not(:disabled),
.save-slot:focus-visible:not(:disabled) {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 177, 201, 0.66);
  box-shadow: 0 8px 22px rgba(165, 95, 125, 0.12);
  transform: translateY(-1px) scale(1.01);
  outline: none;
}

.save-slot:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.save-slot.is-empty {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.24);
}

.save-slot-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.save-slot-name {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.06em;
}

.save-slot-meta {
  max-width: 340px;
  overflow: hidden;
  color: rgba(75, 51, 64, 0.55);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-time {
  flex-shrink: 0;
  color: rgba(195, 82, 121, 0.68);
  font-size: 11px;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.save-note {
  margin: 16px 0 0;
  color: rgba(75, 51, 64, 0.45);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-align: center;
}

.backup-restore {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px dashed rgba(229, 121, 158, 0.48);
  border-radius: 14px;
  background: rgba(255, 218, 231, 0.36);
  color: rgba(151, 60, 92, 0.84);
  font-size: 12px;
  letter-spacing: 0.09em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.backup-restore:hover,
.backup-restore:focus-visible {
  background: rgba(255, 213, 228, 0.62);
  border-color: rgba(229, 121, 158, 0.72);
  outline: none;
}

.backup-restore[hidden] {
  display: none;
}

/* ---------- Toast ---------- */

.game-toast {
  position: fixed;
  top: clamp(84px, 11vh, 112px);
  left: 50%;
  z-index: 1600;
  max-width: calc(100% - 40px);
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  background: rgba(255, 251, 250, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-align: center;
  box-shadow: 0 12px 34px rgba(104, 55, 76, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.game-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Context menu ---------- */

.context-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(57, 35, 49, 0.1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.context-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.context-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1210;
  width: min(248px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 252, 250, 0.94), rgba(255, 241, 247, 0.88)),
    radial-gradient(circle at 100% 0%, rgba(255, 166, 196, 0.26), transparent 48%);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  box-shadow:
    0 24px 66px rgba(63, 34, 48, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.92);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.16s ease;
}

.context-menu.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
}

.context-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 9px;
  color: rgba(75, 51, 64, 0.52);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.context-head em {
  color: var(--pink-deep);
  font-size: 15px;
  font-style: normal;
  letter-spacing: 0;
}

.context-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.context-item:hover,
.context-item:focus-visible {
  border-color: rgba(255, 188, 208, 0.58);
  background: rgba(255, 255, 255, 0.64);
  outline: none;
  transform: translateX(2px) scale(1.015);
}

.context-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 222, 233, 0.9), rgba(232, 246, 255, 0.9));
  color: #b54d74;
  font-size: 14px;
}

.context-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.context-copy strong {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.context-copy small {
  color: rgba(75, 51, 64, 0.45);
  font-size: 8px;
  letter-spacing: 0.13em;
}

.context-item.is-danger .context-icon {
  background: linear-gradient(135deg, rgba(255, 196, 207, 0.92), rgba(255, 228, 214, 0.92));
  color: #b43d58;
}

.context-item.is-danger:hover,
.context-item.is-danger:focus-visible {
  border-color: rgba(238, 133, 158, 0.58);
  background: rgba(255, 232, 237, 0.8);
}

.context-divider {
  height: 1px;
  margin: 6px 8px;
  background: linear-gradient(90deg, transparent, rgba(224, 153, 178, 0.34), transparent);
}

.context-foot {
  margin: 8px 0 2px;
  color: rgba(75, 51, 64, 0.38);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-align: center;
}

/* ---------- Shared modal panels ---------- */

.ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2.6vw, 34px);
  background: rgba(57, 35, 49, 0.34);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.ui-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.ui-panel {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  padding: clamp(20px, 2.8vw, 34px);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  background:
    linear-gradient(145deg, rgba(255, 253, 251, 0.97), rgba(255, 242, 248, 0.93) 55%, rgba(237, 248, 255, 0.91)),
    radial-gradient(circle at 8% 0%, rgba(255, 170, 198, 0.22), transparent 42%);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow:
    0 38px 110px rgba(58, 30, 44, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
  transform: translateY(16px) scale(0.975);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ui-overlay.is-visible .ui-panel {
  transform: translateY(0) scale(1);
}

.ui-panel::before,
.ui-panel::after {
  position: absolute;
  color: rgba(239, 109, 153, 0.22);
  pointer-events: none;
}

.ui-panel::before {
  content: "♡ ✿ ★";
  top: 15px;
  right: 66px;
  font-size: 13px;
  letter-spacing: 0.35em;
}

.ui-panel::after {
  content: "✿";
  right: 17px;
  bottom: 14px;
  font-size: 34px;
  transform: rotate(-14deg);
}

.ui-panel::-webkit-scrollbar,
.context-menu::-webkit-scrollbar {
  width: 7px;
}

.ui-panel::-webkit-scrollbar-thumb,
.context-menu::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(239, 109, 153, 0.28);
}

.ui-panel::-webkit-scrollbar-track,
.context-menu::-webkit-scrollbar-track {
  background: transparent;
}

.ui-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-right: 28px;
}

.ui-kicker {
  margin: 0 0 5px;
  color: var(--pink-deep);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
}

.ui-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.ui-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ui-close {
  width: 34px;
  height: 34px;
}

.ui-note {
  margin: 18px 0 0;
  color: rgba(75, 51, 64, 0.44);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-align: center;
}

.gallery-count {
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  color: rgba(75, 51, 64, 0.5);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

/* ---------- Settings ---------- */

.settings-panel {
  width: min(620px, 100%);
}

.setting-group {
  margin: 18px 0 0;
  padding: 17px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.4);
}

.setting-label {
  margin: 0 0 11px;
  color: rgba(75, 51, 64, 0.62);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.setting-label span {
  color: rgba(75, 51, 64, 0.4);
  letter-spacing: 0.1em;
}

.setting-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setting-chip {
  min-width: 74px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.5);
  color: rgba(75, 51, 64, 0.7);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.setting-chip:hover,
.setting-chip:focus-visible {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(255, 181, 202, 0.7);
  color: var(--ink);
  outline: none;
  transform: translateY(-1px) scale(1.03);
}

.setting-chip.is-active {
  border-color: rgba(255, 255, 255, 0.92);
  background: linear-gradient(135deg, rgba(255, 181, 204, 0.94), rgba(243, 131, 168, 0.88));
  color: #511d33;
  font-weight: 700;
  box-shadow: 0 7px 18px rgba(239, 109, 153, 0.2);
}

.setting-preview {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed rgba(226, 140, 172, 0.5);
  border-radius: 18px;
  background: rgba(255, 247, 250, 0.64);
}

.setting-preview span {
  color: var(--pink-deep);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.setting-preview p {
  margin: 9px 0 0;
  color: var(--ink);
  font-family: var(--dialogue-font);
  font-size: var(--dialogue-size);
  line-height: 1.8;
}

.setting-tip {
  margin: 14px 0 0;
  color: rgba(75, 51, 64, 0.4);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-align: center;
}

/* ---------- Music room ---------- */

.music-panel {
  width: min(700px, 100%);
}

.music-now {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(255, 238, 246, 0.5)),
    radial-gradient(circle at 92% 6%, rgba(159, 212, 239, 0.22), transparent 42%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.music-disc {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border: 5px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff7fa 0 13%, transparent 14%),
    repeating-radial-gradient(circle at 50% 50%, #f6a7c1 0 3px, #e482a5 4px 6px);
  color: #7a2544;
  font-size: 18px;
  box-shadow: 0 9px 24px rgba(196, 95, 133, 0.2);
  animation: spinDisc 9s linear infinite;
}

.music-disc.is-paused {
  animation-play-state: paused;
}

.music-now-copy {
  min-width: 0;
}

.music-now-copy span {
  display: block;
  color: var(--pink-deep);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.music-now-copy p {
  overflow: hidden;
  margin: 4px 0 2px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(20px, 2.4vw, 27px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-now-copy small {
  color: rgba(75, 51, 64, 0.5);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.music-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.music-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.music-item:hover,
.music-item:focus-visible {
  border-color: rgba(255, 181, 203, 0.7);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(165, 95, 125, 0.1);
  outline: none;
  transform: translateX(3px) scale(1.008);
}

.music-item.is-playing {
  border-color: rgba(255, 255, 255, 0.94);
  background:
    linear-gradient(135deg, rgba(255, 187, 209, 0.86), rgba(232, 246, 255, 0.78)),
    radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.5), transparent 48%);
  box-shadow: 0 9px 24px rgba(239, 109, 153, 0.18);
}

.music-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.6);
  color: rgba(181, 77, 116, 0.76);
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 700;
}

.music-item.is-playing .music-index {
  background: rgba(255, 255, 255, 0.8);
  color: #a44165;
}

.music-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.music-copy strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-copy small {
  overflow: hidden;
  color: rgba(75, 51, 64, 0.5);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 18px;
}

.music-bars i {
  width: 3px;
  height: 5px;
  border-radius: 99px;
  background: rgba(181, 77, 116, 0.38);
  transform-origin: bottom;
}

.music-item.is-playing .music-bars i {
  background: var(--pink-deep);
  animation: musicBar 0.8s ease-in-out infinite alternate;
}

.music-item.is-playing .music-bars i:nth-child(2) {
  animation-delay: -0.25s;
}

.music-item.is-playing .music-bars i:nth-child(3) {
  animation-delay: -0.5s;
}

.music-item.is-playing .music-bars i:nth-child(4) {
  animation-delay: -0.12s;
}

@keyframes spinDisc {
  to {
    transform: rotate(360deg);
  }
}

@keyframes musicBar {
  from {
    height: 4px;
  }
  to {
    height: 17px;
  }
}

/* ---------- Gallery ---------- */

.gallery-panel {
  width: min(1120px, 100%);
}

.gallery-viewer {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 7;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  background: linear-gradient(135deg, #ffe7ef, #e8f7ff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.gallery-viewer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.12);
  transform-origin: center center;
}

.gallery-viewer-caption {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: calc(100% - 32px);
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  background: rgba(255, 250, 252, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(70, 38, 53, 0.16);
}

.gallery-viewer-caption span {
  color: var(--pink-deep);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.gallery-viewer-caption p {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.gallery-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  background: #ffeaf1;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.gallery-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.12);
  transform-origin: center center;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-card span {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(37, 22, 31, 0.55);
  color: rgba(255, 250, 252, 0.94);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.gallery-card:hover,
.gallery-card:focus-visible,
.gallery-card.is-active {
  z-index: 1;
  border-color: rgba(255, 181, 204, 0.96);
  box-shadow: 0 10px 26px rgba(174, 88, 122, 0.22);
  outline: none;
  transform: translateY(-2px) scale(1.03);
}

.gallery-card:hover img,
.gallery-card:focus-visible img,
.gallery-card.is-active img {
  transform: scale(1.18);
}

.gallery-card.is-missing {
  display: none;
}

/* ---------- Characters ---------- */

.characters-panel {
  width: min(1160px, 100%);
}

.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 13px;
}

.character-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.44);
  box-shadow: 0 10px 26px rgba(134, 72, 99, 0.08);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 34px rgba(134, 72, 99, 0.14);
}

.character-art {
  position: relative;
  height: 256px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.92), transparent 52%),
    linear-gradient(145deg, #ffe3ec, #e8f7ff);
}

.character-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  transition: transform 0.4s ease;
}

.character-card:hover .character-art img {
  transform: scale(1.025);
}

.character-monogram {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: rgba(181, 77, 116, 0.58);
  font-family: var(--serif);
  font-size: 68px;
  font-weight: 700;
}

.character-sprite-dots {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(255, 251, 252, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sprite-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(218, 146, 174, 0.46);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}

.sprite-dot:hover,
.sprite-dot:focus-visible {
  outline: none;
  transform: scale(1.25);
}

.sprite-dot.is-active {
  background: var(--pink-deep);
  transform: scale(1.18);
}

.character-info {
  padding: 14px 15px 16px;
}

.character-role {
  margin: 0 0 4px;
  color: var(--pink-deep);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.character-name {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
}

.character-bio {
  margin: 8px 0 10px;
  color: rgba(75, 51, 64, 0.62);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.character-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.character-tag {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 236, 243, 0.7);
  color: rgba(151, 60, 92, 0.72);
  font-size: 8px;
  letter-spacing: 0.06em;
}

/* ---------- Chapter select ---------- */

.chapters-panel {
  width: min(760px, 100%);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chapter-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.chapter-item:hover,
.chapter-item:focus-visible {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(255, 178, 201, 0.68);
  box-shadow: 0 8px 22px rgba(165, 95, 125, 0.1);
  outline: none;
  transform: translateX(3px) scale(1.008);
}

.chapter-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255, 215, 229, 0.9), rgba(229, 246, 255, 0.9));
  color: #b54d74;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
}

.chapter-copy {
  min-width: 0;
}

.chapter-copy span {
  display: block;
  color: var(--pink-deep);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.chapter-copy strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-arrow {
  color: rgba(239, 109, 153, 0.6);
  font-size: 16px;
  text-align: right;
}

/* ---------- Gallery focus mode ---------- */

#stage.gallery-focus-mode > :not(.bg-layer):not(.watermark-cover) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

#stage.gallery-focus-mode .bg-layer {
  transform: scale(1.1);
  transform-origin: center center;
}

.gallery-focus {
  position: fixed;
  inset: 0;
  z-index: 1180;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gallery-focus.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.gallery-focus-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(24px, 5vh, 54px);
  padding: 12px 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: rgba(255, 250, 252, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 12px 36px rgba(55, 31, 44, 0.2);
  transform: translateX(-50%);
  animation: focusHint 4.8s ease forwards;
}

.gallery-focus-hint span {
  color: var(--pink-deep);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3em;
}

.gallery-focus-hint p {
  margin: 5px 0 3px;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.06em;
}

.gallery-focus-hint small {
  color: rgba(75, 51, 64, 0.52);
  font-size: 10px;
  letter-spacing: 0.08em;
}

@keyframes focusHint {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  12%,
  72% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 0);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .start-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    max-width: 620px;
  }

  .start-copy {
    text-align: center;
  }

  .start-sub {
    margin-left: auto;
    margin-right: auto;
  }

  .start-ribbon {
    justify-content: center;
  }

  .start-actions {
    width: min(460px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  #start-screen {
    padding: 18px 14px 26px;
  }

  .start-content h1 {
    font-size: clamp(34px, 10vw, 52px);
  }

  .start-content h1 span {
    font-size: 0.48em;
  }

  .start-sub {
    margin-top: 18px;
    margin-bottom: 18px;
    font-size: 13px;
  }

  .start-actions {
    padding: 16px;
    border-radius: 24px;
  }

  .start-actions-title,
  .start-actions-note,
  .start-note {
    display: none;
  }

  .title-btn {
    grid-template-columns: 32px minmax(0, 1fr) 18px;
    padding: 11px 12px;
  }

  .title-btn-icon {
    width: 32px;
    height: 32px;
  }

  .title-btn-copy strong {
    font-size: 12px;
  }

  .title-btn-copy small {
    font-size: 10px;
  }

  .brand-text,
  .progress,
  .hud-hint {
    display: none;
  }

  .hud {
    padding: 12px 14px;
  }

  .brand {
    padding: 6px 11px 6px 7px;
  }

  .sound-btn {
    padding: 8px 12px;
  }

  .dialogue {
    bottom: 12px;
    width: calc(100% - 24px);
    min-height: 180px;
    padding: 30px 22px 28px;
    border-radius: 20px;
  }

  .dialogue-text {
    font-size: var(--dialogue-size);
    line-height: 1.82;
  }

  .next-hint span {
    display: none;
  }

  .next-hint {
    right: 20px;
    bottom: 15px;
  }

  .game-menu {
    top: 68px;
    right: 10px;
    gap: 4px;
    padding: 5px;
    border-radius: 16px;
  }

  .menu-btn {
    min-width: 48px;
    padding: 8px 9px;
    font-size: 10px;
  }

  .save-overlay,
  .ui-overlay {
    padding: 12px;
  }

  .save-panel,
  .ui-panel {
    padding: 18px 15px;
    border-radius: 22px;
  }

  .ui-panel::before {
    display: none;
  }

  .save-slot {
    gap: 10px;
    padding: 13px 14px;
  }

  .save-slot-meta {
    max-width: 180px;
  }

  .save-slot-time {
    font-size: 10px;
  }

  .context-menu {
    width: min(232px, calc(100vw - 20px));
  }

  .gallery-viewer {
    aspect-ratio: 16 / 9;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 7px;
  }

  .characters-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 9px;
  }

  .character-art {
    height: 190px;
  }

  .character-info {
    padding: 11px 12px 13px;
  }

  .character-name {
    font-size: 16px;
  }

  .character-bio {
    font-size: 10px;
  }

  .chapter-item {
    grid-template-columns: 38px minmax(0, 1fr) 18px;
    gap: 9px;
    padding: 11px 12px;
  }

  .chapter-number {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 12px;
  }

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

  .music-now {
    gap: 12px;
    padding: 13px;
  }

  .music-disc {
    width: 52px;
    height: 52px;
    border-width: 4px;
  }

  .music-now-copy p {
    font-size: 20px;
  }

  .music-item {
    grid-template-columns: 34px minmax(0, 1fr) 26px;
    gap: 9px;
    padding: 10px 11px;
  }

  .music-index {
    width: 30px;
    height: 30px;
    font-size: 10px;
  }

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

  .game-toast {
    top: auto;
    bottom: 220px;
  }

  .gallery-focus-hint {
    bottom: 20px;
    padding: 10px 18px;
  }
}

@media (max-height: 680px) {
  .dialogue {
    min-height: 158px;
    padding-top: 28px;
    padding-bottom: 20px;
  }

  .dialogue-text {
    line-height: 1.72;
  }

  .character-art {
    height: 210px;
  }

  .gallery-viewer {
    aspect-ratio: 16 / 6;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
