/* =====================================================================
   style.css  -  All styling for the game.
   Layers over the 3D canvas: HUD, crosshair, score popups, the
   click-to-play blocker, the full-screen upgrade map, and the settings
   modal.
   ===================================================================== */

:root {
  --bg: #070912;
  --panel-top: #141a31;
  --panel-bottom: #0d1124;
  --edge: #2c365f;
  --text: #e8ebff;
  --muted: #8b93c4;
  --accent: #5a7bff;
  --accent-glow: #7e9bff;
  --good: #36e0d0;
  --affordable: #3ddc97;
  --locked: #4b5478;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none;
}

#playspace { position: fixed; inset: 0; display: block; }

/* =====================================================================
   HUD
   ===================================================================== */

#hud { position: fixed; top: 26px; left: 30px; pointer-events: none; }

#score {
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 24px var(--accent-glow);
}

#score-label {
  margin-top: 6px;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}

#targets { margin-top: 14px; font-size: 14px; letter-spacing: 1px; color: var(--good); }

#hint, #fps {
  position: fixed;
  right: 30px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--muted);
  pointer-events: none;
}
#hint { top: 28px; letter-spacing: 2px; text-transform: uppercase; }
#fps { top: 54px; }

/* The Exit-Playground button - shown only while in the sandbox. */
#playground-exit {
  position: fixed;
  top: 80px;
  right: 30px;
  display: none;
  z-index: 45;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  background: #3a2456;
  border: 1px solid #6a4ea0;
  border-radius: 9px;
  padding: 9px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#playground-exit:hover { background: #4a2f6e; border-color: #8a6ad0; }

#dev-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #1a1205;
  background: #ffce5c;
  border-radius: 0 0 10px 10px;
  pointer-events: none;
  z-index: 60;
}

/* =====================================================================
   Crosshair + spawn arcs
   ===================================================================== */

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #eafffb;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.35), 0 0 8px rgba(120, 220, 255, 0.9);
  pointer-events: none;
  transition: transform 0.09s ease;
}
#crosshair.shoot { transform: scale(2.2); }

#spawners { display: flex; gap: 10px; margin-top: 16px; }
.spawn-arc { width: 52px; height: 52px; transition: opacity 0.25s ease; }
.spawn-arc circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.spawn-arc .sa-track { stroke: rgba(255, 255, 255, 0.12); }
.spawn-arc .sa-fill { stroke: var(--good); }
/* The thinner outer ring - live targets as a fraction of the cap. */
.spawn-arc .sa-cap-track { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1.67; }
.spawn-arc .sa-cap-fill { stroke: rgba(232, 236, 255, 0.62); stroke-width: 1.67; }
.spawn-arc .sa-count {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}
/* The numerator carries the focus; the slash + denominator are dimmer. */
.spawn-arc .sa-den { fill-opacity: 0.6; }

/* =====================================================================
   Volley heat gauge  -  the first-shot readiness meter on the HUD
   ===================================================================== */

#volley {
  margin-top: 16px;
  width: 188px;
  padding: 9px 11px;
  background: rgba(13, 17, 36, 0.82);
  border: 1px solid var(--edge);
  border-radius: 10px;
}
.volley-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.volley-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.volley-pct { font-size: 12px; font-weight: 700; color: var(--text); }

.volley-bar {
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.volley-heat { height: 14px; }
.volley-regen { height: 5px; margin-top: 4px; }

.volley-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  border-radius: 3px;
  transition: width 0.08s linear;
}
.volley-regen .volley-fill { background: var(--accent-glow); }

/* The drain tick - the gap from the full bar to it is one shot's worth. */
.volley-tick {
  position: absolute;
  top: -1px; bottom: -1px;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.75);
}

/* The no-regen highlight - a steady glow held for the whole no-regen
   period (.frozen is set from a shot until regeneration resumes). */
.volley-heat.frozen {
  box-shadow: inset 0 0 8px 2px rgba(255, 236, 160, 0.6);
}

.volley-chips { display: flex; gap: 6px; margin-top: 7px; }
.volley-chip {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  overflow: hidden;
}
.vc-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  transition: width 0.08s linear;
}
.vc-key {
  position: relative;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
}
.vc-val {
  position: relative;
  font-size: 11px;
  font-weight: 700;
}
.vc-spd .vc-fill { background: rgba(122, 208, 255, 0.2); }
.vc-spd .vc-val { color: #7ad0ff; }
.vc-dmg .vc-fill { background: rgba(255, 138, 106, 0.2); }
.vc-dmg .vc-val { color: #ff8a6a; }

/* =====================================================================
   Floating score popups
   ===================================================================== */

#popup-layer { position: fixed; inset: 0; pointer-events: none; }

.score-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  --drift: 0px;
  font-size: 22px;
  font-weight: 700;
  color: var(--good);
  text-shadow: 0 0 12px rgba(54, 224, 208, 0.8);
  animation: popup 0.85s ease-out forwards;
}

@keyframes popup {
  0%   { opacity: 0; transform: translate(calc(-50% + var(--drift)), -40%) scale(0.7); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift)), -190%) scale(1.1); }
}

/* =====================================================================
   Blocker
   ===================================================================== */

#blocker {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 9, 18, 0.78);
  cursor: pointer;
}
.blocker-box { text-align: center; padding: 40px 56px; }
.blocker-title {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 30px var(--accent-glow);
}
.blocker-text { margin-top: 16px; font-size: 20px; color: var(--good); }
.blocker-controls { margin-top: 24px; font-size: 13px; letter-spacing: 1px; color: var(--muted); }

/* =====================================================================
   Full-screen upgrade map
   ===================================================================== */

#upgrade-overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(6, 8, 16, 0.96);
  z-index: 40;
}
#upgrade-overlay.open { display: block; }

#upgrade-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#upgrade-map.panning { cursor: grabbing; }

#map-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: linear-gradient(180deg, rgba(6, 8, 16, 0.95), rgba(6, 8, 16, 0));
  z-index: 2;
  pointer-events: none;            /* the bar itself does not block the map */
}
#map-top button { pointer-events: auto; }
#map-detail, #map-hint { pointer-events: none; }

#map-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
}
#map-spacer { flex: 1; }

#map-top button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  background: #1b2142;
  border: 1px solid var(--edge);
  border-radius: 9px;
  padding: 9px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#map-top button:hover { border-color: var(--accent); background: #243056; }
#map-resume { background: var(--accent); border-color: var(--accent); }
#map-resume:hover { background: var(--accent-glow); }

#map-hint {
  position: absolute;
  bottom: 22px;
  right: 24px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  z-index: 2;
  pointer-events: none;
}

/* Legend panel - pinned top-right, spells out the tile visual
   language so the kind + state cues can be read at a glance. */
#map-legend {
  position: absolute;
  top: 68px;
  right: 24px;
  width: 218px;
  padding: 13px 15px;
  background: rgba(13, 17, 36, 0.92);
  border: 1px solid var(--edge);
  border-radius: 12px;
  z-index: 2;
  pointer-events: none;
}
.legend-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
  margin-bottom: 8px;
}
.legend-group {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #6b73a0;
  margin: 9px 0 5px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #c8cde8;
  margin-bottom: 4px;
}
.legend-swatch { flex: none; }
.legend-states { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* =====================================================================
   Hex tiles on the map

   The tiles + connectors are drawn on the #upgrade-map CANVAS by
   menu.js - the old per-tile SVG DOM was the framerate bottleneck on a
   pan. Their colours live in the COLORS table in menu.js; there is no
   per-tile CSS any more.
   ===================================================================== */

/* =====================================================================
   Detail box (shared by the map + reused styling)
   ===================================================================== */

#map-detail {
  position: absolute;
  bottom: 22px;
  left: 24px;
  width: 340px;
  z-index: 2;
}

.upgrade-detail {
  min-height: 132px;
  max-height: 240px;
  overflow-y: auto;
  padding: 14px 16px;
  background: rgba(13, 17, 36, 0.92);
  border: 1px solid var(--edge);
  border-radius: 12px;
}
.upgrade-detail.affordable { border-color: var(--affordable); }
.upgrade-detail.locked { border-color: var(--locked); }

.detail-hint { font-size: 13px; color: var(--muted); }
.detail-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.detail-text { font-size: 13px; line-height: 1.45; color: var(--muted); margin-bottom: 8px; }
.detail-status { font-size: 13px; font-weight: 700; }
.detail-status.owned { color: var(--good); }
.detail-status.buy { color: var(--affordable); }
.detail-status.need { color: var(--locked); }

/* Per-step / path-total / absolute stat readout under the description. */
.detail-stats {
  margin: 8px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--edge);
}
.ds-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  line-height: 1.8;
}
.ds-key { color: var(--muted); }
.ds-val { color: var(--text); font-weight: 700; white-space: nowrap; }
.ds-val strong { color: var(--affordable); font-weight: 700; }

.detail-kind {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  vertical-align: middle;
}
.detail-kind.increment { background: #243056; color: var(--accent-glow); }
.detail-kind.advancement { background: #4a3a12; color: #ffce5c; }

/* =====================================================================
   Settings modal (right-docked; spring tilt set by menu.js)
   ===================================================================== */

#settings-modal {
  position: fixed;
  top: 50%;
  right: 34px;
  width: 320px;
  padding: 24px;
  transform-origin: center center;
  background: linear-gradient(160deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: 0 36px 70px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 50;
}
#settings-modal.open { opacity: 1; visibility: visible; pointer-events: auto; }

.menu-heading {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 5px;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
  margin-bottom: 18px;
}

.setting { margin-bottom: 14px; }
.setting-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.setting-value { color: var(--good); font-weight: 700; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #0d1124;
  border: 1px solid var(--edge);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(126, 155, 255, 0.7);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-glow); border: none; cursor: pointer;
}

.data-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-glow);
  margin: 20px 0 8px;
}

.data-button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: #1b2142;
  border: 1px solid var(--edge);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.data-button:hover { border-color: var(--accent); background: #243056; }

#settings-close {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
}
#settings-close:hover { background: var(--accent-glow); }
