* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: #eaeaea;
  user-select: none;
}

#scene {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* Crosshair */
#crosshair {
  position: fixed;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 5;
  display: none;
}
#crosshair.visible { display: block; }

/* Sniper scope overlay */
#scopeOverlay {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: none;
  pointer-events: none;
  /* No background here on purpose — the black mask comes entirely from
     .scope-circle's box-shadow trick below. If this element paints its
     own opaque background, it sits behind the "cutout" circle and blocks
     the 3D scene from ever showing through, i.e. the whole screen goes
     solid black instead of showing a scoped view. */
}
#scopeOverlay.visible { display: block; }
.scope-circle {
  position: absolute;
  top: 50%; left: 50%;
  width: 46vh; height: 46vh;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px #000;
  border: 2px solid rgba(0,0,0,0.6);
}
.scope-line {
  position: absolute;
  background: rgba(0,0,0,0.75);
}
.scope-line.scope-h {
  top: 50%; left: 6%;
  width: 88%; height: 2px;
  transform: translateY(-50%);
}
.scope-line.scope-v {
  left: 50%; top: 6%;
  height: 88%; width: 2px;
  transform: translateX(-50%);
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  font-weight: 600;
}

.bar-wrap {
  position: absolute;
  bottom: 28px;
  width: 260px;
}
.bar-wrap.self { left: 28px; }
.bar-wrap.enemy { right: 28px; text-align: right; }

.bar-label {
  font-size: 12px;
  letter-spacing: 2px;
  opacity: 0.75;
  margin-bottom: 4px;
}

.bar-bg {
  width: 100%;
  height: 16px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.15s ease-out;
}
.self-fill { background: linear-gradient(90deg, #3ddc84, #2bb673); }
.enemy-fill { background: linear-gradient(90deg, #ff5b5b, #d63b3b); }

.bar-num {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

#weaponHud {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 14px;
  letter-spacing: 2px;
  opacity: 0.85;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#weaponCooldown {
  font-size: 11px;
  opacity: 0.6;
  letter-spacing: 1px;
}
#grenadeHud {
  font-size: 11px;
  opacity: 0.75;
  letter-spacing: 1.5px;
  color: #ffcf9a;
}

#connStatus {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  opacity: 0.6;
  letter-spacing: 1px;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,22,28,0.92), rgba(5,6,8,0.97));
}

.panel {
  width: min(460px, 88vw);
  padding: 32px 28px;
  background: rgba(18,20,26,0.9);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.panel.center-only { padding: 40px 28px; }

.panel h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 3px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
  letter-spacing: 1px;
}

.sub { margin: 0 0 22px; font-size: 13px; opacity: 0.65; line-height: 1.5; }
.hint { font-size: 12px; opacity: 0.55; line-height: 1.5; margin-top: 8px; }
.hint.small { margin-top: 18px; }

.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 1.5px;
  opacity: 0.6;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #fff;
  outline: none;
}
.field input:focus { border-color: #5b8dff; }
.field .row { display: flex; gap: 8px; }
.field .row input { flex: 1; }
.field .row button {
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
}

button.primary, #cancelWaitBtn, #rematchBtn {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  pointer-events: all;
}
button.primary, #rematchBtn {
  background: linear-gradient(90deg, #5b8dff, #7b5bff);
  color: #fff;
}
button.primary:hover, #rematchBtn:hover { filter: brightness(1.1); }
#cancelWaitBtn {
  background: rgba(255,255,255,0.08);
  color: #eee;
  margin-top: 16px;
}

.code {
  font-weight: 700;
  letter-spacing: 3px;
  color: #7fa5ff;
}

.error {
  color: #ff6b6b;
  font-size: 12px;
  margin-top: 10px;
}

#endTitle { font-size: 34px; }

/* ---------------------------------------------------------------------
   Hit feedback: hit marker, hit-direction arrow, damage flash, kill feed
--------------------------------------------------------------------- */
#hitMarker {
  position: fixed;
  top: 50%; left: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
}
#hitMarker::before, #hitMarker::after {
  content: "";
  position: absolute;
  background: #ffe14d;
  box-shadow: 0 0 4px rgba(0,0,0,0.6);
}
#hitMarker::before { top: 50%; left: 0; width: 100%; height: 2px; margin-top: -1px; transform: rotate(45deg); }
#hitMarker::after { top: 0; left: 50%; height: 100%; width: 2px; margin-left: -1px; transform: rotate(45deg); }
#hitMarker.show { animation: hitMarkerPulse 0.18s ease-out; }
#hitMarker.head::before, #hitMarker.head::after { background: #ff5b5b; }
@keyframes hitMarkerPulse {
  0% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(1); }
}

#hitDirection {
  position: fixed;
  top: 50%; left: 50%;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
}
.hitDirectionArrow {
  position: absolute;
  left: -10px; top: -140px;
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 16px solid #ff5b5b;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.7));
}
#hitDirection.show { animation: hitDirectionFade 0.9s ease-out; }
@keyframes hitDirectionFade {
  0% { opacity: 1; }
  70% { opacity: 0.9; }
  100% { opacity: 0; }
}

#damageFlash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at center, rgba(255,0,0,0) 40%, rgba(180,0,0,0.35) 100%);
  opacity: 0;
}
#damageFlash.show { animation: damageFlashPulse 0.4s ease-out; }
@keyframes damageFlashPulse {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

#killFeed {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
  max-width: 320px;
}
.killFeedLine {
  font-size: 12px;
  padding: 5px 10px;
  background: rgba(10,10,14,0.65);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}
.killFeedLine.fade { opacity: 0; }

/* ---------------------------------------------------------------------
   Scoreboard
--------------------------------------------------------------------- */
#scoreboard {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 1.5px;
  opacity: 0.8;
  margin-top: 22px;
}

/* ---------------------------------------------------------------------
   Ready-check + synced countdown + round banner
--------------------------------------------------------------------- */
#countdownOverlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#countdownOverlay:not(.hidden) { display: flex; }
#countdownText {
  font-size: 96px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 24px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.9);
}

#roundBanner {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 7;
  pointer-events: none;
}
#roundBannerText {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 12px 22px;
  border-radius: 8px;
  background: rgba(10,10,14,0.75);
  border: 1px solid rgba(255,255,255,0.15);
  text-align: center;
  white-space: nowrap;
}
#roundBanner.won #roundBannerText { color: #3ddc84; border-color: rgba(61,220,132,0.4); }
#roundBanner.lost #roundBannerText { color: #ff5b5b; border-color: rgba(255,91,91,0.4); }

/* Settings panel (inside the main menu) */
.settingsPanel {
  text-align: left;
  margin-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
}
.settingsPanel summary {
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 1.5px;
  opacity: 0.75;
  margin-bottom: 10px;
}
.settingsPanel .field input[type="range"] {
  width: 100%;
}


/* v8 — practice mode + ammo HUD */
select {
  width: 100%;
  background: #141920;
  color: #e8e2d6;
  border: 1px solid #2c3440;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}
#practiceBtn { flex: 1; }
#ammoCounter {
  margin-left: 10px;
  color: #ffd98a;
  font-weight: 700;
  letter-spacing: 1px;
}
#endStats { margin-top: 4px; }
#menuBtn { margin-top: 10px; }


/* v13 — menu rework: home / online / practice / barracks */
.menuScreen { animation: screenIn 0.18s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.screenTitle {
  margin: 2px 0 12px; color: #ffd98a; font-size: 14px; letter-spacing: 3px; text-align: center;
}
.bigBtn {
  display: block; width: 100%; margin: 10px 0; padding: 14px 16px;
  background: #1a222c; color: #e8e2d6; border: 1px solid #2c3440; border-radius: 10px;
  font-family: inherit; font-size: 16px; font-weight: 700; letter-spacing: 1.5px;
  text-align: left; cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.bigBtn:hover { background: #24303d; border-color: #4da3ff; }
.bigBtn.primary { background: #1e3a5c; border-color: #4da3ff; }
.bigBtn.primary:hover { background: #27496f; }
.bigBtn .bigSub {
  display: block; margin-top: 3px; color: #8fa3b8; font-size: 12px; font-weight: 400; letter-spacing: 0.4px;
}
.backBtn {
  display: block; margin: 14px auto 0; background: none; border: none; color: #8fa3b8;
  font-family: inherit; font-size: 12px; letter-spacing: 2px; cursor: pointer;
}
.backBtn:hover { color: #e8e2d6; }
#charCarousel { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 10px; }
#charCarousel .clsArrow { padding: 12px 14px; font-size: 14px; }
#charPreviewWrap { text-align: center; }
#charPreviewCanvas {
  width: 240px; height: 280px; background: radial-gradient(ellipse at 50% 85%, #1c2733 0%, #0d1218 70%);
  border: 1px solid #2c3440; border-radius: 12px;
}
#charName { margin: 8px 0 2px; font-weight: 700; letter-spacing: 2px; color: #e8e2d6; }
#charDesc { margin: 0; }
