/* ==========================================================================
   《我的爷爷是局长》3D 开放城区版 HUD 与电影级叙事界面样式 (game3d.css)
   ========================================================================== */

:root {
  --ink-bg: rgba(12, 24, 20, 0.84);
  --ink-panel: rgba(18, 36, 30, 0.92);
  --paper-cream: #fbf7ec;
  --brass: #d4a857;
  --brass-light: #f3d28c;
  --red-seal: #b91c1c;
  --jade: #229966;
  --text-main: #f5f2e9;
  --text-sub: #b7c7bf;
  --border-gold: rgba(212, 168, 87, 0.38);
  --shadow-hud: 0 10px 30px rgba(0, 0, 0, 0.52);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1713;
  color: var(--text-main);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  user-select: none;
}

#viewport3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

/* ---------- 顶部紧凑型政务态势 HUD ---------- */
.hud-top {
  position: fixed;
  top: 0.7rem;
  left: 0.85rem;
  right: 0.85rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  pointer-events: none;
  z-index: 15;
}

.hud-top > * {
  pointer-events: auto;
}

/* 左上：雷达小地图 + 当前所处位置 */
.minimap-card {
  background: var(--ink-bg);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--border-gold);
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: var(--shadow-hud);
  width: 196px;
  flex-shrink: 0;
}

#minimapCanvas {
  display: block;
  width: 178px;
  height: 136px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #142822;
}

.loc-badge {
  margin-top: 0.38rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--brass-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 中上：城市六维指标条 + 当前任务追踪罗盘 */
.center-hud-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.48rem;
  max-width: 820px;
  flex: 1;
}

.metrics-bar {
  background: var(--ink-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 0.42rem 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-hud);
}

.game-main-heading {
  margin: 0;
  font-size: 0.92rem;
  color: var(--brass-light);
  padding-right: 0.55rem;
  border-right: 1px solid rgba(212, 168, 87, 0.3);
  white-space: nowrap;
}

.metric-chip {
  display: flex;
  flex-direction: column;
  min-width: 74px;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-sub);
  gap: 0.3rem;
}

.metric-num {
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
}

.hud-meter {
  height: 3.5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  margin-top: 2px;
  overflow: hidden;
}

.hud-meter-fill {
  height: 100%;
  width: calc(var(--pct, 50) * 1%);
  background-color: hsl(var(--hue, 145) 70% 50%);
  transition: width 0.3s ease;
}

/* 任务罗盘追踪条 */
.quest-tracker {
  background: linear-gradient(90deg, rgba(127, 29, 29, 0.88), rgba(20, 42, 35, 0.9));
  border: 1px solid var(--brass);
  border-radius: 999px;
  padding: 0.32rem 0.5rem 0.32rem 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-hud);
  font-size: 0.82rem;
}

.quest-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 10px #fbbf24;
  flex-shrink: 0;
}

.quest-dist {
  color: #fde68a;
  font-weight: 700;
  font-size: 0.76rem;
}

/* 右上：快捷政务包按钮组 */
.quick-btns {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.btn-row {
  display: flex;
  gap: 0.38rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-row-center {
  justify-content: center;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.hud-btn {
  background: var(--ink-panel);
  color: var(--text-main);
  border: 1px solid var(--border-gold);
  border-radius: 7px;
  padding: 0.4rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
}

.hud-btn:hover:not(:disabled) {
  background: #244a3e;
  border-color: var(--brass-light);
}

.hud-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.hud-btn-gold {
  background: linear-gradient(180deg, #b88738 0%, #8a5f1d 100%);
  border-color: #f6d58e;
  color: #fffbeb;
}

.hud-btn-red {
  background: linear-gradient(180deg, #b91c1c 0%, #7f1d1d 100%);
  border-color: #fca5a5;
  color: #fff;
}

.hud-btn-pill {
  border-radius: 999px;
  padding: 0.24rem 0.68rem;
  font-size: 0.74rem;
}

/* ---------- 屏幕中央近距离 3D 交互提示条 ---------- */
.interact-prompt {
  position: fixed;
  left: 50%;
  bottom: 24%;
  transform: translateX(-50%);
  background: rgba(15, 29, 24, 0.92);
  border: 1.5px solid var(--brass-light);
  border-radius: 999px;
  padding: 0.48rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6);
  z-index: 16;
  font-size: 0.9rem;
  font-weight: 700;
}

.interact-prompt[hidden] {
  display: none;
}

.key-badge {
  background: var(--brass-light);
  color: #1c1917;
  font-weight: 900;
  padding: 0.1rem 0.48rem;
  border-radius: 5px;
  font-size: 0.82rem;
}

/* 头顶市民闲谈飘字 Toast */
.speech-toast {
  position: fixed;
  left: 50%;
  top: 21%;
  transform: translateX(-50%);
  background: rgba(251, 247, 236, 0.96);
  color: #1c1917;
  border: 2px solid #92400e;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  max-width: 520px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-hud);
  z-index: 18;
}

.speech-toast[hidden] {
  display: none;
}

/* ---------- 底部操作键位轻提示与实时纪事滚动条 ---------- */
.hud-bottom {
  position: fixed;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 14;
}

.hud-bottom[hidden] {
  display: none;
}

.controls-legend {
  background: rgba(10, 20, 17, 0.76);
  border: 1px solid rgba(212, 168, 87, 0.25);
  border-radius: 8px;
  padding: 0.36rem 0.72rem;
  font-size: 0.74rem;
  color: var(--text-sub);
}

.mini-log-box {
  background: rgba(10, 20, 17, 0.78);
  border: 1px solid rgba(212, 168, 87, 0.25);
  border-radius: 8px;
  padding: 0.38rem 0.75rem;
  max-width: 460px;
  font-size: 0.75rem;
  color: #fde68a;
  text-align: right;
}

/* ---------- 电影感人物对话与红头签批浮层 ---------- */
.cinema-dialogue {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  width: min(820px, calc(100% - 2rem));
  background: linear-gradient(180deg, rgba(16, 32, 27, 0.96) 0%, rgba(10, 20, 17, 0.98) 100%);
  border: 2px solid var(--brass);
  border-radius: 12px;
  padding: 1.15rem 1.4rem;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.8);
  z-index: 25;
}

.cinema-dialogue[hidden] {
  display: none;
}

.dlg-speaker-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}

.dlg-speaker-name {
  background: var(--red-seal);
  color: #fde68a;
  padding: 0.18rem 0.75rem;
  border-radius: 5px;
  font-weight: 800;
  font-size: 0.9rem;
}

.dlg-line-text {
  font-size: 1.02rem;
  line-height: 1.68;
  color: #fffbeb;
  margin: 0.4rem 0 0.9rem;
  min-height: 2.8em;
}

.dlg-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dlg-choice-btn {
  text-align: left;
  background: var(--paper-cream);
  color: #1c1917;
  border: 1px solid #cbbba0;
  border-left: 5px solid var(--red-seal);
  border-radius: 6px;
  padding: 0.65rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 700;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.dlg-choice-btn.choice-private {
  border-left-color: #7c2d12;
  background: #fef3c7;
}

.dlg-choice-btn:hover:not(:disabled) {
  transform: translateX(4px);
  background: #ffffff;
}

.stamp-badge {
  display: inline-block;
  border: 3px solid #dc2626;
  color: #dc2626;
  padding: 0.18rem 0.6rem;
  font-weight: 900;
  transform: rotate(-6deg);
  margin-right: 0.6rem;
}

/* ---------- 开场电影序幕遮罩 ---------- */
.intro-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(14, 30, 24, 0.72) 0%, rgba(5, 11, 9, 0.94) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 40;
  text-align: center;
}

.intro-overlay[hidden] {
  display: none;
}

.intro-card {
  max-width: 680px;
  background: rgba(16, 33, 27, 0.92);
  border: 2px solid var(--brass);
  border-radius: 14px;
  padding: 2rem 2.2rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85);
}

.intro-title {
  margin: 0 0 0.3rem;
  font-size: 2rem;
  color: var(--brass-light);
  letter-spacing: 0.08em;
}

.intro-subtitle {
  margin: 0 0 1.3rem;
  font-size: 0.95rem;
  color: var(--text-sub);
}

.intro-story-p {
  font-size: 1.06rem;
  line-height: 1.8;
  color: #fef3c7;
  min-height: 4.5em;
  margin-bottom: 1.5rem;
}

/* ---------- 现代原生 Dialog 与 Top-Layer 平滑进出场动画 ---------- */
dialog {
  background: var(--ink-panel);
  color: var(--text-main);
  border: 2px solid var(--brass);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  max-width: 720px;
  width: calc(100% - 2rem);
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.82);
  opacity: 0;
  transform: scale(0.94);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(3px);
  transition-property: background-color, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

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

  @starting-style {
    opacity: 0;
    transform: scale(0.94);
  }

  &::backdrop {
    background-color: rgba(0, 0, 0, 0.62);

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

@media (prefers-reduced-motion: reduce) {
  dialog {
    transform: none;
    transition-duration: 0.08s;
  }

  @starting-style {
    dialog[open] {
      transform: none;
    }
  }
}

.dlg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-gold);
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
}

.dlg-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--brass-light);
}

.card-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.item-row {
  background: rgba(10, 20, 17, 0.72);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.item-title {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  color: var(--brass-light);
}

.item-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-sub);
  line-height: 1.45;
}

.section-subhead {
  margin: 0.9rem 0 0.45rem;
  font-size: 0.92rem;
  color: #fde68a;
}

.archive-fold {
  background: rgba(10, 20, 17, 0.72);
  border: 1px solid var(--border-gold);
  border-radius: 7px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.45rem;
}

.archive-fold summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brass-light);
  font-size: 0.86rem;
}

.archive-fold p {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-main);
}

.epigram-quote {
  margin: 0.9rem 0;
  padding: 0.75rem 1rem;
  background: rgba(212, 168, 87, 0.14);
  border-left: 4px solid var(--brass-light);
  color: #fde68a;
  font-style: italic;
}
