:root {
  --gray-0: #f8fafc;
  --gray-1: #e8ebef;
  --gray-2: #d3d3d3;
  --gray-3: #aeb5c1;
  --ink: #151a24;
  --ink-soft: #252c3a;
  --blue: #6d84a6;
  --mint: #a9e2c8;
  --mint-strong: #75c6a5;
  --peach: #f3b8ac;
  --glass: rgba(19, 24, 34, 0.82);
  --glass-strong: rgba(14, 18, 27, 0.94);
  --line: rgba(255, 255, 255, 0.17);
  --shadow: 0 24px 80px rgba(5, 8, 14, 0.36);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0b0e14;
  color: var(--gray-0);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

body {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

#app,
.game,
.screen {
  width: 100%;
  height: 100%;
}

.game {
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 700ms ease, visibility 700ms step-end;
}

.screen.is-active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 700ms ease, visibility 0ms step-start;
}

.loading-screen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background:
    radial-gradient(circle at 50% 46%, rgba(121, 145, 169, 0.16), transparent 32%),
    linear-gradient(145deg, #181e29, #0d1119 66%);
  transition: opacity 700ms ease, visibility 700ms step-end;
}

.loading-screen.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-mark {
  display: flex;
  gap: 8px;
  height: 32px;
  align-items: end;
}

.loading-mark span {
  width: 4px;
  height: 12px;
  border-radius: 3px;
  background: var(--gray-2);
  animation: loading-bars 1.1s ease-in-out infinite;
}

.loading-mark span:nth-child(2) {
  height: 24px;
  animation-delay: 130ms;
  background: var(--mint);
}

.loading-mark span:nth-child(3) {
  height: 17px;
  animation-delay: 260ms;
}

@keyframes loading-bars {
  0%, 100% { transform: scaleY(0.55); opacity: 0.45; }
  50% { transform: scaleY(1); opacity: 1; }
}

.loading-title {
  margin: 22px 0 14px;
  font-size: 20px;
  letter-spacing: 0.35em;
}

.loading-track {
  width: min(290px, 66vw);
  height: 1px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

.loading-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gray-2), var(--mint));
  transition: width 280ms ease;
}

.loading-text {
  margin-top: 12px;
  color: var(--gray-3);
  font-size: 12px;
  letter-spacing: 0.12em;
}

/* Title */

.title-screen {
  overflow: hidden;
  background: #253247;
}

.title-bg,
.ending-bg {
  position: absolute;
  inset: -2.5%;
  background: url("assets/backgrounds/rooftop.jpg") center / cover no-repeat;
  animation: title-drift 18s ease-in-out infinite alternate;
}

@keyframes title-drift {
  from { transform: scale(1.035) translate3d(-0.25%, -0.2%, 0); }
  to { transform: scale(1.075) translate3d(0.45%, 0.4%, 0); }
}

.title-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(15, 20, 31, 0.9) 0%, rgba(21, 28, 41, 0.6) 38%, rgba(21, 28, 41, 0.08) 70%),
    linear-gradient(0deg, rgba(9, 12, 19, 0.58), transparent 42%, rgba(28, 40, 58, 0.08));
}

.title-wash::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.title-layout {
  position: relative;
  z-index: 3;
  display: flex;
  height: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: max(7vh, calc(var(--safe-top) + 44px)) max(5vw, calc(var(--safe-right) + 40px)) max(8vh, calc(var(--safe-bottom) + 48px)) max(7vw, calc(var(--safe-left) + 44px));
  align-items: center;
  gap: clamp(70px, 11vw, 190px);
}

.title-copy {
  width: min(620px, 52vw);
  transform: translateY(-2.5vh);
  text-shadow: 0 3px 26px rgba(0, 0, 0, 0.38);
}

.title-date,
.title-en,
.modal-kicker,
.ending-type {
  margin: 0;
  color: var(--mint);
  font-family: "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: 0.28em;
}

.title-date {
  font-size: clamp(10px, 0.9vw, 13px);
}

.title-copy h1 {
  margin: 14px 0 1px;
  color: #f5f7fa;
  font-size: clamp(52px, 7vw, 108px);
  font-weight: 300;
  letter-spacing: 0.08em;
  line-height: 1.05;
  white-space: nowrap;
}

.title-copy h1 span {
  color: var(--gray-2);
  font-weight: 700;
}

.title-en {
  color: rgba(238, 243, 249, 0.62);
  font-size: clamp(9px, 0.82vw, 12px);
  letter-spacing: 0.48em;
}

.title-rule {
  display: flex;
  width: min(420px, 90%);
  margin: 30px 0 22px;
  align-items: center;
  gap: 13px;
}

.title-rule i {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5));
}

.title-rule i:last-child {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.5), transparent);
}

.title-rule b {
  font-size: 13px;
  filter: grayscale(0.45);
}

.title-tagline {
  margin: 0;
  color: rgba(246, 248, 252, 0.78);
  font-size: clamp(13px, 1.25vw, 18px);
  font-weight: 300;
  letter-spacing: 0.18em;
}

.title-menu {
  display: flex;
  width: min(310px, 29vw);
  flex-direction: column;
  gap: 6px;
}

.menu-btn {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 62px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  padding: 10px 18px;
  align-items: center;
  gap: 15px;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(21, 27, 39, 0.56), rgba(21, 27, 39, 0));
  cursor: pointer;
  text-align: left;
  transition: border-color 220ms ease, padding-left 220ms ease, background 220ms ease;
}

.menu-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: translateX(-102%);
  background: linear-gradient(90deg, rgba(169, 226, 200, 0.19), rgba(169, 226, 200, 0.02));
  transition: transform 240ms ease;
}

.menu-btn:hover:not(:disabled),
.menu-btn:focus-visible {
  border-left-color: var(--mint);
  padding-left: 25px;
}

.menu-btn:hover:not(:disabled)::before,
.menu-btn:focus-visible::before {
  transform: translateX(0);
}

.menu-btn:disabled {
  opacity: 0.35;
}

.menu-btn--primary {
  border-left-width: 3px;
  border-left-color: var(--mint);
}

.menu-index {
  width: 20px;
  color: rgba(255, 255, 255, 0.35);
  font-family: "Segoe UI", sans-serif;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.menu-btn > span:last-child {
  display: grid;
  gap: 3px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  letter-spacing: 0.18em;
}

.menu-btn small {
  color: rgba(255, 255, 255, 0.38);
  font-family: "Segoe UI", sans-serif;
  font-size: 8px;
  letter-spacing: 0.24em;
}

.title-footer {
  position: absolute;
  z-index: 4;
  right: max(3.2vw, var(--safe-right));
  bottom: max(2.8vh, calc(var(--safe-bottom) + 12px));
  margin: 0;
  color: rgba(255, 255, 255, 0.46);
  font-family: "Segoe UI", sans-serif;
  font-size: 10px;
  letter-spacing: 0.13em;
}

/* Scene */

.novel-screen {
  background: #10151f;
  cursor: default;
}

.background-stack,
.scene-bg,
.scene-tint,
.vignette {
  position: absolute;
  inset: 0;
}

.scene-bg {
  opacity: 0;
  transform: scale(1.018);
  background-position: center;
  background-size: cover;
  transition: opacity 1100ms ease, transform 5500ms ease;
}

.scene-bg.is-visible {
  opacity: 1;
  transform: scale(1.045);
}

.scene-tint {
  background: linear-gradient(0deg, rgba(10, 13, 20, 0.38) 0%, transparent 43%), linear-gradient(90deg, rgba(16, 22, 31, 0.09), transparent 28%, rgba(14, 18, 26, 0.1));
  pointer-events: none;
  transition: background 600ms ease;
}

.scene-tint.is-rainy {
  background: linear-gradient(0deg, rgba(9, 14, 24, 0.5), transparent 46%), rgba(36, 54, 74, 0.08);
}

.scene-tint.is-warm {
  background: linear-gradient(0deg, rgba(17, 15, 24, 0.4), transparent 44%), rgba(244, 171, 140, 0.025);
}

.vignette {
  z-index: 5;
  background: radial-gradient(ellipse at center, transparent 47%, rgba(4, 7, 12, 0.27) 100%);
  pointer-events: none;
}

.rain-layer {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.rain-layer.is-raining,
.rain-layer--title {
  opacity: 0.33;
}

.rain-layer--title {
  z-index: 2;
  opacity: 0.13;
}

.rain-drop {
  position: absolute;
  top: -16vh;
  width: 1px;
  height: var(--length, 72px);
  opacity: var(--opacity, 0.45);
  transform: rotate(9deg);
  background: linear-gradient(transparent, rgba(221, 236, 250, 0.7));
  animation: rain-fall var(--duration, 1s) linear infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes rain-fall {
  to { translate: -9vh 128vh; }
}

.game-topbar {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  display: flex;
  width: 100%;
  padding: max(18px, calc(var(--safe-top) + 12px)) max(28px, calc(var(--safe-right) + 18px)) 20px max(28px, calc(var(--safe-left) + 18px));
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(8, 11, 17, 0.44), transparent);
}

.game-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.game-brand__mark {
  display: grid;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  place-items: center;
  color: var(--mint);
  font-family: Georgia, serif;
  font-size: 14px;
}

.game-brand > span:last-child {
  display: grid;
  gap: 1px;
}

.game-brand b {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.game-brand small {
  color: rgba(255, 255, 255, 0.54);
  font-family: "Segoe UI", sans-serif;
  font-size: 8px;
  letter-spacing: 0.22em;
}

.top-actions {
  display: flex;
  gap: 4px;
}

.hud-btn {
  min-width: 50px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 2px;
  padding: 7px 11px;
  background: rgba(12, 16, 24, 0.35);
  backdrop-filter: blur(7px);
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 170ms ease, border-color 170ms ease, background 170ms ease;
}

.hud-btn:hover {
  border-color: rgba(169, 226, 200, 0.66);
  background: rgba(20, 29, 39, 0.72);
  color: white;
}

.hud-btn--icon {
  min-width: 34px;
  font-size: 16px;
}

.chapter-card {
  position: absolute;
  z-index: 50;
  top: 20%;
  left: 0;
  display: grid;
  min-width: min(480px, 55vw);
  padding: 24px 5vw 27px 8vw;
  gap: 5px;
  transform: translateX(-105%);
  opacity: 0;
  background: linear-gradient(90deg, rgba(16, 22, 32, 0.91), rgba(22, 29, 40, 0.46) 76%, transparent);
  border-block: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.chapter-card.is-showing {
  animation: chapter-in 2.35s cubic-bezier(0.22, 0.7, 0.18, 1) both;
}

@keyframes chapter-in {
  0% { transform: translateX(-105%); opacity: 0; }
  16%, 72% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(-12%); opacity: 0; }
}

.chapter-card span {
  color: var(--mint);
  font-family: "Segoe UI", sans-serif;
  font-size: 9px;
  letter-spacing: 0.35em;
}

.chapter-card strong {
  font-size: clamp(23px, 3vw, 38px);
  font-weight: 300;
  letter-spacing: 0.2em;
}

.character-wrap {
  position: absolute;
  z-index: 10;
  bottom: -4vh;
  left: 50%;
  width: min(52vw, 700px);
  height: 95vh;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 320ms ease, transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1), filter 360ms ease;
}

.character-wrap.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(25px);
}

.character-wrap.is-speaking {
  filter: brightness(1.025) drop-shadow(0 18px 27px rgba(6, 9, 14, 0.26));
}

.character-wrap.is-muted {
  filter: brightness(0.73) saturate(0.77) drop-shadow(0 18px 27px rgba(6, 9, 14, 0.27));
}

.character-wrap.is-swapping {
  opacity: 0;
  transform: translateX(-50%) translateY(9px) scale(0.993);
}

.character-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 14px 23px rgba(5, 8, 13, 0.36));
}

.dialogue-box {
  position: absolute;
  z-index: 40;
  right: 0;
  bottom: max(3.5vh, calc(var(--safe-bottom) + 12px));
  left: 0;
  width: min(1180px, calc(100vw - 9vw));
  min-height: 190px;
  margin: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  padding: 47px 70px 47px;
  background:
    linear-gradient(112deg, rgba(25, 32, 44, 0.94), rgba(15, 20, 29, 0.83) 63%, rgba(26, 35, 43, 0.87)),
    var(--glass);
  box-shadow: var(--shadow), inset 3px 0 0 rgba(169, 226, 200, 0.53);
  backdrop-filter: blur(17px) saturate(0.82);
}

.dialogue-box::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.36), transparent);
}

.speaker-name {
  position: absolute;
  top: -19px;
  left: 43px;
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-color: rgba(169, 226, 200, 0.35);
  padding: 11px 30px 10px;
  background: rgba(22, 29, 40, 0.94);
  box-shadow: 0 8px 24px rgba(5, 8, 14, 0.2);
  color: #f5f7fa;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-align: center;
}

.speaker-name.is-narrator {
  color: var(--gray-3);
  font-size: 12px;
}

.speaker-name::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: -5px;
  width: 20px;
  height: 1px;
  transform: rotate(-28deg);
  transform-origin: right;
  background: var(--mint);
}

.dialogue-text {
  position: relative;
  z-index: 2;
  min-height: 76px;
  margin: 0;
  color: rgba(249, 250, 252, 0.95);
  font-size: clamp(16px, 1.42vw, 20px);
  font-weight: 300;
  letter-spacing: 0.065em;
  line-height: 1.95;
  white-space: pre-wrap;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.advance-hitbox {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.advance-indicator {
  position: absolute;
  right: 25px;
  bottom: 27px;
  width: 9px;
  height: 9px;
  border-right: 1px solid var(--mint);
  border-bottom: 1px solid var(--mint);
  transform: rotate(45deg);
  opacity: 0;
  pointer-events: none;
}

.advance-indicator.is-ready {
  opacity: 1;
  animation: next-bob 1.1s ease-in-out infinite;
}

@keyframes next-bob {
  0%, 100% { translate: 0 -3px; opacity: 0.45; }
  50% { translate: 0 3px; opacity: 1; }
}

.dialogue-controls {
  position: absolute;
  z-index: 3;
  right: 19px;
  top: 13px;
  display: flex;
  gap: 6px;
}

.dialogue-controls button {
  border: 0;
  padding: 3px 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.38);
  font-family: "Segoe UI", sans-serif;
  font-size: 8px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 150ms ease;
}

.dialogue-controls button:hover,
.dialogue-controls button.is-active {
  color: var(--mint);
}

.dialogue-controls kbd {
  margin-right: 3px;
  font-family: inherit;
  font-size: 7px;
  opacity: 0.55;
}

.choice-panel {
  position: absolute;
  z-index: 55;
  top: 50%;
  right: 0;
  left: 0;
  width: min(740px, 82vw);
  margin: auto;
  transform: translateY(-47%);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease, visibility 280ms step-end;
}

.choice-panel.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(-50%);
  pointer-events: auto;
  transition: opacity 280ms ease, transform 280ms ease, visibility 0ms step-start;
}

.choice-hint {
  display: flex;
  margin: 0 0 18px;
  align-items: center;
  gap: 14px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-align: center;
}

.choice-hint span {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45));
}

.choice-hint span:last-child {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.45), transparent);
}

.choices {
  display: grid;
  gap: 10px;
}

.choice-btn {
  position: relative;
  width: 100%;
  min-height: 62px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 2px;
  padding: 13px 60px 13px 70px;
  background: rgba(18, 24, 34, 0.89);
  box-shadow: 0 15px 38px rgba(6, 9, 14, 0.22);
  backdrop-filter: blur(14px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  letter-spacing: 0.11em;
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.choice-btn::before {
  content: attr(data-index);
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: 48px;
  place-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.4);
  font-family: "Segoe UI", sans-serif;
  font-size: 10px;
}

.choice-btn::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  transform: scaleY(0);
  background: var(--mint);
  transition: transform 180ms ease;
}

.choice-btn:hover,
.choice-btn:focus-visible {
  transform: translateX(8px);
  border-color: rgba(169, 226, 200, 0.72);
  background: rgba(27, 37, 49, 0.96);
}

.choice-btn:hover::after,
.choice-btn:focus-visible::after {
  transform: scaleY(1);
}

/* Ending */

.ending-screen {
  background: #172033;
}

.ending-bg {
  filter: saturate(0.82) brightness(0.76);
}

.ending-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(224, 203, 198, 0.08), rgba(9, 13, 21, 0.78) 76%), linear-gradient(0deg, rgba(10, 13, 20, 0.64), transparent 55%);
}

.ending-content {
  position: relative;
  z-index: 3;
  display: flex;
  width: min(760px, 86vw);
  height: 100%;
  margin: auto;
  padding: max(8vh, var(--safe-top)) 20px max(7vh, var(--safe-bottom));
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  text-shadow: 0 3px 24px rgba(0, 0, 0, 0.4);
}

.ending-type {
  font-size: 11px;
}

.ending-symbol {
  display: grid;
  width: 66px;
  height: 66px;
  margin: 28px 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.23);
  place-items: center;
  transform: rotate(45deg);
  background: rgba(19, 26, 38, 0.4);
  font-size: 20px;
}

.ending-symbol::first-letter {
  transform: rotate(-45deg);
}

.ending-content h2 {
  margin: 0;
  font-size: clamp(36px, 5.2vw, 72px);
  font-weight: 300;
  letter-spacing: 0.16em;
}

.ending-description {
  max-width: 620px;
  margin: 24px auto 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  letter-spacing: 0.12em;
  line-height: 2;
}

.ending-unlock {
  margin: 25px 0 0;
  color: var(--mint);
  font-size: 11px;
  letter-spacing: 0.17em;
}

.ending-actions {
  display: flex;
  margin-top: 36px;
  gap: 10px;
}

/* Modals */

.modal-backdrop {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  padding: max(24px, var(--safe-top)) max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
  place-items: center;
  visibility: hidden;
  opacity: 0;
  background: rgba(6, 9, 15, 0.76);
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms step-end;
}

.modal-backdrop.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 220ms ease, visibility 0ms step-start;
}

.modal {
  position: relative;
  display: none;
  width: min(520px, 94vw);
  max-height: min(84vh, 820px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 3px;
  padding: 40px 44px;
  transform: translateY(16px) scale(0.985);
  background:
    linear-gradient(140deg, rgba(34, 42, 55, 0.98), rgba(15, 20, 30, 0.985)),
    var(--glass-strong);
  box-shadow: 0 35px 100px rgba(2, 4, 8, 0.56), inset 3px 0 0 rgba(169, 226, 200, 0.45);
  opacity: 0;
  transition: transform 230ms ease, opacity 230ms ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(169, 226, 200, 0.42) transparent;
}

.modal.is-open {
  display: block;
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal h2 {
  margin: 6px 0 8px;
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 300;
  letter-spacing: 0.12em;
}

.modal > p:not(.modal-kicker),
.modal-heading > p {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  letter-spacing: 0.07em;
  line-height: 1.8;
}

.modal-kicker {
  color: var(--mint);
  font-size: 9px;
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 15px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.46);
  font-family: "Segoe UI", sans-serif;
  font-size: 24px;
  font-weight: 200;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--mint);
}

.wide-modal {
  width: min(1050px, 94vw);
}

.modal-heading {
  display: flex;
  margin-bottom: 24px;
  padding-right: 30px;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
}

.modal-heading h2 {
  margin-bottom: 0;
}

.modal-heading > p {
  margin: 0;
  text-align: right;
}

.name-field {
  display: grid;
  margin: 28px 0 24px;
  gap: 9px;
}

.name-field span {
  color: rgba(255, 255, 255, 0.57);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.name-field input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.27);
  padding: 13px 4px;
  background: transparent;
  color: white;
  font-size: 21px;
  letter-spacing: 0.2em;
}

.soft-btn {
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 2px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: border-color 170ms ease, background 170ms ease, color 170ms ease;
}

.soft-btn:hover {
  border-color: rgba(169, 226, 200, 0.72);
  background: rgba(169, 226, 200, 0.08);
  color: white;
}

.soft-btn--primary {
  border-color: rgba(169, 226, 200, 0.55);
  background: rgba(169, 226, 200, 0.1);
}

.soft-btn--wide {
  width: 100%;
}

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

.save-slot {
  position: relative;
  min-height: 112px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 2px;
  padding: 18px 46px 17px 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  text-align: left;
  transition: border-color 170ms ease, background 170ms ease, transform 170ms ease;
}

.save-slot:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(169, 226, 200, 0.53);
  background: rgba(169, 226, 200, 0.055);
}

.save-slot:disabled {
  opacity: 0.48;
}

.save-slot__number {
  display: block;
  margin-bottom: 12px;
  color: var(--mint);
  font-family: "Segoe UI", sans-serif;
  font-size: 9px;
  letter-spacing: 0.23em;
}

.save-slot strong {
  display: block;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot small {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.39);
  font-family: "Segoe UI", sans-serif;
  font-size: 9px;
  letter-spacing: 0.05em;
}

.save-slot__delete {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  width: 27px;
  height: 27px;
  border: 0;
  place-items: center;
  background: transparent;
  color: rgba(255, 255, 255, 0.28);
  cursor: pointer;
}

.save-slot__delete:hover {
  color: var(--peach);
}

.log-list {
  display: grid;
  max-height: 56vh;
  overflow-y: auto;
  gap: 0;
}

.log-entry {
  display: grid;
  grid-template-columns: 125px 1fr;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 15px 8px;
  gap: 22px;
}

.log-entry:first-child {
  border-top: 0;
}

.log-entry b {
  color: var(--mint);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-align: right;
}

.log-entry p {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  letter-spacing: 0.055em;
  line-height: 1.8;
  user-select: text;
}

.empty-state {
  margin: 50px auto;
  color: rgba(255, 255, 255, 0.38);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-align: center;
}

.settings-modal {
  width: min(680px, 94vw);
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 230px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding: 20px 2px;
  align-items: center;
  gap: 30px;
}

.setting-row:first-of-type {
  margin-top: 28px;
}

.setting-row > div {
  display: grid;
  gap: 5px;
}

.setting-row b {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.1em;
}

.setting-row small {
  color: rgba(255, 255, 255, 0.37);
  font-size: 10px;
  letter-spacing: 0.05em;
}

input[type="range"] {
  width: 100%;
  height: 3px;
  appearance: none;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(169, 226, 200, 0.72), rgba(255, 255, 255, 0.16));
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.setting-row--toggle {
  grid-template-columns: 1fr auto;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  position: relative;
  display: block;
  width: 44px;
  height: 23px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--gray-3);
  transition: transform 180ms ease, background 180ms ease;
}

.toggle input:checked + span {
  border-color: rgba(169, 226, 200, 0.55);
  background: rgba(169, 226, 200, 0.14);
}

.toggle input:checked + span::after {
  transform: translateX(21px);
  background: var(--mint);
}

.settings-actions {
  display: flex;
  margin-top: 20px;
  gap: 9px;
}

.ending-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.memory-card {
  position: relative;
  min-height: 260px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  overflow: hidden;
  background: #151b27;
}

.memory-card__image {
  position: absolute;
  inset: 0;
  background: url("assets/backgrounds/rooftop.jpg") center / cover;
  filter: brightness(0.5) saturate(0.65);
  transition: transform 500ms ease, filter 500ms ease;
}

.memory-card:hover .memory-card__image {
  transform: scale(1.045);
  filter: brightness(0.57) saturate(0.85);
}

.memory-card.is-locked .memory-card__image {
  filter: brightness(0.22) grayscale(1) blur(4px);
}

.memory-card__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(7, 10, 16, 0.94), rgba(7, 10, 16, 0.1) 75%);
}

.memory-card__content {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 18px;
}

.memory-card__content small {
  color: var(--mint);
  font-family: "Segoe UI", sans-serif;
  font-size: 8px;
  letter-spacing: 0.2em;
}

.memory-card__content h3 {
  margin: 6px 0 7px;
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 0.1em;
}

.memory-card__content p {
  margin: 0;
  color: rgba(255, 255, 255, 0.48);
  font-size: 10px;
  line-height: 1.7;
}

.memory-card.is-locked .memory-card__content h3,
.memory-card.is-locked .memory-card__content p {
  color: rgba(255, 255, 255, 0.24);
}

.confirm-modal {
  text-align: center;
}

.confirm-actions {
  display: flex;
  margin-top: 28px;
  justify-content: center;
  gap: 10px;
}

.toast {
  position: fixed;
  z-index: 500;
  top: max(25px, calc(var(--safe-top) + 12px));
  left: 50%;
  min-width: 220px;
  border: 1px solid rgba(169, 226, 200, 0.38);
  border-radius: 2px;
  padding: 11px 24px;
  transform: translate(-50%, -18px);
  visibility: hidden;
  opacity: 0;
  background: rgba(14, 20, 29, 0.91);
  box-shadow: 0 12px 40px rgba(4, 7, 12, 0.34);
  color: rgba(255, 255, 255, 0.84);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-align: center;
  pointer-events: none;
  transition: opacity 190ms ease, transform 190ms ease, visibility 190ms step-end;
}

.toast.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
  transition: opacity 190ms ease, transform 190ms ease, visibility 0ms step-start;
}

/* Responsive */

@media (max-width: 900px) {
  .title-layout {
    padding-left: 7vw;
    gap: 5vw;
  }

  .title-copy {
    width: 58vw;
  }

  .title-menu {
    width: 33vw;
  }

  .dialogue-box {
    width: 92vw;
    min-height: 175px;
    padding: 43px 45px 42px;
  }

  .character-wrap {
    width: min(60vw, 610px);
  }

  .setting-row {
    grid-template-columns: 1fr 190px;
  }
}

@media (max-width: 680px), (max-height: 520px) and (orientation: landscape) {
  .title-layout {
    align-items: end;
    flex-direction: column;
    justify-content: center;
    gap: 5vh;
    padding: max(6vh, calc(var(--safe-top) + 20px)) max(7vw, calc(var(--safe-right) + 18px)) max(8vh, calc(var(--safe-bottom) + 30px)) max(7vw, calc(var(--safe-left) + 18px));
  }

  .title-copy,
  .title-menu {
    width: 100%;
  }

  .title-copy {
    transform: none;
  }

  .title-copy h1 {
    font-size: clamp(43px, 13vw, 72px);
  }

  .title-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-btn {
    min-height: 53px;
  }

  .title-footer {
    display: none;
  }

  .game-brand > span:last-child,
  .top-actions .hud-btn:nth-child(-n+2) {
    display: none;
  }

  .game-topbar {
    padding: max(11px, calc(var(--safe-top) + 7px)) max(12px, calc(var(--safe-right) + 8px)) 10px max(12px, calc(var(--safe-left) + 8px));
  }

  .hud-btn {
    min-width: 42px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .character-wrap {
    bottom: 0;
    width: 84vw;
    height: 88vh;
  }

  .dialogue-box {
    bottom: max(1.6vh, calc(var(--safe-bottom) + 6px));
    width: 95vw;
    min-height: 162px;
    padding: 39px 25px 35px;
  }

  .speaker-name {
    top: -16px;
    left: 20px;
    min-width: 125px;
    padding: 8px 20px;
    font-size: 13px;
  }

  .dialogue-text {
    min-height: 78px;
    font-size: 15px;
    line-height: 1.8;
  }

  .dialogue-controls {
    right: 10px;
    top: 8px;
  }

  .dialogue-controls kbd {
    display: none;
  }

  .choice-panel {
    width: 92vw;
  }

  .choice-btn {
    min-height: 56px;
    padding: 12px 20px 12px 62px;
    font-size: 13px;
  }

  .modal {
    max-height: 90vh;
    padding: 34px 24px;
  }

  .save-grid,
  .ending-gallery {
    grid-template-columns: 1fr;
  }

  .memory-card {
    min-height: 190px;
  }

  .setting-row {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .setting-row--toggle {
    grid-template-columns: 1fr auto;
  }

  .log-entry {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .log-entry b {
    text-align: left;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .title-layout {
    align-items: center;
    flex-direction: row;
    gap: 6vw;
  }

  .title-copy {
    width: 56vw;
  }

  .title-menu {
    display: flex;
    width: 33vw;
  }

  .menu-btn {
    min-height: 44px;
    padding-block: 5px;
  }

  .character-wrap {
    width: 42vw;
    height: 97vh;
  }

  .dialogue-box {
    right: 2vw;
    bottom: max(2.5vh, var(--safe-bottom));
    left: auto;
    width: 66vw;
    min-height: 126px;
    padding: 32px 35px 24px;
  }

  .dialogue-text {
    min-height: 55px;
    font-size: 13px;
    line-height: 1.7;
  }
}

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

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
}

body.reduce-motion .rain-layer {
  display: none;
}

noscript {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  background: #151a24;
  color: white;
}
