:root {
  --bg-color: #04060a;
  --surface: rgba(14, 20, 32, 0.75);
  --border: rgba(255, 255, 255, 0.12);
  --p1-color: #00e5ff;
  --p2-color: #ff9100;
  --p3-color: #d500f9;
  --p4-color: #76ff03;
  --danger: #ff1744;
  --success: #00e676;
  --warning: #ffd600;
  --font-hud: 'Chakra Petch', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-text: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  font-family: var(--font-hud);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 9:16 Container */
.stream-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100vh * (9 / 16));
  aspect-ratio: 9 / 16;
  background: var(--bg-color);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
}

/* Sandwich Layers */
.sandwich-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#video-layer {
  z-index: 1;
  background: #020305;
  overflow: hidden;
}

#bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none; /* revealed dynamically if video loads */
}

#procedural-bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#entity-canvas {
  z-index: 2;
}

#darkness-canvas {
  z-index: 3;
}

#hud-layer {
  z-index: 4;
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

/* OBS Drag & Resize Styles (Standard Forastream Overlay Pattern) */
.obs-draggable-item {
  position: absolute;
  cursor: grab !important;
  user-select: none !important;
  pointer-events: auto !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  transform-origin: top left;
}

.obs-draggable-item:hover {
  outline: 2px dashed #00e5ff;
  outline-offset: 3px;
}

.obs-draggable-item.is-dragging {
  cursor: grabbing !important;
  opacity: 0.94;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9), 0 0 30px #00e5ff !important;
  z-index: 999 !important;
  outline: 2.5px solid #00e5ff;
}

/* Corner Resize Handle */
.obs-resize-handle {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: nwse-resize !important;
  color: #00e5ff;
  background: rgba(0, 0, 0, 0.7);
  border-top-left-radius: 6px;
  border-bottom-right-radius: 8px;
  opacity: 0.7;
  transition: all 0.2s ease;
  z-index: 60;
  user-select: none;
  touch-action: none;
}

.obs-draggable-item:hover .obs-resize-handle {
  opacity: 1;
  background: rgba(0, 229, 255, 0.3);
}

.obs-resize-handle:hover {
  opacity: 1 !important;
  color: #000000 !important;
  background: #ffd600 !important;
  transform: scale(1.15);
  box-shadow: 0 0 14px #ffd600;
}

.obs-draggable-item.is-resizing {
  outline: 2.5px solid #ffd600 !important;
  box-shadow: 0 0 35px #ffd600 !important;
}

/* Layout Reset Floating Button */
.layout-reset-btn {
  position: absolute;
  bottom: 8px;
  right: 12px;
  background: rgba(14, 20, 32, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #94a3b8;
  font-family: var(--font-hud);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.4;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.layout-reset-btn:hover {
  opacity: 1;
  color: #fff;
  border-color: #00e5ff;
}

/* Brand Widget Default Positioning */
.brand-badge {
  top: 24px;
  left: 20px;
  background: rgba(8, 12, 22, 0.96);
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 10px 16px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7);
}

.live-dot {
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
  margin-bottom: 6px;
  box-shadow: 0 0 10px var(--danger);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.brand-sub {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #ff1744;
}

/* Audio Control Widget */
.audio-badge {
  position: absolute;
  top: 24px;
  left: 200px;
  z-index: 50;
  pointer-events: auto;
}

.audio-btn {
  background: rgba(14, 20, 32, 0.88);
  border: 1.5px solid rgba(0, 229, 255, 0.4);
  color: #fff;
  padding: 7px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.audio-btn:hover {
  border-color: #00e5ff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.35);
}

.audio-btn.audio-prompt {
  border-color: #ff9100;
  color: #ff9100;
  animation: pulse-audio-prompt 1.8s infinite ease-in-out;
}

@keyframes pulse-audio-prompt {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 145, 0, 0.25); border-color: rgba(255, 145, 0, 0.45); }
  50% { box-shadow: 0 0 22px rgba(255, 145, 0, 0.75); border-color: #ff9100; }
}

.audio-btn.audio-muted {
  border-color: #ff1744;
  color: #ff1744;
}

.audio-btn.audio-active {
  border-color: rgba(0, 230, 118, 0.5);
  color: #00e676;
}

.objective-card {
  top: 24px;
  right: 20px;
  width: 320px;
  background: rgba(8, 12, 22, 0.96);
  border: 2px solid rgba(0, 229, 255, 0.35);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7);
}

.obj-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.obj-progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.obj-fill {
  height: 100%;
  background: linear-gradient(90deg, #00b0ff, #00e676);
  box-shadow: 0 0 12px #00e676;
  transition: width 0.4s ease;
}

.obj-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
}

#obj-count-text {
  font-size: 16px;
  font-weight: 800;
  color: #00e676;
  text-shadow: 0 0 10px rgba(0, 230, 118, 0.8);
}

/* Event Banner */
.event-banner {
  position: absolute;
  top: 130px;
  left: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.92);
  border-left: 5px solid var(--warning);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  z-index: 10;
  color: #ffffff;
  text-shadow: 0 2px 4px #000;
}

.event-banner.active {
  transform: translateY(0);
  opacity: 1;
}

/* Compact Screen-Freeing Trivia Ticker Bar */
.chat-trivia-widget {
  top: 96px;
  left: 20px;
  max-width: 500px;
  background: rgba(8, 12, 22, 0.96);
  border: 1.5px solid rgba(0, 229, 255, 0.4);
  border-radius: 8px;
  padding: 8px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0px;
}

.trivia-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--p1-color);
  background: rgba(0, 229, 255, 0.15);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(0, 229, 255, 0.4);
}

.trivia-timer {
  font-size: 13px;
  font-weight: 800;
  color: var(--warning);
  text-shadow: 0 0 6px rgba(255, 214, 0, 0.5);
}

.trivia-q {
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 2px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trivia-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.trivia-opt {
  font-family: var(--font-text);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  display: flex;
  gap: 4px;
  color: #ffffff;
}

.trivia-opt .letter {
  font-family: var(--font-hud);
  font-weight: 800;
  color: var(--p1-color);
}

.command-cheatsheet {
  font-family: var(--font-text);
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 3px;
}

.command-cheatsheet strong {
  color: #00e5ff;
  font-weight: 800;
}

/* Footer Player Cards */
.hud-footer {
  bottom: 20px;
  left: 20px;
  width: calc(100% - 40px);
}

.player-slot-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.player-card {
  background: rgba(8, 12, 22, 0.96);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
}

.player-card.slot-1 { border-top: 4px solid var(--p1-color); }
.player-card.slot-2 { border-top: 4px solid var(--p2-color); }
.player-card.slot-3 { border-top: 4px solid var(--p3-color); }
.player-card.slot-4 { border-top: 4px solid var(--p4-color); }

.player-card.empty {
  opacity: 0.45;
}

.player-card .card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slot-badge {
  font-size: 13px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.p-name {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
  text-shadow: 0 1px 3px #000;
}

.p-hp-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.2s ease;
}

.p-ammo-row {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
}

.ammo-val {
  color: #ffd600;
  font-weight: 800;
  font-size: 13px;
}

/* ==========================================================================
   Tactical Biohazard Loading Screen (Layer 5)
   ========================================================================== */

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 38%, #0f1c2e 0%, #060b13 55%, #020407 100%);
  overflow: hidden;
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.loading-screen.fade-out {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

/* Subtle Tactical Scanlines */
.loading-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.22) 0px,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  opacity: 0.8;
  z-index: 1;
}

/* Subtle Tactical Grid Overlay */
.loading-grid-bg {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 2;
}

.loading-content {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 86%;
  max-width: 440px;
  text-align: center;
}

/* Animated Radar Scope & Hazard Emblem */
.loading-emblem-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-scope {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 229, 255, 0.35);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.2), inset 0 0 16px rgba(0, 229, 255, 0.15);
  overflow: hidden;
}

.radar-scope::before {
  content: '';
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 1px dashed rgba(0, 229, 255, 0.25);
}

.radar-crosshair {
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(to right, transparent 49.5%, rgba(0, 229, 255, 0.25) 50%, transparent 50.5%),
    linear-gradient(to bottom, transparent 49.5%, rgba(0, 229, 255, 0.25) 50%, transparent 50.5%);
}

.radar-sweep {
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg at 50% 50%, rgba(0, 229, 255, 0.45) 0deg, rgba(0, 229, 255, 0) 65deg);
  animation: radarSpin 2.4s linear infinite;
  transform-origin: 50% 50%;
}

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

.emblem-center {
  position: relative;
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(14, 25, 43, 0.88);
  border: 1.5px solid #00e5ff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.45);
}

.hazard-icon {
  width: 24px;
  height: 24px;
  color: #00e5ff;
  animation: hazardPulse 2s ease-in-out infinite;
}

@keyframes hazardPulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); filter: drop-shadow(0 0 8px #00e5ff); }
}

/* Titles */
.loading-titles {
  margin-bottom: 26px;
}

.loading-brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #00e5ff;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.loading-main-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ffffff;
  text-transform: uppercase;
  margin: 0;
  text-shadow: 0 0 25px rgba(0, 229, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.8);
}

.loading-subtitle {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #94a3b8;
  margin-top: 6px;
  text-transform: uppercase;
}

/* Progress Bar Container */
.loading-progress-container {
  width: 100%;
  margin-bottom: 22px;
}

.loading-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.loading-status {
  color: #cbd5e1;
}

.loading-pct {
  color: #00e5ff;
  font-family: var(--font-hud);
  font-size: 13px;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

.loading-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(0, 229, 255, 0.28);
  border-radius: 6px;
  overflow: hidden;
  padding: 1.5px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
}

.loading-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #00b0ff, #00e5ff 70%, #76ff03);
  position: relative;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.7);
}

.loading-bar-glow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  background: #ffffff;
  filter: blur(2px);
  opacity: 0.9;
}

/* Checklist Badges Grid */
.loading-badges-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.asset-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #64748b;
  transition: all 0.35s ease;
}

.asset-badge:last-child:nth-child(odd) {
  grid-column: span 2;
  justify-content: center;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #475569;
  transition: all 0.35s ease;
}

.asset-badge.ready {
  border-color: rgba(0, 229, 255, 0.4);
  color: #ffffff;
  background: rgba(14, 28, 48, 0.75);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

.asset-badge.ready .badge-dot {
  background: #00e5ff;
  box-shadow: 0 0 8px #00e5ff;
}

/* Log Box */
.loading-log-box {
  width: 100%;
  padding: 8px 12px;
  background: rgba(3, 7, 18, 0.85);
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 4px;
  font-family: monospace;
  font-size: 10.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  overflow: hidden;
  white-space: nowrap;
}

.log-prefix {
  color: #00e5ff;
  font-weight: bold;
}

.log-text {
  text-overflow: ellipsis;
  overflow: hidden;
}

.loading-skip-btn {
  margin-top: 18px;
  padding: 8px 20px;
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 4px;
  color: #00e5ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.loading-skip-btn:hover {
  background: rgba(0, 229, 255, 0.28);
  border-color: #00e5ff;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.45);
  transform: translateY(-1px);
}

