/* ==========================================================================
   1. ROOT VARIABLES & THEME FOUNDATIONS
   ========================================================================== */
:root {
  /* Typography Scale */
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-hud: 'Share Tech Mono', monospace; /* Specific for Game HUD */
  
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Spacing System */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 4rem;

  /* Global Radius & Transitions */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --ease-spring: cubic-bezier(.4, 1.4, .6, 1);
  --ease-smooth: 150ms ease-out;
}

/* THEME: DASHBOARD (Default - Dark/Tech) */
:root, body[data-theme="dashboard"] {
  --bg-app: #0b1020;
  --bg-surface: #151a2b;
  --bg-surface-alt: #1f2436;
  --bg-overlay: rgba(5, 8, 20, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-main: #f5f7ff;
  --text-muted: #a9b1d0;
  --text-invert: #050814;

  --color-primary: #4fd1c5; /* Teal */
  --color-primary-glow: rgba(79, 209, 197, 0.35);
  --color-danger: #f56565;
  --color-success: #48bb78;
  
  --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.45);
}

/* THEME: GAME (Fantasy/Paper/Neon) */
body[data-theme="game"] {
  --bg-app: #050a10;
  --bg-surface: rgba(10, 15, 25, 0.85);
  --bg-surface-alt: rgba(0, 0, 0, 0.2);
  --bg-overlay: rgba(0, 0, 0, 0.75);

  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);

  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --text-invert: #050814;

  --color-primary: #00f3ff;
  --color-primary-glow: rgba(0, 243, 255, 0.35);
  --color-danger: #ef4444;
  --color-success: #22c55e;

  /* Shared game UI tokens */
  --neon-blue: #00f3ff;
  --neon-orange: #ff9d00;
  --glass-bg: rgba(10, 15, 25, 0.85);
  --glass-border: 1px solid rgba(255, 255, 255, 0.15);
  --font-body: 'Rajdhani', sans-serif;
}

/* ==========================================================================
   PERSONA TOASTS (Trigger System)
   ========================================================================== */
.persona-toast-container {
  position: fixed;
  right: var(--space-lg, 1.5rem);
  bottom: calc(72px + var(--space-lg, 1.5rem));
  z-index: 1050;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 0.5rem);
  pointer-events: none;
}

.persona-toast {
  pointer-events: auto;
  width: 320px;
  max-width: calc(100vw - 2rem);
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-surface, rgba(10, 15, 25, 0.85));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  border-left: 3px solid var(--color-primary, #00f3ff);
  color: var(--text-main, #fff);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  text-align: left;
  cursor: pointer;
  transform: translateY(6px);
  opacity: 0;
  animation: personaToastIn 160ms var(--ease-smooth, ease-out) forwards;
}

.persona-toast.is-hiding {
  animation: personaToastOut 180ms var(--ease-smooth, ease-out) forwards;
}

.persona-toast__avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.2));
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.persona-toast__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.persona-toast__avatar-fallback {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--color-primary, #00f3ff);
  box-shadow: 0 0 12px var(--color-primary-glow, rgba(0, 243, 255, 0.35));
}

.persona-toast__content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.persona-toast__name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.1;
}

.persona-toast__message {
  font-size: 0.85rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.persona-toast__cta {
  font-size: 0.75rem;
  color: var(--color-primary, #00f3ff);
}

@keyframes personaToastIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes personaToastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(6px); }
}

/* ==========================================================================
   2. GAME CONTROLLER FOOTER (HUD)
   ========================================================================== */
.game-controller-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 1040;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  background: rgba(33, 37, 41, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4), 0 -2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 180ms ease, height 180ms ease;
}

/* Alert dot for footer/advisor buttons */
.game-btn--has-dot {
  position: relative;
}

.game-footer__alert-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--color-danger, #ef4444);
  box-shadow: 0 0 0 2px rgba(5, 10, 16, 0.9), 0 0 12px rgba(239, 68, 68, 0.25);
}

.game-controller-footer.footer-minimized {
  transform: translateY(65%);
}

.game-footer__deck,
.footer-section-left,
.footer-section-center,
.footer-section-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
}

.game-footer__deck--left, .footer-section-left { justify-content: flex-start; flex: 0 0 30%; }
.game-footer__deck--center, .footer-section-center { justify-content: center; flex: 1 1 auto; }
.game-footer__deck--right, .footer-section-right { justify-content: flex-end; flex: 0 0 30%; }

@media (max-width: 1100px) {
  .hud-timer { padding: 0.35rem 0.45rem; gap: 0.35rem; }
  .hud-timer__label { display: none; }
  .game-footer__phase { display: none; }
}

/* ==========================================================================
   3. BUTTONS & INTERACTIVE ELEMENTS
   ========================================================================== */
.game-btn {
  border: none;
  background: transparent;
  color: #ecf0f1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md, 12px);
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  font-weight: 600;
}

.game-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.game-btn:active { transform: translateY(1px); }

/* --------------------------------------------------------------------------
   DASHBOARD: STAT CARDS & RADIAL PROGRESS
   -------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg, 16px);
  background: linear-gradient(145deg, rgba(21, 26, 43, 0.8), rgba(17, 21, 34, 0.9));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.05), transparent 45%);
  pointer-events: none;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  flex-shrink: 0;
}

.stat-card .stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-card .stat-info h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main, #f5f7ff);
}

.stat-card .stat-info span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted, #a9b1d0);
  font-weight: 600;
}

.radial-progress {
  width: 82px;
  height: 82px;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  flex-shrink: 0;
}

.radial-progress circle {
  fill: transparent;
  stroke-width: 8px;
  stroke-linecap: round;
}

.radial-progress .radial-track {
  stroke: rgba(255, 255, 255, 0.08);
}

.radial-progress .radial-fill {
  stroke: var(--color-primary, #4fd1c5);
  stroke-dasharray: 0 999;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 900ms ease-out;
}

.stat-card.stat-finance .radial-fill { stroke: #2ecc71; }
.stat-card.stat-stress .radial-fill { stroke: #f56565; }
.stat-card.stat-social .radial-fill { stroke: #f59e0b; }
.stat-card.stat-legal .radial-fill { stroke: #9b59b6; }
.stat-card.stat-career .radial-fill { stroke: #06b6d4; }

.progress-bar {
  transition: width 0.1s linear;
}

/* --------------------------------------------------------------------------
   DASHBOARD: STAT CARDS & RADIAL PROGRESS
   -------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg, 16px);
  background: linear-gradient(145deg, rgba(21, 26, 43, 0.8), rgba(17, 21, 34, 0.9));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.05), transparent 45%);
  pointer-events: none;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  flex-shrink: 0;
}

.stat-card .stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-card .stat-info h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main, #f5f7ff);
}

.stat-card .stat-info span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted, #a9b1d0);
  font-weight: 600;
}

.radial-progress {
  width: 82px;
  height: 82px;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  flex-shrink: 0;
}

.radial-progress circle {
  fill: transparent;
  stroke-width: 8px;
  stroke-linecap: round;
}

.radial-progress .radial-track {
  stroke: rgba(255, 255, 255, 0.08);
}

.radial-progress .radial-fill {
  stroke: var(--color-primary, #4fd1c5);
  stroke-dasharray: 0 999;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 900ms ease-out;
}

.stat-card.stat-finance .radial-fill { stroke: #2ecc71; }
.stat-card.stat-stress .radial-fill { stroke: #f56565; }
.stat-card.stat-social .radial-fill { stroke: #f59e0b; }
.stat-card.stat-legal .radial-fill { stroke: #9b59b6; }
.stat-card.stat-career .radial-fill { stroke: #06b6d4; }

.progress-bar {
  transition: width 0.1s linear;
}

.game-btn--primary,
.game-btn-main {
  background: linear-gradient(135deg, var(--color-primary, #4fd1c5), var(--neon-orange, #ff9d00));
  color: #0a0e18;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-full, 9999px);
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.35);
  font-weight: 700;
  letter-spacing: 0.4px;
}

.game-btn--primary:hover,
.game-btn-main:hover {
  box-shadow: 0 0 24px rgba(0, 243, 255, 0.45);
}

.btn-pulse {
  animation: pulse-glow 1.6s ease-in-out infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 14px rgba(0, 243, 255, 0.35), 0 0 0 0 rgba(0, 243, 255, 0.2); }
  50% { box-shadow: 0 0 18px rgba(0, 243, 255, 0.55), 0 0 0 6px rgba(0, 243, 255, 0.08); }
  100% { box-shadow: 0 0 14px rgba(0, 243, 255, 0.35), 0 0 0 0 rgba(0, 243, 255, 0.02); }
}

/* ==========================================================================
   4. DASHBOARD: STAT CARDS & RADIALS
   ========================================================================== */
.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg, 16px);
  background: linear-gradient(145deg, rgba(21, 26, 43, 0.8), rgba(17, 21, 34, 0.9));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  flex-shrink: 0;
}

.stat-card.stat-finance .radial-fill { stroke: #2ecc71; }
.stat-card.stat-stress .radial-fill { stroke: #f56565; }
.stat-card.stat-social .radial-fill { stroke: #f59e0b; }
.stat-card.stat-legal .radial-fill { stroke: #9b59b6; }
.stat-card.stat-career .radial-fill { stroke: #06b6d4; }

.radial-progress {
  width: 82px;
  height: 82px;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  flex-shrink: 0;
}

.radial-progress circle {
  fill: transparent;
  stroke-width: 8px;
  stroke-linecap: round;
}

.radial-progress .radial-track { stroke: rgba(255, 255, 255, 0.08); }
.radial-progress .radial-fill {
  stroke: var(--color-primary, #4fd1c5);
  stroke-dasharray: 0 999;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 900ms ease-out;
}

/* ==========================================================================
   5. HUD ELEMENTS: TIMERS & PHASES
   ========================================================================== */
.game-footer__phase {
  font-family: var(--font-hud, 'Share Tech Mono', monospace);
  font-size: var(--text-xs, 0.75rem);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main, #f5f7ff);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hud-timer {
  font-family: var(--font-hud, 'Share Tech Mono', monospace);
  color: var(--text-main, #f5f7ff);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md, 12px);
  padding: 0.35rem 0.6rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: color 0.3s ease, text-shadow 0.3s ease, border-color 0.3s ease;
}

.hud-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-timer__stack {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.hud-timer__label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
}

.hud-timer__value {
  font-weight: 800;
  font-size: 1.25rem;
  font-family: var(--font-hud, ui-monospace, SFMono-Regular, Menlo, monospace);
}

.hud-timer__unit {
  align-self: flex-end;
  margin-bottom: 2px;
  font-size: 0.7rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
}

.timer-warning { color: #f6ad55; border-color: rgba(246, 173, 85, 0.4); }
.timer-danger {
  color: #f56565;
  border-color: rgba(245, 101, 101, 0.65);
  text-shadow: 0 0 5px rgba(245, 101, 101, 0.8);
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}
.anim-shake { animation: shake 0.5s ease; }

/* ==========================================================================
   6. ATMOSPHERE / BACKGROUND FX (Task 16)
   ========================================================================== */
#game-background-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  transition: background 0.6s ease, filter 0.4s ease;
  isolation: isolate;
  pointer-events: none;
}

#game-background-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--scenario-art-image, none);
  background-size: cover;
  background-position: center;
  opacity: var(--scenario-art-opacity, 0.28);
  filter: saturate(1.05) contrast(1.05);
  z-index: 0;
}

#vignette-overlay, #noise-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

#vignette-overlay {
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.7) 80%);
  opacity: 0;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

#vignette-overlay.stress-high { opacity: 0.8; }
#vignette-overlay.stress-panic { opacity: 0.9; filter: blur(2px); }

#noise-overlay {
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 3px 3px;
  opacity: 0.12;
  mix-blend-mode: soft-light;
}

/* Themes */
.bg-theme-neutral { background: linear-gradient(135deg, #0f172a 0%, #0b1224 50%, #0f172a 100%); }
.bg-theme-street_day { background: linear-gradient(160deg, #1f2937 0%, #111827 30%, #1e293b 100%); }
.bg-theme-street_rain {
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 45%, #0b1220 100%),
    repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.05) 0, rgba(255, 255, 255, 0.05) 2px, transparent 2px, transparent 6px);
  background-blend-mode: screen;
}
.bg-theme-office_bright {
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.12), transparent 35%),
    linear-gradient(135deg, #1b2a3c 0%, #243447 100%);
}
.bg-theme-office_dim {
  background: radial-gradient(circle at 70% 15%, rgba(255, 255, 255, 0.08), transparent 35%),
    linear-gradient(160deg, #0f172a 0%, #0a101f 100%);
}
.bg-theme-interrogation { background: radial-gradient(circle at center, #444, #000 70%); }
.bg-theme-hostel { background: linear-gradient(135deg, #18212f 0%, #0f172a 100%); }

.anim-shake-continuous { animation: camera-shake 2s ease-in-out infinite; }
@keyframes camera-shake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px) rotate(-0.4deg); }
  40% { transform: translate(3px, -2px) rotate(0.4deg); }
  60% { transform: translate(-2px, 1px) rotate(-0.2deg); }
  80% { transform: translate(2px, -1px) rotate(0.2deg); }
  100% { transform: translate(0, 0); }
}

/* ==========================================================================
   7. SCENARIO MAP (Task 18)
   ========================================================================== */
.map-viewport {
  position: relative;
  height: calc(100vh - 80px);
  overflow-x: auto;
  overflow-y: hidden;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #0f2027 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.map-overlay {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.map-overlay__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-overlay__kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
}

.map-overlay__heading {
  margin: 0;
}

.map-overlay__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 243, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.map-bottom-center {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
}

.map-node {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.map-node:hover { transform: scale(1.08); box-shadow: 0 0 12px rgba(0, 243, 255, 0.45); }
.map-node.node-active {
  background: radial-gradient(circle at 30% 30%, #ffb347, #ff7e00);
  box-shadow: 0 0 15px rgba(255, 158, 0, 0.7);
  animation: map-node-pulse 1.6s ease-in-out infinite;
}
.map-node.node-completed { background: linear-gradient(135deg, var(--color-primary), #0ae0ff); border-color: #fff; }
.map-node.node-locked { opacity: 0.65; cursor: not-allowed; border-style: dashed; }
.map-node.node-current { box-shadow: 0 0 16px rgba(0, 243, 255, 0.8); transform: scale(1.12); }

@keyframes map-node-pulse {
  0% { box-shadow: 0 0 15px rgba(255, 158, 0, 0.7); }
  50% { box-shadow: 0 0 20px rgba(255, 158, 0, 0.9), 0 0 0 8px rgba(255, 158, 0, 0.12); }
  100% { box-shadow: 0 0 15px rgba(255, 158, 0, 0.7); }
}

/* ==========================================================================
   8. ADVISOR CHAT (Task 14)
   ========================================================================== */
.chat-overlay {
  position: fixed;
  right: 18px;
  bottom: calc(var(--footer-height, 88px) + 18px);
  width: 340px;
  height: 400px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(11, 15, 27, 0.95), rgba(9, 12, 22, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
  color: #f5f7ff;
  transform: translateY(140%);
  opacity: 0;
  pointer-events: none;
  transition: transform 260ms ease, opacity 240ms ease;
  z-index: 1060;
}

.chat-overlay.chat-overlay--advisor {
  right: 18px;
  left: auto;
}

.chat-overlay.chat-overlay--persona {
  left: 18px;
  right: auto;
}

.chat-overlay.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }

@media (max-width: 1100px) {
  .chat-overlay {
    bottom: calc(var(--footer-height, 78px) + 12px);
  }
}

.chat-overlay__header {
  background: linear-gradient(90deg, rgba(79, 209, 197, 0.08), rgba(255, 157, 0, 0.08));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.chat-overlay__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Vignette overlay (visual events) */
.vignette-card {
  position: absolute;
  inset: 12px 12px auto auto;
  max-width: 360px;
  background: rgba(9, 12, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  color: #f5f7ff;
  animation: vignette-in 220ms ease forwards;
  z-index: 1050;
}

.vignette-card__media {
  width: 100%;
  height: 180px;
  background-size: cover;
  background-position: center;
}

.vignette-card__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}

.vignette-card__body {
  padding: 12px 14px 14px;
}

.vignette-card__title {
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.vignette-card__caption {
  font-size: 0.95rem;
  line-height: 1.35;
  opacity: 0.9;
}

.vignette-card--fade {
  animation: vignette-out 240ms ease forwards;
}

@keyframes vignette-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes vignette-out {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(10px); opacity: 0; }
}

.chat-overlay__kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
}

.chat-overlay__name {
  font-weight: 800;
}

.chat-overlay__close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

.chat-overlay__close:hover {
  border-color: rgba(0, 243, 255, 0.42);
  box-shadow: 0 0 0 1px rgba(0, 243, 255, 0.18);
}

.chat-overlay__controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Minimized state: show only the header bar. */
.chat-overlay.is-minimized {
  height: auto;
}

.chat-overlay.is-minimized .chat-overlay__body,
.chat-overlay.is-minimized .chat-overlay__input {
  display: none;
}

/* Modal maximize: show as a centered overlay with a page backdrop. */
.chat-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 1059;
}

.chat-overlay-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

.chat-overlay.is-maximized {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 32px));
  height: min(78vh, 720px);
  z-index: 1061;
}

@media (max-width: 768px) {
  .chat-overlay.is-maximized {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
  }
}

.chat-overlay__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: radial-gradient(circle at 18% 20%, rgba(79, 209, 197, 0.05), transparent 35%);
}

.chat-overlay__body {
  padding: 12px 14px;
}

.chat-overlay__input {
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-overlay__form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.chat-overlay__field {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.92);
  outline: none;
}

.chat-overlay__field:focus {
  border-color: rgba(0, 243, 255, 0.42);
  box-shadow: 0 0 0 1px rgba(0, 243, 255, 0.18);
}

.chat-overlay__send {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  font-weight: 700;
}

.chat-overlay__send:hover {
  border-color: rgba(0, 243, 255, 0.42);
  box-shadow: 0 0 0 1px rgba(0, 243, 255, 0.18);
}

.chat-overlay__notice {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
}

.chat-msg {
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.3;
  max-width: 92%;
}

.chat-msg-advisor {
  align-self: flex-start;
  background: rgba(79, 209, 197, 0.08);
  border: 1px solid rgba(79, 209, 197, 0.2);
}

.chat-msg-user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.chat-msg-assistant {
  align-self: flex-start;
  background: rgba(79, 209, 197, 0.08);
  border: 1px solid rgba(79, 209, 197, 0.2);
  box-shadow: inset 0 0 0 1px rgba(79, 209, 197, 0.08);
}

.chat-msg-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
}

.typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #f5f7ff;
  border-radius: 50%;
  animation: typingBounce 1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ==========================================================================
   9. DEBRIEF & STAMPS (Task 8)
   ========================================================================== */
.debrief-hero {
  min-height: min(84vh, 920px);
  display: flex;
  align-items: center;
  color: var(--text-main);
  background:
    radial-gradient(circle at 18% 18%, var(--color-primary-glow, rgba(79, 209, 197, 0.22)), transparent 52%),
    radial-gradient(circle at 86% 20%, rgba(255, 255, 255, 0.05), transparent 45%),
    linear-gradient(135deg, rgba(10, 15, 25, 0.92), rgba(5, 8, 20, 0.96));
}

.page-debrief .debrief-container {
  max-width: 980px;
}

.page-debrief .status-title {
  letter-spacing: -0.02em;
}

.paper-card {
  border-radius: var(--radius-xl, 24px);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.18));
  backdrop-filter: blur(10px);
}

.status-stamp {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  transform: rotate(-8deg);
  padding: 0.5rem 1.1rem;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.16rem;
  text-transform: uppercase;
  font-family: var(--font-hud, ui-monospace, SFMono-Regular, Menlo, monospace);
  opacity: 0.92;
  background: rgba(0, 0, 0, 0.30);
}
.status-stamp--success { color: var(--color-success); }
.status-stamp--danger { color: var(--color-danger); }

.page-debrief .debrief-metrics .list-group-item {
  background: rgba(255, 255, 255, 0.02);
}

.page-debrief .action-deck {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.animate-fade-in {
  animation: bqFadeInUp 240ms ease-out both;
}

@keyframes bqFadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .status-stamp {
    position: static;
    transform: none;
    display: inline-flex;
    margin-top: 0.75rem;
  }
}

/* ==========================================================================
   10. VISUAL FX (Task 17 - Floating Text)
   ========================================================================== */
.flash-danger {
  animation: flash-danger 0.4s ease-in-out 2;
  background-color: rgba(220, 38, 38, 0.08);
}
@keyframes flash-danger {
  0% { background-color: rgba(220, 38, 38, 0.2); }
  100% { background-color: transparent; }
}

.floating-text {
  position: fixed;
  font-weight: 800;
  font-family: var(--font-hud);
  z-index: 2000;
  pointer-events: none;
  animation: floatUpFade 1.5s ease-out forwards;
}
.ft-good { color: #2ecc71; text-shadow: 0 0 5px rgba(46, 204, 113, 0.5); }
.ft-bad { color: #e74c3c; text-shadow: 0 0 5px rgba(231, 76, 60, 0.5); }
.ft-stress { color: #9b59b6; }
.ft-warn { color: #f39c12; }

@keyframes floatUpFade {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-30px) scale(1.1); opacity: 0; }
}

/* ==========================================================================
   11. RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .game-controller-footer { gap: 0.25rem; padding: 0.25rem 0.5rem; }
  .game-controller-footer .game-btn span { display: none; }
  .game-footer__deck--left, .game-footer__deck--right { flex: 0 0 35%; }
  .chat-overlay { width: 90%; right: 5%; bottom: 80px; }
  .chat-overlay.chat-overlay--advisor,
  .chat-overlay.chat-overlay--persona {
    left: 5%;
    right: 5%;
  }
}

/* Re-assert overlay corners (theme.css defines .chat-overlay twice). */
.chat-overlay.chat-overlay--advisor { right: 18px; left: auto; }
.chat-overlay.chat-overlay--persona { left: 18px; right: auto; }

.flash-danger {
  animation: flash-danger 0.4s ease-in-out 2;
  background-color: rgba(220, 38, 38, 0.08);
}

@keyframes flash-danger {
  0% {
    background-color: rgba(220, 38, 38, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

.chat-overlay {
  position: fixed;
  right: 18px;
  bottom: 90px;
  width: 340px;
  max-width: calc(100% - 32px);
  height: 400px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(11, 15, 27, 0.95), rgba(9, 12, 22, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
  color: #f5f7ff;
  overflow: hidden;
  transform: translateY(140%);
  opacity: 0;
  pointer-events: none;
  transition: transform 260ms ease, opacity 240ms ease;
  z-index: 1060;
}

.chat-overlay.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-overlay__header {
  background: linear-gradient(90deg, rgba(79, 209, 197, 0.08), rgba(255, 157, 0, 0.08));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-overlay__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: radial-gradient(circle at 18% 20%, rgba(79, 209, 197, 0.05), transparent 35%),
    radial-gradient(circle at 80% 12%, rgba(255, 157, 0, 0.05), transparent 32%);
}

.chat-overlay__input {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.chat-msg {
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.3;
  max-width: 92%;
}

.chat-msg-advisor {
  align-self: flex-start;
  background: rgba(79, 209, 197, 0.08);
  border: 1px solid rgba(79, 209, 197, 0.2);
  box-shadow: inset 0 0 0 1px rgba(79, 209, 197, 0.08);
}

.chat-msg-system {
  align-self: center;
  color: #9ba7c7;
  font-style: italic;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

.chat-msg-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
}

.typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #f5f7ff;
  border-radius: 50%;
  animation: typingBounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   FLOATING FEEDBACK (Combat Text)
   -------------------------------------------------------------------------- */
@keyframes floatUpFade {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-30px) scale(1.1);
    opacity: 0;
  }
}

.floating-text {
  position: fixed;
  font-weight: 800;
  font-family: var(--font-hud, 'Share Tech Mono', monospace);
  z-index: 2000;
  pointer-events: none;
  animation: floatUpFade 1.5s ease-out forwards;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
  will-change: transform, opacity;
}

.ft-good {
  color: #2ecc71;
}

.ft-bad {
  color: #e74c3c;
}

.ft-stress {
  color: #9b59b6;
}

.ft-warn {
  color: #f39c12;
}
