/* =========================
   Global variables / reset
========================== */
:root {
  --bg: #0b0b11;
  --panel: rgba(18, 18, 26, 0.92);
  --panel-soft: rgba(28, 28, 38, 0.88);
  --text: #eee7dd;
  --muted: #b8aea3;
  --accent: #a44848;
  --accent-soft: rgba(164, 72, 72, 0.18);
  --border: rgba(255, 255, 255, 0.12);
  --gold: #c8a56b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #0a0910 0%, #13101a 100%);
  color: var(--text);
  font-family: "Georgia", "Times New Roman", serif;
}

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

button {
  appearance: none;
  border: 1px solid rgba(200, 165, 107, 0.3);
  background: linear-gradient(180deg, rgba(113, 28, 28, 0.7), rgba(53, 12, 12, 0.95));
  color: #fff7ef;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s ease;
  font-size: 1rem;
  font-family: "Georgia", "Times New Roman", serif;
}

button:hover {
  transform: translateY(-2px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
  color: var(--muted);
}

/* =========================
   Intro
========================== */
.intro-screen {
  position: relative;
  justify-content: center;
  align-items: center;
  padding: 32px;
  overflow: hidden;
}

.intro-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.05), transparent 20%),
    radial-gradient(circle at 70% 30%, rgba(255,255,255,0.03), transparent 22%),
    radial-gradient(circle at 30% 70%, rgba(255,255,255,0.04), transparent 18%);
  filter: blur(24px);
}

.intro-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  background: rgba(8, 8, 12, 0.76);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: var(--shadow);
}

.intro-card h1 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.intro-subtitle {
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detective-form {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 18px;
  flex-wrap: wrap;
}

.detective-name-input {
  min-width: min(360px, 100%);
  border: none;
  border-bottom: 2px solid rgba(200, 165, 107, 0.72);
  background: transparent;
  color: var(--text);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  padding: 8px 4px;
  outline: none;
}

.detective-name-input::placeholder {
  color: rgba(238, 231, 221, 0.38);
  font-style: italic;
}

.detective-name-input:focus {
  border-bottom-color: var(--gold);
  box-shadow: 0 10px 18px rgba(200, 165, 107, 0.08);
}

.intro-warning {
  max-width: 980px;
  line-height: 1.45;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  color: rgba(238, 231, 221, 0.96);
}

/* =========================
   Briefing
========================== */
.briefing-screen {
  justify-content: center;
  align-items: center;
  padding: 32px;
}

.briefing-shell {
  width: min(900px, 100%);
}

.briefing-card {
  background: rgba(8, 8, 12, 0.88);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: min(86vh, 820px);
}

.briefing-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.briefing-header p {
  margin: 6px 0 0;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.briefing-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  line-height: 1.9;
}

.briefing-content {
  max-width: 720px;
}

.briefing-content p {
  margin: 0 0 1.2rem;
}

.briefing-task {
  color: #f2d4a5;
  font-size: 1.04rem;
}

.briefing-location-box {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid rgba(200, 165, 107, 0.24);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(200, 165, 107, 0.07), rgba(255, 255, 255, 0.025));
}

.briefing-location-box p {
  margin: 0 0 14px;
  color: rgba(238, 231, 221, 0.9);
  line-height: 1.8;
}

.location-result-text {
  margin-top: 14px;
  color: var(--gold);
  line-height: 1.75;
  font-size: 0.98rem;
}

.location-result-text p {
  margin: 0 0 0.65rem;
}

.location-result-text p:last-child {
  margin-bottom: 0;
}

.briefing-footer {
  display: flex;
  justify-content: flex-end;
}

.briefing-enter-btn {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.briefing-enter-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* =========================
   Room 1 / Room 2 shared game layout
========================== */
.game-screen {
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: rgba(10, 10, 16, 0.8);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 16px;
}

.top-bar h2 {
  margin: 0;
}

.top-bar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.game-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 16px;
}

.scene-panel,
.side-panel {
  background: rgba(10, 10, 16, 0.82);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.scene-panel {
  padding: 16px;
}

.scene-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 18px;
  background: #111;
}

.scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.35s ease, transform 0.35s ease;
}

.scene-image.blurred {
  filter: blur(5px) brightness(0.82);
  transform: scale(1.01);
}

/* =========================
   Hotspots
========================== */
.hotspot {
  position: absolute;
  border: 1px dashed rgba(255,255,255,0.0002);
  background: rgba(255,255,255,0.003);
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s ease;
}

.hotspot:hover {
  background: rgba(164, 72, 72, 0.18);
  border-color: rgba(200, 165, 107, 0.55);
}

.hotspot.discovered {
  background: rgba(200, 165, 107, 0.08);
  border-color: rgba(200, 165, 107, 0.3);
}

.hs-photo {
  left: 67%;
  top: 60%;
  width: 16%;
  height: 17%;
}

.hs-mirror {
  left: 11.2%;
  top: 12%;
  width: 12%;
  height: 48%;
}

.hs-doll {
  left: 54%;
  top: 41.5%;
  width: 7.5%;
  height: 11%;
}

.hs-computer {
  left: 78%;
  top: 40%;
  width: 15%;
  height: 22%;
}

.hs-camera {
  left: 76.3%;
  top: 19.5%;
  width: 22.5%;
  height: 10.5%;
}

.hs-polaroid {
  left: 83.5%;
  top: 69%;
  width: 9%;
  height: 12%;
}

.hs-archive-mirror {
  left: 17%;
  top: 60%;
  width: 16%;
  height: 17%;
}

.hs-photo-mirror {
  left: 28%;
  top: 72%;
  width: 14%;
  height: 13%;
}

/* =========================
   Side panels / reports
========================== */
.side-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-block {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.panel-block h3 {
  margin-top: 0;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.story-text {
  line-height: 1.8;
  color: var(--text);
}

.report-scroll {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 8px;
}

.report-entry {
  margin: 0 0 1rem;
  line-height: 1.85;
}

.report-entry:last-child {
  margin-bottom: 0;
}

.report-entry-label {
  color: var(--gold);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.report-entry-body p {
  margin: 0 0 0.9rem;
  text-align: justify;
}

.report-entry-body p:last-child {
  margin-bottom: 0;
}

.report-entry-body-emphasis p {
  color: var(--gold);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.progress-status-text {
  margin-top: 12px;
  line-height: 1.8;
  color: var(--text);
}

.progress-status-text p {
  margin: 0 0 0.75rem;
}

.progress-status-text p:last-child {
  margin-bottom: 0;
}

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

.evidence-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 84px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  color: var(--text);
  text-align: center;
  padding: 10px 8px;
}

.evidence-btn span {
  display: block;
  font-size: 0.85rem;
}

.evidence-btn.visible {
  display: flex;
}

/* =========================
   Modal
========================== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 22px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  z-index: 9000;
}

.modal.active {
  display: flex;
}

.modal-card {
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: rgba(12, 12, 18, 0.98);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
}

.modal-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-right: 50px;
}

.modal-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 2rem;
  background: rgba(164, 72, 72, 0.15);
  border: 1px solid rgba(200, 165, 107, 0.25);
}

.modal-subtitle {
  color: var(--gold);
  margin-top: 6px;
}

.modal-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.artifact-view {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  height: 460px;
  min-height: 460px;
}

.artifact-image {
  width: 100%;
  height: 100%;
  max-height: 120%;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  background: #111;
}

.artifact-note {
  display: block;
  line-height: 2;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  min-height: 500px;
  height: 500px;
}

/* =========================
   Typewriter
========================== */
.typewriter-line {
  opacity: 0;
}

.typewriter-line.is-typing {
  opacity: 1;
  animation: fadeInSegment 0.6s ease forwards;
}

.typewriter-line.is-done {
  opacity: 1;
}

@keyframes fadeInSegment {
  from {
    opacity: 0;
    filter: blur(2px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

/* =========================
   Photo stack
========================== */
.photo-stack-shell {
  width: 100%;
  padding-bottom: 12px;
}

.photo-stack-instruction {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.photo-stack-stage {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  border: none;
}

.photo-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  max-width: 340px;
  aspect-ratio: 3 / 4;
  transform-style: preserve-3d;
  transition:
    transform 0.45s ease,
    opacity 0.35s ease,
    filter 0.35s ease;
  cursor: grab;
}

.photo-card.dragging {
  transition: none;
  cursor: grabbing;
}

.photo-card-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  overflow: hidden;
  backface-visibility: hidden;
}

.photo-card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card-back {
  transform: rotateY(180deg);
  background: #111;
  border: none;
  padding: 0;
}

.photo-card.flipped {
  transform: translate(-50%, -50%) rotateY(180deg) !important;
}

.photo-back-inner {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
}

.photo-back-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-card.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.photo-card.is-back-2 {
  transform: translate(-50%, -50%) scale(0.9) translateY(-6px);
  opacity: 0.35;
  z-index: 1;
  filter: blur(1px);
}

.photo-card.is-back-1 {
  transform: translate(-50%, -50%) scale(0.95) translateY(-3px);
  opacity: 0.55;
  z-index: 2;
  filter: blur(0.5px);
}

.photo-card.is-active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  z-index: 5;
}

.photo-card.is-next-1 {
  transform: translate(-50%, -50%) scale(0.97) translateY(4px);
  opacity: 0.6;
  z-index: 3;
}

.photo-card.is-next-2 {
  transform: translate(-50%, -50%) scale(0.92) translateY(8px);
  opacity: 0.35;
  z-index: 2;
}

.photo-stack-footer {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.photo-stack-counter {
  color: var(--gold);
  font-size: 0.95rem;
}

.photo-stack-hint {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.photo-stack-hint.important {
  color: #f2d4a5;
}

.photo-flip-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 86px;
}

.photo-flip-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* =========================
   Doll interaction
========================== */
.doll-shell {
  width: 100%;
}

.doll-stage {
  position: relative;
  width: 100%;
  min-height: 440px;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--border);
}

.doll-main-image {
  width: 100%;
  height: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
  background: #111;
}

.doll-belly-hotspot {
  position: absolute;
  left: 41%;
  top: 52%;
  width: 18%;
  height: 18%;
  border: 2px dashed rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  cursor: pointer;
  transition: 0.2s ease;
}

.doll-belly-hotspot:hover {
  background: rgba(164, 72, 72, 0.16);
  border-color: rgba(255, 120, 120, 0.7);
}

.doll-dissolve-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle, rgba(255,255,255,0.12), rgba(0,0,0,0.28)),
    rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.doll-dissolve-overlay.active {
  opacity: 1;
}

.doll-red-circle {
  position: absolute;
  left: 43.5%;
  top: 55%;
  width: 13%;
  height: 13%;
  border: 4px solid #d92828;
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(217, 40, 40, 0.35);
  opacity: 0;
  transform: scale(0.8);
  transition: 0.28s ease;
  pointer-events: none;
}

.doll-red-circle.visible {
  opacity: 1;
  transform: scale(1);
}

/* =========================
   Collapse / mirror animations
========================== */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 9998;
}

@keyframes mirrorFlash {
  0%, 100% {
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    opacity: 0.2;
    filter: brightness(2.2);
  }
}

.mirror-finale-image {
  cursor: default;
}

.mirror-finale-image.mirror-flashing {
  animation: mirrorFlash 0.16s steps(2, end) infinite;
}

.mirror-finale-image.mirror-final-form {
  cursor: pointer;
}

@keyframes imageBlackoutSlow {
  0%   { filter: brightness(1); }
  12%  { filter: brightness(1); }
  18%  { filter: brightness(0.15); }
  27%  { filter: brightness(1); }
  45%  { filter: brightness(1); }
  53%  { filter: brightness(0.05); }
  61%  { filter: brightness(1); }
  100% { filter: brightness(1); }
}

.image-blackout-stage-1 {
  animation: imageBlackoutSlow 1.6s infinite;
}

@keyframes imageShakeMedium {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1.01); }
  12%  { transform: translate(-6px, 4px) rotate(-0.8deg) scale(1.012); }
  24%  { transform: translate(7px, -5px) rotate(0.9deg) scale(1.015); }
  36%  { transform: translate(-9px, 6px) rotate(-1.1deg) scale(1.01); }
  48%  { transform: translate(8px, -7px) rotate(1deg) scale(1.014); }
  60%  { transform: translate(-7px, 5px) rotate(-0.9deg) scale(1.012); }
  72%  { transform: translate(6px, -6px) rotate(0.8deg) scale(1.015); }
  84%  { transform: translate(-5px, 4px) rotate(-0.7deg) scale(1.01); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1.01); }
}

.image-shake-stage-2 {
  animation: imageShakeMedium 0.55s infinite;
}

@keyframes imageBlackoutMedium {
  0%   { filter: brightness(1); }
  15%  { filter: brightness(1); }
  24%  { filter: brightness(0.1); }
  34%  { filter: brightness(1); }
  56%  { filter: brightness(1); }
  68%  { filter: brightness(0.15); }
  77%  { filter: brightness(1); }
  100% { filter: brightness(1); }
}

.image-blackout-stage-2 {
  animation: imageBlackoutMedium 0.95s infinite;
}

@keyframes imageBlackoutHard {
  0%   { filter: brightness(1); }
  14%  { filter: brightness(0.22); }
  28%  { filter: brightness(0.04); }
  46%  { filter: brightness(0.55); }
  64%  { filter: brightness(0.02); }
  82%  { filter: brightness(0.35); }
  100% { filter: brightness(0.12); }
}

.image-blackout-stage-5 {
  animation: imageBlackoutHard 0.28s infinite;
}

@keyframes borderPulseChaos {
  0%, 100% {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
  }
  22% {
    border-color: rgba(200, 165, 107, 0.85);
    box-shadow: 0 0 12px rgba(200, 165, 107, 0.25);
  }
  58% {
    border-color: rgba(255, 255, 255, 0.82);
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.12);
  }
  78% {
    border-color: rgba(164, 72, 72, 0.9);
    box-shadow: 0 0 16px rgba(164, 72, 72, 0.2);
  }
}

body.borders-flicker-stage-3 .scene-panel,
body.borders-flicker-stage-3 .side-panel,
body.borders-flicker-stage-3 .top-bar,
body.borders-flicker-stage-3 .panel-block,
body.borders-flicker-stage-3 .evidence-btn,
body.borders-flicker-stage-3 .modal-card {
  animation: borderPulseChaos 0.42s infinite;
}

@keyframes textShakeChaos {
  0%   { transform: translate(0, 0); opacity: 1; }
  18%  { transform: translate(-1px, 1px); }
  36%  { transform: translate(1px, -1px); }
  54%  { transform: translate(-2px, 0); }
  72%  { transform: translate(2px, 1px); }
  88%  { transform: translate(-1px, -1px); }
  100% { transform: translate(0, 0); opacity: 1; }
}

body.text-chaos-stage-4 .top-bar h2,
body.text-chaos-stage-4 .top-bar p,
body.text-chaos-stage-4 .panel-block h3,
body.text-chaos-stage-4 .panel-block p,
body.text-chaos-stage-4 .story-text,
body.text-chaos-stage-4 .evidence-btn span,
body.text-chaos-stage-4 .evidence-btn {
  animation: textShakeChaos 0.18s infinite;
}

@keyframes bodyFlashStage4 {
  0%, 100% { opacity: 0; }
  18% { opacity: 0.18; }
  34% { opacity: 0.45; }
  52% { opacity: 0.12; }
  74% { opacity: 0.65; }
}

body.global-flicker-stage-4::after {
  animation: bodyFlashStage4 0.5s infinite;
}

@keyframes wholeScreenShakeHard {
  0%   { transform: translate(0, 0) rotate(0deg); }
  10%  { transform: translate(-2px, 2px) rotate(-0.4deg); }
  20%  { transform: translate(3px, -2px) rotate(0.5deg); }
  35%  { transform: translate(-4px, 1px) rotate(-0.6deg); }
  50%  { transform: translate(4px, -3px) rotate(0.6deg); }
  65%  { transform: translate(-3px, 2px) rotate(-0.5deg); }
  80%  { transform: translate(2px, -4px) rotate(0.4deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.whole-screen-shake-stage-5 {
  animation: wholeScreenShakeHard 0.08s infinite;
}

@keyframes bodyFlashStage5 {
  0%   { opacity: 0; }
  12%  { opacity: 0.18; }
  24%  { opacity: 0.82; }
  42%  { opacity: 0.96; }
  58%  { opacity: 0.42; }
  76%  { opacity: 1; }
  100% { opacity: 0.1; }
}

body.global-flicker-stage-5::after {
  animation: bodyFlashStage5 0.32s infinite;
}

@keyframes finalBlackoutSlowdown {
  0%   { opacity: 0.95; }
  20%  { opacity: 0.25; }
  45%  { opacity: 1; }
  70%  { opacity: 0.4; }
  100% { opacity: 0.85; }
}

body.final-blackout-stage::after {
  animation: finalBlackoutSlowdown 1.2s ease-in-out infinite;
}

.final-image-takeover .top-bar,
.final-image-takeover .side-panel {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.final-image-takeover .scene-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9997;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: #000 !important;
  box-shadow: none !important;
}

.final-image-takeover .scene-wrapper {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0 !important;
  background: #000;
}

.final-image-takeover .scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.final-image-takeover .game-layout {
  display: block !important;
}

.final-image-takeover .panel-block,
.final-image-takeover .scene-panel,
.final-image-takeover .side-panel,
.final-image-takeover .top-bar {
  box-shadow: none !important;
  border-color: transparent !important;
}

/* =========================
   Scaffold debug nav

.scaffold-nav {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20000;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.scaffold-nav button {
  pointer-events: auto;
}
========================== */

/* =========================
   Room 2 archive / photo modal
========================== */
.modal-card:has(.room2-object-stack) {
  width: min(1080px, 96vw);
}

.modal-content:has(.room2-object-stack) {
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 14px;
  align-items: stretch;
}

.modal-content:has(.room2-object-stack) .artifact-view,
.modal-content:has(.room2-object-stack) .artifact-note {
  height: 540px;
  min-height: 540px;
}

.modal-content:has(.room2-object-stack) .artifact-view {
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-content:has(.room2-object-stack) .artifact-note {
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.95rem;
  line-height: 1.85;
}

.modal-content:has(.room2-object-stack) .report-entry {
  line-height: 1.85;
}

.modal-content:has(.room2-object-stack) .report-entry-label {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

.modal-content:has(.room2-object-stack) .report-entry-body p {
  margin: 0 0 0.8rem;
  text-align: justify;
}

.room2-object-stack {
  width: 100%;
}

.room2-object-stage {
  position: relative;
  width: 100%;
  height: 430px;
  margin: 0;
  background: transparent !important;
  border: none !important;
  overflow: visible;
}

.room2-object-stack .photo-card {
  width: 96%;
  max-width: 560px;
  height: 390px;
  aspect-ratio: auto;
}

.room2-object-stack .photo-card-face,
.room2-object-stack .photo-card-back,
.room2-object-stack .photo-back-inner {
  background: transparent !important;
  border: none !important;
  border-radius: 0;
  overflow: visible;
  padding: 0 !important;
}

.room2-object-stack .photo-card-face img,
.room2-object-stack .photo-back-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
  background: transparent !important;
  display: block;
}

.room2-object-stack .photo-card.is-active {
  transform: translate(-50%, -50%) scale(1.1);
  opacity: 1;
  z-index: 5;
}

.room2-object-stack .photo-card.is-back-2 {
  transform: translate(-50%, -50%) scale(0.96) translateY(-8px);
  opacity: 0.35;
  z-index: 1;
  filter: blur(1px);
}

.room2-object-stack .photo-card.is-back-1 {
  transform: translate(-50%, -50%) scale(1.02) translateY(-4px);
  opacity: 0.55;
  z-index: 2;
  filter: blur(0.5px);
}

.room2-object-stack .photo-card.is-next-1 {
  transform: translate(-50%, -50%) scale(1.02) translateY(5px);
  opacity: 0.6;
  z-index: 3;
}

.room2-object-stack .photo-card.is-next-2 {
  transform: translate(-50%, -50%) scale(0.96) translateY(10px);
  opacity: 0.35;
  z-index: 2;
}

.room2-object-stack .photo-card.flipped {
  transform: translate(-50%, -50%) rotateY(180deg) scale(1.1) !important;
}

.room2-object-stack .photo-stack-footer {
  width: 100%;
  margin-top: 18px;
}

/* =========================
   Room 2 final / blinking / door
========================== */
#gameScreen2.room2-door-visible #roomImage2 {
  cursor: pointer;
}

.room2-progress-wrap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.room2-progress-count {
  margin: 0;
  color: var(--gold);
  font-size: 1.04rem;
  letter-spacing: 0.04em;
}

.room2-scene-controls {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.room2-flip-btn[hidden] {
  display: none !important;
}

.blink-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 12000;
  transition: opacity 0.08s linear;
}

.blink-overlay.active {
  opacity: 1;
}

#gameScreen2.room2-fullscreen .top-bar,
#gameScreen2.room2-fullscreen .side-panel {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#gameScreen2.room2-fullscreen .scene-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 11000;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: #000 !important;
  box-shadow: none !important;
}

#gameScreen2.room2-fullscreen .scene-wrapper {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0 !important;
  background: #000;
}

#gameScreen2.room2-fullscreen .scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#gameScreen2.room2-fullscreen .room2-scene-controls {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 11001;
  margin-top: 0;
}

#gameScreen2.room2-door-visible #roomImage2 {
  cursor: pointer;
}

/* Door view: hide Room 2 evidence hotspots */
#gameScreen2.room2-door-visible .hotspot {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Normal mirrored room view: show Room 2 evidence hotspots */
#gameScreen2:not(.room2-door-visible) .hs-archive-mirror,
#gameScreen2:not(.room2-door-visible) .hs-photo-mirror {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.room2-door-enter-zoom {
  animation: room2DoorEnterZoom 0.82s ease forwards;
  transform-origin: center center;
}

@keyframes room2DoorEnterZoom {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  100% {
    transform: scale(1.16);
    filter: brightness(0.85);
  }
}

@keyframes room2ShakeBasic {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1.01); }
  20%  { transform: translate(-2px, 1px) rotate(-0.2deg) scale(1.012); }
  40%  { transform: translate(2px, -1px) rotate(0.2deg) scale(1.01); }
  60%  { transform: translate(-1px, 2px) rotate(-0.15deg) scale(1.012); }
  80%  { transform: translate(1px, -2px) rotate(0.15deg) scale(1.01); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1.01); }
}

@keyframes room2ShakeLateralGrow {
  0%   { transform: translateX(0) translateY(0) rotate(0deg) scale(1.01); }
  15%  { transform: translateX(-5px) translateY(1px) rotate(-0.25deg) scale(1.012); }
  30%  { transform: translateX(7px) translateY(-1px) rotate(0.3deg) scale(1.014); }
  45%  { transform: translateX(-11px) translateY(2px) rotate(-0.45deg) scale(1.016); }
  60%  { transform: translateX(15px) translateY(-2px) rotate(0.55deg) scale(1.018); }
  75%  { transform: translateX(-20px) translateY(3px) rotate(-0.7deg) scale(1.02); }
  90%  { transform: translateX(25px) translateY(-3px) rotate(0.85deg) scale(1.022); }
  100% { transform: translateX(-28px) translateY(2px) rotate(-0.9deg) scale(1.024); }
}

@keyframes room2ShakeViolent {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1.035); }
  10%  { transform: translate(-24px, 10px) rotate(-1.4deg) scale(1.04); }
  20%  { transform: translate(28px, -12px) rotate(1.6deg) scale(1.045); }
  35%  { transform: translate(-34px, 8px) rotate(-1.9deg) scale(1.04); }
  50%  { transform: translate(36px, -15px) rotate(2deg) scale(1.048); }
  65%  { transform: translate(-30px, 13px) rotate(-1.7deg) scale(1.044); }
  80%  { transform: translate(26px, -10px) rotate(1.5deg) scale(1.04); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1.035); }
}

#gameScreen2.room2-shake-basic .scene-panel {
  animation: room2ShakeBasic 0.14s infinite;
}

#gameScreen2.room2-shake-lateral .scene-panel {
  animation: room2ShakeLateralGrow 10s linear forwards;
}

#gameScreen2.room2-shake-violent .scene-panel {
  animation: room2ShakeViolent 0.065s infinite;
}

/* =========================
   CHAPTER 3 / CHASE CLEAN VERSION
========================== */

#gameScreen3 {
  position: relative !important;
  width: 100vw !important;
  height: 100vh !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #000 !important;
}

#gameScreen3.active {
  display: flex !important;
}

#chaseScene {
  position: relative !important;
  width: 100% !important;
  height: 100vh !important;
  overflow: hidden !important;
  background: #000 !important;
}

#chaseImage {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* =========================
   Chapter 3 title screen
========================== */

#chaseChapterIntro {
  position: fixed !important;
  inset: 0 !important;
  z-index: 99991 !important;
  display: grid !important;
  place-items: center !important;
  background: #000 !important;
  color: #fff !important;
  text-align: center !important;
  cursor: pointer !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

#chaseChapterIntro[hidden] {
  display: none !important;
}

#chaseChapterIntro.is-visible {
  opacity: 1 !important;
  pointer-events: auto !important;
}

#chaseChapterIntro.is-leaving {
  animation: chaseChapterZoomIn 0.82s ease forwards;
}

.chase-chapter-intro-inner {
  text-align: center;
  padding: 24px;
}

.chase-chapter-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(2.3rem, 5vw, 4rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.chase-chapter-subtitle {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes chaseChapterZoomIn {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }

  100% {
    opacity: 0;
    transform: scale(1.22);
    filter: blur(10px);
  }
}

.chapter-zoom-in {
  animation: chaseSceneZoomIn 0.82s ease;
}

@keyframes chaseSceneZoomIn {
  0% {
    transform: scale(1);
    filter: brightness(0.5);
  }

  100% {
    transform: scale(1.08);
    filter: brightness(1);
  }
}

/* =========================
   Bottom answer bar
========================== */

#gameScreen3 #chaseDialogueBox {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;

  width: 100vw !important;
  max-width: none !important;
  min-width: 0 !important;

  height: 34vh !important;
  min-height: 34vh !important;
  max-height: 34vh !important;

  transform: none !important;

  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;

  padding: 18px 42px !important;

  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  gap: 6px !important;

  background: linear-gradient(
    180deg,
    rgba(164, 72, 72, 0.12) 0%,
    rgba(18, 16, 24, 0.32) 35%,
    rgba(10, 10, 16, 0.24) 72%,
    rgba(10, 10, 16, 0) 100%
  ) !important;

  backdrop-filter: blur(2px);
  opacity: 1 !important;
  z-index: 75 !important;
  pointer-events: auto !important;
  overflow: hidden !important;
}

#gameScreen3 #chaseDialogueBox[hidden] {
  display: none !important;
}

#gameScreen3 #chaseDialogueBox .chase-dialogue-header,
#gameScreen3 #chaseAnswerScroll {
  width: min(1180px, calc(100vw - 84px));
  margin-left: auto;
  margin-right: auto;
}

#gameScreen3 .chase-dialogue-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 0 !important;
}

#gameScreen3 #chaseNodeTitle {
  margin: 0 0 4px;
  color: var(--gold);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1.15rem, 1.8vw, 1.45rem);
  line-height: 1.35;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#gameScreen3 #chaseQuestion {
  margin: 0;
  color: rgba(255, 255, 255, 0.95);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1rem, 1.22vw, 1.14rem);
  line-height: 1.65;
}

#gameScreen3 #chaseQuestion p {
  margin: 0 0 0.45rem;
}

#gameScreen3 .chase-hint-line {
  color: rgba(255, 255, 255, 0.62);
  font-style: italic;
}

#gameScreen3 #chaseProgressTag {
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

#gameScreen3 #chaseAnswerScroll {
  flex: 1 1 auto;
  min-height: 4.8rem !important;
  max-height: none !important;
  overflow-y: hidden !important;
  overflow-x: hidden !important;
  padding-right: 10px;
  padding-bottom: 2px;
  margin-top: 2px !important;
}

#gameScreen3 #chaseAnswerText {
  min-height: 4.2rem !important;
  padding-bottom: 6px !important;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1rem, 1.25vw, 1.16rem);
  line-height: 1.88;
  transition: color 0.22s ease, opacity 0.22s ease;
}

#gameScreen3 #chaseAnswerText p {
  margin: 0 0 0.9rem;
}

#gameScreen3 #chaseAnswerText p:last-child {
  margin-bottom: 0;
}

#gameScreen3 #chaseAnswerText.answer-preview {
  color: rgba(255, 255, 255, 0.42) !important;
  overflow: hidden !important;
}

#gameScreen3 #chaseAnswerText.answer-locked {
  color: rgba(255, 255, 255, 1) !important;
}

#gameScreen3 #chaseDialogueBox.is-locked #chaseAnswerScroll {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

#gameScreen3 #chaseProceedBtn[hidden] {
  display: none !important;
}

#gameScreen3 #chaseProceedBtn {
  width: auto !important;
  min-width: 140px !important;
  align-self: center !important;
  margin: 8px auto 0 !important;
  display: inline-flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 12px 28px !important;
  font-family: "Georgia", "Times New Roman", serif !important;
}

/* =========================
   Direction buttons
========================== */

.chase-choice-btn {
  position: absolute !important;
  z-index: 40 !important;
  border: none !important;
  background: transparent !important;
  color: rgba(255, 255, 255, 0.78) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  padding: 14px 18px !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  min-width: 170px !important;
  max-width: 240px !important;
  box-shadow: none !important;
  transform: none !important;
  font-family: "Georgia", "Times New Roman", serif !important;
}

.chase-choice-btn:hover {
  transform: none !important;
}

.chase-choice-btn[hidden] {
  display: none !important;
}

.chase-choice-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

.chase-choice-left {
  left: 18px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
}

.chase-choice-left::before {
  background: linear-gradient(
    90deg,
    rgba(164, 72, 72, 0.44),
    rgba(164, 72, 72, 0)
  );
}

.chase-choice-right {
  right: 18px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
}

.chase-choice-right::before {
  background: linear-gradient(
    270deg,
    rgba(164, 72, 72, 0.44),
    rgba(164, 72, 72, 0)
  );
}

.chase-choice-forward {
  left: 50% !important;
  top: 18px !important;
  transform: translateX(-50%) !important;
}

.chase-choice-forward::before {
  background: linear-gradient(
    180deg,
    rgba(164, 72, 72, 0.44),
    rgba(164, 72, 72, 0)
  );
}

.chase-choice-btn:hover::before,
.chase-choice-btn.is-preview::before {
  opacity: 1;
}

.chase-choice-arrow {
  position: relative;
  z-index: 1;
  font-size: 1.35rem;
  line-height: 1;
  color: #fff;
}

.chase-choice-label {
  position: relative;
  z-index: 1;
  font-size: 1.05rem;
  line-height: 1.2;
  white-space: nowrap;
  color: inherit;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* =========================
   Encounter / Spirit / Item layers
========================== */

#blinkOverlay,
.blink-overlay {
  z-index: 99990 !important;
}

#gameScreen3 #chaseEncounterLayer {
  position: absolute !important;
  inset: 0 !important;
  z-index: 99992 !important;
  pointer-events: auto !important;
  overflow: hidden !important;
}

#gameScreen3 #chaseEncounterLayer[hidden] {
  display: none !important;
}

#gameScreen3 #chaseEncounterLayer.is-spirit-close,
#gameScreen3 #chaseEncounterLayer.is-spirit-full,
#gameScreen3 #chaseEncounterLayer.is-item-question {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px) brightness(0.48);
}

/* ghost suddenly appears: upper body, centered horizontally, touching bottom */
#gameScreen3 #chaseEncounterLayer.is-spirit-close {
  display: block !important;
}

#gameScreen3 .chase-spirit-close {
  position: absolute !important;
  left: 50% !important;
  bottom: 0 !important;

  width: min(82vw, 980px);
  height: min(96vh, 980px);
  max-height: none;

  object-fit: cover;
  object-position: center top;

  opacity: 0;
  transform: translateX(-50%) translateY(0) scale(1.7) !important;
  animation: chaseSpiritCloseIn 0.46s ease forwards;

  filter: drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
  clip-path: inset(0 0 18% 0);
}


#gameScreen3 .chase-spirit-close.zooming-out {
  animation: chaseSpiritZoomOut 0.24s ease forwards;
}

/* ghost full reveal: centered */
#gameScreen3 #chaseEncounterLayer.is-spirit-full {
  display: grid !important;
  place-items: center !important;
}

#gameScreen3 .chase-spirit-full {
  width: min(44vw, 560px);
  max-width: 82vw;
  opacity: 0;
  animation: chaseSpiritFullIn 0.44s ease forwards;
  filter: drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
}

/* item + question: centered */
#gameScreen3 #chaseEncounterLayer.is-item-question {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

#gameScreen3 .chase-encounter-card {
  width: min(980px, 86vw);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(34px, 5vw, 72px);
}

#gameScreen3 .chase-item-large {
  width: min(24vw, 280px);
  max-height: 48vh;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 22px rgba(255, 255, 255, 0.14));
}

#gameScreen3 .chase-encounter-copy {
  width: min(560px, 48vw);
  color: #fff;
  line-height: 1.85;
  font-family: "Georgia", "Times New Roman", serif;
  text-align: left;
}

#gameScreen3 .chase-encounter-question {
  max-width: 560px;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  color: var(--gold);
  line-height: 1.48;
}

#gameScreen3 .chase-encounter-hint {
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

@keyframes chaseSpiritCloseIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8vh) scale(2);
    filter: blur(12px) drop-shadow(0 0 34px rgba(255, 255, 255, 0.16));
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.7);
    filter: blur(0) drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
  }
}

@keyframes chaseSpiritZoomOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.7);
    filter: blur(0) drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(-2vh) scale(0.72);
    filter: blur(4px) drop-shadow(0 0 26px rgba(255, 255, 255, 0.16));
  }
}

@keyframes chaseSpiritFullIn {
  from {
    opacity: 0;
    transform: scale(0.94);
    filter: blur(8px) drop-shadow(0 0 28px rgba(255, 255, 255, 0.14));
  }

  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0) drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
  }
}

/* =========================
   Final ghost speech black screen
========================== */

#gameScreen3 #chaseEncounterLayer.ghost-speech-layer {
  display: grid !important;
  place-items: center !important;
  background: #000 !important;
  backdrop-filter: none !important;
  cursor: pointer;
}

.ghost-speech-text {
  max-width: min(980px, 82vw);
  color: #ffffff;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1.5rem, 3vw, 2.6rem);
  line-height: 1.5;
  text-align: center;
  white-space: pre-line;
  letter-spacing: 0.02em;
}

.ghost-speech-layer.ghost-line-zoom .ghost-speech-text {
  animation: ghostSpeechZoom 0.42s ease both;
}

@keyframes ghostSpeechZoom {
  0% {
    opacity: 0;
    transform: scale(0.94);
    filter: blur(6px);
  }

  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* =========================
   Chase transitions
========================== */

.chase-transition-overlay {
  position: absolute !important;
  inset: 0 !important;
  z-index: 60 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  display: none;
}

.chase-transition-overlay.active {
  display: block !important;
}

.chase-pan-track {
  position: absolute;
  inset: 0;
  width: 200%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  filter: blur(0);
}

.chase-pan-frame {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chase-transition-overlay.slide-left .chase-pan-track {
  transform: translateX(-50%);
}

.chase-transition-overlay.slide-left.play .chase-pan-track {
  transition:
    transform 0.98s cubic-bezier(0.18, 0.82, 0.24, 1),
    filter 0.98s ease;
  transform: translateX(0);
  filter: blur(18px);
}

.chase-transition-overlay.slide-right .chase-pan-track {
  transform: translateX(0);
}

.chase-transition-overlay.slide-right.play .chase-pan-track {
  transition:
    transform 0.98s cubic-bezier(0.18, 0.82, 0.24, 1),
    filter 0.98s ease;
  transform: translateX(-50%);
  filter: blur(18px);
}

.chase-zoom-stack {
  position: absolute;
  inset: 0;
}

.chase-zoom-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chase-zoom-current {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.chase-zoom-next {
  opacity: 0;
  transform: scale(1.08);
  filter: blur(12px);
}

.chase-transition-overlay.zoom-transition.play .chase-zoom-current {
  transition:
    transform 0.86s cubic-bezier(0.18, 0.82, 0.24, 1),
    filter 0.86s ease,
    opacity 0.86s ease;
  transform: scale(1.28);
  filter: blur(15px);
  opacity: 0;
}

.chase-transition-overlay.zoom-transition.play .chase-zoom-next {
  transition:
    transform 0.86s cubic-bezier(0.18, 0.82, 0.24, 1),
    filter 0.86s ease,
    opacity 0.86s ease;
  transform: scale(1);
  filter: blur(0);
  opacity: 1;
}

.chase-zoom-next-out {
  opacity: 0;
  transform: scale(0.9);
  filter: blur(12px);
}

.chase-transition-overlay.zoom-out-transition.play .chase-zoom-current {
  transition:
    transform 0.86s cubic-bezier(0.18, 0.82, 0.24, 1),
    filter 0.86s ease,
    opacity 0.86s ease;
  transform: scale(0.82);
  filter: blur(15px);
  opacity: 0;
}

.chase-transition-overlay.zoom-out-transition.play .chase-zoom-next-out {
  transition:
    transform 0.86s cubic-bezier(0.18, 0.82, 0.24, 1),
    filter 0.86s ease,
    opacity 0.86s ease;
  transform: scale(1);
  filter: blur(0);
  opacity: 1;
}

.chase-dark-fill {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
}

.chase-transition-overlay.dark-transition.play .chase-dark-fill {
  transition: opacity 0.65s ease;
  opacity: 1;
}

/* =========================
   Drum game
========================== */

.drum-game-panel {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  z-index: 80 !important;
  transform: translate(-50%, -50%) !important;
  width: min(620px, 90vw);
  background: rgba(6, 6, 10, 0.9);
  border: 1px solid rgba(200, 165, 107, 0.35);
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.drum-game-panel[hidden] {
  display: none !important;
}

.drum-game-panel h2 {
  margin: 0 0 10px;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drum-board {
  position: relative;
  width: min(360px, 70vw);
  aspect-ratio: 1 / 1;
  margin: 20px auto;
  background:
    radial-gradient(circle, rgba(200, 165, 107, 0.16), rgba(45, 18, 10, 0.92)),
    url("images/room/鼓.png");
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  border: 2px solid rgba(200, 165, 107, 0.35);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.75);
}

.drum-pad {
  position: absolute;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0.45;
}

.drum-pad:hover {
  transform: none;
  opacity: 0.75;
}

.drum-pad.active {
  background: rgba(248, 217, 132, 0.5);
  box-shadow: 0 0 32px rgba(248, 217, 132, 0.75);
  opacity: 1;
}

.drum-pad-tl {
  left: 2%;
  top: 2%;
}

.drum-pad-tr {
  right: 2%;
  top: 2%;
}

.drum-pad-bl {
  left: 2%;
  bottom: 2%;
}

.drum-pad-br {
  right: 2%;
  bottom: 2%;
}

.drum-round-text {
  color: var(--gold);
  letter-spacing: 0.06em;
}

/* =========================
   Death sequence
========================== */

#gameScreen3 #chaseEncounterLayer.chase-death-layer {
  position: absolute !important;
  inset: 0 !important;
  z-index: 99993 !important;
  display: grid !important;
  place-items: center !important;
  pointer-events: auto !important;
  cursor: pointer;
}

#gameScreen3 #chaseEncounterLayer.death-red-phase {
  background:
    radial-gradient(circle, rgba(255, 60, 40, 0.38), rgba(110, 0, 0, 0.9)),
    rgba(110, 0, 0, 0.72);
  backdrop-filter: blur(10px) brightness(0.45);
  animation: deathRedPulse 0.12s infinite;
}

#gameScreen3 #chaseEncounterLayer.death-black-phase {
  background: #000 !important;
  backdrop-filter: none !important;
}

.chase-death-spirit {
  width: min(44vw, 560px);
  max-width: 82vw;
  opacity: 0;
  animation: chaseSpiritFullIn 0.44s ease forwards;
  filter: drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
}

.chase-death-text {
  width: min(960px, 82vw);
  margin: 0 auto;
  color: #ffffff;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.4vw, 2.25rem);
  line-height: 1.7;
  text-align: center;
  animation: deathTextAppear 0.8s ease both;
}

.chase-death-text p {
  margin: 0 0 1.2rem;
}

.chase-death-hint {
  color: rgba(255, 255, 255, 0.62);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes deathRedPulse {
  0% {
    filter: brightness(0.8);
  }

  50% {
    filter: brightness(1.25);
  }

  100% {
    filter: brightness(0.8);
  }
}

@keyframes deathTextAppear {
  from {
    opacity: 0;
    transform: scale(0.96);
    filter: blur(8px);
  }

  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* =========================
   Responsive
========================== */

@media (max-width: 900px) {
  #gameScreen3 #chaseDialogueBox {
    padding: 22px 24px 28px !important;
  }

  #gameScreen3 #chaseDialogueBox .chase-dialogue-header,
  #gameScreen3 #chaseAnswerScroll {
    width: min(1180px, calc(100vw - 48px));
  }

  .chase-choice-btn {
    min-width: 130px !important;
    max-width: 190px !important;
    padding: 12px 14px !important;
  }

  .chase-choice-label {
    font-size: 0.95rem;
  }

  #gameScreen3 .chase-spirit-close {
    width: min(90vw, 760px);
  }

  #gameScreen3 .chase-spirit-full,
  .chase-death-spirit {
    width: min(66vw, 420px);
  }

  #gameScreen3 .chase-encounter-card {
    width: min(92vw, 640px);
    flex-direction: column;
    gap: 24px;
    text-align: center;
  }

  #gameScreen3 .chase-item-large {
    width: min(48vw, 300px);
    max-height: 34vh;
  }

  #gameScreen3 .chase-encounter-copy {
    width: 100%;
    text-align: center;
  }

  #gameScreen3 .chase-encounter-question {
    max-width: none;
  }

  .chase-death-text {
    width: min(88vw, 720px);
    font-size: clamp(1.15rem, 5vw, 1.8rem);
  }
}

/* =========================
   Final photo / gift sequence
========================== */

.final-photo-layer {
  position: absolute !important;
  inset: 0 !important;
  z-index: 99994 !important;
  display: grid !important;
  place-items: center !important;
  background: rgba(0, 0, 0, 0.72) !important;
  backdrop-filter: blur(10px) brightness(0.48);
  overflow: hidden;
}

.final-photo-stage {
  position: relative;
  width: min(520px, 72vw);
  aspect-ratio: 3 / 4;
  perspective: 1200px;
}

.final-photo-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.8s ease;
}

.final-photo-card.flipped {
  transform: rotateY(180deg);
}

.final-photo-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  border: 1px solid rgba(200, 165, 107, 0.35);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
}

.final-photo-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.final-photo-back {
  transform: rotateY(180deg);
  padding: 26px;
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.9);
  font-family: "Georgia", "Times New Roman", serif;
  line-height: 1.75;
  font-size: clamp(0.82rem, 1.1vw, 1rem);
}

.final-photo-back h3 {
  margin: 0 0 12px;
  color: var(--gold);
}

.final-photo-flip-btn {
  position: absolute !important;
  left: 50% !important;
  bottom: 30px !important;
  transform: translateX(-50%) !important;
  z-index: 99996 !important;
}

.final-photo-flip-btn[hidden] {
  display: none !important;
}

.final-photo-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34vh;
  padding: 20px 42px;
  background: linear-gradient(
    180deg,
    rgba(164, 72, 72, 0.12) 0%,
    rgba(18, 16, 24, 0.42) 35%,
    rgba(10, 10, 16, 0.82) 100%
  );
  backdrop-filter: blur(3px);
  z-index: 99995;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.final-photo-scroll {
  width: min(1100px, calc(100vw - 84px));
  flex: 1;
  overflow-y: auto;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1rem, 1.2vw, 1.14rem);
  line-height: 1.85;
  color: rgba(255, 255, 255, 0.92);
  padding-right: 12px;
}

.final-photo-proceed {
  margin-top: 10px !important;
  align-self: center !important;
}

.final-photo-proceed[hidden] {
  display: none !important;
}

.final-spirit-dissolve {
  animation: finalSpiritDissolve 1.3s ease forwards;
}

@keyframes finalSpiritDissolve {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.7);
    filter: blur(0) drop-shadow(0 0 34px rgba(255, 255, 255, 0.22));
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-4vh) scale(0.28);
    filter: blur(16px) drop-shadow(0 0 10px rgba(255, 255, 255, 0));
  }
}

.remain-storm-layer {
  position: absolute;
  inset: 0;
  z-index: 99996;
  background: #000;
  overflow: hidden;
  pointer-events: none;
}

.remain-word {
  position: absolute;
  color: rgba(255, 255, 255, 0.72);
  font-family: "Georgia", "Times New Roman", serif;
  white-space: nowrap;
  animation: remainFloat 4.5s ease-in-out infinite alternate;
}

@keyframes remainFloat {
  from {
    transform: translateY(0) scale(1);
    filter: blur(0);
  }

  to {
    transform: translateY(-18px) scale(1.06);
    filter: blur(1.5px);
  }
}

/* =========================
   Final gift photo sequence
========================== */

#gameScreen3 #chaseEncounterLayer.final-gift-layer {
  position: absolute !important;
  inset: 0 !important;
  z-index: 99994 !important;
  display: grid !important;
  place-items: center !important;
  background: rgba(0, 0, 0, 0.82) !important;
  backdrop-filter: blur(10px) brightness(0.42);
  overflow: hidden !important;
  pointer-events: auto !important;
}

.final-gift-stage {
  position: relative;
  width: min(1100px, 88vw);
  height: min(74vh, 760px);
  display: grid;
  place-items: center;
}

.final-gift-main-image {
  width: min(1180px, 82vw);
  height: min(68vh, 760px);
  object-fit: contain;
  display: block;

  opacity: 0;
  transform: scale(0.985);
  transition:
    opacity 6.8s ease,
    transform 6.8s ease,
    filter 6.8s ease;

  filter: drop-shadow(0 24px 70px rgba(0, 0, 0, 0.72));
  z-index: 2;
}

.final-gift-spirit-overlay {
  position: absolute;
  inset: 0;
  z-index: 99995;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.final-gift-main-image.visible {
  opacity: 1;
  transform: scale(1);
}

.final-gift-main-image.flip-anim {
  animation: finalGiftFlipImage 1s ease both;
}

@keyframes finalGiftFlipImage {
  0% {
    transform: rotateY(0deg) scale(1);
    filter: drop-shadow(0 24px 70px rgba(0, 0, 0, 0.72));
  }

  50% {
    transform: rotateY(90deg) scale(0.97);
    filter: drop-shadow(0 18px 52px rgba(0, 0, 0, 0.62));
  }

  100% {
    transform: rotateY(0deg) scale(1);
    filter: drop-shadow(0 24px 70px rgba(0, 0, 0, 0.72));
  }
}

/* 直接复用 chase 阶段鬼的样式 */
.final-gift-layer .chase-spirit-close,
.final-gift-layer .chase-spirit-full {
  pointer-events: none;
  z-index: 5;
}

.final-gift-layer .chase-spirit-full.final-gift-dissolve {
  animation: chaseSpiritZoomOut 1.05s ease forwards;
}

/* transparent flip button like room2 */
.final-gift-flip-btn {
  position: absolute !important;
  left: 50% !important;
  bottom: 34px !important;
  transform: translateX(-50%) !important;
  z-index: 99997 !important;

  min-width: 120px !important;
  padding: 16px 32px !important;

  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(238, 231, 221, 0.92) !important;

  font-family: "Georgia", "Times New Roman", serif !important;
  font-size: 1.25rem !important;
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(8px) !important;
}

.final-gift-flip-btn:hover {
  transform: translateX(-50%) translateY(-2px) !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

.final-gift-flip-btn[hidden] {
  display: none !important;
}

/* bottom text bar */
.final-gift-text-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  height: 34vh;
  padding: 18px 42px;

  z-index: 99996;

  display: flex;
  flex-direction: column;
  align-items: center;

  background: linear-gradient(
    180deg,
    rgba(164, 72, 72, 0.12) 0%,
    rgba(18, 16, 24, 0.32) 35%,
    rgba(10, 10, 16, 0.72) 100%
  );

  backdrop-filter: blur(3px);
}

.final-gift-text-bar[hidden] {
  display: none !important;
}

.final-gift-scroll {
  width: min(1180px, calc(100vw - 84px));
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 12px;

  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1rem, 1.22vw, 1.15rem);
  line-height: 1.85;
  color: rgba(255, 255, 255, 0.92);
}

.final-gift-scroll p {
  margin: 0 0 0.95rem;
}

.final-gift-scroll strong {
  color: var(--gold);
}

.final-gift-proceed-btn {
  margin-top: 10px !important;
  align-self: center !important;
  min-width: 140px !important;
}

.final-gift-proceed-btn[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .final-gift-stage {
    width: 92vw;
    height: 62vh;
  }

  .final-gift-main-image {
    max-width: 90vw;
    max-height: 56vh;
  }

  .final-gift-text-bar {
    padding: 18px 24px;
  }

  .final-gift-scroll {
    width: calc(100vw - 48px);
  }
}
/* =========================
   Room 2 gift card + global narrative
========================== */

.room2-gift-dock {
  position: absolute;
  right: 24px;
  top: 120px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.room2-gift-dock[hidden] {
  display: none !important;
}

.room2-gift-card {
  width: 126px;
  background: rgba(18, 14, 18, 0.84);
  border: 1px solid rgba(198, 157, 96, 0.34);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.room2-gift-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.48);
}

.room2-gift-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.room2-gift-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.room2-gift-label {
  margin-top: 8px;
  text-align: center;
  color: var(--gold);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.room2-gift-panel {
  width: min(560px, 42vw);
  max-height: min(78vh, 820px);
  padding: 18px;
  border-radius: 18px;
  background: rgba(12, 10, 16, 0.94);
  border: 1px solid rgba(198, 157, 96, 0.28);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.52);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room2-gift-panel[hidden] {
  display: none !important;
}

.room2-gift-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.room2-gift-panel-title {
  margin: 0;
  color: var(--gold);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: lowercase;
}

.room2-gift-close {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.room2-gift-figure {
  width: 100%;
  height: min(270px, 30vh);
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  overflow: hidden;
}

.room2-gift-figure img {
  width: min(100%, 100%);
  height: 100%;
  object-fit: contain;
  display: block;
}

.room2-gift-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.room2-gift-flip {
  min-width: 118px !important;
  padding: 13px 28px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(238, 231, 221, 0.92) !important;
  font-family: "Georgia", "Times New Roman", serif !important;
  font-size: 1.05rem !important;
  backdrop-filter: blur(8px) !important;
  cursor: pointer;
}

.room2-gift-flip:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

.room2-gift-text {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 8px;
  color: rgba(255,255,255,0.92);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(0.98rem, 1.06vw, 1.06rem);
  line-height: 1.8;
  min-height: 160px;
}

.room2-gift-text p {
  margin: 0 0 0.95rem;
}

.room2-gift-text strong {
  color: var(--gold);
}

.room2-gift-proceed {
  align-self: center;
  min-width: 140px;
}

.room2-gift-proceed[hidden] {
  display: none !important;
}

/* global black narrative overlay */
.global-narrative-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #000;
  display: grid;
  place-items: center;
  padding: 6vh 8vw;
}

.global-narrative-overlay[hidden] {
  display: none !important;
}

.global-narrative-text {
  max-width: min(1080px, 84vw);
  color: #fff;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(1.5rem, 3vw, 2.85rem);
  line-height: 1.58;
  text-align: center;
  white-space: pre-line;
}

.global-narrative-text p {
  margin: 0 0 1.1rem;
}

.global-narrative-text strong {
  color: rgba(255,255,255,0.96);
}

.global-remain-layer {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #000;
  overflow: hidden;
  pointer-events: none;
}

.global-remain-word {
  position: absolute;
  white-space: nowrap;
  color: rgba(255,255,255,0.7);
  animation: globalRemainFloat 4.5s ease-in-out infinite alternate;
}

@keyframes globalRemainFloat {
  from {
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
  to {
    transform: translateY(-18px) scale(1.06);
    filter: blur(1.6px);
  }
}

.global-haunt-stage {
  position: fixed;
  inset: 0;
  z-index: 999999;
  pointer-events: none;
}

.global-haunt-stage .chase-spirit-close,
.global-haunt-stage .chase-spirit-full {
  z-index: 2;
}

@media (max-width: 980px) {
  .room2-gift-dock {
    right: 14px;
    top: 96px;
  }

  .room2-gift-panel {
    width: min(86vw, 560px);
  }
}

/* =========================
   Room 4: Gift room
========================== */

#gameScreen4 {
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

#gameScreen4.screen.active {
  display: flex;
}

#gameScreen4.room4-door-mode {
  padding: 0 !important;
  background: #000 !important;
}

#gameScreen4.room4-door-mode .top-bar,
#gameScreen4.room4-door-mode .side-panel {
  display: none !important;
}

#gameScreen4.room4-door-mode .game-layout {
  display: block !important;
  width: 100vw !important;
  height: 100vh !important;
}

#gameScreen4.room4-door-mode .scene-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: #000 !important;
  box-shadow: none !important;
  z-index: 11000;
}

#gameScreen4.room4-door-mode .scene-wrapper {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0 !important;
  background: #000;
}

#gameScreen4.room4-door-mode .scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room4-flip-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

#gameScreen4.room4-door-mode .room4-flip-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 11001;
}

.room4-flip-btn[hidden] {
  display: none !important;
}

.room4-scene-turning {
  animation: room4SceneTurn 0.82s ease forwards;
  transform-origin: center center;
}

@keyframes room4SceneTurn {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  55% {
    transform: scale(1.08);
    filter: brightness(0.18) blur(8px);
  }

  100% {
    transform: scale(1);
    filter: brightness(1) blur(0);
  }
}

/* =========================
   Room 4 gift evidence button
========================== */

.room4-gift-side-block {
  display: none !important;
}

.room4-gift-inline {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.room4-gift-inline-card {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(200, 165, 107, 0.28);
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
  padding: 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  align-items: center;
  text-align: left;
}

.room4-gift-inline-card:hover {
  background: rgba(164, 72, 72, 0.16);
  border-color: rgba(200, 165, 107, 0.55);
  transform: none !important;
}

.room4-gift-inline-thumb {
  width: 92px;
  height: 92px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
}

.room4-gift-inline-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room4-gift-inline-title {
  color: var(--gold);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.room4-gift-inline-desc {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.room4-gift-inline[hidden] {
  display: none !important;
}

.room4-gift-side-block[hidden] {
  display: none !important;
}

.room4-gift-evidence-btn {
  width: 100%;
  min-height: 96px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  text-align: left;
}

.room4-gift-evidence-btn:hover {
  background: rgba(164, 72, 72, 0.16);
  border-color: rgba(200, 165, 107, 0.55);
}

.room4-gift-evidence-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  flex: 0 0 auto;
  background: rgba(255,255,255,0.04);
}

.room4-gift-evidence-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room4-gift-evidence-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room4-gift-evidence-title {
  color: var(--gold);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.room4-gift-evidence-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Room4 gift modal: same evidence modal logic */
.room4-gift-modal-content {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1.05fr);
  gap: 18px;
  align-items: stretch;
}

.room4-gift-modal-image-wrap {
  height: 540px;
  min-height: 540px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.room4-gift-modal-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.room4-gift-modal-note {
  height: 540px;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.room4-gift-modal-text {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 8px;
  color: rgba(255,255,255,0.92);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 0.98rem;
  line-height: 1.85;
}

.room4-gift-modal-text p {
  margin: 0 0 0.95rem;
  text-align: justify;
}

.room4-gift-modal-text strong {
  color: var(--gold);
}

.room4-gift-modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.room4-gift-flip {
  min-width: 118px !important;
  padding: 13px 28px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(238, 231, 221, 0.92) !important;
  font-family: "Georgia", "Times New Roman", serif !important;
  font-size: 1.05rem !important;
  backdrop-filter: blur(8px) !important;
  cursor: pointer;
}

.room4-gift-proceed {
  min-width: 140px;
}

.room4-gift-proceed[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .room4-gift-modal-content {
    grid-template-columns: 1fr;
  }

  .room4-gift-modal-image-wrap,
  .room4-gift-modal-note {
    height: 360px;
    min-height: 360px;
  }
}

.room4-gift-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.room4-gift-panel-title {
  margin: 0;
  color: var(--gold);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: lowercase;
}

.room4-gift-close {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.room4-gift-figure {
  width: 100%;
  height: min(270px, 30vh);
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  overflow: hidden;
}

.room4-gift-figure img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.room4-gift-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.room4-gift-flip {
  min-width: 118px !important;
  padding: 13px 28px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(238, 231, 221, 0.92) !important;
  font-family: "Georgia", "Times New Roman", serif !important;
  font-size: 1.05rem !important;
  backdrop-filter: blur(8px) !important;
  cursor: pointer;
}

.room4-gift-text {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 8px;
  color: rgba(255,255,255,0.92);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(0.98rem, 1.06vw, 1.06rem);
  line-height: 1.8;
  min-height: 160px;
}

.room4-gift-text p {
  margin: 0 0 0.95rem;
}

.room4-gift-text strong {
  color: var(--gold);
}

.room4-gift-proceed {
  align-self: center;
  min-width: 140px;
}

.room4-gift-proceed[hidden] {
  display: none !important;
}

/* =========================
   Room4 gift modal ratio fix
========================== */

.room4-gift-modal-content {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 18px !important;
  align-items: stretch !important;
}

.room4-gift-modal-image-wrap,
.room4-gift-modal-note {
  height: 540px !important;
  min-height: 540px !important;
}

.room4-gift-modal-image-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

/* prevent room from flashing before remain sequence */
.global-narrative-overlay.keep-black {
  background: #000 !important;
}

/* staged remain appearance */
.global-remain-word {
  opacity: 0;
}

.global-remain-word.is-visible {
  opacity: var(--remain-opacity, 0.6);
}
/* =========================
   FIX Room4 gift modal layout
========================== */

.modal-card:has(.room4-gift-modal-content) {
  width: min(1180px, 92vw) !important;
  max-height: 90vh !important;
}

#modalContent:has(.room4-gift-modal-content) {
  display: block !important;
}

.room4-gift-modal-content {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 18px !important;
  align-items: stretch !important;
}

.room4-gift-modal-image-wrap,
.room4-gift-modal-note {
  height: min(540px, 62vh) !important;
  min-height: min(540px, 62vh) !important;
}

.room4-gift-modal-image-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

.room4-gift-modal-text {
  width: 100% !important;
  overflow-y: auto !important;
  text-align: left !important;
}

.room4-gift-modal-text p {
  text-align: left !important;
  word-spacing: normal !important;
  letter-spacing: normal !important;
}

@media (max-width: 900px) {
  .room4-gift-modal-content {
    grid-template-columns: 1fr !important;
  }

  .room4-gift-modal-image-wrap,
  .room4-gift-modal-note {
    height: 360px !important;
    min-height: 360px !important;
  }
}