*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --cursor-dv: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Crect x='4' y='10' width='18' height='14' rx='3' fill='%23282830' stroke='%23ccc' stroke-width='1'/%3E%3Ccircle cx='11' cy='17' r='5' fill='%23181820' stroke='%23aaa'/%3E%3Ccircle cx='11' cy='17' r='2.5' fill='%233a5060'/%3E%3Crect x='18' y='8' width='8' height='6' rx='1' fill='%23202028' stroke='%23aaa'/%3E%3Crect x='20' y='14' width='8' height='12' rx='1' fill='%23303038' stroke='%23aaa'/%3E%3Ccircle cx='24' cy='18' r='2' fill='%23dc2828'/%3E%3C/svg%3E")
    12 12;
  --scene-w: 2048;
  --scene-h: 1152;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050505;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Serif SC", serif;
}

/* ── 开始 / 结束界面 ── */

.screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: #000;
}

.screen[hidden] {
  display: none;
}

.screen--start {
  padding: 0;
  gap: 0;
}

.screen__cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  pointer-events: none;
}

.screen__start-actions {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  width: auto;
  padding-bottom: 0;
}

.btn-start {
  padding: 0.7rem 3rem;
  border: 1px solid rgba(220, 200, 160, 0.65);
  border-radius: 2px;
  background: rgba(10, 8, 6, 0.72);
  backdrop-filter: blur(4px);
  color: #f5ecd8;
  font-family: inherit;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  cursor: pointer;
  box-shadow:
    0 0 24px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 240, 210, 0.1);
  transition: background 0.25s, border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

.btn-start:hover {
  background: rgba(30, 24, 16, 0.88);
  border-color: rgba(240, 220, 170, 0.9);
  box-shadow:
    0 0 32px rgba(200, 170, 100, 0.15),
    inset 0 1px 0 rgba(255, 240, 210, 0.15);
  transform: translateY(-2px);
}

.screen__title {
  margin: 0;
  color: #e8dcc8;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
}

.screen__subtitle {
  margin: 0;
  color: rgba(200, 170, 120, 0.65);
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  letter-spacing: 0.3em;
}

.btn-primary {
  margin-top: 1rem;
  padding: 0.65rem 2.5rem;
  border: 1px solid rgba(180, 150, 90, 0.55);
  border-radius: 2px;
  background: rgba(40, 32, 22, 0.9);
  color: #f5ecd8;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-primary:hover {
  background: rgba(70, 56, 38, 0.95);
  border-color: rgba(210, 180, 110, 0.75);
}

/* ── 视频层 ── */

.video-layer {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-layer[hidden] {
  display: none;
}

#gameVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-loading {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(200, 180, 140, 0.7);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  pointer-events: none;
}

/* ── 黑幕动画 ── */

.cinematic {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: #000;
  opacity: 1;
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.cinematic--intertitle {
  z-index: 260;
}

.cinematic.is-fading {
  opacity: 0;
}

.cinematic[hidden] {
  display: none;
}

.cinematic__text {
  margin: 0;
  padding: 0 1.5rem;
  color: #e8dcc8;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  letter-spacing: 0.25em;
  text-align: center;
  animation: text-in 1s ease both;
}

.cinematic__sub {
  margin: 0;
  color: rgba(200, 170, 120, 0.75);
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  letter-spacing: 0.15em;
  animation: text-in 1s ease 0.4s both;
}

.cinematic--complete .cinematic__text {
  color: #c9a86a;
}

@keyframes text-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── HUD ── */

.hud {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: 50;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(180, 150, 90, 0.3);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.hud.is-visible {
  opacity: 1;
}

.hud[hidden] {
  display: none;
}

.hud__label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: rgba(200, 170, 120, 0.8);
}

.hud__count {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: #f5ecd8;
}

/* ── 点错提示 ── */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  z-index: 60;
  transform: translateX(-50%) translateY(0);
  padding: 0.55rem 1.25rem;
  background: rgba(30, 20, 20, 0.9);
  border: 1px solid rgba(140, 80, 80, 0.5);
  border-radius: 2px;
  color: rgba(220, 180, 180, 0.95);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.toast.is-hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

.toast[hidden] {
  display: none;
}

/* ── 场景 ── */

#puzzleLayer[hidden] {
  display: none;
}

.scene-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.scene-container.is-shaking {
  animation: screen-shake 0.38s ease-out;
}

@keyframes screen-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-3px, 1px);
  }
  40% {
    transform: translate(3px, -1px);
  }
  60% {
    transform: translate(-2px, 1px);
  }
  80% {
    transform: translate(2px, 0);
  }
}

.scene-wrapper {
  position: relative;
  aspect-ratio: var(--scene-w) / var(--scene-h);
  width: min(100vw, calc(100vh * var(--scene-w) / var(--scene-h)));
  height: min(100vh, calc(100vw * var(--scene-h) / var(--scene-w)));
  opacity: 0;
  cursor: var(--cursor-dv), crosshair;
  transition: opacity 1.2s ease;
}

.scene-wrapper.is-visible {
  opacity: 1;
}

.scene-wrapper.is-disabled {
  pointer-events: none;
}

.scene-bg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

/* ── 线索弹窗 ── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal[hidden] {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(3px);
}

.clue-panel {
  position: relative;
  z-index: 1;
  width: min(94vw, 680px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #2a241c 0%, #1a1612 40%, #12100e 100%);
  border: 1px solid rgba(180, 150, 90, 0.35);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 24px 60px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 220, 160, 0.08);
  overflow: hidden;
}

.clue-panel__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(180, 150, 90, 0.25);
}

.clue-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #c9a86a;
}

.btn-back {
  flex-shrink: 0;
  padding: 0.45rem 1rem;
  border: 1px solid rgba(180, 150, 90, 0.5);
  border-radius: 2px;
  background: rgba(60, 48, 32, 0.8);
  color: #e8dcc8;
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-back:hover {
  background: rgba(90, 72, 48, 0.95);
  border-color: rgba(210, 180, 110, 0.7);
  color: #fff8ee;
}

.clue-panel__body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  overflow-y: auto;
}

.clue-frame {
  position: relative;
  padding: 0.75rem;
  background: #0e0c0a;
  border: 2px solid rgba(100, 85, 60, 0.6);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

.clue-frame__label {
  position: absolute;
  top: 0.5rem;
  left: 0.75rem;
  z-index: 1;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: rgba(200, 180, 140, 0.7);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(180, 150, 90, 0.2);
}

.clue-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: 38vh;
  padding-top: 1.25rem;
}

.clue-image {
  max-width: 100%;
  max-height: 36vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  filter: sepia(0.15) contrast(1.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* 档案翻页 */
.flipbook-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(100, 85, 60, 0.3);
}

.flipbook-nav[hidden] {
  display: none;
}

.btn-flip {
  padding: 0.35rem 0.85rem;
  border: 1px solid rgba(180, 150, 90, 0.4);
  border-radius: 2px;
  background: rgba(40, 32, 22, 0.8);
  color: #e8dcc8;
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-flip:hover:not(:disabled) {
  background: rgba(70, 56, 38, 0.95);
}

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

.flipbook-nav__indicator {
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: rgba(200, 170, 120, 0.85);
}

.clue-text-box {
  position: relative;
  padding: 1rem 1.15rem 1.15rem;
  background:
    linear-gradient(135deg, rgba(255, 248, 220, 0.04) 0%, transparent 50%),
    linear-gradient(180deg, #3d3428 0%, #2e2720 100%);
  border: 1px solid rgba(160, 130, 80, 0.45);
  border-radius: 2px;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 230, 180, 0.06);
}

.clue-text-box::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(180, 60, 50, 0.35);
}

.clue-text-box__label {
  margin-bottom: 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: rgba(200, 170, 120, 0.85);
}

.clue-description {
  margin: 0;
  min-height: 3em;
  padding-left: 0.5rem;
  color: #f5ecd8;
  font-size: clamp(0.95rem, 2.4vw, 1.08rem);
  line-height: 1.75;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.clue-description::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  color: #c9a86a;
  animation: cursor-blink 0.75s step-end infinite;
}

.clue-description.is-done::after {
  display: none;
}

@keyframes cursor-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
