/* ==========================================================================
   Strike Zone — layout, HUD, panel
   ========================================================================== */
:root {
  --bg: #050608;
  --panel: #14161f;
  --panel-border: #252a3a;
  --text: #e8eaf2;
  --muted: #8b90a6;
  --accent: #fe2c55;
  --accent-2: #25f4ee;
  --gold: #ffd84d;
  --ok: #3ddc84;
  --warn: #ffb02e;
  --err: #ff5c6c;
  --hud: #f2f2f2;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}
body { display: flex; }

#stage { position: relative; flex: 1; min-width: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: #000; }
#viewport { position: relative; overflow: hidden; container-type: size; font-size: 2.2cqmin; }
#game-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; color: var(--hud); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }

#lowhp {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(160, 0, 0, 0.75) 100%);
}

/* Crosshair: four lines that spread apart with --gap */
#crosshair { --gap: 6px; position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair i { position: absolute; background: #7dff8a; box-shadow: 0 0 2px #000; transition: transform 0.06s; }
#crosshair .t, #crosshair .b { width: 2px; height: 9px; left: -1px; }
#crosshair .l, #crosshair .r { width: 9px; height: 2px; top: -1px; }
#crosshair .t { bottom: var(--gap); }
#crosshair .b { top: var(--gap); }
#crosshair .l { right: var(--gap); }
#crosshair .r { left: var(--gap); }
#crosshair .dot { width: 2px; height: 2px; left: -1px; top: -1px; }
#crosshair[hidden] { display: none; }

/* Hit marker: an X around the crosshair */
#hitmarker { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
#hitmarker i { position: absolute; width: 10px; height: 2px; background: #fff; left: -5px; top: -1px; }
#hitmarker i:nth-child(1) { transform: rotate(45deg) translateX(-10px); }
#hitmarker i:nth-child(2) { transform: rotate(45deg) translateX(10px); }
#hitmarker i:nth-child(3) { transform: rotate(-45deg) translateX(-10px); }
#hitmarker i:nth-child(4) { transform: rotate(-45deg) translateX(10px); }
#hitmarker.head i { background: #ff3b3b; }
#hitmarker.show { animation: hit 0.25s ease-out; }

/* Damage direction arcs */
#damage { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.dmg {
  position: absolute; left: -12cqmin; top: -24cqmin; width: 24cqmin; height: 6cqmin;
  transform-origin: 12cqmin 24cqmin;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 30, 30, 0.85), rgba(255, 30, 30, 0) 70%);
  border-radius: 50% 50% 0 0;
  animation: dmg 0.9s ease-out forwards;
}

/* Sniper scope */
#scope { position: absolute; inset: 0; }
#scope[hidden] { display: none; }
#scope .lens {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, transparent 0, transparent 38cqmin, #000 38.3cqmin);
}
#scope .hair { position: absolute; background: #000; }
#scope .hair.h { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
#scope .hair.v { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }

/* Top */
#radar {
  position: absolute; top: 2.5cqmin; left: 2.5cqmin; width: 24cqmin; height: 24cqmin; border-radius: 50%;
}
.top-center { position: absolute; top: 2cqmin; left: 0; right: 0; text-align: center; }
#round { font-size: 3.4cqmin; font-weight: 900; letter-spacing: 0.3cqmin; color: var(--gold); }
#kills { font-size: 2.4cqmin; font-weight: 700; margin-top: 0.3cqmin; }
#alive { font-size: 1.8cqmin; opacity: 0.8; }

#killfeed { position: absolute; top: 2.5cqmin; right: 2.5cqmin; display: flex; flex-direction: column; align-items: flex-end; gap: 0.5cqmin; }
.kf-line { background: rgba(0, 0, 0, 0.55); padding: 0.4cqmin 1.2cqmin; border-radius: 0.5cqmin; font-size: 1.9cqmin; animation: slideIn 0.2s; }
.kf-line .me { color: var(--accent-2); }
.kf-line .wpn { color: #aaa; font-size: 1.6cqmin; }
.kf-line .hs { color: #ff3b3b; }

#feed { position: absolute; top: 29cqmin; left: 2.5cqmin; max-width: 50%; display: flex; flex-direction: column; gap: 0.5cqmin; }
.feed-line { align-self: flex-start; padding: 0.5cqmin 1.2cqmin; border-radius: 0.6cqmin; background: rgba(0, 0, 0, 0.55); font-weight: 700; font-size: 2.1cqmin; animation: slideIn 0.25s; transition: opacity 0.5s; }
.feed-line.fade { opacity: 0; }

/* Bottom */
.bottom-left { position: absolute; left: 2.5cqmin; bottom: 2.5cqmin; width: 26cqmin; }
.vital { display: inline-flex; align-items: baseline; gap: 0.8cqmin; font-size: 5.5cqmin; font-weight: 900; margin-right: 2.5cqmin; }
.vital .ico { font-size: 3cqmin; color: #ff6b6b; }
.vital.armor .ico { color: #4aa8ff; }
.bar { height: 1cqmin; background: rgba(0, 0, 0, 0.55); border-radius: 99px; overflow: hidden; margin-top: 0.6cqmin; }
.bar.likes { height: 0.6cqmin; }
.fill { height: 100%; transition: width 0.2s; }
.fill.ok { background: #3ddc84; }
.fill.warn { background: #ffb02e; }
.fill.low { background: #ff4d5e; }
#like-fill { background: #ff6b9a; }

.bottom-right { position: absolute; right: 2.5cqmin; bottom: 2.5cqmin; text-align: right; }
#weapon-name { font-size: 2.2cqmin; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: 0.2cqmin; }
.ammo { font-weight: 900; line-height: 1; }
#ammo-mag { font-size: 7cqmin; }
#ammo-mag.empty { color: #ff4d5e; }
#ammo-res { font-size: 3cqmin; opacity: 0.75; margin-left: 0.6cqmin; }
#reload-hint { font-size: 2cqmin; font-weight: 800; color: #ffb070; min-height: 2.4cqmin; }

#banner {
  position: absolute; top: 24%; left: 0; right: 0; text-align: center; font-size: 6.5cqmin; font-weight: 900;
  letter-spacing: 0.4cqmin; opacity: 0; -webkit-text-stroke: 0.15cqmin #000;
}
#banner.show { animation: banner 1.8s ease-out forwards; }
#toast { position: absolute; top: 60%; left: 0; right: 0; text-align: center; font-size: 3.2cqmin; font-weight: 900; opacity: 0; }
#toast.show { animation: toast 1.3s ease-out forwards; }

/* ---------- Overlays ---------- */
#lock-overlay, #game-over, #loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqmin;
}
#lock-overlay { background: rgba(5, 6, 10, 0.6); cursor: pointer; backdrop-filter: blur(2px); }
#lock-overlay[hidden], #game-over[hidden], #loading[hidden] { display: none; }
.lo-title { font-size: 9cqmin; font-weight: 900; font-style: italic; letter-spacing: 0.5cqmin; color: #fff; text-shadow: 0 0 4cqmin rgba(254, 44, 85, 0.6); }
.lo-click { font-size: 3.6cqmin; font-weight: 900; color: var(--accent-2); animation: pulse 1.2s infinite alternate; }
.lo-keys { display: grid; grid-template-columns: repeat(3, auto); gap: 1cqmin 3cqmin; font-size: 2cqmin; color: #ccd; margin-top: 1cqmin; }
.lo-keys b { color: #fff; }

#game-over { background: radial-gradient(ellipse at center, rgba(70, 0, 0, 0.6), rgba(0, 0, 0, 0.9)); cursor: pointer; animation: fadeIn 0.6s; }
.go-title { font-size: 7.5cqmin; font-weight: 900; color: #ff3b3b; letter-spacing: 0.4cqmin; }
#go-stats { font-size: 2.6cqmin; line-height: 1.7; text-align: center; }
#go-stats b { color: #fff; }
.go-hint { color: var(--accent-2); font-size: 2.3cqmin; font-weight: 800; margin-top: 1cqmin; }
#go-countdown { color: var(--muted); font-size: 2cqmin; }

#loading { background: #07080c; }
.loading-title { font-size: 8cqmin; font-weight: 900; font-style: italic; color: var(--accent); }
.loading-track { width: 50%; height: 1cqmin; background: #1c1f2a; border-radius: 99px; overflow: hidden; }
#loading-bar { width: 0; height: 100%; background: var(--accent-2); transition: width 0.3s; }
.loading-sub { color: var(--muted); font-size: 2.2cqmin; }

@keyframes hit { 0% { opacity: 1; transform: scale(1.3); } 100% { opacity: 0; transform: scale(1); } }
@keyframes dmg { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes banner { 0% { opacity: 0; transform: scale(0.7); } 15% { opacity: 1; transform: scale(1.05); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
@keyframes toast { 0% { opacity: 0; transform: translateY(1.5cqmin); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-2cqmin); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-2cqmin); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

/* ==========================================================================
   Streamer panel
   ========================================================================== */
#panel { width: 320px; flex-shrink: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--panel-border); padding: 16px; }
body.panel-hidden #panel { display: none; }
#show-panel-btn { display: none; position: absolute; top: 8px; right: 8px; opacity: 0.25; flex: none; z-index: 5; }
#show-panel-btn:hover { opacity: 1; }
body.panel-hidden #show-panel-btn { display: block; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 10px; color: var(--accent-2); }
h3 { font-size: 12px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
section { padding: 14px 0; border-top: 1px solid var(--panel-border); }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.at { color: var(--muted); font-weight: 600; }
input { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--panel-border); background: #0d0f16; color: var(--text); font-size: 14px; }
input:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; }
button { flex: 1; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--panel-border); background: #20243a; color: var(--text); font-size: 13px; cursor: pointer; }
button:hover:not(:disabled) { filter: brightness(1.25); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.small { flex: none; padding: 4px 8px; font-size: 12px; }
button.active { background: #1f6f4a; border-color: var(--ok); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid .wide { grid-column: span 2; }
.status { margin: 4px 0 0; padding: 8px 10px; border-radius: 6px; background: #0d0f16; font-size: 13px; }
.status::before { content: "● "; }
.status-idle::before, .status-disconnected::before { color: var(--muted); }
.status-connecting::before { color: var(--warn); }
.status-connected::before { color: var(--ok); }
.status-error::before { color: var(--err); }
.status-error { color: var(--err); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.hint a { color: var(--accent-2); }
.hint b { color: var(--text); }
code { background: #0d0f16; padding: 1px 4px; border-radius: 4px; font-size: 11px; }

/* Home button (panel header) */
.panel-header { gap: 8px; }
.panel-header h1 { flex: 1; }
.home-btn {
  flex: none;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent-2, #25f4ee);
  background: rgba(37, 244, 238, 0.12);
  color: var(--text, #e8eaf2);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.home-btn:hover { background: rgba(37, 244, 238, 0.25); }
