* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family:
    "Arial Narrow", Impact, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050505;
  color: #fff4d2;

  /* 安全距离：优先读取系统 env()，无支持时使用固定默认值 */
  --safe-top: max(56px, env(safe-area-inset-top, 0px));
  --safe-bottom: max(34px, env(safe-area-inset-bottom, 0px));
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: #050505;
}

button {
  border: 2px solid rgba(255, 211, 41, 0.74);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.72);
  color: #ffd329;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  min-height: 40px;
  padding: 0 14px;
  text-transform: uppercase;
  transform: none;
}

button:hover {
  border-color: #fff6d8;
  background: rgba(229, 31, 25, 0.28);
}

.stage-shell {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
}

#threeCanvas,
#mvCanvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
}

#threeCanvas {
  z-index: 0;
  opacity: 0;
  transition: opacity 180ms ease;
}

#threeCanvas.is-active {
  opacity: 1;
}

#mvCanvas {
  z-index: 1;
}

#camera {
  position: fixed;
  right: 18px;
  bottom: calc(72px + var(--safe-bottom));
  width: min(18vw, 160px);
  max-height: 120px;
  border: 1px solid rgba(255, 211, 41, 0.3);
  filter: grayscale(0.6) contrast(1.4);
  opacity: 0.42;
  transform: scaleX(-1);
  z-index: 6;
}

.audio-dock {
  position: fixed;
  left: 18px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 22;
  width: min(320px, calc(100vw - 36px));
  height: 34px;
  opacity: 0.86;
  filter: sepia(0.4) saturate(1.2) contrast(1.1);
}

.hud {
  position: fixed;
  z-index: 7;
  pointer-events: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

.hud-left {
  left: clamp(16px, 4vw, 54px);
  top: calc(clamp(18px, 5vh, 56px) + var(--safe-top));
  max-width: min(420px, calc(100vw - 32px));
}

.kicker {
  margin: 0 0 10px;
  color: #ffd329;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #fff6d8;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(34px, 5vw, 78px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.78;
  max-width: 11ch;
  paint-order: stroke fill;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.55);
  text-transform: uppercase;
  transform: skewX(-10deg);
}

.status {
  margin: 10px 0 0;
  max-width: 300px;
  color: rgba(255, 246, 216, 0.72);
  font-size: 12px;
  line-height: 1.45;
}

.hud-right {
  right: clamp(16px, 4vw, 54px);
  top: calc(clamp(18px, 5vh, 56px) + var(--safe-top));
  display: grid;
  gap: 10px;
  width: 152px;
}

.meter {
  border: 2px solid rgba(255, 246, 216, 0.24);
  background: rgba(0, 0, 0, 0.48);
  padding: 10px;
  transform: skewX(-6deg);
}

.meter span,
.meter strong {
  display: block;
}

.meter span {
  color: rgba(255, 246, 216, 0.62);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meter strong {
  margin-top: 3px;
  color: #ffd329;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 30px;
  letter-spacing: 0;
}

.controls {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + var(--safe-bottom));
  z-index: 20;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;
  max-width: calc(100vw - 36px);
}

.ticker {
  position: fixed;
  left: 0;
  bottom: 0;
  padding-bottom: var(--safe-bottom);
  z-index: 3;
  display: flex;
  width: 100vw;
  overflow: hidden;
  border-top: 2px solid rgba(255, 246, 216, 0.2);
  color: rgba(255, 211, 41, 0.9);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(22px, 5vw, 62px);
  letter-spacing: 0;
  line-height: 0.82;
  mix-blend-mode: screen;
  pointer-events: none;
  text-transform: uppercase;
}

.ticker span {
  flex: 0 0 auto;
  padding: 10px 34px 8px;
  animation: crawl 11s linear infinite;
  white-space: nowrap;
}

@keyframes crawl {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@media (max-width: 760px) {
  /* 默认隐藏所有非关键 UI，让画面全屏呈现 */
  .hud-left,
  .hud-right,
  .ticker,
  .audio-dock {
    display: none;
  }

  #camera {
    display: none;
  }

  /* 按钮区默认半透明悬浮在底部，不遮主画面 */
  .controls {
    left: 0;
    right: 0;
    transform: none;
    bottom: 0;
    justify-content: center;
    gap: 0;
    padding: 0;
    padding-bottom: var(--safe-bottom);
    background: rgba(5, 5, 5, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .audio-dock {
    display: none;
  }

  button {
    flex: 1 1 0;
    font-size: 11px;
    min-height: 44px;
    border-left-width: 0;
    border-right-width: 0;
    border-bottom-width: 0;
    border-top: 1px solid rgba(255, 211, 41, 0.3);
    border-radius: 0;
  }

  button:first-child {
    border-left-width: 0;
  }

  /* 点击画面后显示 HUD（通过 JS 切换 .hud-visible class） */
  .stage-shell.hud-visible .hud-left {
    max-width: calc(100vw - 32px);
  }

  .stage-shell.hud-visible h1 {
    font-size: clamp(20px, 5.5vw, 36px);
    max-width: 9ch;
  }

  .stage-shell.hud-visible .hud-right {
    display: grid;
    left: 16px;
    right: auto;
    top: auto;
    bottom: calc(130px + var(--safe-bottom));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(260px, calc(100vw - 32px));
  }

  .stage-shell.hud-visible .ticker {
    font-size: clamp(13px, 3.5vw, 24px);
  }

  .stage-shell.hud-visible .gesture-hint {
    right: 16px;
    left: auto;
    bottom: calc(130px + var(--safe-bottom));
    font-size: 10px;
  }
}

/* 全局语言切换 — 始终固定右上角 */
.global-lang {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 20px;
  z-index: 200;
}

.global-lang .lang-btn {
  background: rgba(5,5,5,0.65);
  border: 1px solid rgba(255,211,41,0.35);
  color: rgba(255,244,210,0.75);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: pointer;
  padding: 5px 10px;
  min-height: unset;
  text-transform: uppercase;
  transition: color 180ms, border-color 180ms;
  border-radius: 2px;
}

.global-lang .lang-btn:hover {
  color: #ffd329;
  border-color: rgba(255,211,41,0.7);
}

/* 手势操作提示面板 — 右上角，语言按钮下方 */
.gesture-hint {
  position: fixed;
  right: 18px;
  top: calc(52px + var(--safe-top));
  z-index: 8;
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 244, 210, 0.72);
  text-transform: uppercase;
  line-height: 1.9;
}

.gesture-hint ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 760px) {
  .gesture-hint {
    right: 16px;
    left: auto;
    bottom: calc(52px + var(--safe-bottom));
    font-size: 10px;
  }
}

/* 默认隐藏主界面操控组件，进入后才显示 */
.controls,
.ticker,
.gesture-hint {
  display: none !important;
}

body.has-entered .controls,
body.has-entered .ticker,
body.has-entered .gesture-hint {
  display: flex !important;
}

body.has-entered .ticker {
  display: flex !important;
}

body.has-entered .gesture-hint {
  display: block !important;
}

/* ── 首屏 CTA ── */
.entry-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* 渐变蒙层：中部通透，上下压暗，文字区域用 text-shadow 保可读性 */
  background: linear-gradient(
    to bottom,
    rgba(5, 5, 5, 0.55) 0%,
    rgba(5, 5, 5, 0.38) 35%,
    rgba(5, 5, 5, 0.38) 65%,
    rgba(5, 5, 5, 0.62) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* 语言切换 */
.entry-lang {
  display: none;
}

.lang-btn {
  background: transparent;
  border: none;
  color: rgba(255, 244, 210, 0.4);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 4px 2px;
  min-height: unset;
  text-transform: uppercase;
  transition: color 180ms;
}

.lang-btn.active,
.lang-btn:hover {
  color: #ffd329;
}

.lang-sep {
  color: rgba(255, 244, 210, 0.2);
  font-size: 11px;
}

.entry-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 32px 40px;
  background: rgba(5, 5, 5, 0.62);
  border: 1px solid rgba(255, 211, 41, 0.18);
  max-width: min(480px, calc(100vw - 40px));
}

.entry-title {
  margin: 0;
  font-family: Impact, "Arial Narrow Bold", sans-serif;
  font-size: clamp(52px, 14vw, 120px);
  font-weight: 900;
  color: #fff6d8;
  line-height: 0.9;
  letter-spacing: -0.02em;
  transform: skewX(-8deg);
  text-shadow: 0 0 40px rgba(5,5,5,0.9), 0 2px 8px rgba(5,5,5,0.95);
}

.entry-role-hint {
  margin: 0;
  font-size: clamp(11px, 2.5vw, 13px);
  color: rgba(255, 244, 210, 0.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.role-tag {
  color: #ffd329;
  font-weight: 900;
}

.entry-desc {
  margin: 0;
  font-size: clamp(14px, 3.5vw, 18px);
  color: rgba(255, 244, 210, 0.9);
  max-width: 340px;
  line-height: 1.5;
  text-shadow: 0 1px 12px rgba(5,5,5,0.95);
}

.entry-role-hint {
  margin: 0;
  font-size: clamp(11px, 2.5vw, 13px);
  color: rgba(255, 244, 210, 0.72);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(5,5,5,0.95);
}

.entry-btn {
  margin-top: 8px;
  padding: 14px 36px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.1em;
  border: 2px solid #ffd329;
  background: transparent;
  color: #ffd329;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 180ms, color 180ms;
  align-self: center;
  width: 100%;
}

.entry-btn:hover {
  background: #ffd329;
  color: #050505;
}

/* ── 玩法介绍弹窗 ── */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 5, 5, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.tutorial-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-card {
  background: rgba(12, 12, 12, 0.96);
  border: 2px solid rgba(255, 211, 41, 0.5);
  padding: 32px 36px 28px;
  max-width: min(420px, calc(100vw - 40px));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tutorial-tag {
  margin: 0;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: rgba(255, 211, 41, 0.6);
  text-transform: uppercase;
}

.tutorial-title {
  margin: 0;
  font-family: Impact, "Arial Narrow Bold", sans-serif;
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 900;
  color: #fff6d8;
  transform: skewX(-6deg);
  line-height: 1;
}

.tutorial-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 244, 210, 0.82);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tutorial-list strong {
  color: #ffd329;
}

.tutorial-hint {
  margin: 0;
  font-size: 11px;
  color: rgba(255, 244, 210, 0.45);
  line-height: 1.5;
}

.tutorial-start {
  align-self: flex-start;
  padding: 12px 28px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
  border: 2px solid #ffd329;
  background: #ffd329;
  color: #050505;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 180ms, color 180ms;
}

.tutorial-start:hover {
  background: transparent;
  color: #ffd329;
}
