:root {
  --ct-color: #7fb4e8;
  --ct-glow: #2d7de0;
  --t-color: #eec14b;
  --t-glow: #d9982b;
  --hud-yellow: #d7c07a;
  --hp-green: #97e058;
  --danger: #ff4747;
  --panel-bg: rgba(12, 16, 20, 0.86);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Segoe UI", "Arial Narrow", Arial, sans-serif;
  color: #fff;
  cursor: default;
  user-select: none;
}

#game-container { position: fixed; inset: 0; }
canvas { display: block; }

.hidden { display: none !important; }

/* ---------------- Crosshair ---------------- */
#crosshair {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  pointer-events: none;
  z-index: 30;
}
.ch-line {
  position: absolute;
  background: #24ff45;
  box-shadow: 0 0 1px #000;
  left: 50%; top: 50%;
}
.ch-top, .ch-bottom { width: 2px; height: 7px; margin-left: -1px; }
.ch-left, .ch-right { width: 7px; height: 2px; margin-top: -1px; }
.ch-top { transform: translate(0, calc(-100% - var(--ch-gap, 4px))); }
.ch-bottom { transform: translate(0, var(--ch-gap, 4px)); }
.ch-left { transform: translate(calc(-100% - var(--ch-gap, 4px)), 0); }
.ch-right { transform: translate(var(--ch-gap, 4px), 0); }
.ch-dot {
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 2px; margin: -1px 0 0 -1px;
  background: #24ff45; display: none;
}

/* ---------------- Hit marker ---------------- */
#hitmarker {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 26px; z-index: 31;
  opacity: 0; pointer-events: none;
}
#hitmarker.show { animation: hm 0.28s ease-out; }
#hitmarker.kill span { background: #ff5555; }
@keyframes hm { 0% { opacity: 1; } 100% { opacity: 0; } }
#hitmarker span {
  position: absolute; width: 8px; height: 2px; background: #fff;
}
#hitmarker span:nth-child(1) { top: 3px; left: 3px; transform: rotate(45deg); }
#hitmarker span:nth-child(2) { top: 3px; right: 3px; transform: rotate(-45deg); }
#hitmarker span:nth-child(3) { bottom: 3px; left: 3px; transform: rotate(-45deg); }
#hitmarker span:nth-child(4) { bottom: 3px; right: 3px; transform: rotate(45deg); }

/* ---------------- Hurt overlay ---------------- */
#hurt-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 25;
  box-shadow: inset 0 0 200px 40px rgba(200, 0, 0, 0);
  transition: box-shadow 0.4s ease-out;
}
#hurt-overlay.hit { box-shadow: inset 0 0 220px 70px rgba(200, 0, 0, 0.7); transition: none; }

/* ---------------- Scope ---------------- */
#scope-overlay {
  position: fixed; inset: 0; z-index: 28; pointer-events: none; display: none;
  background: radial-gradient(circle at center, transparent 34%, #000 34.4%);
}
#scope-overlay.active { display: block; }
.scope-circle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 68vh; height: 68vh; border: 2px solid #000; border-radius: 50%;
}
.scope-line { position: absolute; background: #000; }
.scope-h { left: 0; right: 0; top: 50%; height: 1px; }
.scope-v { top: 0; bottom: 0; left: 50%; width: 1px; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

#top-bar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: var(--panel-bg); padding: 6px 10px; border-radius: 3px;
}
#round-timer {
  font-size: 26px; font-weight: 700; min-width: 78px; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
}
.team-score {
  font-size: 26px; font-weight: 800; min-width: 42px; text-align: center;
  padding: 0 6px; border-radius: 2px;
}
.team-ct { color: #0d1418; background: var(--ct-color); }
.team-t { color: #0d1418; background: var(--t-color); }
#round-phase {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  font-size: 14px; color: var(--hud-yellow); text-shadow: 0 1px 2px #000;
}

#vitals {
  position: absolute; bottom: 20px; left: 26px;
  display: flex; gap: 26px; align-items: flex-end;
}
.vital-item { display: flex; align-items: center; gap: 8px; }
.vital-icon { font-size: 26px; opacity: 0.85; }
.vital-value {
  font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 4px #000;
}
#vitals .vital-item:first-child .vital-icon { color: var(--hp-green); }
#vitals .vital-item:nth-child(2) .vital-icon { color: var(--ct-color); }

#ammo-box {
  position: absolute; bottom: 20px; right: 26px;
  font-variant-numeric: tabular-nums; text-align: right;
  text-shadow: 0 2px 4px #000;
}
#ammo-clip { font-size: 46px; font-weight: 300; }
#ammo-sep { font-size: 30px; opacity: 0.5; margin: 0 3px; }
#ammo-reserve { font-size: 30px; opacity: 0.7; }
#weapon-name {
  display: block; font-size: 15px; letter-spacing: 2px; text-transform: uppercase;
  opacity: 0.75; margin-top: -4px;
}
#money-box {
  position: absolute; bottom: 96px; right: 26px;
  font-size: 26px; font-weight: 600; color: var(--hp-green);
  text-shadow: 0 2px 4px #000; font-variant-numeric: tabular-nums;
}
#money-box.flash { animation: moneyflash 0.6s ease; }
@keyframes moneyflash { 0% { transform: scale(1.25); color: #fff; } 100% { transform: scale(1); } }

#killfeed {
  position: absolute; top: 60px; right: 20px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.kf-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.5); padding: 3px 9px; border-radius: 2px;
  font-size: 14px; font-weight: 600; animation: kfin 0.2s ease;
}
@keyframes kfin { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; } }
.kf-name.ct { color: var(--ct-color); }
.kf-name.t { color: var(--t-color); }
.kf-weapon { opacity: 0.85; font-style: italic; }
.kf-hs { color: var(--danger); }

#radar {
  position: absolute; top: 16px; left: 16px;
  width: 220px; height: 220px;
  background: rgba(8, 12, 16, 0.72);
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.08);
}

#bomb-status {
  position: absolute; bottom: 150px; left: 26px;
  font-size: 15px; font-weight: 700; letter-spacing: 1px;
}
#bomb-status.planted { color: var(--danger); }

#weapon-slots {
  position: absolute; top: 50%; right: 18px; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 5px; align-items: flex-end;
}
.wslot {
  background: rgba(0,0,0,0.4); padding: 4px 12px; border-radius: 2px;
  font-size: 13px; color: #aaa; letter-spacing: 1px; min-width: 120px; text-align: right;
  border-right: 3px solid transparent;
}
.wslot.active { background: rgba(215,192,122,0.22); color: #fff; border-right-color: var(--hud-yellow); }
.wslot .wslot-key { opacity: 0.5; margin-right: 8px; font-size: 11px; }

#center-msg {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%);
  font-size: 40px; font-weight: 800; text-align: center;
  text-shadow: 0 3px 10px #000; opacity: 0; transition: opacity 0.3s;
  letter-spacing: 2px;
}
#center-msg.show { opacity: 1; }
#center-msg .sub { display: block; font-size: 20px; font-weight: 400; margin-top: 6px; opacity: 0.85; }

/* ---------------- Buy menu ---------------- */
#buy-menu {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 9, 12, 0.92);
  display: flex; flex-direction: column; padding: 30px 60px;
}
.buy-header { display: flex; align-items: baseline; gap: 24px; border-bottom: 1px solid #333; padding-bottom: 14px; }
.buy-header h1 { font-size: 30px; letter-spacing: 4px; font-weight: 800; }
.buy-money { font-size: 26px; color: var(--hp-green); font-weight: 700; }
.buy-hint { margin-left: auto; color: #888; font-size: 14px; }
.buy-body { display: flex; gap: 24px; margin-top: 20px; flex: 1; }
.buy-categories { display: flex; flex-direction: column; gap: 6px; width: 240px; }
.buy-cat {
  background: rgba(255,255,255,0.05); padding: 12px 16px; border-radius: 3px;
  cursor: pointer; font-size: 15px; letter-spacing: 1px; display: flex; gap: 10px; align-items: center;
  border-left: 3px solid transparent;
}
.buy-cat:hover { background: rgba(255,255,255,0.1); }
.buy-cat.active { background: rgba(215,192,122,0.18); border-left-color: var(--hud-yellow); }
.buy-cat .cat-key { color: var(--hud-yellow); font-weight: 700; }
.buy-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-content: start; flex: 1; }
.buy-item {
  background: rgba(255,255,255,0.05); border-radius: 4px; padding: 14px;
  cursor: pointer; transition: background 0.12s, transform 0.12s; position: relative;
  border: 1px solid transparent;
}
.buy-item:hover { background: rgba(215,192,122,0.14); transform: translateY(-2px); border-color: rgba(215,192,122,0.4); }
.buy-item.owned { opacity: 0.5; }
.buy-item.cant-afford { opacity: 0.4; cursor: not-allowed; }
.buy-item .bi-name { font-size: 16px; font-weight: 600; }
.buy-item .bi-price { color: var(--hp-green); font-size: 15px; margin-top: 6px; }
.buy-item .bi-meta { color: #888; font-size: 12px; margin-top: 4px; }
.buy-item .bi-icon { font-size: 22px; margin-bottom: 8px; opacity: 0.7; }

/* ---------------- Scoreboard ---------------- */
#scoreboard {
  position: fixed; inset: 0; z-index: 38;
  background: rgba(6, 9, 12, 0.85);
  display: flex; flex-direction: column; align-items: center; padding-top: 60px;
}
.sb-title { font-size: 24px; letter-spacing: 3px; margin-bottom: 24px; font-weight: 700; }
.sb-teams { display: flex; flex-direction: column; gap: 20px; width: 70%; max-width: 900px; }
.sb-team-header { font-size: 20px; font-weight: 800; padding: 8px 14px; letter-spacing: 2px; }
.sb-team-header.ct { background: rgba(45,125,224,0.35); color: var(--ct-color); }
.sb-team-header.t { background: rgba(217,152,43,0.35); color: var(--t-color); }
.sb-team-header span { float: right; }
.sb-team table { width: 100%; border-collapse: collapse; }
.sb-team td { padding: 7px 14px; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sb-team td.num { text-align: center; width: 70px; font-variant-numeric: tabular-nums; }
.sb-row.dead { opacity: 0.4; }
.sb-row.you td:first-child { color: var(--hud-yellow); font-weight: 700; }
.sb-head td { color: #888; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* ---------------- Start screen ---------------- */
#start-screen {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(circle at 50% 30%, #1a2632, #060809 70%);
  display: flex; align-items: center; justify-content: center;
}
.start-inner { text-align: center; max-width: 560px; padding: 20px; }
.game-logo { font-size: 72px; font-weight: 900; letter-spacing: 4px; line-height: 0.9; }
.game-logo span { color: var(--t-color); }
.tagline { color: #9fb0bd; margin: 10px 0 30px; font-size: 16px; letter-spacing: 1px; }
.start-panel {
  background: rgba(255,255,255,0.04); border-radius: 8px; padding: 20px 26px; margin-bottom: 24px;
}
.setting-row { display: flex; align-items: center; gap: 14px; margin: 14px 0; }
.setting-row label { width: 160px; text-align: right; font-size: 14px; color: #c3d0da; }
.setting-row input[type=range] { flex: 1; }
.setting-row select {
  flex: 1; padding: 6px 10px; background: #111; color: #fff; border: 1px solid #333; border-radius: 4px;
}
#sens-value { width: 34px; font-variant-numeric: tabular-nums; }
#start-btn {
  background: var(--t-color); color: #0d1418; border: none; padding: 16px 40px;
  font-size: 20px; font-weight: 800; letter-spacing: 2px; border-radius: 5px; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}
#start-btn:hover { transform: scale(1.04); box-shadow: 0 0 30px rgba(238,193,75,0.5); }
.controls-help { margin-top: 30px; text-align: left; }
.controls-help h3 { text-align: center; color: #9fb0bd; font-size: 14px; letter-spacing: 3px; margin-bottom: 12px; }
.controls-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 30px; font-size: 13px; color: #c3d0da; }
.controls-grid b { color: var(--t-color); display: inline-block; min-width: 74px; }

/* ---------------- Pause ---------------- */
#pause-screen {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(6, 9, 12, 0.7);
  display: flex; align-items: center; justify-content: center;
}
.pause-inner { text-align: center; }
.pause-inner h2 { font-size: 44px; letter-spacing: 6px; }
.pause-inner p { color: #9fb0bd; margin-top: 10px; font-size: 18px; }

/* low health pulse */
#health-value.low { color: var(--danger); animation: lowpulse 1s infinite; }
@keyframes lowpulse { 50% { opacity: 0.5; } }
