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

:root {
  --ink-pale: #f3e6cf;
  --ink-soft: #d4bd9b;
  --ink-dim:  #ad9679;
  --card-ink: #3a2c1c;
  --card-ink-soft: #6a513a;
  --ok: #5edc7b;
  --bad: #ff5a52;
  --brass: #d6b67a;
  --cute-font: "Chalkboard SE", "Marker Felt", "Comic Sans MS", "STHeitiSC-Light",
    "PingFang SC", system-ui, -apple-system, sans-serif;
  --handwrite-font: "Ma Shan Zheng", "Kaiti SC", "STKaiti", "KaiTi", "楷体",
    "Marker Felt", var(--cute-font);
  /* 主区域最大宽度：根据视口高度和主图 16:9 估算，保证 frame + clues 同宽 */
  --board-max-w: min(100%, calc((100vh - 240px) * 16 / 9));
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--cute-font);
  color: var(--ink-pale);
  background: #120d0a;
  overflow-x: hidden;
}

/* 主图模糊后铺满屏，让整屏颜色自然延伸 */
body::before {
  content: "";
  position: fixed;
  inset: -60px;
  background-image: var(--bg-img, none);
  background-size: cover;
  background-position: center;
  filter: blur(52px) brightness(0.55) saturate(1.3);
  transform: scale(1.08);
  z-index: -2;
  pointer-events: none;
}

/* 暗角 + 上下渐深罩层 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 85% 70% at 50% 50%, transparent 0%, rgba(10, 6, 4, 0.55) 100%),
    linear-gradient(180deg, rgba(10, 6, 4, 0.3) 0%, transparent 20%, transparent 72%, rgba(10, 6, 4, 0.5) 100%);
  z-index: -1;
  pointer-events: none;
}

code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9em;
  color: #ffcc88;
  background: rgba(255, 200, 120, 0.18);
  padding: 0 4px;
  border-radius: 4px;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ===== 顶部时间卡片 ===== */

.topbar {
  flex-shrink: 0;
  padding: 12px 22px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.level-label {
  margin: 0;
  width: calc(var(--board-max-w) * 0.92);
  max-width: 100%;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-pale);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.time-card {
  width: calc(var(--board-max-w) * 0.92);
  max-width: 100%;
  min-height: 54px;
  padding: 10px 24px;
  border-radius: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  background:
    linear-gradient(180deg, rgba(52, 36, 24, 0.72) 0%, rgba(24, 16, 10, 0.78) 100%);
  border: 1px solid rgba(214, 182, 122, 0.28);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 220, 180, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
}

.time-card__label {
  color: var(--ink-soft);
  font-size: 0.88rem;
  letter-spacing: 6px;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.time-card__num {
  color: var(--ink-pale);
  font-weight: 800;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1.5px;
  white-space: nowrap;
  text-shadow:
    0 0 14px rgba(230, 190, 120, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.6);
}

.bar {
  position: relative;
  width: 100%;
}

.bar__track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(10, 6, 4, 0.72);
  overflow: hidden;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.85),
    inset 0 -1px 0 rgba(255, 220, 180, 0.08),
    0 1px 0 rgba(255, 220, 180, 0.12);
}

.bar__fill {
  position: absolute;
  inset: 0;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(120, 75%, 50%), hsl(135, 80%, 62%));
  transition: width 380ms cubic-bezier(.25,.85,.35,1.05), background 220ms ease;
  box-shadow: 0 0 10px rgba(80, 200, 110, 0.55);
}

.bar__shimmer {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.7) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  background-position: 200% 0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

.bar--overflow .bar__shimmer {
  opacity: 1;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -100% 0; }
}

.bar--gain .bar__track { animation: gainPulse 620ms ease-out; }
.bar--loss .bar__track { animation: lossPulse 620ms ease-out; }

@keyframes gainPulse {
  0%, 100% {
    box-shadow:
      inset 0 1px 2px rgba(0, 0, 0, 0.8),
      0 1px 0 rgba(255, 220, 180, 0.12);
    transform: scale(1);
  }
  35% {
    box-shadow:
      0 0 0 4px rgba(100, 220, 120, 0.5),
      0 0 22px rgba(100, 220, 120, 0.85),
      inset 0 1px 2px rgba(0, 0, 0, 0.8);
    transform: scale(1.02);
  }
}

@keyframes lossPulse {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-4px);
         box-shadow:
           0 0 0 4px rgba(255, 90, 80, 0.55),
           inset 0 1px 2px rgba(0, 0, 0, 0.8); }
  50%  { transform: translateX(4px); }
  75%  { transform: translateX(-2px); }
  100% { transform: translateX(0);
         box-shadow:
           inset 0 1px 2px rgba(0, 0, 0, 0.8),
           0 1px 0 rgba(255, 220, 180, 0.12); }
}

/* ===== 中间舞台：主图 + 线索 ===== */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 10px 18px 14px;
}

.hint {
  color: #ffcc99;
  max-width: 40rem;
  text-align: center;
  line-height: 1.5;
  margin: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.frame {
  position: relative;
  width: var(--board-max-w);
  max-height: calc(100vh - 240px);
  aspect-ratio: 16 / 9;
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 220, 180, 0.15),
    0 22px 50px rgba(0, 0, 0, 0.6),
    0 0 120px rgba(0, 0, 0, 0.35);
}

.main-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: #fff;
  background: rgba(10, 6, 4, 0.65);
  padding: 16px;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.banner[hidden] { display: none; }
.banner--win  { background: rgba(60, 150, 85, 0.82); }
.banner--lose { background: rgba(190, 50, 40, 0.82); }

/* ===== 底部线索便签（纯 CSS） ===== */

.clues {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;     /* 给顶部"胶带"留空间 */
  width: var(--board-max-w);
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex-shrink: 0;
}

.clue-slot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 92px;
  --tilt: 0deg;
}

.clue-slot:nth-child(1) { --tilt: -1.8deg; }
.clue-slot:nth-child(2) { --tilt: 0.9deg; }
.clue-slot:nth-child(3) { --tilt: -0.7deg; }

.clue {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 18px;
  background:
    radial-gradient(ellipse at 25% 15%, rgba(255, 245, 220, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 85%, rgba(190, 150, 95, 0.35) 0%, transparent 65%),
    linear-gradient(140deg, #f3e2bd 0%, #e7ceA2 55%, #d8bd85 100%);
  border-radius: 3px 7px 4px 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.6),
    inset 0 -2px 0 rgba(110, 80, 45, 0.18),
    inset 0 0 24px rgba(120, 85, 50, 0.08);
  filter:
    drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  transform-origin: center top;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 220ms cubic-bezier(.3,.8,.4,1.2),
    opacity 220ms ease;
}

/* 顶部"胶带"小细节 */
.clue::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 28%;
  width: 44%;
  height: 14px;
  background: linear-gradient(
    180deg,
    rgba(228, 196, 138, 0.9) 0%,
    rgba(186, 150, 92, 0.78) 100%
  );
  border: 1px solid rgba(105, 75, 40, 0.35);
  border-bottom-color: rgba(90, 60, 30, 0.25);
  transform: rotate(-2.5deg);
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.32);
  opacity: 0.92;
}

/* 右下角翻折暗色阴影，增加纸感 */
.clue::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  background: linear-gradient(
    135deg,
    transparent 48%,
    rgba(100, 70, 35, 0.22) 50%,
    rgba(60, 40, 20, 0.35) 100%
  );
  border-bottom-right-radius: 4px;
  pointer-events: none;
}

.clue__text {
  margin: 0;
  font-family: var(--handwrite-font);
  font-weight: 700;
  font-size: clamp(1rem, 2.2vw, 1.55rem);
  line-height: 1.2;
  color: var(--card-ink);
  letter-spacing: 2px;
  text-shadow: 0 1px 0 rgba(255, 240, 215, 0.4);
}

.clue--enter { animation: clueEnter 420ms cubic-bezier(.2,.8,.3,1.1); }

.clue--tearing {
  animation: clueTear 560ms cubic-bezier(.5,.05,.75,.05) forwards;
  pointer-events: none;
  z-index: 2;
}

.clue--tearing .clue__text {
  animation: textCrumple 420ms ease-in forwards;
}

@keyframes clueEnter {
  0%   { transform: rotate(var(--tilt, 0deg)) translateY(-18px) scale(0.8);  opacity: 0; }
  55%  { transform: rotate(var(--tilt, 0deg)) translateY(5px)   scale(1.05); opacity: 1; }
  100% { transform: rotate(var(--tilt, 0deg)) translateY(0)     scale(1);    opacity: 1; }
}

@keyframes clueTear {
  0%   { transform: rotate(var(--tilt, 0deg)) translate(0, 0) scale(1); }
  12%  { transform: rotate(calc(var(--tilt, 0deg) - 4deg)) translate(-3px, -4px) scale(1.03); }
  22%  { transform: rotate(calc(var(--tilt, 0deg) + 5deg)) translate(4px, -2px) scale(1.02); }
  34%  { transform: rotate(calc(var(--tilt, 0deg) - 3deg)) translate(-2px, 2px) scale(1.01); }
  100% {
    transform: rotate(-38deg) translate(-32px, 130px) scale(0.55);
    opacity: 0;
    filter: blur(1px);
  }
}

@keyframes textCrumple {
  0%   { transform: scale(1); opacity: 1; letter-spacing: 2px; }
  100% { transform: scale(0.6); opacity: 0; letter-spacing: 0; filter: blur(2px); }
}

/* ===== 飞行时间数字 + 冲击 ===== */

.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.time-bonus {
  position: absolute;
  pointer-events: none;
  font-family: var(--cute-font);
  font-weight: 900;
  font-size: clamp(2rem, 4vw, 2.8rem);
  color: var(--ok);
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  letter-spacing: 1px;
  -webkit-text-stroke: 2px rgba(10, 6, 4, 0.85);
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.9),
    0 2px 0 rgba(0, 0, 0, 0.5),
    0 0 22px rgba(100, 220, 120, 0.9);
}

.time-bonus--bad {
  color: var(--bad);
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.9),
    0 2px 0 rgba(0, 0, 0, 0.5),
    0 0 22px rgba(255, 100, 90, 0.9);
}

.impact-ring {
  position: absolute;
  width: 130px;
  height: 130px;
  margin-left: -65px;
  margin-top: -65px;
  border: 3px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 0 28px currentColor, inset 0 0 16px currentColor;
  pointer-events: none;
  color: #6fe088;
}

.impact-ring--bad { color: #ff6054; }

.impact-burst {
  position: absolute;
  width: 90px;
  height: 90px;
  margin-left: -45px;
  margin-top: -45px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(200, 255, 210, 0.95) 0%,
    rgba(130, 230, 150, 0.6) 40%,
    rgba(80, 180, 100, 0) 75%
  );
  pointer-events: none;
  filter: blur(1px);
}

.impact-burst--bad {
  background: radial-gradient(
    circle,
    rgba(255, 210, 200, 0.95) 0%,
    rgba(255, 130, 110, 0.6) 40%,
    rgba(220, 60, 50, 0) 75%
  );
}

/* ===== 剧情全屏视频 ===== */

.cinematic {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050403;
}

.cinematic[hidden] {
  display: none !important;
}

.cinematic__video {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
  background: #000;
}

.cinematic__skip {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 210;
  padding: 10px 18px;
  font-family: var(--cute-font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-pale);
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid rgba(214, 182, 122, 0.45);
  background: linear-gradient(
    180deg,
    rgba(52, 36, 24, 0.88) 0%,
    rgba(24, 16, 10, 0.92) 100%
  );
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.cinematic__skip:hover {
  border-color: rgba(214, 182, 122, 0.75);
}

/* ===== 开场：封面循环短片 + 提示 ===== */

.story-gate {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.story-gate[hidden] {
  display: none !important;
}

.story-gate__video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #050403;
}

.story-gate__veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 72% 58% at 50% 44%,
      rgba(18, 14, 10, 0.12) 0%,
      rgba(12, 8, 6, 0.42) 55%,
      rgba(6, 4, 3, 0.62) 100%
    );
}

/* 每遍播完：渐出黑幕 → 接第二遍时再渐亮 */
.story-gate__flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-gate__flash--show {
  visibility: visible;
}

.story-gate__flash--opaque {
  opacity: 1;
}

.story-gate__hint {
  position: relative;
  z-index: 3;
  margin: 0;
  max-width: 92vw;
  padding: 0.35em 0.85em;
  font-family: var(--handwrite-font);
  font-size: clamp(1.65rem, 4.8vw, 2.5rem);
  font-weight: 400;
  color: #faf4e8;
  letter-spacing: 0.14em;
  text-align: center;
  line-height: 1.5;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.85),
    0 0 20px rgba(0, 0, 0, 0.55),
    0 0 36px rgba(214, 182, 122, 0.35);
  animation: story-gate-breathe 2.6s ease-in-out infinite;
}

@keyframes story-gate-breathe {
  0%,
  100% {
    opacity: 0.9;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.018);
  }
}

@media (max-width: 820px) {
  :root {
    --board-max-w: 100%;
  }
  .frame {
    max-height: calc(100vh - 360px);
  }
  .clues { gap: 10px; }
  .clue-slot { height: 80px; }
}
