:root {
  --paper: #f6eedc;
  --paper-deep: #eadbc0;
  --ink: #3b2f25;
  --ink-soft: rgba(59, 47, 37, 0.62);
  --moss: #6e8b4a;
  --amber: #d8a23f;
  --spider-red: #b83a2e;
  --web-blue: #2f6f8f;
  --shadow: 0 8px 24px rgba(38, 27, 18, 0.22);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #17130f;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

#stage16x9 {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0e0b08;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.55);
  isolation: isolate;
}

#gl, #flat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#cutscene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
  z-index: 5;
}
#cutscene.playing { display: block; }

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, transparent 52%, rgba(22, 13, 8, 0.42) 100%);
  z-index: 4;
}

#paperGrain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.1;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  color: var(--ink);
}

#topBar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 26px 0;
  background: linear-gradient(180deg, rgba(246, 238, 220, 0.94), rgba(246, 238, 220, 0.62) 58%, transparent 100%);
  min-height: 106px;
}

.top-left { padding-top: 2px; }

.dayline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.dayline .day { font-weight: 800; letter-spacing: 0.08em; }
.dayline .slash { opacity: 0.45; font-weight: 400; }

.weather {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.weather-icon { font-size: 14px; opacity: 0.8; }

.top-right {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-btn {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(59, 47, 37, 0.22);
  background: rgba(246, 238, 220, 0.88);
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(59, 47, 37, 0.12);
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: #fff8e9; }
.icon-btn:active { transform: translateY(0); }

.paper-card {
  background: linear-gradient(180deg, rgba(250, 244, 230, 0.97), rgba(242, 231, 209, 0.96));
  border: 1px solid rgba(59, 47, 37, 0.2);
  border-radius: 16px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(2px);
}

#playerCard {
  position: absolute;
  top: 104px;
  left: 26px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 15px 9px 9px;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  background:
    radial-gradient(circle at 35% 28%, #ff8b7d 0 8%, transparent 9%),
    radial-gradient(circle at 50% 50%, #b83a2e, #7f2119);
  color: #fff7ea;
  border: 2px solid rgba(246, 238, 220, 0.9);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.22);
}

.player-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.hearts {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  font-size: 19px;
  line-height: 1;
  color: var(--spider-red);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.hearts .heart { transition: opacity 0.2s ease, transform 0.2s ease; }
.hearts .heart.empty { opacity: 0.22; transform: scale(0.92); filter: grayscale(1); }

#resources {
  position: absolute;
  top: 104px;
  right: 26px;
  display: flex;
  gap: 7px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 11px;
  border-radius: 18px;
  background: rgba(246, 238, 220, 0.92);
  border: 1px solid rgba(59, 47, 37, 0.2);
  box-shadow: 0 3px 9px rgba(59, 47, 37, 0.13);
  font-size: 12px;
  color: var(--ink-soft);
}
.chip b { color: var(--ink); font-size: 14px; font-weight: 800; }
.chip-max { font-size: 11px; opacity: 0.6; }
.chip-icon { font-size: 13px; }
.chip-label { letter-spacing: 0.02em; }

#objectiveCard {
  position: absolute;
  top: 154px;
  right: 26px;
  width: 296px;
  padding: 13px 16px 12px;
}

.objective-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.objective-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--spider-red);
  font-weight: 700;
}
.objective-check {
  font-size: 15px;
  color: var(--moss);
}
.objective-title {
  margin-top: 7px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.objective-sub {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.objective-progress {
  margin-top: 8px;
  font-size: 11px;
  color: var(--web-blue);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ---------- 对白 / BOSS ---------- */
.dialogue-bubble {
  position: absolute;
  left: 50%;
  top: 51%;
  transform: translate(-50%, -50%);
  width: min(700px, 62%);
  padding: 18px 22px 12px;
  background: linear-gradient(180deg, #fbf5e7, #f2e6cd);
  border: 1px solid rgba(59, 47, 37, 0.22);
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(34, 22, 14, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  z-index: 9;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dialogue-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid #f2e6cd;
  filter: drop-shadow(0 2px 1px rgba(59, 47, 37, 0.12));
}
.dialogue-speaker {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--spider-red);
  font-weight: 800;
  margin-bottom: 6px;
}
.dialogue-text {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.62;
  letter-spacing: 0.02em;
}
.dialogue-hint {
  margin-top: 8px;
  text-align: right;
  font-size: 10.5px;
  color: var(--ink-soft);
  opacity: 0.8;
}

#bossBanner {
  position: absolute;
  left: 50%;
  top: 31%;
  transform: translateX(-50%);
  text-align: center;
  color: #fff8e8;
  text-shadow: 0 3px 16px rgba(24, 14, 8, 0.65);
  z-index: 7;
}
.boss-kicker { font-size: 11px; letter-spacing: 0.25em; opacity: 0.85; }
.boss-title {
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.boss-sub { font-size: 13px; letter-spacing: 0.12em; opacity: 0.8; margin-top: 4px; }

/* ---------- 底栏 ---------- */
#bottomBar {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

#itemBar {
  display: flex;
  gap: 7px;
  padding: 7px;
  border-radius: 15px;
}

.item-slot {
  position: relative;
  width: 92px;
  height: 56px;
  border-radius: 11px;
  border: 1px solid rgba(59, 47, 37, 0.18);
  background: rgba(255, 252, 244, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
}
.item-slot.active {
  background: linear-gradient(180deg, #4a3a2c, #33271c);
  color: #f8efd9;
  border-color: rgba(255, 244, 220, 0.25);
}
.slot-key {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 9.5px;
  font-weight: 800;
  opacity: 0.6;
}
.slot-icon { font-size: 20px; line-height: 1; }
.slot-name { font-size: 11px; letter-spacing: 0.02em; }
.slot-cd {
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-size: 8.5px;
  color: var(--amber);
  font-weight: 800;
}

#locationLabel {
  font-size: 12px;
  color: var(--ink);
  opacity: 0.72;
  text-shadow: 0 1px 2px rgba(255, 246, 224, 0.5);
  margin-bottom: 8px;
}

.hint-bar {
  position: absolute;
  left: 50%;
  bottom: 98px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(32, 24, 17, 0.54);
  color: #f7edd8;
  font-size: 12px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  backdrop-filter: blur(5px);
  transition: opacity 0.8s ease;
  z-index: 7;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(32, 24, 17, 0.78);
  color: #f7edd8;
  font-size: 13px;
  border: 1px solid rgba(246, 238, 220, 0.18);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 12;
  white-space: nowrap;
}
.toast.warn { background: rgba(126, 40, 30, 0.88); }

.fps {
  position: absolute;
  left: 28px;
  top: 62px;
  font-size: 11px;
  color: #d7ffd2;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(23, 17, 12, 0.55);
  backdrop-filter: blur(6px);
  transition: opacity 0.25s ease;
}

.start-card {
  width: min(580px, 82%);
  padding: 38px 44px 32px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(252, 247, 236, 0.98), rgba(240, 228, 205, 0.98)),
    var(--paper);
  border: 1px solid rgba(59, 47, 37, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  text-align: center;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
.start-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(59, 47, 37, 0.18);
  border-radius: 17px;
  pointer-events: none;
}

.start-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--spider-red);
  font-weight: 800;
}
.start-card h1 {
  font-family: var(--serif);
  font-size: 54px;
  line-height: 1.08;
  margin: 12px 0 8px;
  letter-spacing: 0.06em;
}
.start-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.start-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 22px 0 24px;
}
.start-controls span {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(59, 47, 37, 0.07);
  border: 1px solid rgba(59, 47, 37, 0.1);
  color: var(--ink-soft);
}

.start-btn {
  pointer-events: auto;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 34px;
  background: linear-gradient(180deg, #c84634, #9e2d22);
  color: #fff6e5;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(150, 47, 34, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(150, 47, 34, 0.42); }
.start-btn:active { transform: translateY(0); }

.start-note {
  margin-top: 18px;
  font-size: 10.5px;
  color: var(--ink-soft);
  opacity: 0.8;
}

/* ---------- 章节转场卡 ---------- */
#chapterCard { z-index: 15; background: rgba(23, 17, 12, 0.62); }
.chapter-card {
  width: min(560px, 82%);
  padding: 34px 40px;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(252, 247, 236, 0.98), rgba(240, 228, 205, 0.98));
  border: 1px solid rgba(59, 47, 37, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  color: var(--ink);
}
.chapter-kicker {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--spider-red);
  font-weight: 800;
}
.chapter-title {
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-top: 12px;
}
.chapter-sub {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ---------- Touch ---------- */
#touchControls {
  position: absolute;
  inset: auto 0 16px 0;
  z-index: 14;
  display: none;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
}
.touch-left, .touch-right { display: flex; gap: 10px; align-items: flex-end; }
.touch-btn {
  pointer-events: auto;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid rgba(246, 238, 220, 0.35);
  background: rgba(32, 24, 17, 0.52);
  color: #f8efd9;
  font-size: 19px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  touch-action: none;
}
.touch-btn:active { background: rgba(184, 58, 46, 0.82); }
.touch-small { width: 52px; height: 52px; font-size: 15px; }

@media (pointer: coarse), (max-width: 900px) {
  #touchControls { display: flex; }
  .hint-bar { display: none; }
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 1100px) {
  #topBar { padding: 10px 14px 0; min-height: 80px; }
  .dayline { font-size: 15px; }
  .weather { font-size: 10px; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  #playerCard { top: 78px; left: 14px; padding: 7px 10px 7px 7px; }
  .avatar { width: 38px; height: 38px; font-size: 19px; }
  .player-name { font-size: 12px; }
  .hearts { font-size: 15px; }
  #resources { top: 78px; right: 14px; gap: 5px; }
  .chip { height: 30px; padding: 0 8px; font-size: 10px; }
  .chip b { font-size: 12px; }
  #objectiveCard { top: 118px; right: 14px; width: 220px; padding: 9px 11px; }
  .objective-title { font-size: 13px; }
  .objective-sub { font-size: 10px; }
  #bottomBar { left: 14px; right: 14px; bottom: 12px; }
  .item-slot { width: 68px; height: 44px; }
  .slot-name { font-size: 9px; }
  .slot-icon { font-size: 15px; }
  #locationLabel { font-size: 10px; }
  .dialogue-bubble { width: 76%; padding: 13px 16px 9px; }
  .dialogue-text { font-size: 15px; }
  .start-card h1 { font-size: 38px; }
  .start-card { padding: 26px 24px 22px; }
  .hint-bar { bottom: 72px; font-size: 10px; padding: 6px 10px; }
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ---------- 启动画面（boot 背景） ---------- */
.start-overlay { background: #0e0b08; backdrop-filter: none; display: block; }
.start-boot { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.start-boot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.start-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,8,6,.42) 0%, rgba(10,8,6,.04) 32%, rgba(10,8,6,.16) 56%, rgba(10,8,6,.82) 100%); }
.start-content { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 4.5% 5% 5.5%; z-index: 2; }
.start-topline { display: flex; justify-content: flex-start; }
.start-kicker { font-size: 12px; letter-spacing: .24em; color: #f6eedc; text-shadow: 0 2px 10px rgba(0,0,0,.6); background: rgba(20,14,10,.35); padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(246,238,220,.25); }
.start-bottom { display: flex; flex-direction: column; align-items: center; gap: 11px; text-align: center; }
.start-title { font-family: var(--serif); font-size: clamp(34px, 5.6vw, 82px); line-height: 1.05; letter-spacing: .08em; color: #fff3dc; margin: 0; text-shadow: 0 4px 26px rgba(0,0,0,.65), 0 1px 0 rgba(255,255,255,.15); }
.start-sub { margin: 0; font-size: clamp(12px, 1.25vw, 17px); color: rgba(255,243,220,.88); letter-spacing: .08em; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.start-bottom .start-btn { margin-top: 6px; padding: 14px 46px; font-size: clamp(16px, 1.6vw, 22px); }
.start-bottom .start-controls { margin: 8px 0 0; }
.start-bottom .start-controls span { background: rgba(20,14,10,.44); border-color: rgba(246,238,220,.22); color: #f4ead6; }
.start-bottom .start-note { margin-top: 4px; color: rgba(246,238,220,.66); }

/* ---------- 提示卡 ---------- */
#hintCard {
  position: absolute; right: 24px; bottom: 100px; width: 320px; z-index: 18;
  padding: 14px 16px 12px; pointer-events: auto;
  background: linear-gradient(180deg, rgba(250,244,230,.98), rgba(240,228,205,.98));
  border: 1px solid rgba(59,47,37,.22); border-radius: 16px;
  box-shadow: 0 18px 42px rgba(34,22,14,.28), inset 0 1px 0 rgba(255,255,255,.6);
  color: var(--ink);
}
.hint-head { display: flex; align-items: center; justify-content: space-between; }
.hint-head-title { font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--spider-red); }
.hint-close { appearance: none; border: 0; background: transparent; color: var(--ink-soft); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.hint-title { margin-top: 8px; font-family: var(--serif); font-size: 16px; font-weight: 700; }
.hint-text { margin-top: 6px; font-size: 13px; line-height: 1.65; color: rgba(59,47,37,.88); }
.hint-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.hint-btn { appearance: none; border: 1px solid rgba(59,47,37,.2); background: #3b2f25; color: #f8efd9; border-radius: 999px; padding: 7px 14px; font-size: 12px; cursor: pointer; }
.hint-btn.ghost { background: transparent; color: var(--ink); }
.hint-btn:hover { filter: brightness(1.08); }
@media (max-width: 1100px) { #hintCard { width: 260px; right: 14px; bottom: 88px; padding: 10px 12px; } .hint-text { font-size: 11px; } }

/* ---------- 瞄准十字 ---------- */
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 28px; height: 28px;
  transform: translate(-50%, -50%); z-index: 7; pointer-events: none; opacity: .92;
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: rgba(255,246,225,.9);
  box-shadow: 0 0 3px rgba(0,0,0,.75), 0 0 7px rgba(0,0,0,.35);
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }
#crosshair span {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px;
  transform: translate(-50%, -50%); border: 1.5px solid rgba(255,246,225,.95);
  border-radius: 50%; box-shadow: 0 0 4px rgba(0,0,0,.7);
}
.start-bottom { gap: 18px; }
.start-bottom .start-btn { margin-top: 2px; }

/* ================= v9 UI ================= */
/* 1) 操作提示贴底，不留空白 */
#hintBar.hint-bar {
  left: 0; right: 0; bottom: 0 !important; transform: none;
  width: 100%; border-radius: 0; padding: 9px 18px;
  background: rgba(20,14,10,.82); backdrop-filter: blur(4px);
  text-align: center; font-size: 12px; letter-spacing: .03em;
  border-top: 1px solid rgba(246,238,220,.16); z-index: 9;
}
#bottomBar { bottom: 46px; }

/* 2) 对话框：左下，不挡画面 */
#dialogueBubble.dialogue-bubble {
  left: 3.2%; bottom: 104px; top: auto; transform: none;
  width: min(520px, 44%); max-width: 520px;
  padding: 14px 16px 10px;
}
#dialogueBubble::after {
  left: 34px; bottom: -12px; transform: none;
}
.dialogue-row { display: flex; gap: 12px; align-items: flex-start; }
.dialogue-main { flex: 1; min-width: 0; }
.dialogue-avatar {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 12px;
  display: grid; place-items: center; font-size: 30px;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.35), rgba(184,58,46,.18));
  border: 2px solid rgba(184,58,46,.45);
  box-shadow: inset 0 -4px 8px rgba(0,0,0,.12);
}
#dialogueBubble .dialogue-text { font-size: 17px; line-height: 1.6; }
#dialogueBubble .dialogue-hint { text-align: right; }

/* 3) 敌方血条 */
.enemy-bar {
  position: absolute; top: 104px; left: 50%; transform: translateX(-50%);
  width: min(520px, 46%); z-index: 8; padding: 8px 12px 9px;
  background: rgba(24, 16, 12, .72); border: 1px solid rgba(246,238,220,.2);
  border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,.32);
  backdrop-filter: blur(5px); color: #f6eedc;
}
.enemy-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.enemy-name { font-family: var(--serif); font-size: 14px; font-weight: 700; letter-spacing: .08em; }
.enemy-hp { font-size: 11px; color: rgba(246,238,220,.72); }
.enemy-track { height: 9px; border-radius: 999px; background: rgba(0,0,0,.45); overflow: hidden; border: 1px solid rgba(246,238,220,.15); }
.enemy-fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #d84a34, #ffb14a); transition: width .18s ease; }

/* 4) 扫描线 / 像素风 */
#scanlines {
  position: absolute; inset: 0; z-index: 5; pointer-events: none; display: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 2px, transparent 2px 4px);
  mix-blend-mode: multiply; opacity: .55;
}
#stage16x9.mode-2d #scanlines { display: block; }
#stage16x9.mode-2d #flat { image-rendering: pixelated; filter: saturate(1.08) contrast(1.04); }
#stage16x9.mode-2d #crosshair { opacity: .75; }

@media (max-width: 1100px) {
  #hintBar.hint-bar { bottom: 0 !important; font-size: 10px; padding: 6px 10px; }
  #bottomBar { bottom: 34px; }
  #dialogueBubble.dialogue-bubble { left: 2.5%; bottom: 78px; width: 58%; padding: 10px 12px 8px; }
  .dialogue-avatar { width: 42px; height: 42px; font-size: 23px; border-radius: 10px; }
  #dialogueBubble .dialogue-text { font-size: 14px; }
  .enemy-bar { top: 84px; width: 60%; }
}

/* ---------- 漫画过场（替代缺失视频） ---------- */
.comic {
  position: absolute; inset: 0; z-index: 5; display: flex;
  align-items: center; justify-content: center; background: #07080a;
}
.comic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.comic-hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  padding: 7px 16px; border-radius: 999px; background: rgba(20,14,10,.72);
  border: 1px solid rgba(246,238,220,.2); color: #f6eedc; font-size: 12px;
  letter-spacing: .04em; pointer-events: none;
}

/* v10：对话框移到左侧中部，避免遮挡底部/中央元素 */
#dialogueBubble.dialogue-bubble {
  left: 3.2%; top: 30%; bottom: auto; transform: none;
  width: min(470px, 38%); max-width: 470px;
}
@media (max-width: 1100px) {
  #dialogueBubble.dialogue-bubble { left: 2.5%; top: 34%; width: 56%; max-width: 56%; }
}

/* v10：漫画提示避开贴底操作条 */
.comic-hint { bottom: 52px; z-index: 6; }
@media (max-width: 1100px) { .comic-hint { bottom: 42px; } }

/* ================= v12 ================= */
/* 漫画窗口：右侧中部，带边框，约占画面 1/3–1/4 */
#comic.comic {
  inset: auto; right: 4%; top: 50%; transform: translateY(-50%);
  width: 30%; max-width: 560px; aspect-ratio: 16 / 9;
  border: 5px solid #f6eedc; border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55), inset 0 0 0 2px rgba(120,90,50,.55);
  background: #07080a; overflow: hidden; z-index: 7;
}
#comic.comic img { width: 100%; height: 100%; object-fit: cover; }
#comic.comic .comic-hint { bottom: 8px; font-size: 11px; padding: 5px 12px; }
#comic.comic.persist .comic-hint { display: none; }
#bottomBar { justify-content: flex-start; }
@media (max-width: 1100px) {
  #comic.comic { width: 44%; right: 3%; border-width: 3px; }
}

#comic.comic { top: 58%; }

/* ================= v13 ================= */
/* 漫画：画面正中间偏上 */
#comic.comic {
  left: 50%; right: auto; top: 10%; transform: translateX(-50%);
  width: 34%; max-width: 640px;
}
/* v4 / 悟空：全屏 */
#comic.comic.full {
  left: 0; top: 0; right: 0; width: 100%; max-width: none;
  height: 100%; aspect-ratio: auto; transform: none;
  border: 0; border-radius: 0; box-shadow: none; z-index: 12;
}
#comic.comic.full img { object-fit: contain; }

/* 2D 俯视双手 */
#firstPersonHands { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#firstPersonHands.hidden { display: none; }
#firstPersonHands .hand {
  position: absolute; bottom: -2.5%; width: 190px; height: auto;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.45));
  transition: transform .12s ease, bottom .12s ease;
}
#firstPersonHands .hand-left { left: 1.5%; transform: scaleX(-1) rotate(-7deg); }
#firstPersonHands .hand-right { right: 1.5%; transform: rotate(7deg); }
#firstPersonHands.shooting .hand-right { transform: translate(-12px, -16px) rotate(-2deg) scale(.96); }
#firstPersonHands.shooting .hand-left { transform: scaleX(-1) rotate(-3deg) translate(-6px, -6px); }
.mode-2d #firstPersonHands { display: none; }
@media (max-width: 1100px) { #firstPersonHands .hand { width: 140px; } }

/* 制作人名单 */
.credits {
  position: absolute; inset: 0; z-index: 20; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #1b1410, #07080a 70%);
}
.credits-track {
  position: absolute; left: 50%; top: 100%; width: min(680px, 82%);
  transform: translateX(-50%); text-align: center; color: #f6eedc;
  animation: creditsUp 14s linear forwards;
}
.credit-kicker { font-size: 12px; letter-spacing: .35em; color: #e8b04a; margin-bottom: 18px; }
.credit-title { font-family: var(--font-display, serif); font-size: 34px; margin-bottom: 30px; color: #fff; }
.credit-role { margin-top: 18px; font-size: 12px; letter-spacing: .18em; color: #d9b08a; }
.credit-name { margin-top: 4px; font-size: 20px; color: #f6eedc; }
.credit-end { margin-top: 34px; font-size: 15px; color: #e8b04a; }
@keyframes creditsUp { from { transform: translate(-50%, 0); } to { transform: translate(-50%, -220%); } }

/* v13：漫画在正上时，对白略下移避免遮挡 */
#dialogueBubble.dialogue-bubble { top: 47%; }
@media (max-width: 1100px) { #dialogueBubble.dialogue-bubble { top: 48%; } }

/* ================= v14 ================= */
/* 开场 v0：纯全屏视频，不叠任何 UI */
#stage16x9.video-mode #hud,
#stage16x9.video-mode #hintBar,
#stage16x9.video-mode #crosshair,
#stage16x9.video-mode #firstPersonHands,
#stage16x9.video-mode #bottomBar,
#stage16x9.video-mode #scanlines,
#stage16x9.video-mode #comic,
#stage16x9.video-mode #dialogueBubble,
#stage16x9.video-mode #startOverlay { display: none !important; }
#stage16x9.video-mode #cutscene {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; display: block; z-index: 30;
}

#stage16x9.video-mode {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  aspect-ratio: auto; border-radius: 0;
}

/* ================= v16 ================= */
/* F 交互提示：抖动 + 文字 */
#interactPrompt {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 9px; z-index: 9;
  padding: 8px 14px 8px 9px; border-radius: 999px;
  background: rgba(20,14,10,.82); border: 1px solid rgba(246,238,220,.28);
  color: #f6eedc; font-size: 14px; letter-spacing: .03em;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#interactPrompt.hidden { display: none; }
#interactPrompt .interact-key {
  display: inline-flex; width: 26px; height: 26px; border-radius: 7px;
  align-items: center; justify-content: center; font-weight: 800; color: #1b1410;
  background: #f6eedc; box-shadow: 0 2px 0 #b8a98c;
  animation: keyShake .55s ease-in-out infinite;
}
@keyframes keyShake {
  0%, 100% { transform: translate(0,0) rotate(0); }
  20% { transform: translate(-1.5px,1px) rotate(-3deg); }
  40% { transform: translate(1.5px,-1px) rotate(3deg); }
  60% { transform: translate(-1px,-1px) rotate(-2deg); }
  80% { transform: translate(1px,1px) rotate(2deg); }
}
#stage16x9.video-mode #interactPrompt { display: none !important; }

.credit-sub { font-size: 12px; color: #d9b08a; margin: 2px 0 10px; letter-spacing: .04em; }

/* ================= v17 mobile / tablet ================= */
@media (pointer: coarse), (max-width: 1100px) {
  #topBar { padding: 6px 8px 0; min-height: 54px; }
  .dayline { font-size: 11px; }
  .weather { font-size: 8px; }
  .icon-btn { width: 26px; height: 26px; font-size: 11px; }
  .top-actions { gap: 4px; }
  #playerCard { top: 52px; left: 6px; padding: 4px 7px 4px 5px; gap: 6px; }
  .avatar { width: 30px; height: 30px; font-size: 15px; }
  .player-name { font-size: 10px; }
  .hearts { font-size: 11px; gap: 1px; margin-top: 2px; }
  #resources { top: 52px; right: 6px; gap: 3px; }
  .chip { height: 22px; padding: 0 5px; font-size: 8px; gap: 3px; }
  .chip b { font-size: 10px; }
  .chip-icon { font-size: 9px; }
  .chip-max { font-size: 8px; }
  #objectiveCard { top: 84px; right: 6px; width: min(44%, 200px); padding: 6px 8px; border-radius: 10px; }
  .objective-label { font-size: 8px; }
  .objective-title { font-size: 11px; line-height: 1.25; }
  .objective-sub { font-size: 8px; line-height: 1.3; margin-top: 2px; }
  .objective-progress { font-size: 8px; margin-top: 4px; }
  #enemyBar { top: 84px; width: 44%; padding: 5px 8px; }
  .enemy-name, .enemy-hp { font-size: 10px; }
  .enemy-track { height: 5px; margin-top: 3px; }

  #dialogueBubble.dialogue-bubble {
    left: 6px; right: auto; top: auto; bottom: calc(108px + env(safe-area-inset-bottom));
    width: min(52%, 340px); max-width: 340px; padding: 8px 10px 6px;
    transform: none; max-height: 28%; overflow: auto;
  }
  .dialogue-row { gap: 7px; }
  .dialogue-avatar { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
  .dialogue-speaker { font-size: 9px; }
  #dialogueBubble .dialogue-text { font-size: 11.5px; line-height: 1.45; }
  .dialogue-hint { font-size: 8px; margin-top: 2px; }

  #comic.comic {
    left: 50%; right: auto; top: 7%; transform: translateX(-50%);
    width: min(31%, 270px); border-width: 3px; border-radius: 6px;
  }
  #comic.comic .comic-hint { font-size: 8px; padding: 3px 7px; bottom: 5px; }

  #bottomBar, #locationLabel, #hintBar { display: none !important; }
  #touchControls { bottom: max(6px, env(safe-area-inset-bottom)); padding: 0 6px; }
  .touch-left { gap: 6px; }
  .touch-right { display: grid; grid-template-columns: repeat(3, auto); gap: 6px; align-items: end; }
  .touch-btn { width: 46px; height: 46px; font-size: 13px; background: rgba(32,24,17,.38); backdrop-filter: blur(3px); }
  .touch-small { width: 42px; height: 42px; font-size: 11px; }
  #interactPrompt { bottom: calc(108px + env(safe-area-inset-bottom)); font-size: 11px; padding: 6px 10px 6px 7px; }
  .interact-key { width: 22px; height: 22px; font-size: 12px; }
  #hintCard { width: min(86%, 300px); right: 6px; bottom: calc(108px + env(safe-area-inset-bottom)); padding: 9px 11px; }
  .hint-text { font-size: 10px; }

  .start-card { padding: 18px 16px 16px; }
  .start-card h1 { font-size: 28px; }
  .start-card p { font-size: 12px; }
  .start-btn { font-size: 14px; padding: 10px 26px; }
  .overlay { padding: 12px; }
}

/* 竖屏手机：直接提示横屏，避免 16:9 被压成一条 */
@media (orientation: portrait) and (max-width: 900px) {
  #touchControls { display: none !important; }
  #rotateHint { display: flex !important; }
}
#rotateHint {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(circle at 50% 35%, #1b1410, #07080a 70%);
  color: #f6eedc; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px;
}
#rotateHint .rotate-icon { font-size: 54px; animation: rotateHint 1.8s ease-in-out infinite; }
#rotateHint p { margin: 0; font-size: 22px; letter-spacing: .08em; }
#rotateHint span { color: #d9b08a; font-size: 12px; }
@keyframes rotateHint { 0%,100% { transform: rotate(0); } 50% { transform: rotate(90deg); } }

/* v17 mobile refinements */
@media (pointer: coarse), (max-width: 1100px) {
  #comic.comic { width: min(28%, 250px); }
  #dialogueBubble.dialogue-bubble { max-height: 31%; scrollbar-width: none; }
  #dialogueBubble.dialogue-bubble::-webkit-scrollbar { display: none; }
  #dialogueBubble .dialogue-hint { display: none; }
  .credit-title { font-size: 24px; }
  .credit-name { font-size: 15px; }
  .credit-sub { font-size: 10px; }
  .credits-track { width: 86%; }
}
