/* ============================================================
   SKY DOGFIGHT 3D — flight combat UI
   Vanilla CSS · dark sky-neon HUD · responsive · touch-ready
   ============================================================ */

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

:root {
  --accent: #4ad4ff;
  --accent2: #2f7bff;
  --accent3: #6a4bd8;
  --gold: #ffd166;
  --danger: #ff4d6d;
  --ok: #5ee0a0;
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

html, body {
  height: 100%;
  background: #040812;
  color: #e8ecff;
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

.game-wrap {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}

#scene { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- FX overlays ---------- */
.fx-flash {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255,77,109,0.55), transparent 70%);
}
.fx-flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.fx-vignette {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255,20,40,0.55) 100%);
  transition: opacity .3s ease;
}
.fx-vignette.on { opacity: 1; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ opacity: .55; } 50%{ opacity: .95; } }

/* ---------- HUD ---------- */
.hud {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 12px clamp(10px, 3vw, 26px);
  text-shadow: 0 0 8px rgba(74,212,255,0.5);
}
.hud.hidden { display: none; }
.hud-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hud-mid { flex: 1; align-items: flex-start; justify-content: flex-end; }
.hud-bottom { align-items: flex-end; }

.hud-box { display: flex; flex-direction: column; gap: 2px; background: rgba(4,8,18,0.4); border: 1px solid rgba(74,212,255,0.25); border-radius: 10px; padding: 6px 12px; backdrop-filter: blur(3px); }
.hud-box.center { align-items: center; }
.hud-box.right { align-items: flex-end; }
.hud-box b { font-size: clamp(15px, 2.6vw, 22px); color: #fff; }
.hud-box .lbl { font-size: clamp(8px, 1.5vw, 11px); color: #9fb0ff; letter-spacing: 1px; }
.hud-box .lbl.best { color: var(--gold); }
.hud-box .lbl i, .hud-box .lbl b { font-style: normal; }
#killsVal { font-size: clamp(18px, 3.4vw, 28px); color: var(--accent); }
#killsVal small { font-size: 0.5em; color: #9fb0ff; }

.icon-btn {
  pointer-events: auto;
  background: rgba(47,123,255,0.2); border: 1px solid rgba(74,212,255,0.4);
  color: #fff; border-radius: 8px; width: 38px; height: 34px; font-size: 15px; cursor: pointer;
  margin-left: 8px; transition: background .2s, transform .1s;
}
.icon-btn:hover { background: rgba(74,212,255,0.3); }
.icon-btn:active { transform: scale(0.92); }

/* ---------- Crosshair ---------- */
.crosshair {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 5;
}
.ch-h, .ch-v { position: absolute; background: rgba(74,212,255,0.85); box-shadow: 0 0 6px rgba(74,212,255,0.8); }
.ch-h { top: 50%; left: 0; width: 100%; height: 2px; transform: translateY(-1px); }
.ch-v { left: 50%; top: 0; height: 100%; width: 2px; transform: translateX(-1px); }
.ch-dot { position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); transform: translate(-50%, -50%); box-shadow: 0 0 8px var(--danger); }

/* ---------- Gauges / instruments ---------- */
.gauge-box { display: flex; flex-direction: column; gap: 4px; align-items: center; min-width: 100px; }
.gauge-box .lbl { font-size: clamp(8px,1.5vw,11px); color: var(--accent); letter-spacing: 2px; }
.bar-track { width: clamp(90px, 22vw, 160px); height: 12px; background: rgba(255,255,255,0.12); border: 1px solid rgba(74,212,255,0.5); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 100%; transition: width .1s linear; }
.bar-fill.health { background: linear-gradient(90deg, var(--danger), var(--gold), var(--ok)); }
.bar-fill.throttle { background: linear-gradient(90deg, var(--accent2), var(--accent)); }

.instruments { display: flex; gap: 14px; }
.instrument { display: flex; flex-direction: column; align-items: center; background: rgba(4,8,18,0.4); border: 1px solid rgba(74,212,255,0.25); border-radius: 10px; padding: 6px 14px; }
.instrument b { font-size: clamp(20px, 4vw, 34px); color: #fff; line-height: 1; text-shadow: 0 0 12px var(--accent); }
.instrument .lbl { font-size: clamp(8px,1.5vw,11px); color: #9fb0ff; letter-spacing: 2px; }

/* ---------- Countdown ---------- */
.countdown {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.countdown.hidden { display: none; }
.countdown span {
  font-size: clamp(70px, 22vw, 180px); font-weight: 800; color: #fff;
  text-shadow: 0 0 24px var(--accent), 0 0 60px var(--accent3);
  animation: countPop .8s ease-out;
}
@keyframes countPop { from { transform: scale(2.2); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); opacity: 0.15; } }

/* ---------- Overlays / panels ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,8,18,0.8); backdrop-filter: blur(4px); padding: 16px;
}
.overlay.hidden { display: none; }
.panel {
  text-align: center; padding: clamp(20px, 4vw, 40px); width: 100%; max-width: 460px;
  border: 2px solid rgba(74,212,255,0.35); border-radius: 18px;
  background: linear-gradient(160deg, rgba(47,123,255,0.14), rgba(106,75,216,0.08));
  box-shadow: 0 0 48px rgba(74,212,255,0.22);
}
.title { font-size: clamp(28px, 7vw, 50px); font-weight: 800; letter-spacing: 2px; color: #fff; text-shadow: 0 0 14px var(--accent), 0 0 34px var(--accent2); animation: flicker 4s infinite; }
.title.small { font-size: clamp(22px, 6vw, 38px); }
@keyframes flicker { 0%,92%,100%{opacity:1} 93%{opacity:.7} 95%{opacity:1} 97%{opacity:.8} }
.tagline { margin: 10px 0 20px; color: #9fb0ff; font-size: clamp(12px, 2.6vw, 16px); letter-spacing: 1px; }

.menu-btns { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.btn {
  pointer-events: auto; padding: 13px 22px; font-family: var(--font); font-weight: 700;
  font-size: clamp(13px, 2.4vw, 16px); letter-spacing: 1.5px; color: #fff;
  background: rgba(255,255,255,0.06); border: 2px solid rgba(74,212,255,0.5); border-radius: 12px;
  cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:hover { background: rgba(74,212,255,0.15); box-shadow: 0 0 18px rgba(74,212,255,.35); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent2), var(--accent3)); border-color: transparent; box-shadow: 0 6px 20px rgba(47,123,255,.5); }
.btn.ghost { border-color: rgba(159,176,255,0.35); color: #cdd6ff; font-size: clamp(12px,2.2vw,14px); padding: 10px 18px; }
.hint { margin-top: 12px; font-size: 11px; color: #6f7bb5; line-height: 1.6; }

.help-list { text-align: left; list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 10px 0 20px; font-size: clamp(12px, 2.2vw, 14px); color: #cdd6ff; line-height: 1.5; }

.result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 18px; }
.result div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 3px; }
.result span { font-size: 10px; color: #9fb0ff; letter-spacing: 1px; }
.result b { font-size: clamp(15px,3vw,20px); color: var(--gold); }
.new-high { color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; animation: flicker 1.1s infinite; }
#overScreen .btn, #pauseScreen .btn, #menuScreen .btn { width: 100%; }
#overScreen .btn + .btn, #pauseScreen .btn + .btn { margin-top: 8px; }

.scores-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 18px; }
.scores-list .row { display: flex; justify-content: space-between; background: rgba(255,255,255,0.05); padding: 9px 12px; border-radius: 8px; font-size: clamp(11px,2.2vw,14px); }
.scores-list .row span { color: #9fb0ff; }
.scores-list .row b { color: #fff; }

/* ---------- Touch controls ---------- */
.touch {
  position: absolute; inset: 0; z-index: 8;
  display: none; pointer-events: none;
}
.touch-stick { position: absolute; left: clamp(14px,4vw,30px); bottom: clamp(14px,4vw,30px); pointer-events: auto; }
.stick-base { width: 120px; height: 120px; border-radius: 50%; background: rgba(74,212,255,0.12); border: 2px solid rgba(74,212,255,0.4); position: relative; touch-action: none; }
.stick-knob { position: absolute; top: 50%; left: 50%; width: 52px; height: 52px; border-radius: 50%; background: rgba(74,212,255,0.55); border: 1px solid rgba(255,255,255,0.5); transform: translate(-50%,-50%); transition: background .1s; }
.stick-knob.active { background: rgba(74,212,255,0.85); }

.touch-right { position: absolute; right: clamp(14px,4vw,30px); bottom: clamp(14px,4vw,30px); display: grid; grid-template-columns: repeat(2, 56px); gap: 10px; pointer-events: none; justify-items: center; }
.tbtn {
  pointer-events: auto;
  width: 56px; height: 56px; border-radius: 14px;
  background: rgba(47,123,255,0.3); border: 1px solid rgba(74,212,255,0.5);
  color: #fff; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  touch-action: none; transition: background .1s, transform .05s;
}
.tbtn:active, .tbtn.active { background: rgba(74,212,255,0.6); transform: scale(0.92); }
.tbtn.yaw { font-size: 20px; }
.tbtn.fire {
  grid-column: span 2; width: 100%; height: 56px; border-radius: 28px;
  background: radial-gradient(circle at 40% 35%, rgba(255,77,109,.75), rgba(118,20,40,.6));
  border: 2px solid rgba(255,77,109,0.7);
}
@media (hover: none) and (pointer: coarse) { .touch { display: block; } }
body.touch-mode .touch { display: block; }
body.touch-mode .crosshair { opacity: .5; }

.back-home {
  position: absolute; left: 10px; top: 8px; z-index: 6;
  font-size: 11px; color: #7f8bc7; text-decoration: none;
  background: rgba(0,0,0,.3); padding: 4px 8px; border-radius: 6px;
}
.back-home:hover { color: var(--accent); }
@media (max-width: 620px) { .back-home { top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2; } }
