:root {
  color-scheme: dark;
  --ink: #edf5ff;
  --muted: #a5b7cc;
  --line: rgba(205, 228, 255, 0.26);
  --blue: #7bbbea;
  --warm: #efc36f;
  --danger: #f18496;
  --ok: #9bd8bc;
  --dark: #050a12;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--dark);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

#rainCanvas {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.blackout {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  padding: 24px;
  background: #000;
  color: #f3f3f3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 900ms ease;
}

.blackout.show {
  opacity: 1;
  pointer-events: auto;
}

.blackout p {
  margin: 0;
  font-size: clamp(22px, 3vw, 42px);
  letter-spacing: 0;
  font-weight: 600;
}

#blackoutSecond {
  opacity: 0;
  font-size: clamp(18px, 2vw, 30px);
  color: #d6d6d6;
  transition: opacity 900ms ease;
}

.blackout.second #blackoutSecond {
  opacity: 1;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  background: #050a12;
}

.scene {
  position: relative;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  background-color: #07111f;
  background-position: center;
  background-size: cover;
  transition: filter 260ms ease;
}

.scene-door {
  background-image: url("./assets/doorway.png");
}

.scene-phone,
.scene-puddle {
  background-image: url("./assets/rainy-street.png");
}

.scene-alley {
  background-image: url("./assets/umbrella-alley.png");
}

.scene-store {
  background-image: url("./assets/store-close.png");
}

.scene-crossing {
  background-image: url("./assets/red-crossing.png");
}

.scene-bridge {
  background-image: url("./assets/bridge.png");
}

.scene-station,
.scene-ending {
  background-image: url("./assets/station.png");
}

.scene-he {
  background-image: url("./assets/he-bridge.png");
}

.shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(3, 8, 14, 0.12), rgba(3, 8, 14, 0.42) 58%, rgba(3, 8, 14, 0.9)),
    radial-gradient(circle at 48% 40%, transparent 0 16rem, rgba(2, 7, 14, 0.18) 30rem),
    linear-gradient(90deg, rgba(0, 0, 0, 0.2), transparent 26%, transparent 70%, rgba(0, 0, 0, 0.34));
}

.linwan {
  position: absolute;
  z-index: 3;
  left: 4%;
  bottom: 284px;
  width: min(27vw, 330px);
  min-width: 230px;
  max-height: 54vh;
  opacity: 0.96;
  filter: drop-shadow(0 26px 32px rgba(0, 0, 0, 0.7));
  transform-origin: bottom center;
  transition: opacity 260ms ease, transform 260ms ease, filter 260ms ease;
}

.linwan img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.linwan.hidden {
  opacity: 0;
}

.scene-he .linwan,
.scene-ending .linwan {
  opacity: 0;
}

.linwan.wary {
  transform: translateX(-14px) scale(0.98);
  filter: grayscale(0.15) drop-shadow(0 26px 32px rgba(0, 0, 0, 0.72));
}

.linwan.soft {
  transform: translateX(12px);
  filter: saturate(1.08) drop-shadow(0 26px 32px rgba(0, 0, 0, 0.62));
}

.linwan.afraid {
  transform: translateX(-24px) scale(0.96);
  opacity: 0.82;
  filter: grayscale(0.38) contrast(0.92) drop-shadow(0 26px 32px rgba(0, 0, 0, 0.78));
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 24px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

h1 {
  margin: 0;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 700;
  text-shadow: 0 0 24px rgba(123, 187, 234, 0.55);
}

#placeLabel {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.meters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 540px;
}

.meters span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(4, 12, 22, 0.56);
  backdrop-filter: blur(12px);
  font-size: 13px;
}

.meters b {
  color: var(--ink);
}

.dialogue-panel {
  position: absolute;
  z-index: 6;
  left: clamp(20px, 2vw, 34px);
  right: clamp(20px, 2vw, 34px);
  bottom: 24px;
  min-height: 258px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(10, 24, 41, 0.8), rgba(4, 10, 18, 0.94)),
    rgba(4, 10, 18, 0.86);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  overflow: hidden;
}

.speaker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#speakerName {
  color: var(--blue);
  font-size: 16px;
  font-weight: 700;
}

#moodLabel {
  color: var(--muted);
  font-size: 13px;
}

#dialogueText {
  min-height: 84px;
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.7;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.effect-line {
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--warm);
  font-size: 13px;
}

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

button.choice {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(205, 228, 255, 0.28);
  color: var(--ink);
  background: rgba(8, 20, 34, 0.82);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button.choice:hover,
button.choice:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(123, 187, 234, 0.92);
  background: rgba(21, 52, 83, 0.9);
  outline: none;
}

button.choice.end {
  border-color: rgba(239, 195, 111, 0.64);
}

.memory-panel {
  z-index: 7;
  min-width: 0;
  padding: 26px 20px;
  overflow-y: auto;
  border-left: 1px solid rgba(205, 228, 255, 0.18);
  background: rgba(3, 8, 15, 0.88);
}

.memory-title {
  margin-bottom: 14px;
  color: var(--blue);
  font-weight: 700;
}

.logic-card {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid rgba(205, 228, 255, 0.16);
  background: rgba(8, 18, 32, 0.56);
}

.logic-card b {
  display: block;
  margin-bottom: 6px;
  color: var(--warm);
  font-size: 13px;
}

.logic-card p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.route-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.route-map span {
  min-height: 30px;
  padding: 7px 8px;
  border: 1px solid rgba(205, 228, 255, 0.14);
  color: #7d93aa;
  background: rgba(8, 18, 32, 0.54);
  font-size: 12px;
  text-align: center;
}

.route-map span.active {
  border-color: rgba(123, 187, 234, 0.86);
  color: var(--ink);
  background: rgba(24, 61, 96, 0.76);
}

.route-map span.passed {
  color: var(--ok);
  border-color: rgba(155, 216, 188, 0.28);
}

#memoryList {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

#memoryList li {
  margin-bottom: 10px;
}

.flash {
  animation: flash 620ms ease;
}

.shake {
  animation: shake 420ms ease;
}

.whiteout .shade {
  animation: whiteFade 1350ms ease;
}

@keyframes flash {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.65); }
  100% { filter: brightness(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

@keyframes whiteFade {
  0% {
    background: rgba(245, 248, 255, 0.98);
  }
  54% {
    background: rgba(245, 248, 255, 0.92);
  }
  100% {
    background:
      linear-gradient(180deg, rgba(3, 8, 14, 0.04), rgba(3, 8, 14, 0.34) 58%, rgba(3, 8, 14, 0.82)),
      radial-gradient(circle at 48% 40%, transparent 0 16rem, rgba(2, 7, 14, 0.12) 30rem),
      linear-gradient(90deg, rgba(0, 0, 0, 0.12), transparent 26%, transparent 70%, rgba(0, 0, 0, 0.24));
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .game-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .scene {
    min-height: 790px;
  }

  .topbar {
    flex-direction: column;
  }

  .meters {
    justify-content: flex-start;
  }

  .linwan {
    left: 4%;
    width: 280px;
    bottom: 285px;
  }

  .dialogue-panel {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .choices {
    grid-template-columns: 1fr;
  }

  .memory-panel {
    border-left: 0;
    border-top: 1px solid rgba(205, 228, 255, 0.18);
    min-height: 260px;
  }
}
