/* ===== base ===== */
body {
  margin: 0;
  font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
  background: #0c0d11;
  color: #e9ecf5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* back button */
.back-button {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(20,22,28,0.85);
  color: #fff;
  border: 1px solid #2a2f3a;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 2000;
  transition: background .15s ease, border-color .15s ease;
}
.back-button:hover { background: rgba(32,36,46,0.92); border-color:#3a4252; }

/* map */
#map-container {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: radial-gradient(1200px 600px at 50% 30%, #111625, #0c0d11 60%);
}
#map-wrapper {
  position: absolute; top: 0; left: 0;
  transform-origin: center center;
  cursor: grab;
}
#map-wrapper:active { cursor: grabbing; }
#mapCanvas {
  display: block;
  width: 1024px; height: 1024px;
  max-width: none;
  user-select: none; pointer-events: none;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,0.45));
}

/* HUD (right) */
#hud {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  width: 280px;
  background: rgba(12,14,18,0.88);
  border: 1px solid #2d3342;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  z-index: 900;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
#hud h3 {
  margin: 8px 0 6px;
  font-size: 12px;
  color: #aebdf6;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.hud-player {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  padding: 6px 8px;
  background: rgba(28,32,42,0.55);
  border: 1px solid rgba(60,66,84,0.5);
  border-radius: 8px;
}
.hud-player.dead { opacity: 0.55; }
.hud-player .dot { width: 10px; height: 10px; border-radius: 50%; }
.hud-player .dot.ct { background: #6aa6ff; }
.hud-player .dot.t  { background: #f2c14e; }
.hud-player .name { font-weight: 600; color: #e7ecff; }
.hud-player .hp   { color: #b9c3ff; font-size: 12px; }
.hud-player .weapon { color: #cfd3dd; font-size: 12px; }

/* killfeed (top-right, above HUD) */
#killfeed {
  position: absolute;
  top: 14px; right: 20px;
  width: 320px;
  font-size: 13px;
  max-height: 220px;
  overflow: hidden;
  z-index: 950;
  text-shadow: 0 1px 1px #000;
}
.kill-entry {
  background: rgba(18,20,26,0.7);
  border: 1px solid rgba(56,64,82,0.6);
  border-radius: 8px;
  padding: 4px 8px;
  margin-bottom: 4px;
}
.kill-entry .killer { color: #e7ecff; font-weight: 600; }
.kill-entry .verb   { color: #ff6b6b; }
.kill-entry .victim { color: #ffeaa0; font-weight: 600; }
.kill-entry .weap   { color: #b2b7c4; margin-left: 6px; }

/* bomb & defuse */
#bomb-status {
  position: absolute;
  bottom: 110px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(210,40,40,0.95), rgba(160,20,20,0.95));
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px; font-weight: 700;
  display: none; z-index: 950;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
#defuse-bar {
  position: absolute;
  bottom: 84px; left: 50%; transform: translateX(-50%);
  width: 240px; height: 10px;
  border: 1px solid #606a84;
  background: rgba(255,255,255,0.08);
  display: none; z-index: 950;
  border-radius: 8px; overflow: hidden;
}
#defuse-progress { height: 100%; width: 0%; background: #4aa3ff; }

/* timeline */
#timeline {
  background: #101219;
  border-top: 1px solid #222836;
  display: flex; flex-direction: column;
  gap: 6px; padding: 8px 10px 10px;
}
#round-strip {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px;
  overflow-x: auto;
  background: #131724;
  border: 1px solid #2a3142;
  border-radius: 10px;
}
.round-box {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 1px solid #4a4f61;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #0f141e; font-weight: 800;
  user-select: none;
}
.round-box.ct    { background: #6aa6ff; }
.round-box.t     { background: #f2c14e; }
.round-box.draw  { background: #b6bdc9; color:#1b2331; }
.round-box.knife { background: #9adbb1; color:#0f2a19; border-color:#6fb787; }
.round-box.warmup{ background: #c2c8e0; color:#1d2333; border-color:#9aa3c6; }
.round-box.active { outline: 2px solid #ffffff; outline-offset: 1px; }
.halftime { margin: 0 6px; color: #cfd6ff; font-size: 14px; }

#scrub-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 6px 8px;
  background: #131724;
  border: 1px solid #2a3142;
  border-radius: 10px;
}
.pp-btn {
  width: 42px; height: 30px; border-radius: 8px;
  background: #23293a; color: #eee;
  border: 1px solid #384052; cursor: pointer; font-size: 16px;
}
.pp-btn:hover { background: #2b3246; }

#round-slider {
  width: 100%; appearance: none; height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #2e3446, #242a3a);
  outline: none;
}
#round-slider::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid #6aa6ff; cursor: pointer; margin-top: -4px;
}
#round-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid #6aa6ff; cursor: pointer;
}
#round-timer {
  min-width: 52px; text-align: right;
  font-variant-numeric: tabular-nums;
  color: #cfe0ff;
}
.speed-wrap select {
  background: #1c2130; border: 1px solid #2f3850; color: #eef2ff;
  padding: 2px 6px; border-radius: 8px;
}

/* ===== Popup Overlay ===== */
#demo-popup {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
#popup-box {
  width: 520px; max-width: calc(100vw - 40px);
  background: #141820;
  border: 1px solid #263042;
  border-radius: 16px;
  padding: 22px 24px 18px;
  color: #e8eefc;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
#popup-box h2 {
  margin: 0 0 16px;
  font-weight: 800; letter-spacing: .2px;
  text-align: center;
}
#popup-box input[type="file"] {
  display: block;
  margin: 8px auto 14px;
  color: #cfd7ee;
}
#popup-box button {
  display: block; margin: 4px auto 16px;
  background: #2a3346;
  color: #eaf1ff;
  border: 1px solid #3b4761;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
#popup-box button:hover { background: #33405a; }
#popup-box button:disabled { opacity: .6; cursor: not-allowed; }

/* Progress bar */
#progress-bar {
  position: relative;
  width: 100%; height: 12px;
  background: #1b2332;
  border: 1px solid #2a364d;
  border-radius: 999px;
  overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #4aa3ff, #7bc3ff);
  transition: width .28s ease;
}
#progress-bar.indeterminate #progress-fill {
  width: 100%;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.25) 0 10px, rgba(255,255,255,0) 10px 20px),
    linear-gradient(90deg, #4aa3ff, #7bc3ff);
  animation: pb-stripes 1s linear infinite;
}
@keyframes pb-stripes {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 20px 0, 0 0; }
}
#progress-text {
  margin-top: 8px;
  font-size: 12.5px;
  color: #b7c5e6;
  text-align: center;
}