:root {
  --hud-amber: #d8af72;
  --hud-cyan: #6ec4b8;
  --hud-red: #e05846;
  --hud-bg: rgba(10, 9, 8, 0.48);
  --hud-border: rgba(216, 175, 114, 0.48);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0b0a09;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  color: var(--hud-amber);
}

#webgl-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* Photographic Optical Vignette & Subtle Edge Depth-of-Field Softness */
#webgl-container::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  backdrop-filter: blur(1.6px);
  -webkit-backdrop-filter: blur(1.6px);
  mask-image: radial-gradient(ellipse at 50% 50%, transparent 64%, rgba(0, 0, 0, 0.85) 96%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent 64%, rgba(0, 0, 0, 0.85) 96%);
}

#webgl-container::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    ellipse at 50% 48%,
    rgba(0, 0, 0, 0) 52%,
    rgba(6, 5, 4, 0.36) 82%,
    rgba(4, 3, 3, 0.72) 100%
  );
}

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

/* Clean Screenshot Toggle via Escape Key */
body.hud-hidden #top-bar,
body.hud-hidden #hud-overlay,
body.hud-hidden #compact-telemetry,
body.hud-hidden #intro-prompt {
  opacity: 0 !important;
  pointer-events: none !important;
}

#top-bar,
#hud-overlay,
#compact-telemetry {
  transition: opacity 0.25s ease;
}

/* SVG Telemetry Overlay HUD */
#hud-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 3;
  pointer-events: none;
  shape-rendering: geometricPrecision;
}

.hud-box {
  fill: var(--hud-bg);
  stroke: var(--hud-border);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.16s ease, fill 0.16s ease;
}

.hud-box.bell-flash {
  stroke: var(--hud-red);
  stroke-width: 1.8px;
  fill: rgba(82, 20, 14, 0.65);
}

.hud-title {
  fill: rgba(216, 175, 114, 0.75);
  font-size: 8px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
}

.hud-value {
  fill: #f4ece0;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.7px;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
}

.hud-sub {
  fill: var(--hud-cyan);
  font-size: 8.5px;
  letter-spacing: 1.0px;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
}

/* Reduced telemetry dashed leader lines opacity by half */
.leader-line {
  fill: none;
  stroke: rgba(216, 175, 114, 0.21);
  stroke-width: 1px;
  stroke-dasharray: 3 2;
}

.leader-dot {
  fill: #f0d098;
  stroke: #d8af72;
  stroke-width: 1.2px;
}

.corner-tick {
  fill: none;
  stroke: rgba(216, 175, 114, 0.50);
  stroke-width: 1.2px;
}

/* Single Bottom Bar Readout for Portrait / Small Screens */
#compact-telemetry {
  position: fixed;
  bottom: 8px;
  left: 8px;
  right: 8px;
  z-index: 4;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(10, 9, 8, 0.80);
  border: 1px solid var(--hud-border);
  font-size: 9.5px;
  letter-spacing: 0.6px;
  color: #f4ece0;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
}

/* Center Intro Prompt */
#intro-prompt {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
  text-align: center;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s ease;
}

#intro-prompt.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

.prompt-pill {
  display: inline-block;
  padding: 5px 14px;
  background: rgba(12, 11, 10, 0.84);
  border: 1px solid rgba(216, 175, 114, 0.58);
  color: #f4e6d0;
  font-size: 10px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  box-shadow: 0 0 14px rgba(216, 175, 114, 0.12);
  animation: pulseGlow 2.4s infinite ease-in-out;
  white-space: nowrap;
}

.prompt-sub {
  margin-top: 3px;
  font-size: 8px;
  letter-spacing: 1.1px;
  color: rgba(216, 175, 114, 0.68);
  white-space: nowrap;
}

@keyframes pulseGlow {
  0%, 100% {
    border-color: rgba(216, 175, 114, 0.36);
    box-shadow: 0 0 8px rgba(216, 175, 114, 0.08);
  }
  50% {
    border-color: rgba(216, 175, 114, 0.85);
    box-shadow: 0 0 18px rgba(216, 175, 114, 0.22);
  }
}

/* Hidden Mobile Input */
#mobile-input {
  position: fixed;
  bottom: 8px;
  left: 50%;
  width: 60px;
  height: 32px;
  margin-left: -30px;
  font-size: 16px;
  opacity: 0.01;
  border: 0;
  padding: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  z-index: -1;
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
}

/* Top Bar Header & Controls */
#top-bar {
  position: fixed;
  top: 10px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  z-index: 4;
  pointer-events: none;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex-shrink: 1;
}

.brand-name {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2.2px;
  color: #e8d2b0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-meta {
  font-size: 8.5px;
  letter-spacing: 1.3px;
  color: rgba(216, 175, 114, 0.58);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-controls {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 5px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(12, 11, 10, 0.76);
  border: 1px solid rgba(216, 175, 114, 0.48);
  color: #e8d2b0;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  font-size: 9px;
  letter-spacing: 1.0px;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.hud-btn:hover {
  border-color: #e8d2b0;
  background: rgba(216, 175, 114, 0.16);
}

.hud-btn.active {
  border-color: var(--hud-cyan);
  color: var(--hud-cyan);
}

.hud-btn.warn {
  border-color: var(--hud-red);
  color: var(--hud-red);
}

/* On narrow/portrait screens, collapse HUD to the single bottom bar */
@media (max-width: 820px), (max-height: 560px) {
  #top-bar {
    display: none;
  }
  #hud-cards-group, #hud-leaders {
    display: none;
  }
  #compact-telemetry {
    display: flex;
  }
  #intro-prompt {
    bottom: 42px;
  }
  .prompt-sub {
    display: none;
  }
}


/* Print / Save menu */
#print-menu {
  position: fixed;
  top: 64px;
  right: 14px;
  z-index: 30;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(16, 18, 20, 0.92);
  border: 1px solid rgba(114, 214, 201, 0.35);
  border-radius: 4px;
  pointer-events: auto;
}
#print-menu.open { display: flex; }
#print-menu .pm-title {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #72d6c9;
  margin-bottom: 2px;
}
@media (max-width: 700px) {
  #print-menu { top: auto; bottom: 14px; right: 50%; transform: translateX(50%); flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 94vw; }
  #print-menu .pm-title { width: 100%; text-align: center; }
}

#mobile-bar { display: none; }
@media (max-width: 820px), (max-height: 560px) {
  #mobile-bar {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 31;
    display: flex;
    gap: 6px;
    pointer-events: auto;
  }
  #print-menu { top: 54px; bottom: auto; right: 50%; transform: translateX(50%); flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 94vw; }
}
