/* public/style.css — Native Mobile Game Floating HUD, Virtual Thumbstick, Fan Action Wheel & Film Theater */

@font-face {
  font-family: "PelicanSerif";
  src: url("./fonts/NotoSerifSC.woff2?v=b3f7932ea1d6") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PelicanSans";
  src: url("./fonts/NotoSansSC.woff2?v=85860db27eca") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PelicanWenKai";
  src: url("./fonts/LXGWWenKai.woff2?v=efe171facba8") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PelicanMono";
  src: url("./fonts/JetBrainsMono-Regular.woff2?v=5c04c0852c90") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PelicanMono";
  src: url("./fonts/JetBrainsMono-Bold.woff2?v=e9d3844ca355") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --target-size: 28px;
  --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
  --bg-obsidian: #0d0c0b;
  --bg-walnut: #1b1612;
  --brass: #d4a373;
  --brass-bright: #efc488;
  --gold-accent: #facc15;
  --cream-text: #f4efe4;
  --muted-text: #bfb4a0;
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100dvh;
  background: var(--bg-obsidian);
  color: var(--cream-text);
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  overflow-wrap: break-word;
  -webkit-user-select: none;
  user-select: none;
}

:where(a, code) {
  overflow-wrap: anywhere;
}

:where(button, select, input:not([type="checkbox"], [type="radio"]), [role="button"]) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
}

body.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
}

:where(.toolbar > :not(button, input, select, textarea, a, [role="button"], label)) {
  min-inline-size: 0;
}

/* ============================================================================
 * 1. Film Mode Classic Theater Header (`body.is-film-mode` ONLY)
 * ============================================================================ */
body.is-game-mode #top-hud {
  display: none;
}

#top-hud {
  width: 100%;
  min-block-size: 50px;
  background: linear-gradient(180deg, #1d1814 0%, #120f0d 100%);
  border-bottom: 1px solid rgba(212, 163, 115, 0.22);
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding-top: max(5px, env(safe-area-inset-top, 0px));
  padding-bottom: 5px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  z-index: 20;
}

.mode-switch {
  display: inline-flex;
  background: #100d0b;
  padding: 3px;
  border-radius: 9px;
  border: 1px solid rgba(212, 163, 115, 0.28);
  gap: 3px;
}

.mode-btn {
  background: transparent;
  color: var(--muted-text);
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.mode-btn.is-active {
  background: var(--brass);
  color: #17120d;
}

.hud-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ============================================================================
 * 2. Full-Bleed Stage & Canvas Sizing
 * ============================================================================ */
#stage-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 42%, #231e19 0%, #0d0b0a 100%);
  touch-action: none;
}

#canvas-host {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.is-game-mode #canvas-host canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

body.is-film-mode #stage-wrap {
  padding: 10px 16px 6px;
  cursor: pointer;
}

body.is-film-mode #canvas-host canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  aspect-ratio: 9 / 16;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 245, 225, 0.14);
  border-radius: 6px;
}

body.render-mode {
  margin: 0;
  padding: 0;
  background: #000;
  height: 1920px;
}
body.render-mode #canvas-host {
  width: 1080px;
  height: 1920px;
  display: block;
}
body.render-mode canvas {
  display: block;
  width: 1080px !important;
  height: 1920px !important;
}

/* ============================================================================
 * 3. De-Webified Floating Game HUD Capsules & 20-Era Progress Map
 * ============================================================================ */
body.is-film-mode #game-floating-hud,
body.is-film-mode #mobile-game-pad {
  display: none;
}

#game-floating-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  pointer-events: none;
  z-index: 22;
}

.game-hud-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-capsule {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(18, 14, 11, 0.76);
  border: 1px solid rgba(226, 194, 134, 0.34);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

.game-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.gmp-btn {
  background: transparent;
  color: #cbbda6;
  border: none;
  border-radius: 999px;
  padding: 5px 11px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, transform 110ms var(--ease-out-quint);
}

.gmp-btn.is-active {
  background: linear-gradient(180deg, #efc488 0%, #d4a373 100%);
  color: #17120c;
  box-shadow: 0 2px 10px rgba(212, 163, 115, 0.35);
}

/* Top-Center 20-Stage Progress Map Capsule */
.stage-map-capsule {
  cursor: pointer;
  padding: 5px 14px;
  gap: 10px;
  color: #fbf3e2;
  transition: border-color 150ms ease, background-color 150ms ease, transform 110ms var(--ease-out-quint);
}

.stage-map-capsule:hover {
  border-color: #fde047;
  background: rgba(28, 22, 17, 0.88);
}

.stage-era-name {
  font-family: "PelicanSerif", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  font-weight: 700;
  font-size: 13.5px;
  color: #fef3c7;
  white-space: nowrap;
}

.stage-progress-rail {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: clamp(110px, 18vw, 220px);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  overflow: visible;
}

.stage-progress-fill {
  height: 100%;
  width: 2%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d97706 0%, #fde047 100%);
  transition: width 90ms linear;
}

.stage-progress-dots {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px;
  pointer-events: none;
}

.stage-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
}

.stage-dot.is-sealed {
  width: 4.5px;
  height: 4.5px;
  background: #fde047;
  box-shadow: 0 0 5px rgba(250, 204, 21, 0.85);
}

.stage-rider-pip {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: #fde047;
  border: 2px solid #18120b;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.95);
  transition: left 80ms linear;
}

.stage-map-caret {
  font-size: 11px;
  color: #d4a373;
}

.badge-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}
.badge-dot.is-gold {
  background: rgba(250, 204, 21, 0.24);
  color: #fde047;
  border: 1px solid rgba(250, 204, 21, 0.55);
}
.badge-dot.is-cyan {
  background: rgba(34, 211, 238, 0.20);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.50);
}

.hud-stat-btn,
.hud-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(42, 34, 26, 0.82);
  color: var(--cream-text);
  border: 1px solid rgba(212, 163, 115, 0.30);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 110ms var(--ease-out-quint), border-color 150ms ease, background-color 150ms ease;
}

.hud-stat-btn strong {
  color: #fde047;
  font-family: "PelicanMono", monospace;
}

.hud-icon-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(42, 34, 26, 0.82);
  color: #f6efe0;
  border: 1px solid rgba(212, 163, 115, 0.32);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 110ms var(--ease-out-quint), background-color 140ms ease, border-color 140ms ease;
}

.hud-stat-btn:hover,
.hud-action-btn:hover,
.hud-icon-round:hover,
.hud-icon-round[aria-pressed="true"] {
  background: rgba(212, 163, 115, 0.28);
  border-color: #fde047;
  color: #fffbeb;
}

.hud-stat-btn:active,
.hud-action-btn:active,
.hud-icon-round:active,
.gmp-btn:active,
.stage-map-capsule:active,
.gold-cta-btn:active {
  transform: scale(0.94);
}

.hud-stat-btn.is-pop {
  border-color: #fde047;
  background: rgba(250, 204, 21, 0.28);
}

@media (prefers-reduced-motion: no-preference) {
  .hud-stat-btn.is-pop {
    transform: scale(1.13);
  }
}

/* ============================================================================
 * 4. Native Mobile Game Controller: Left Floating Thumbstick + Right Skill Wheel
 * ============================================================================ */
body.hide-game-pad #mobile-game-pad,
body.is-finale-active #mobile-game-pad {
  display: none;
}

#mobile-game-pad {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 18;
}

/* --- A. Left Half Dynamic Floating Virtual Joystick (`#joy-zone`) --- */
#joy-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 64%;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
}

#joy-zone.is-dragging {
  cursor: grabbing;
}

.joy-base {
  position: fixed;
  left: max(22px, calc(env(safe-area-inset-left, 0px) + 18px));
  bottom: max(22px, calc(env(safe-area-inset-bottom, 0px) + 18px));
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(30, 24, 18, 0.42) 0%, rgba(16, 13, 10, 0.72) 100%);
  border: 2px solid rgba(239, 196, 136, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.50), inset 0 0 18px rgba(212, 163, 115, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 160ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.joy-base.is-active {
  border-color: rgba(250, 204, 21, 0.82);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.62), 0 0 18px rgba(250, 204, 21, 0.25);
}

.joy-sprint-halo {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px dashed rgba(250, 204, 21, 0);
  opacity: 0;
  transition: opacity 140ms ease, border-color 140ms ease;
}

.joy-base.is-sprinting .joy-sprint-halo {
  opacity: 1;
  border-color: rgba(253, 224, 71, 0.85);
}

@media (prefers-reduced-motion: no-preference) {
  .joy-base.is-sprinting .joy-sprint-halo {
    animation: joyHaloSpin 3.2s linear infinite;
  }
}

@keyframes joyHaloSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.joy-dir {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: rgba(239, 196, 136, 0.58);
  pointer-events: none;
}
.joy-dir.is-left {
  left: 11px;
}
.joy-dir.is-right {
  right: 11px;
}

.joy-stick {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, #fef08a 0%, #eab308 55%, #a16207 100%);
  border: 2px solid rgba(255, 251, 235, 0.88);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate3d(0px, 0px, 0px);
  will-change: transform;
}

.joy-base:not(.is-active) .joy-stick {
  transition: transform 180ms var(--ease-out-quint);
}

.joy-stick-core {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(24, 18, 11, 0.28);
  border: 1.5px solid rgba(255, 251, 235, 0.65);
}

/* --- B. Right Bottom Fan-Shaped Circular Action Wheel (`#action-wheel`) --- */
#action-wheel {
  position: fixed;
  right: max(18px, calc(env(safe-area-inset-right, 0px) + 14px));
  bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 14px));
  width: 186px;
  height: 178px;
  pointer-events: none;
}

.skill-circle {
  position: absolute;
  pointer-events: auto;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.58);
  transition: transform 95ms var(--ease-out-quint), border-color 140ms ease, background-color 140ms ease;
}

.skill-circle:active,
.skill-circle.is-pressed {
  transform: scale(0.89);
}

.skill-glyph {
  font-family: "PelicanSerif", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.05;
}

.skill-glyph.is-lg {
  font-size: 25px;
}

.skill-sub {
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0.92;
}

/* 1. Primary Corner Jump Button (`82x82px`) */
.skill-circle.is-jump-main {
  right: 0;
  bottom: 0;
  width: 82px;
  height: 82px;
  background: radial-gradient(circle at 38% 30%, #fef08a 0%, #f59e0b 65%, #b45309 100%);
  border: 2.5px solid #fef9c3;
  color: #18120a;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.40), 0 4px 12px rgba(0, 0, 0, 0.55);
}

.jump-pips {
  display: inline-flex;
  gap: 5px;
  margin-top: 3px;
}

.jump-pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(24, 18, 10, 0.26);
  transition: background-color 120ms ease, transform 120ms ease;
}

.jump-pip.is-lit {
  background: #18120a;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

/* 2. Arc-Left Contextual Era Spectacle Skill (`64x64px`) */
.skill-circle.is-spectacle {
  right: 104px;
  bottom: 4px;
  width: 64px;
  height: 64px;
  background: radial-gradient(circle at 40% 32%, rgba(22, 78, 99, 0.90) 0%, rgba(15, 23, 42, 0.92) 100%);
  border: 2px solid rgba(103, 232, 249, 0.62);
  color: #cffafe;
}

.spec-radar-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(103, 232, 249, 0);
  pointer-events: none;
}

.skill-circle.is-spectacle.is-ready {
  border-color: #67e8f9;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.42), 0 8px 22px rgba(0, 0, 0, 0.55);
}

@media (prefers-reduced-motion: no-preference) {
  .skill-circle.is-spectacle.is-ready .spec-radar-ring {
    border-color: rgba(103, 232, 249, 0.82);
    animation: specRadarPulse 1.55s var(--ease-out-quint) infinite;
  }
}

@keyframes specRadarPulse {
  0% {
    transform: scale(0.92);
    opacity: 0.92;
  }
  100% {
    transform: scale(1.24);
    opacity: 0;
  }
}

/* 3. Arc-Upper Nitro Boost Dash Skill (`62x62px` + 360° SVG Ring) */
.skill-circle.is-boost {
  right: 12px;
  bottom: 102px;
  width: 62px;
  height: 62px;
  background: radial-gradient(circle at 40% 32%, rgba(66, 48, 24, 0.92) 0%, rgba(24, 19, 14, 0.94) 100%);
  border: 1.5px solid rgba(250, 204, 21, 0.35);
  color: #fde047;
}

.skill-circle.is-boost.is-boosting {
  background: radial-gradient(circle at 40% 32%, rgba(161, 98, 7, 0.95) 0%, rgba(66, 32, 6, 0.95) 100%);
  box-shadow: 0 0 22px rgba(250, 204, 21, 0.55);
}

.boost-ring-svg {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.boost-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 3.2;
}

.boost-ring-fg {
  fill: none;
  stroke: #fde047;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 188.5;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 80ms linear;
}

/* Finale Press Conference Action Overlay (Anchored cleanly at bottom) */
#finale-overlay-bar {
  position: absolute;
  bottom: max(22px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-inline-size: calc(100dvw - 24px);
  padding: 9px 14px;
  border-radius: 16px;
  background: rgba(16, 13, 11, 0.88);
  border: 1px solid rgba(250, 204, 21, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 24;
}

#finale-overlay-bar[hidden] {
  display: none;
}

.gold-cta-btn {
  background: linear-gradient(180deg, #facc15 0%, #eab308 100%);
  color: #17120b;
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(250, 204, 21, 0.25);
}

.gold-cta-btn:hover {
  filter: brightness(1.06);
}

/* ============================================================================
 * 5. Film Mode Bottom Control Bar & Shared Audio Controls
 * ============================================================================ */
#control-bar {
  width: 100%;
  min-block-size: 56px;
  background: linear-gradient(180deg, #191714 0%, #110f0d 100%);
  border-top: 1px solid rgba(226, 206, 170, 0.16);
  align-items: center;
  gap: 12px;
  padding-top: 6px;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  font-size: 14px;
}

#control-bar[hidden] {
  display: none;
}

#btn-play {
  background: var(--brass);
  color: #18130e;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-inline-size: 78px;
}

#btn-play:hover {
  background: var(--brass-bright);
}

#time-readout {
  font-family: "PelicanMono", monospace;
  font-size: 13px;
  color: #d6cec0;
  min-inline-size: 112px;
}

#scrubber {
  flex: 1;
  min-inline-size: 140px;
  accent-color: var(--brass);
  cursor: pointer;
}

#scene-jump {
  background: #241f1a;
  color: #efe7d6;
  border: 1px solid rgba(212, 163, 115, 0.35);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 13px;
  cursor: pointer;
}

#era-badge {
  font-family: "PelicanSerif", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  font-weight: 600;
  color: #f3ead8;
  white-space: nowrap;
}

#audio-controls {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(36, 32, 27, 0.78);
  border: 1px solid rgba(212, 163, 115, 0.24);
  white-space: nowrap;
}

#btn-mute {
  background: transparent;
  color: #efe7d6;
  border: none;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}

#volume-slider {
  width: 62px;
  accent-color: var(--brass);
  cursor: pointer;
}

#audio-status {
  font-size: 12px;
  color: #a9b89c;
  padding-left: 5px;
  border-left: 1px solid rgba(226, 206, 170, 0.16);
}

#audio-status.is-loading {
  color: #bfa980;
}

#audio-status.is-ready::before {
  content: "● ";
  color: #7bd389;
}

#btn-fullscreen {
  background: rgba(36, 32, 27, 0.78);
  color: #efe7d6;
  border: 1px solid rgba(212, 163, 115, 0.35);
  border-radius: 7px;
  padding: 4px 10px;
  font-family: "PelicanSans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

/* ============================================================================
 * 6. Native Modal Dialogs (`closedby="any"` + Top-Layer Discrete Animation)
 * ============================================================================ */
#stamp-book-dialog {
  width: min(880px, calc(100dvw - 24px));
}

#finale-dialog {
  width: min(520px, calc(100dvw - 24px));
}

dialog {
  margin: auto;
  border: 1px solid rgba(226, 194, 134, 0.42);
  border-radius: 16px;
  background: #1a1511;
  color: var(--cream-text);
  max-inline-size: min(920px, calc(100dvw - 24px));
  max-block-size: calc(100dvh - 32px);
  padding: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.85);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: var(--ease-out-quint);
  transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
  dialog {
    transform: scale(0.95);
  }
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog[open]:where(:not([data-closing])) {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: scale(1);

    @starting-style {
      transform: scale(0.95);
    }
  }
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background-color: rgba(6, 5, 4, 0);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
  transition-property: background-color, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog[open]:where(:not([data-closing]))::backdrop {
  background-color: rgba(6, 5, 4, 0.72);

  @starting-style {
    background-color: rgba(6, 5, 4, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog,
  dialog::backdrop {
    transition-duration: 0.1s;
  }
}

.dialog-sheet {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
  overflow-y: auto;
}

.dialog-sheet.is-compact {
  max-inline-size: 540px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.dialog-eyebrow {
  font-family: "PelicanMono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--brass-bright);
  margin-bottom: 3px;
}

.dialog-header h2 {
  font-family: "PelicanSerif", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  font-size: clamp(1.20rem, 1.02rem + 0.8vw, 1.65rem);
  color: #fff8eb;
}

.dialog-close-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream-text);
  border: 1px solid rgba(212, 163, 115, 0.28);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.dialog-sub {
  font-size: 13.5px;
  color: var(--muted-text);
}

.dialog-sub strong {
  color: #fde047;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 10px;
}

.stamp-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 11px 12px;
  border-radius: 11px;
  background: #231d17;
  border: 1px solid rgba(212, 163, 115, 0.20);
  text-align: left;
  color: var(--cream-text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.stamp-card:hover {
  transform: translateY(-2px);
  border-color: var(--brass-bright);
}

.stamp-card.is-collected {
  background: linear-gradient(155deg, rgba(56, 44, 28, 0.92) 0%, rgba(30, 24, 18, 0.96) 100%);
  border-color: rgba(250, 204, 21, 0.52);
}

.stamp-card-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.stamp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-weight: 800;
  font-size: 15px;
}

.stamp-era-name {
  font-family: "PelicanSerif", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  font-weight: 700;
  font-size: 14.5px;
  color: #fdf6e7;
}

.stamp-seal-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #fde047;
}

.stamp-card:not(.is-collected) .stamp-seal-title {
  color: #8c8273;
}

.stamp-lore {
  font-size: 12px;
  line-height: 1.45;
  color: #c8bca8;
}

.dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(212, 163, 115, 0.16);
}

.subtle-danger-btn {
  background: transparent;
  color: #bca995;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 12.5px;
  cursor: pointer;
}

.subtle-danger-btn:hover {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.45);
}

.finale-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.finale-stat-card {
  background: #241d17;
  border: 1px solid rgba(212, 163, 115, 0.25);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-num {
  font-family: "PelicanMono", monospace;
  font-size: 24px;
  font-weight: 800;
  color: #fde047;
}

.stat-lbl {
  font-size: 12.5px;
  color: var(--muted-text);
}

.finale-note {
  font-size: 13.5px;
  line-height: 1.55;
  color: #dfd4c0;
}

.finale-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ext-pill {
  flex: 1;
  min-inline-size: 160px;
  text-align: center;
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
}

.ext-pill.is-douyin {
  background: #fe2c55;
}

.ext-pill.is-wechat {
  background: #07c160;
}

/* ============================================================================
 * 7. Mobile Portrait & Mobile Landscape Ergonomic Adaptations
 * ============================================================================ */
@media (pointer: coarse) {
  .is-desktop-only {
    display: none;
  }
  .hud-icon-round {
    width: 44px;
    height: 44px;
  }
}

/* Portrait Phone (`<= 760px`) */
@media (max-width: 760px) {
  #audio-status,
  #volume-slider,
  #btn-fullscreen,
  .is-desktop-only,
  #btn-inspect-zoom {
    display: none;
  }

  #game-floating-hud {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .game-hud-row-main {
    gap: 6px;
  }

  .hud-capsule {
    padding: 3px 5px;
    gap: 4px;
  }

  .gmp-btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  .hud-stat-btn {
    padding: 4px 7px;
    font-size: 12px;
    gap: 4px;
  }

  /* Stage Map drops neatly to a slim centered floating pill below the corner capsules */
  .stage-map-capsule {
    order: 3;
    margin-inline: auto;
    padding: 3px 12px;
  }

  .stage-era-name {
    font-size: 12.5px;
  }

  .stage-progress-rail {
    width: 112px;
  }

  .joy-base {
    left: max(16px, calc(env(safe-area-inset-left, 0px) + 12px));
    bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 14px));
    width: 110px;
    height: 110px;
  }

  .joy-stick {
    width: 48px;
    height: 48px;
  }

  #action-wheel {
    right: max(14px, calc(env(safe-area-inset-right, 0px) + 10px));
    bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 14px));
    width: 174px;
    height: 168px;
  }

  .skill-circle.is-jump-main {
    width: 78px;
    height: 78px;
  }

  .skill-circle.is-spectacle {
    right: 96px;
    bottom: 2px;
    width: 60px;
    height: 60px;
  }

  .skill-circle.is-boost {
    right: 10px;
    bottom: 94px;
    width: 58px;
    height: 58px;
  }
}

/* Mobile Landscape (`max-height: 500px`) */
@media (max-height: 500px) {
  #game-floating-hud {
    padding-top: max(6px, env(safe-area-inset-top, 0px));
  }

  .joy-base {
    bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    width: 102px;
    height: 102px;
  }

  .joy-stick {
    width: 44px;
    height: 44px;
  }

  #action-wheel {
    bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    transform-origin: bottom right;
    transform: scale(0.90);
  }
}
