/* ============================================================
   GRAPPLE MECH 3D — mech arena combat UI
   Vanilla CSS · neon sci-fi HUD · responsive · touch-ready
   ============================================================ */

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

:root {
  --accent: #35d2ff;
  --accent2: #7cffb0;
  --accent3: #ff5c3d;
  --gold: #ffd166;
  --danger: #ff3b5c;
  --ok: #4dffb0;
  --panel: rgba(6, 10, 20, 0.6);
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

html, body {
  height: 100%;
  background: #05070c;
  color: #eaf6ff;
  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,92,0.55), transparent 70%); }
.fx-flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.fx-killflash { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(53,210,255,0.5), transparent 65%); }
.fx-killflash.on { animation: killflash .5s ease-out; }
@keyframes killflash { 0% { opacity: 1; } 100% { opacity: 0; } }

.fx-vignette { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, 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: .5; } 50%{ opacity: .9; } }

.fx-heatwarn { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(255,140,30,0.4) 100%); transition: opacity .3s ease; }
.fx-heatwarn.on { opacity: 1; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; text-shadow: 0 0 6px rgba(53,210,255,0.5); }
.hud.hidden { display: none; }

.radar-box { position: absolute; top: 12px; left: 12px; z-index: 6; background: var(--panel); border: 2px solid rgba(53,210,255,0.5); border-radius: 50%; padding: 6px; display: flex; flex-direction: column; align-items: center; backdrop-filter: blur(3px); }
.radar-box canvas { display: block; border-radius: 50%; background: #070c16; }
.radar-label { position: absolute; bottom: -16px; font-size: 8px; letter-spacing: 1.5px; color: var(--accent); white-space: nowrap; }

.leaderboard { position: absolute; top: 12px; right: 12px; z-index: 6; background: var(--panel); border: 1px solid rgba(53,210,255,0.4); border-radius: 10px; padding: 8px 12px; min-width: 150px; }
.lb-head { font-size: 9px; letter-spacing: 1.5px; color: var(--accent2); border-bottom: 1px solid rgba(53,210,255,0.3); padding-bottom: 4px; margin-bottom: 4px; }
.lb-row { display: flex; justify-content: space-between; font-size: 11px; padding: 2px 0; }
.lb-row .lb-name { color: #b9d7e8; }
.lb-row b { color: #fff; }
.lb-row.leader .lb-name { color: var(--gold); }

.hud-row { position: absolute; left: 0; right: 0; display: flex; justify-content: flex-end; padding: 10px 14px; }
.hud-mid { top: 70px; }

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

.storm-banner { position: absolute; top: 110px; left: 50%; transform: translateX(-50%); z-index: 6; font-size: clamp(11px,2vw,15px); font-weight: 800; letter-spacing: 1.5px; color: var(--accent3); text-shadow: 0 0 14px rgba(255,92,61,0.8); background: rgba(10,4,2,0.5); padding: 6px 16px; border-radius: 20px; border: 1px solid rgba(255,92,61,0.5); animation: stormPulse 1s infinite; }
.storm-banner.hidden { display: none; }
@keyframes stormPulse { 0%,100%{ opacity: 1; } 50%{ opacity: .55; } }

/* ---------- crosshair & hit marker ---------- */
.crosshair { position: absolute; top: 50%; left: 50%; width: 32px; height: 32px; transform: translate(-50%, -50%); pointer-events: none; z-index: 5; }
.ch-h, .ch-v { position: absolute; background: rgba(53,210,255,0.85); box-shadow: 0 0 6px rgba(53,210,255,0.8); }
.ch-h { top: 50%; left: 5px; width: calc(100% - 10px); height: 2px; transform: translateY(-1px); }
.ch-v { left: 50%; top: 5px; height: calc(100% - 10px); width: 2px; transform: translateX(-1px); }
.ch-dot { position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; border-radius: 50%; background: #ff3b5c; 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); } }

.killfeed { position: absolute; top: 90px; right: 14px; z-index: 6; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; max-width: 60vw; }
.killfeed .kf-row { font-size: 11px; background: rgba(6,10,20,0.6); border: 1px solid rgba(53,210,255,0.3); border-radius: 6px; padding: 4px 10px; color: #cfe9f7; animation: kfIn .3s ease-out, kfOut .4s ease-in 3.6s forwards; }
@keyframes kfIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes kfOut { to { opacity: 0; } }

/* ---------- Status panel (bottom-left) ---------- */
.status-panel { position: absolute; bottom: 14px; left: 14px; z-index: 6; background: var(--panel); border: 1px solid rgba(53,210,255,0.35); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.gauge { display: flex; flex-direction: column; gap: 2px; }
.gauge .lbl { font-size: 9px; color: var(--accent2); letter-spacing: 1.5px; }
.bar-track { width: 100%; height: 10px; background: rgba(255,255,255,0.1); border: 1px solid rgba(53,210,255,0.4); border-radius: 5px; overflow: hidden; }
.bar-track.small { height: 7px; }
.bar-fill { height: 100%; width: 100%; transition: width .12s linear; }
.bar-fill.shield { background: linear-gradient(90deg, #1a6fa8, var(--accent)); }
.bar-fill.armor { background: linear-gradient(90deg, var(--danger), var(--gold), var(--ok)); }
.bar-fill.heat { background: linear-gradient(90deg, #4a3a1a, var(--accent3)); }
.bar-fill.hook { background: linear-gradient(90deg, #5a1a6a, #c767ff); }
.bar-fill.weapon { background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.hook-row { display: flex; gap: 10px; }
.hook-ind { flex: 1; display: flex; flex-direction: column; gap: 2px; }

/* ---------- weapon box (bottom-right) ---------- */
.weapon-box { position: absolute; bottom: 14px; right: 14px; z-index: 6; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; background: var(--panel); border: 1px solid rgba(53,210,255,0.35); border-radius: 10px; padding: 8px 14px; min-width: 170px; }
.weapon-box b { font-size: clamp(13px,2.4vw,17px); color: #fff; letter-spacing: 1px; }
.weapon-box .hint-sm { font-size: 9px; color: #7fa3b8; }

/* ---------- 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(5,7,12,0.85); 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(53,210,255,0.35); border-radius: 18px; background: linear-gradient(160deg, rgba(53,210,255,0.14), rgba(124,255,176,0.08)); box-shadow: 0 0 48px rgba(53,210,255,0.22); }
.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: #b9d7e8; 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(53,210,255,0.5); border-radius: 12px; cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s; }
.btn:hover { background: rgba(53,210,255,0.15); box-shadow: 0 0 18px rgba(53,210,255,.35); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, #1a6fa8, #35d2ff); border-color: transparent; color: #06121a; box-shadow: 0 6px 20px rgba(53,210,255,.45); }
.btn.ghost { border-color: rgba(185,215,232,0.35); color: #cfe9f7; font-size: clamp(12px,2.2vw,14px); padding: 10px 18px; }
.hint { margin-top: 12px; font-size: 11px; color: #6f8ea0; 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: #cfe9f7; 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: #b9d7e8; 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: #b9d7e8; }
.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; 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: 108px; height: 108px; border-radius: 50%; background: rgba(53,210,255,0.1); border: 2px solid rgba(53,210,255,0.4); position: relative; touch-action: none; }
.stick-knob { position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; border-radius: 50%; background: rgba(53,210,255,0.5); border: 1px solid rgba(255,255,255,0.5); transform: translate(-50%,-50%); transition: background .1s; }
.stick-knob.active { background: rgba(53,210,255,0.85); }

.touch-right { position: absolute; right: clamp(10px,3vw,24px); bottom: clamp(14px,4vw,30px); display: grid; grid-template-columns: repeat(2, 54px); gap: 8px; pointer-events: none; z-index: 2; justify-items: center; }
.tbtn { pointer-events: auto; width: 54px; height: 54px; border-radius: 13px; background: rgba(26,111,168,0.35); border: 1px solid rgba(53,210,255,0.5); color: #fff; font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; text-align: center; touch-action: none; transition: background .1s, transform .05s; }
.tbtn:active, .tbtn.active { background: rgba(53,210,255,0.6); transform: scale(0.92); }
.tbtn.fire { grid-column: span 2; width: 100%; background: radial-gradient(circle at 40% 35%, rgba(255,92,61,.7), rgba(120,20,10,.55)); border: 2px solid rgba(255,92,61,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: #6f8ea0; 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) { .leaderboard { transform: scale(0.82); transform-origin: top right; } .status-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; } }
