/* ============================================================
   COMMANDO SQUAD 3D — tactical urban combat UI
   Vanilla CSS · military HUD · responsive · touch-ready
   ============================================================ */

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

:root {
  --accent: #8fd13f;
  --accent2: #c7ff4d;
  --accent3: #ff9b3d;
  --gold: #ffd166;
  --danger: #ff3b3b;
  --ok: #4dffb0;
  --panel: rgba(10, 16, 6, 0.55);
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

html, body {
  height: 100%;
  background: #05070a;
  color: #eaf4df;
  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; cursor: crosshair; }

/* ---------- FX overlays ---------- */
.fx-flash {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255,59,59,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(180,10,10,0.6) 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; text-shadow: 0 0 6px rgba(143,209,63,0.5); }
.hud.hidden { display: none; }
.hud-row { position: absolute; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px clamp(10px, 3vw, 26px); }
.hud-top { top: 0; }
.hud-mid { top: 48px; justify-content: flex-end; }
.hud-bottom { bottom: 0; align-items: flex-end; }

.hud-box { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid rgba(143,209,63,0.3); border-radius: 10px; padding: 6px 12px; backdrop-filter: blur(3px); max-width: 60vw; }
.hud-box.right { align-items: flex-end; }
.hud-box b { font-size: clamp(13px, 2.2vw, 18px); color: #fff; }
.hud-box .lbl { font-size: clamp(8px, 1.5vw, 11px); color: #b8d99a; letter-spacing: 1px; }

.icon-btn {
  pointer-events: auto;
  background: rgba(143,209,63,0.15); border: 1px solid rgba(143,209,63,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(143,209,63,0.3); }
.icon-btn:active { transform: scale(0.92); }

/* ---------- Minimap ---------- */
.minimap-box {
  position: absolute; top: 12px; left: 12px; z-index: 6;
  background: rgba(5,10,3,0.55); border: 2px solid rgba(143,209,63,0.5); border-radius: 10px;
  padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.minimap-box canvas { display: block; border-radius: 6px; background: #0c1708; }
.minimap-label { font-size: 9px; letter-spacing: 2px; color: #8fd13f; }

/* ---------- Crosshair & hit marker ---------- */
.crosshair { position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; transform: translate(-50%, -50%); pointer-events: none; z-index: 5; }
.ch-h, .ch-v { position: absolute; background: rgba(143,209,63,0.85); box-shadow: 0 0 6px rgba(143,209,63,0.8); }
.ch-h { top: 50%; left: 6px; width: calc(100% - 12px); height: 2px; transform: translateY(-1px); }
.ch-v { left: 50%; top: 6px; height: calc(100% - 12px); width: 2px; transform: translateX(-1px); }
.ch-dot { position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); }

.hitmarker { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; transform: translate(-50%,-50%); pointer-events: none; z-index: 6; opacity: 0; }
.hitmarker span { position: absolute; width: 11px; height: 2px; background: var(--danger); }
.hitmarker span:nth-child(1) { top: 2px; left: 2px; transform: rotate(45deg); }
.hitmarker span:nth-child(2) { top: 2px; right: 2px; transform: rotate(-45deg); }
.hitmarker span:nth-child(3) { bottom: 2px; left: 2px; transform: rotate(-45deg); }
.hitmarker span:nth-child(4) { bottom: 2px; right: 2px; transform: rotate(45deg); }
.hitmarker.on { animation: hitpop .32s ease-out; }
@keyframes hitpop { 0% { opacity: 1; transform: translate(-50%,-50%) scale(0.6); } 40% { opacity: 1; transform: translate(-50%,-50%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1.3); } }

/* ---------- Squad status panel ---------- */
.squad-panel {
  position: absolute; bottom: 14px; left: 14px; z-index: 6;
  background: var(--panel); border: 1px solid rgba(143,209,63,0.35); border-radius: 12px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 190px; backdrop-filter: blur(3px);
}
.squad-row { display: grid; grid-template-columns: 22px 54px 1fr 72px; align-items: center; gap: 6px; font-size: 10px; }
.squad-id { color: var(--accent2); font-weight: 800; }
.squad-role { color: #b8d99a; letter-spacing: 0.5px; }
.squad-bar-track { height: 7px; background: rgba(255,255,255,0.12); border: 1px solid rgba(143,209,63,0.4); border-radius: 4px; overflow: hidden; }
.squad-bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--danger), var(--gold), var(--accent)); transition: width .15s linear; }
.squad-state { text-align: right; color: #d9f0c2; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.squad-row.down .squad-id, .squad-row.down .squad-state { color: var(--danger); }
.squad-cmds { display: flex; gap: 4px; margin-top: 2px; flex-wrap: wrap; }
.cmd-chip { font-size: 8px; letter-spacing: 0.5px; background: rgba(143,209,63,0.12); border: 1px solid rgba(143,209,63,0.4); border-radius: 10px; padding: 3px 7px; color: #d9f0c2; transition: background .15s; }
.cmd-chip.active { background: rgba(199,255,77,0.4); color: #0a0f04; font-weight: 800; }

/* ---------- Bottom-right gauges ---------- */
.gauge-box { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 140px; }
.gauge-box .lbl { font-size: clamp(8px,1.5vw,11px); color: var(--accent); letter-spacing: 2px; }
.bar-track { width: clamp(120px, 26vw, 220px); height: 14px; background: rgba(255,255,255,0.12); border: 1px solid rgba(143,209,63,0.5); border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; width: 100%; transition: width .12s linear; }
.bar-fill.health { background: linear-gradient(90deg, var(--danger), var(--gold), var(--accent)); }

.weapon-box { display: flex; flex-direction: column; align-items: flex-end; background: var(--panel); border: 1px solid rgba(143,209,63,0.3); border-radius: 10px; padding: 6px 14px; }
.weapon-box b { font-size: clamp(14px, 2.6vw, 20px); color: #fff; letter-spacing: 1px; }
.weapon-box .lbl { font-size: clamp(11px,2vw,15px); color: var(--accent2); }

/* ---------- 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,3,0.82); backdrop-filter: blur(4px); padding: 16px; }
.overlay.hidden { display: none; }
.panel {
  text-align: center; padding: clamp(20px, 4vw, 40px); width: 100%; max-width: 480px;
  border: 2px solid rgba(143,209,63,0.35); border-radius: 18px;
  background: linear-gradient(160deg, rgba(79,110,34,0.2), rgba(20,30,10,0.4));
  box-shadow: 0 0 48px rgba(143,209,63,0.2);
}
.title { font-size: clamp(26px, 7vw, 48px); font-weight: 800; letter-spacing: 2px; color: #fff; text-shadow: 0 0 14px var(--accent), 0 0 34px var(--accent3); animation: flicker 4s infinite; }
.title.small { font-size: clamp(20px, 5.4vw, 34px); }
@keyframes flicker { 0%,92%,100%{opacity:1} 93%{opacity:.7} 95%{opacity:1} 97%{opacity:.8} }
.tagline { margin: 10px 0 20px; color: #b8d99a; font-size: clamp(12px, 2.4vw, 15px); letter-spacing: 0.5px; }

.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(143,209,63,0.5); border-radius: 12px;
  cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:hover { background: rgba(143,209,63,0.15); box-shadow: 0 0 18px rgba(143,209,63,.35); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, #4f6e22, #8fd13f); border-color: transparent; color: #0a0f04; box-shadow: 0 6px 20px rgba(143,209,63,.45); }
.btn.ghost { border-color: rgba(184,217,154,0.35); color: #d9f0c2; font-size: clamp(12px,2.2vw,14px); padding: 10px 18px; }
.hint { margin-top: 12px; font-size: 11px; color: #83976b; 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.1vw, 14px); color: #d9f0c2; 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: #b8d99a; 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: #b8d99a; }
.scores-list .row b { color: #fff; }

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

.touch-right { position: absolute; right: clamp(14px,4vw,30px); bottom: clamp(14px,4vw,30px); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; z-index: 2; }
.tbtn {
  pointer-events: auto; width: 52px; height: 52px; border-radius: 14px;
  background: rgba(79,110,34,0.4); border: 1px solid rgba(143,209,63,0.5);
  color: #fff; font-size: 11px; 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(143,209,63,0.6); transform: scale(0.92); }
.tbtn.fire { width: 76px; height: 76px; border-radius: 50%; font-size: 13px; background: radial-gradient(circle at 40% 35%, rgba(255,59,59,.7), rgba(120,10,10,.55)); border: 2px solid rgba(255,59,59,0.7); }
@media (hover: none) and (pointer: coarse) { .touch { display: block; } }
body.touch-mode .touch { display: block; }
body.touch-mode .crosshair { opacity: .6; }

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