/* =============================================================================
 * REEF DEFENCE — style.css
 * Black Reef Ops branding: black / charcoal / gold, stencil-style headings,
 * clean tactical HUD. Fully responsive; the 3D canvas always fills the screen.
 * ========================================================================== */

:root {
  --bg: #060809;
  --panel: rgba(10, 13, 16, 0.92);
  --panel-solid: #0c0f13;
  --line: #262d34;
  --gold: #e8b25a;
  --gold-bright: #f2c877;
  --gold-dim: #caa24e;
  --bone: #e7e2d4;
  --dim: #8b9096;
  --green: #5fae72;
  --green-bright: #7fe6a0;
  --orange: #e2794a;
  --red: #c0392b;
}

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

html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--bone);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---- battlefield canvas -------------------------------------------------- */
#rd-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.rd-playing #rd-canvas { cursor: none; }

/* ---- screen dressing ------------------------------------------------------ */
.rd-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse 75% 65% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
.rd-scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0.5;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(0, 0, 0, 0.14) 3px 4px);
}
#rd-damage-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(192, 57, 43, 0.45) 100%);
}
#rd-damage-flash.hit { animation: rd-dmg 0.5s ease-out; }
@keyframes rd-dmg { 0% { opacity: 1; } 100% { opacity: 0; } }

/* crosshair follows the pointer (hidden until a mission is live) */
#rd-crosshair {
  position: fixed; top: 0; left: 0; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  z-index: 5; pointer-events: none; color: rgba(232, 178, 90, 0.92); display: none;
  filter: drop-shadow(0 0 6px rgba(232, 178, 90, 0.5));
}
body.rd-playing #rd-crosshair { display: block; }
#rd-crosshair svg { width: 100%; height: 100%; }

/* ---- shared type ---------------------------------------------------------- */
.rd-eyebrow {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.34em;
  text-transform: uppercase; color: var(--gold);
}
.rd-eyebrow.danger { color: var(--red); }
h1, h2 {
  font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase;
  letter-spacing: 0.04em; line-height: 0.96;
}
h2.danger { color: var(--red); text-shadow: 0 0 44px rgba(192, 57, 43, 0.5); }

/* ---- buttons — clean, centred, consistent --------------------------------- */
.rd-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Oswald', sans-serif; font-weight: 600; font-size: 14px;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 13px 26px; border-radius: 3px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.18s ease; text-align: center;
}
.rd-btn.primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-dim));
  color: #14100a; border-color: var(--gold);
  box-shadow: 0 8px 30px rgba(232, 178, 90, 0.22);
}
.rd-btn.primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.rd-btn.big { font-size: 17px; padding: 17px 46px; letter-spacing: 0.2em; }
.rd-btn.ghost { background: rgba(255, 255, 255, 0.02); border-color: var(--line); color: var(--bone); }
.rd-btn.ghost:hover { border-color: var(--gold); color: var(--gold-bright); }
.rd-btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; filter: none; }

/* ---- overlays -------------------------------------------------------------- */
.rd-overlay {
  position: fixed; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center; padding: 22px;
  background: radial-gradient(ellipse at 50% 40%, rgba(6, 8, 9, 0.66), rgba(3, 4, 5, 0.9));
  backdrop-filter: blur(5px);
  animation: rd-fade 0.3s ease;
}
.rd-overlay.show { display: flex; }
@keyframes rd-fade { from { opacity: 0; } to { opacity: 1; } }

.rd-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 34px 38px; max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(232, 178, 90, 0.06);
  position: relative; text-align: center;
}
.rd-panel.wide { max-width: 880px; text-align: left; }
.rd-panel h2 { font-size: clamp(26px, 4.4vw, 40px); margin: 6px 0 14px; }
.rd-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; text-align: left; }
.rd-note { color: var(--dim); font-size: 13.5px; margin-bottom: 8px; }
.rd-x {
  background: none; border: 1px solid var(--line); border-radius: 3px; color: var(--dim);
  width: 34px; height: 34px; font-size: 15px; cursor: pointer; transition: 0.18s; flex-shrink: 0;
}
.rd-x:hover { color: var(--bone); border-color: var(--gold); }
.rd-stack { display: flex; flex-direction: column; gap: 11px; margin-top: 20px; align-items: stretch; }
.rd-stack.row { flex-direction: row; justify-content: center; }

/* ---- main menu -------------------------------------------------------------- */
#rd-menu { background: radial-gradient(ellipse at 50% 30%, rgba(6, 8, 9, 0.42), rgba(3, 4, 5, 0.88)); }
.rd-menu-inner { text-align: center; max-width: 720px; width: 100%; }
.rd-title {
  font-size: clamp(58px, 12vw, 128px); margin: 14px 0 4px;
  background: linear-gradient(180deg, var(--gold-bright) 20%, var(--gold-dim) 85%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  text-shadow: 0 30px 90px rgba(232, 178, 90, 0.18);
}
.rd-subtitle {
  font-family: 'Oswald', sans-serif; font-size: clamp(13px, 2vw, 17px);
  letter-spacing: 0.52em; color: var(--dim); text-transform: uppercase; margin-bottom: 30px;
}

#rd-aircraft-row { display: flex; gap: 12px; justify-content: center; margin-bottom: 30px; flex-wrap: wrap; }
.rd-air-card {
  width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  padding: 16px 14px; cursor: pointer; transition: 0.18s; color: var(--bone); text-align: center;
}
.rd-air-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.rd-air-card.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 12px 40px rgba(232, 178, 90, 0.18); }
.rd-air-icon { display: block; width: 44px; height: 44px; margin: 0 auto 8px; color: var(--gold); }
.rd-air-icon svg { width: 100%; height: 100%; }
.rd-air-card b { display: block; font-family: 'Oswald', sans-serif; font-size: 13.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.rd-air-card i { display: block; font-family: 'JetBrains Mono', monospace; font-style: normal; font-size: 9px; letter-spacing: 0.2em; color: var(--gold-dim); margin: 3px 0 7px; }
.rd-air-card p { font-size: 11.5px; color: var(--dim); line-height: 1.45; }

.rd-menu-buttons { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rd-menu-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.rd-hint {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: 0.05em;
  color: var(--dim); margin-top: 26px;
}
.rd-hint b { color: var(--gold); }
.rd-back {
  display: inline-block; margin-top: 18px; font-family: 'Oswald', sans-serif; font-size: 11.5px;
  letter-spacing: 0.2em; color: var(--dim); transition: color 0.18s;
}
.rd-back:hover { color: var(--gold); }

/* ---- HUD -------------------------------------------------------------------- */
#rd-hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: none; }
#rd-hud.on { display: block; }
.rd-hud-block { position: absolute; pointer-events: auto; }

.rd-tl { top: 16px; left: 16px; display: flex; flex-direction: column; gap: 8px; }
.rd-stat {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold-dim);
  border-radius: 3px; padding: 7px 14px 8px; min-width: 130px; backdrop-filter: blur(4px);
}
.rd-stat .lbl { display: block; font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.22em; color: var(--dim); text-transform: uppercase; }
.rd-stat .val { font-family: 'Anton', sans-serif; font-size: 23px; letter-spacing: 0.03em; }
.rd-stat.gold .val { color: var(--gold); }

#rd-feed { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.rd-feed-item {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: 0.08em;
  color: var(--green-bright); text-shadow: 0 0 12px rgba(127, 230, 160, 0.5);
  animation: rd-feed 2.1s ease forwards;
}
@keyframes rd-feed { 0% { opacity: 0; transform: translateX(-8px); } 12% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

.rd-tr { top: 16px; right: 16px; }
.rd-ctrl {
  width: 42px; height: 42px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 3px; color: var(--bone); font-size: 15px; cursor: pointer; transition: 0.18s;
  backdrop-filter: blur(4px);
}
.rd-ctrl:hover { border-color: var(--gold); color: var(--gold); }

.rd-tc { top: 18px; left: 50%; transform: translateX(-50%); width: min(46vw, 430px); display: none; }
.rd-tc.show { display: block; }
.rd-tc .name {
  font-family: 'Oswald', sans-serif; font-size: 12px; letter-spacing: 0.34em; text-align: center;
  color: var(--red); text-shadow: 0 0 14px rgba(192, 57, 43, 0.7); margin-bottom: 5px;
}
.rd-tc .bar { height: 9px; background: rgba(0, 0, 0, 0.65); border: 1px solid var(--red); border-radius: 4px; overflow: hidden; }
.rd-tc .fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #7a1e14, var(--red)); transition: width 0.15s linear; }

/* bars shared */
.rd-bar { height: 8px; background: rgba(255, 255, 255, 0.07); border-radius: 4px; overflow: hidden; }
.rd-bar.big { height: 11px; }
.rd-bar.mag { height: 5px; margin-top: 9px; }
.rd-bar .fill { display: block; height: 100%; width: 100%; transition: width 0.15s ease, background 0.3s; }
.fill.ok { background: linear-gradient(90deg, #3c7c4e, var(--green)); }
.fill.warn { background: linear-gradient(90deg, #8a6a2c, var(--gold)); }
.fill.bad { background: linear-gradient(90deg, #7a1e14, var(--red)); }
.fill.gold { background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright)); }
.fill.reload { background: linear-gradient(90deg, #3c7c4e, var(--green-bright)); }
.rd-bar-label {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.2em;
  color: var(--dim); text-transform: uppercase; margin-bottom: 5px;
}
.rd-bar-label.center { text-align: center; margin: 5px 0 0; }

.rd-bl { left: 16px; bottom: 18px; width: min(30vw, 250px); }
.rd-br { right: 16px; bottom: 16px; }
#rd-radar {
  display: block; border: 1px solid rgba(95, 174, 114, 0.4); border-radius: 50%;
  box-shadow: 0 0 30px rgba(95, 174, 114, 0.12), inset 0 0 24px rgba(0, 0, 0, 0.6);
}

.rd-bc {
  left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(44vw, 420px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 5px; padding: 12px 16px 12px; backdrop-filter: blur(5px);
}
.rd-weapon-name {
  font-family: 'Oswald', sans-serif; font-size: 12px; letter-spacing: 0.3em; color: var(--gold);
  text-align: center; margin: 10px 0 7px;
}
#rd-weapon-row { display: flex; gap: 7px; justify-content: center; }
.rd-slot {
  flex: 1; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 3px;
  color: var(--bone); font-family: 'Oswald', sans-serif; font-size: 10.5px; letter-spacing: 0.1em;
  padding: 7px 4px; cursor: pointer; transition: 0.15s; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.rd-slot b { color: var(--gold-dim); font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.rd-slot:hover { border-color: var(--gold-dim); }
.rd-slot.active { border-color: var(--gold); color: var(--gold-bright); background: rgba(232, 178, 90, 0.08); }
.rd-slot.locked { opacity: 0.32; cursor: not-allowed; }
#rd-ammo-row { display: flex; gap: 6px; justify-content: center; margin-top: 7px; }
.rd-chip {
  background: none; border: 1px solid var(--line); border-radius: 20px; color: var(--dim);
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.14em;
  padding: 3px 12px; cursor: pointer; transition: 0.15s;
}
.rd-chip:hover { border-color: var(--gold-dim); color: var(--bone); }
.rd-chip.active { border-color: var(--gold); color: var(--gold); background: rgba(232, 178, 90, 0.09); }
.rd-chip.locked { opacity: 0.3; cursor: not-allowed; }

/* wave banner */
#rd-banner {
  position: absolute; top: 26%; left: 50%; transform: translateX(-50%);
  font-family: 'Anton', sans-serif; font-size: clamp(22px, 4.4vw, 44px); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold); text-shadow: 0 0 46px rgba(232, 178, 90, 0.45);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
#rd-banner.danger { color: var(--red); text-shadow: 0 0 46px rgba(192, 57, 43, 0.55); }
#rd-banner.show { animation: rd-banner 2.6s ease forwards; }
@keyframes rd-banner {
  0% { opacity: 0; transform: translateX(-50%) scale(0.92); }
  12% { opacity: 1; transform: translateX(-50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.02); }
}

/* ---- command phase ----------------------------------------------------------- */
.rd-cmd-funds { display: flex; align-items: center; gap: 14px; }
.rd-cmd-funds .lbl { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.24em; color: var(--dim); }
.rd-cmd-funds .val { font-family: 'Anton', sans-serif; font-size: 30px; color: var(--gold); }
#rd-cmd-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px; margin: 18px 0 20px;
}
.rd-cmd-section {
  grid-column: 1 / -1; font-family: 'Oswald', sans-serif; font-size: 12px; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--line);
  padding-bottom: 6px; margin-top: 8px;
}
.rd-cmd-card {
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--line); border-radius: 4px;
  padding: 13px 14px; display: flex; flex-direction: column; gap: 6px;
}
.rd-cmd-card b { font-family: 'Oswald', sans-serif; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.rd-cmd-card p { font-size: 11.5px; color: var(--dim); line-height: 1.45; flex-grow: 1; }
.rd-cmd-card.owned { border-color: rgba(95, 174, 114, 0.35); }
.rd-owned { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.2em; color: var(--green-bright); }
.rd-pips { font-size: 11px; color: var(--gold); letter-spacing: 0.14em; }
.rd-btn-buy { padding: 8px 12px; font-size: 12px; background: rgba(232, 178, 90, 0.12); border-color: var(--gold-dim); color: var(--gold-bright); }
.rd-btn-buy:hover:not(:disabled) { background: rgba(232, 178, 90, 0.24); }
#rd-btn-launch { width: 100%; }

/* ---- settings ------------------------------------------------------------------ */
.rd-setting {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  padding: 13px 0; border-bottom: 1px solid var(--line); text-align: left;
}
.rd-setting label { font-family: 'Oswald', sans-serif; font-size: 12.5px; letter-spacing: 0.16em; color: var(--bone); }
.rd-setting input[type=range] { width: 170px; accent-color: var(--gold); }
.rd-setting input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--gold); }
.rd-setting select {
  background: var(--panel-solid); color: var(--bone); border: 1px solid var(--line);
  border-radius: 3px; padding: 7px 12px; font-family: 'JetBrains Mono', monospace; font-size: 11px;
}

/* ---- leaderboard ---------------------------------------------------------------- */
.rd-lb { width: 100%; border-collapse: collapse; font-family: 'JetBrains Mono', monospace; font-size: 12px; margin: 14px 0 6px; }
.rd-lb th {
  font-weight: 400; font-size: 9px; letter-spacing: 0.2em; color: var(--dim);
  padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left;
}
.rd-lb td { padding: 6px 8px; border-bottom: 1px solid rgba(38, 45, 52, 0.5); text-align: left; }
.rd-lb th:nth-child(n+3), .rd-lb td:nth-child(n+3) { text-align: right; }
.rd-lb-rank { color: var(--gold); }
.rd-lb-name { letter-spacing: 0.16em; }
.rd-lb-score { color: var(--gold-bright); }
.rd-lb-you { background: rgba(232, 178, 90, 0.1); }
.rd-lb-you td { color: var(--gold-bright); }
.rd-lb-empty { text-align: center !important; color: var(--dim); padding: 16px !important; }

/* ---- game over -------------------------------------------------------------------- */
.rd-go-stats { display: flex; gap: 26px; justify-content: center; margin: 18px 0 20px; flex-wrap: wrap; }
.rd-go-stats div { display: flex; flex-direction: column; align-items: center; }
.rd-go-stats b { font-family: 'Anton', sans-serif; font-size: 30px; line-height: 1; }
.rd-go-stats b.gold { color: var(--gold); }
.rd-go-stats span { font-family: 'JetBrains Mono', monospace; font-size: 8.5px; letter-spacing: 0.18em; color: var(--dim); margin-top: 5px; }
#rd-nameentry { margin: 4px 0 14px; }
#rd-nameentry label {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.2em;
  color: var(--green-bright); margin-bottom: 9px;
}
#rd-nameentry .row { display: flex; gap: 9px; justify-content: center; }
#rd-name {
  width: 158px; background: #05070a; border: 1px solid var(--gold); border-radius: 3px;
  color: var(--gold-bright); font-family: 'Anton', sans-serif; font-size: 24px;
  letter-spacing: 0.26em; text-align: center; text-transform: uppercase; padding: 7px 10px;
}
#rd-name:focus { outline: none; box-shadow: 0 0 0 2px rgba(232, 178, 90, 0.3); }

/* ---- boot failure ------------------------------------------------------------------- */
#rd-bootfail {
  position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  background: var(--bg); padding: 22px;
}
#rd-bootfail p { color: var(--dim); margin: 12px 0 20px; }

/* ---- responsive ----------------------------------------------------------------------- */
@media (max-width: 860px) {
  .rd-bc { width: min(64vw, 420px); }
  #rd-radar { width: 110px; height: 110px; }
  .rd-stat { min-width: 104px; padding: 5px 10px 6px; }
  .rd-stat .val { font-size: 18px; }
  .rd-bl { width: 200px; }
}
@media (max-width: 620px) {
  .rd-panel { padding: 24px 18px; }
  .rd-bc { left: 12px; right: 12px; transform: none; width: auto; }
  .rd-bl { bottom: 165px; }
  .rd-br { bottom: 165px; }
  #rd-radar { width: 84px; height: 84px; }
  .rd-air-card { width: 46%; }
  .rd-go-stats { gap: 16px; }
}
