:root {
  --ink: #0b0e14;
  --ink-panel: rgba(11, 14, 21, 0.62);
  --ink-deep: rgba(9, 12, 18, 0.74);
  --gold: #d4af6a;
  --gold-bright: #f2d598;
  --gold-dim: rgba(212, 175, 106, 0.32);
  --cinnabar: #9e2a2b;
  --cinnabar-glow: #c83b3b;
  --celadon: #3b726b;
  --celadon-light: #71b5ac;
  --paper: #f3ebdc;
  --paper-muted: #c8bfb0;
  --serif: "Noto Serif TC", "Songti TC", "Songti SC", "STSong", "Source Han Serif SC", "SimSun", Georgia, serif;
  --sans: "Noto Sans TC", "PingFang TC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* 3D WebGL2 Canvas */
#viewport {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cinema-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 48%, rgba(6, 8, 12, 0.68) 100%),
    linear-gradient(180deg, rgba(8, 10, 15, 0.55) 0%, transparent 18%, transparent 74%, rgba(8, 10, 15, 0.82) 100%);
}

/* 3D Projected Hotspots */
#hotspot-layer {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.hotspot-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 19, 27, 0.88);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(212, 175, 106, 0.38);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.hotspot-pin::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 10px var(--gold-bright);
  animation: pulseDot 1.8s infinite;
}

.hotspot-pin.checked {
  border-color: var(--celadon-light);
  color: #c8f5ec;
  background: rgba(25, 58, 54, 0.9);
}

.hotspot-pin.checked::before {
  background: var(--celadon-light);
  animation: none;
}

.hotspot-pin:hover {
  transform: translate(-50%, -50%) scale(1.06);
  background: rgba(34, 24, 18, 0.96);
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.45; }
}

/* Top HUD */
.top-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(10, 13, 20, 0.9) 0%, rgba(10, 13, 20, 0.45) 75%, transparent 100%);
  border-bottom: 1px solid rgba(212, 175, 106, 0.16);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seal-chip {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--cinnabar);
  border: 1.5px solid var(--gold);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 4px 16px rgba(158, 42, 43, 0.45);
}

.brand-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gold-bright);
}

.brand-sub {
  font-size: 12px;
  color: var(--paper-muted);
}

.judge-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 18, 26, 0.78);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  backdrop-filter: blur(10px);
}

.judge-nav-label {
  font-size: 11px;
  color: var(--gold);
  padding: 0 6px;
  letter-spacing: 1px;
  border-right: 1px solid var(--gold-dim);
}

.nav-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--paper-muted);
  font-family: var(--sans);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-pill:hover {
  color: var(--paper);
  border-color: var(--gold-dim);
}

.nav-pill.active {
  background: rgba(158, 42, 43, 0.82);
  border-color: var(--gold);
  color: var(--paper);
  font-weight: 600;
}

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

.trust-meter {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(20, 25, 34, 0.85);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  font-size: 12px;
  color: var(--paper-muted);
}

.trust-meter strong {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--gold-bright);
}

.icon-btn {
  background: rgba(18, 22, 31, 0.85);
  border: 1px solid var(--gold-dim);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--gold);
  background: rgba(42, 32, 22, 0.92);
}

/* Frameless Cinema Title Screen — ZERO opaque box covering the 3D Ming Hall! */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 28px 24px 26px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(8, 10, 15, 0.12) 0%, rgba(7, 9, 14, 0.42) 68%, rgba(6, 8, 12, 0.72) 100%),
    linear-gradient(180deg, rgba(8, 10, 14, 0.18) 0%, transparent 32%, rgba(8, 10, 14, 0.56) 72%, rgba(7, 9, 14, 0.84) 100%);
}

.title-card {
  max-width: 740px;
  width: 100%;
  text-align: center;
  padding: 12px 20px 18px;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  margin-bottom: 18px;
}

.title-kicker {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 2.4px;
  color: var(--gold-bright);
  padding: 5px 16px;
  border: 1px solid rgba(212, 175, 106, 0.48);
  background: rgba(18, 12, 12, 0.52);
  backdrop-filter: blur(6px);
  margin-bottom: 16px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
}

.title-logo {
  font-family: var(--serif);
  font-size: clamp(46px, 6.8vw, 76px);
  font-weight: 900;
  letter-spacing: 16px;
  padding-left: 16px;
  color: #faf3e4;
  text-shadow: 0 6px 34px rgba(0, 0, 0, 0.92), 0 0 42px rgba(212, 175, 106, 0.36);
  margin-bottom: 8px;
}

.title-en {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 3.4px;
  color: var(--gold-bright);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
  margin-bottom: 16px;
}

.title-desc {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.85;
  color: #f0e8da;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.95), 0 1px 4px rgba(0, 0, 0, 0.9);
  margin-bottom: 24px;
}

.title-cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #a62b2c 0%, #7d1b1d 100%);
  border: 1px solid var(--gold);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 12px 26px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(158, 42, 43, 0.48);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(212, 175, 106, 0.35);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(18, 23, 32, 0.82);
  border: 1px solid var(--gold-dim);
  color: var(--gold-bright);
  font-family: var(--sans);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--gold);
  background: rgba(34, 28, 22, 0.92);
}

.btn-primary.small, .btn-secondary.small {
  padding: 8px 16px;
  font-size: 13px;
}

.title-tech-strip {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: #ddd2be;
  padding: 7px 16px;
  background: rgba(10, 13, 20, 0.52);
  border: 1px solid rgba(212, 175, 106, 0.24);
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

/* Unified Zero-Occlusion Stage Panels (Docked to Right Rail or Slim Top Ribbon!) */
.stage-panel {
  position: fixed;
  top: 68px;
  left: auto;
  right: 20px;
  transform: none;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 238px);
  overflow-y: auto;
  z-index: 12;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 106, 0.45) rgba(12, 16, 24, 0.45);
}

.stage-panel::-webkit-scrollbar {
  width: 5px;
}
.stage-panel::-webkit-scrollbar-track {
  background: rgba(10, 13, 20, 0.4);
}
.stage-panel::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 106, 0.48);
  border-radius: 3px;
}

.stage-panel.ch1-mode {
  width: min(336px, calc(100vw - 24px));
}

.stage-panel.crown-mode {
  width: min(344px, calc(100vw - 24px));
}

.stage-panel.ch3-mode {
  width: min(388px, calc(100vw - 24px));
}

.stage-panel.epilogue-mode {
  width: min(592px, calc(100vw - 24px));
}

/* Chapter 2A Open 3D Spatial Seating Mode — ZERO center screen blocking! */
.stage-panel.seat-mode {
  top: 66px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  max-height: none;
  overflow: visible;
  pointer-events: none;
}

.seat-ribbon {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 16px;
  background: rgba(10, 13, 20, 0.62);
  border: 1px solid rgba(212, 175, 106, 0.36);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.seat-ribbon-main {
  font-size: 13px;
  color: #efe5d5;
  line-height: 1.5;
}

.seat-ribbon-main strong {
  font-family: var(--serif);
  color: var(--gold-bright);
  margin-right: 6px;
}

.seat-compass-pill {
  flex-shrink: 0;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--gold-bright);
  padding: 4px 12px;
  border: 1px solid var(--gold-dim);
  background: rgba(24, 20, 16, 0.78);
  white-space: nowrap;
}

/* 3D-Anchored Spatial Seat Cards floating cleanly over East/West 3D Daises */
.seat-anchor-card {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  width: 224px;
  padding: 12px 14px;
  text-align: center;
  background: rgba(12, 15, 22, 0.84);
  border: 1.5px solid rgba(212, 175, 106, 0.52);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  color: var(--paper);
  transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.seat-anchor-card:hover {
  transform: translate(-50%, -104%) scale(1.03);
  border-color: var(--gold-bright);
  box-shadow: 0 14px 36px rgba(212, 175, 106, 0.28);
}

.seat-anchor-card.role-host {
  border-color: var(--cinnabar-glow);
  background: rgba(68, 18, 20, 0.86);
  box-shadow: 0 0 28px rgba(200, 59, 59, 0.42);
}

.seat-anchor-card.role-guest {
  border-color: var(--celadon-light);
  background: rgba(18, 48, 45, 0.86);
  box-shadow: 0 0 24px rgba(113, 181, 172, 0.34);
}

.seat-anchor-card.verified {
  border-color: var(--gold-bright);
  box-shadow: 0 0 32px rgba(242, 213, 152, 0.48);
}

.seat-anchor-dir {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.seat-anchor-role {
  display: inline-block;
  padding: 4px 10px;
  margin: 4px 0 6px;
  border-radius: 3px;
  background: rgba(10, 12, 18, 0.65);
  border: 1px solid rgba(212, 175, 106, 0.35);
  font-family: var(--serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--paper);
}

.seat-anchor-hint {
  font-size: 11px;
  color: var(--paper-muted);
}

.seat-float-actions {
  position: fixed;
  bottom: 184px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.seat-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: rgba(10, 13, 20, 0.72);
  border: 1px solid rgba(212, 175, 106, 0.42);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Unified Translucent Palace Museum Glass Side Rail */
.stage-card {
  background: var(--ink-panel);
  border: 1px solid rgba(212, 175, 106, 0.34);
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.48);
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.stage-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 1px;
}

.stage-instruction {
  font-size: 12.5px;
  color: #dfd6c6;
  line-height: 1.55;
  margin-bottom: 11px;
}

/* 3D-Projected Ming Seal Inspection Pins for Chapter 1 Scroll Stand */
.scroll-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1.5px solid #ff6b66;
  background: rgba(126, 24, 24, 0.86);
  color: #fff6ec;
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 5px rgba(255, 94, 91, 0.22), 0 6px 24px rgba(0, 0, 0, 0.6);
  animation: anomalyPulse 1.8s infinite;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

.scroll-pin:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

.scroll-pin-seal {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #b92c2a;
  border: 1px solid #ffd8a0;
  font-size: 13px;
  font-weight: 900;
}

.scroll-pin.fixed {
  border-color: var(--celadon-light);
  background: rgba(24, 62, 58, 0.88);
  color: #daf8f2;
  box-shadow: 0 0 18px rgba(113, 181, 172, 0.55);
  animation: none;
}

.scroll-pin.fixed .scroll-pin-seal {
  background: var(--celadon);
  border-color: #b8f2e8;
}

/* Subtle Floating Museum Plaque below the 3D Exhibition Stand (Ch1 & Ch3) */
.scroll-plaque {
  position: fixed;
  bottom: 186px;
  left: 36%;
  transform: translateX(-50%);
  z-index: 9;
  pointer-events: none;
  padding: 5px 14px;
  background: rgba(10, 13, 20, 0.62);
  border: 1px solid rgba(212, 175, 106, 0.34);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-family: var(--serif);
  font-size: 12px;
  color: var(--gold-bright);
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

@keyframes anomalyPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 94, 91, 0.24), 0 0 20px rgba(255, 94, 91, 0.55); }
  50% { box-shadow: 0 0 0 11px rgba(255, 94, 91, 0.04), 0 0 28px rgba(255, 94, 91, 0.82); }
}

.audit-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.audit-item {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  background: rgba(16, 20, 30, 0.64);
  border: 1px solid rgba(212, 175, 106, 0.28);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  color: var(--paper-muted);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.audit-item:hover {
  border-color: var(--gold-bright);
  background: rgba(34, 24, 20, 0.72);
}

.audit-item.fixed {
  border-color: var(--celadon-light);
  background: rgba(24, 54, 50, 0.48);
  color: #dff7f2;
}

.audit-item strong {
  display: block;
  color: var(--gold-bright);
  margin-bottom: 3px;
  font-family: var(--serif);
  font-size: 13px;
}

.feedback-banner {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.55;
  margin-top: 6px;
}

.feedback-banner.ok {
  background: rgba(28, 68, 62, 0.72);
  border: 1px solid var(--celadon-light);
  color: #dcf7f1;
}

.feedback-banner.warn {
  background: rgba(124, 34, 30, 0.78);
  border: 1px solid #e67c73;
  color: #ffe3df;
}

/* Chapter 2B Crown 3D Card */
.crown-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.crown-step {
  padding: 9px 11px;
  border: 1px solid rgba(212, 175, 106, 0.30);
  background: rgba(16, 20, 30, 0.64);
  cursor: pointer;
  text-align: left;
  color: var(--paper);
  transition: all 0.2s ease;
}

.crown-step:hover {
  border-color: var(--gold-bright);
}

.crown-step.checked {
  border-color: var(--celadon-light);
  background: rgba(24, 58, 54, 0.54);
}

.crown-step strong {
  display: block;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--gold-bright);
  margin-bottom: 3px;
}

.crown-step span {
  font-size: 12px;
  color: var(--paper-muted);
  line-height: 1.45;
  display: block;
}

/* Chapter 3 Sleek Right-Docked Live LLM Chat Rail (3D Xiancanli Painting Stands Open on Left!) */
.quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.quick-chip {
  text-align: left;
  padding: 6px 10px;
  background: rgba(16, 20, 30, 0.66);
  border: 1px solid rgba(212, 175, 106, 0.28);
  color: #e6ddce;
  font-size: 11.5px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.18s ease;
}

.quick-chip:hover {
  border-color: var(--gold-bright);
  background: rgba(45, 32, 24, 0.82);
}

.llm-input-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.llm-textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  background: rgba(8, 11, 16, 0.78);
  border: 1px solid rgba(212, 175, 106, 0.34);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.48;
  resize: vertical;
}

.llm-textarea:focus {
  outline: none;
  border-color: var(--gold-bright);
}

.llm-result-box {
  margin-top: 8px;
  padding: 9px 11px;
  background: rgba(22, 42, 40, 0.62);
  border: 1px solid var(--celadon-light);
}

.verdict-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.verdict-tag {
  background: var(--cinnabar);
  border: 1px solid var(--gold);
  padding: 2px 9px;
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--paper);
  white-space: nowrap;
  flex-shrink: 0;
}

.tier-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--celadon-light);
  text-align: right;
}

/* Epilogue Scroll Card */
.epilogue-grid {
  display: grid;
  grid-template-columns: 244px 1fr;
  gap: 16px;
  align-items: center;
}

.scroll-preview {
  width: 100%;
  border: 1px solid var(--gold);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65);
  display: block;
}

.epilogue-info h3 {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--gold-bright);
  margin-bottom: 7px;
}

.epilogue-info p {
  font-size: 12.5px;
  line-height: 1.65;
  color: #dfd6c7;
  margin-bottom: 11px;
}

.epilogue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Sleeker Translucent Bottom Ming Portrait + Dialogue Dock */
.dialogue-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 32px));
  z-index: 16;
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 14px;
  align-items: end;
  background: var(--ink-deep);
  border: 1px solid rgba(212, 175, 106, 0.36);
  padding: 9px 16px 11px 10px;
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.62);
}

.portrait-frame {
  position: relative;
  width: 116px;
  height: 144px;
  margin-top: -26px;
  border: 1.5px solid var(--gold);
  overflow: hidden;
  background: #12171e;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6);
  transition: box-shadow 0.3s ease;
}

.portrait-frame.speaking {
  box-shadow: 0 0 24px rgba(212, 175, 106, 0.55);
}

.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.portrait-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 5px 6px;
  background: linear-gradient(180deg, transparent, rgba(8, 10, 14, 0.94));
  text-align: center;
}

.npc-name {
  display: block;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 3px;
}

.npc-role {
  display: block;
  font-size: 9.5px;
  white-space: nowrap;
  color: var(--paper-muted);
}

.dialogue-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialogue-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-pill {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--gold-bright);
  padding: 2px 9px;
  border: 1px solid var(--gold-dim);
  background: rgba(158, 42, 43, 0.32);
}

.voice-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--paper-muted);
}

.wave-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.wave-bars i {
  display: block;
  width: 2.5px;
  height: 4px;
  background: var(--gold);
  transition: height 0.15s ease;
}

.voice-indicator.active .wave-bars i:nth-child(1) { animation: wave 0.55s infinite 0.0s; }
.voice-indicator.active .wave-bars i:nth-child(2) { animation: wave 0.55s infinite 0.12s; }
.voice-indicator.active .wave-bars i:nth-child(3) { animation: wave 0.55s infinite 0.24s; }
.voice-indicator.active .wave-bars i:nth-child(4) { animation: wave 0.55s infinite 0.36s; }

@keyframes wave {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}

.mini-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold-bright);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.dialogue-text {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.62;
  color: var(--paper);
  min-height: 36px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.dialogue-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* AI Settings Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(700px, 100%);
  background: #11151f;
  border: 1px solid var(--gold);
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.modal-head h2 {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--gold-bright);
}

.modal-sub {
  font-size: 12px;
  color: var(--paper-muted);
  margin-top: 3px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.field-row select {
  flex: 1;
  background: #0b0e14;
  border: 1px solid var(--gold-dim);
  color: var(--paper);
  padding: 7px 10px;
  font-size: 13px;
}

.tier-box {
  padding: 12px;
  background: rgba(18, 23, 33, 0.8);
  border: 1px solid rgba(212, 175, 106, 0.24);
  margin-bottom: 12px;
}

.tier3-box p {
  font-size: 12px;
  color: var(--paper-muted);
  line-height: 1.55;
}

.tier-title {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gold-bright);
  margin-bottom: 8px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1.4fr 1.1fr 0.9fr;
  gap: 8px;
}

.grid-3 input {
  background: #0b0e14;
  border: 1px solid var(--gold-dim);
  color: var(--paper);
  padding: 7px 9px;
  font-size: 12px;
  font-family: var(--mono);
}

.probe-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.probe-result {
  font-size: 12px;
  color: var(--celadon-light);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Telemetry Strip (SKYREND signature) */
.telemetry-hud {
  position: fixed;
  left: 14px;
  bottom: 6px;
  z-index: 25;
  display: flex;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(212, 175, 106, 0.68);
  pointer-events: none;
}

@media (max-width: 820px) {
  .judge-nav { display: none; }
  .epilogue-grid, .grid-3 { grid-template-columns: 1fr; }
  .dialogue-dock { grid-template-columns: 80px 1fr; bottom: 10px; }
  .portrait-frame { width: 80px; height: 104px; margin-top: -14px; }
  .stage-panel,
  .stage-panel.ch1-mode,
  .stage-panel.crown-mode,
  .stage-panel.ch3-mode,
  .stage-panel.epilogue-mode {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100vw - 24px);
  }
  .scroll-plaque { left: 50%; max-width: calc(100vw - 28px); white-space: normal; text-align: center; }
}
