/* In-game HUD: score bar, killfeed, vitals, ammo, speed, crosshair, scope, damage. */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; -webkit-user-select: none; font-family: var(--font-display); color: var(--ink); text-shadow: var(--text-shadow); }
.hud-panel { position: absolute; background: var(--panel); border: 1px solid rgba(255, 255, 255, .07); border-radius: var(--radius); }

/* ---- Score bar --------------------------------------------------------- */
#topbar { left: 50%; top: 12px; transform: translateX(-50%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 16px; padding: 6px 16px 9px; min-width: 300px; }
#topbar .team { display: flex; align-items: baseline; gap: 8px; color: var(--team); }
#topbar .team-blue { justify-content: flex-end; }
#topbar .name { font-size: 12px; font-weight: 700; letter-spacing: .18em; opacity: .9; }
#topbar .team-info { display: flex; flex-direction: column; gap: 3px; }
#topbar .elo { font: 600 10px/1.2 var(--font-ui); white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
#topbar .score { font-size: 32px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: center; }
#topbar .center { display: flex; flex-direction: column; align-items: center; line-height: 1; }
#topbar .clock { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
#topbar .goal { margin-top: 3px; font-size: 10px; font-weight: 700; letter-spacing: .16em; color: var(--ink-3); }
#topbar .bars { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 7px; }
#topbar .bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .13); overflow: hidden; display: flex; }
#topbar .bar.red { justify-content: flex-end; }
#topbar .bar i { display: block; height: 100%; width: 0; border-radius: 2px; transition: width .35s ease-out; }
#topbar .bar.blue i { background: var(--blue); }
#topbar .bar.red i { background: var(--red); }
#topbar.over { box-shadow: 0 0 0 1px rgba(255, 201, 77, .5); }

/* ---- Killfeed ---------------------------------------------------------- */
/* Never as wide as to reach the centred score bar (300 px; names ellipsize first). */
#killfeed { position: absolute; top: 12px; right: calc(14px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: min(46vw, 460px, calc(50vw - 186px)); }
.kf { display: flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 7px; background: rgba(10, 14, 18, .64); font: 600 14px/1.35 var(--font-ui); text-shadow: none; white-space: nowrap; max-width: 100%; animation: kf-in .22s ease-out; }
.kf.me { background: rgba(38, 29, 8, .78); box-shadow: inset 0 0 0 1px rgba(255, 201, 77, .65); }
.kf.out { animation: kf-out .3s ease-in forwards; }
.kf > * { flex: none; }
/* Names give way first (both sides ellipsize), so a row never runs past the screen edge. */
.kf .who { flex: 0 1 auto; min-width: 2.5em; overflow: hidden; text-overflow: ellipsis; max-width: 150px; color: var(--team, var(--ink)); }
.kf .weapon-icon { width: 42px; height: 13px; color: var(--ink); opacity: .92; }
.kf .weapon-icon.knife { width: 26px; height: 13px; }
.kf .mark { display: inline-flex; color: var(--accent); }
.kf .mark .icon { width: 15px; height: 15px; }
.kf.system { font-weight: 500; color: var(--ink-2); }
.kf.system .accent { color: var(--accent); font-weight: 700; letter-spacing: .04em; }
@keyframes kf-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes kf-out { to { opacity: 0; transform: translateX(10px); } }

/* ---- Net stats --------------------------------------------------------- */
#netstats { position: fixed; left: calc(12px + var(--safe-l)); top: 12px; padding: 4px 8px; border-radius: 6px; background: rgba(10, 14, 18, .52); font: 600 11px/1.4 var(--font-ui); color: var(--ink-2); text-shadow: none; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
body:not(.netstats) #netstats { display: none; }

/* ---- Vitals ------------------------------------------------------------ */
#vitals { left: calc(18px + var(--safe-l)); bottom: calc(18px + var(--safe-b)); display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; padding: 10px 16px 12px; min-width: 210px; --hp: var(--ink); }
#vitals .hp-icon { display: inline-flex; color: var(--hp); }
#vitals .hp-icon .icon { width: 22px; height: 22px; }
#vitals .hp-value { font-size: 42px; font-weight: 700; line-height: .9; color: var(--hp); font-variant-numeric: tabular-nums; }
#vitals .hp-bar { grid-column: 1 / -1; height: 5px; margin-top: 9px; border-radius: 3px; background: rgba(255, 255, 255, .14); overflow: hidden; }
#vitals .hp-bar i { display: block; height: 100%; width: 100%; background: var(--hp); border-radius: 3px; transition: width .2s ease-out, background-color .2s; }
#vitals.hurt { --hp: var(--warn); }
#vitals.low { --hp: var(--danger); animation: low-pulse 1s ease-in-out infinite; }
#vitals .protect { display: none; }
#vitals.protected .protect { display: block; position: absolute; left: 0; bottom: calc(100% + 6px); padding: 3px 8px; border-radius: 6px; background: rgba(88, 157, 255, .22); color: #cfe2ff; font: 600 11px/1.3 var(--font-ui); letter-spacing: .06em; text-shadow: none; white-space: nowrap; }
@keyframes low-pulse { 50% { box-shadow: 0 0 0 1px rgba(255, 90, 78, .55), 0 0 22px rgba(255, 90, 78, .3); } }

/* ---- Ammo -------------------------------------------------------------- */
#ammo { right: calc(18px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; align-items: flex-end; gap: 9px; padding: 10px 16px 12px; min-width: 210px; }
#ammo .weapon { display: flex; align-items: center; gap: 10px; }
#ammo .weapon-name { font-size: 14px; font-weight: 700; letter-spacing: .2em; color: var(--ink-2); }
#ammo .weapon-glyph { display: inline-flex; }
#ammo .weapon-glyph svg { width: 58px; height: 18px; color: var(--ink); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
#ammo .rounds { display: flex; gap: 4px; height: 20px; }
#ammo .rounds i { width: 6px; height: 100%; border-radius: 2px; background: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .5); transition: background-color .12s, opacity .12s; }
#ammo .rounds i.spent { background: rgba(255, 255, 255, .17); box-shadow: none; }
#ammo .rounds i.cycling { animation: bolt .5s ease-in-out infinite alternate; }
#ammo .reload { display: none; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 14px; font-weight: 700; letter-spacing: .2em; color: var(--warn); }
#ammo .reload-bar { width: 112px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .15); overflow: hidden; }
#ammo .reload-bar i { display: block; height: 100%; width: 0; background: var(--warn); }
#ammo.reloading .rounds { display: none; }
#ammo.reloading .reload { display: flex; }
#ammo.knife .rounds, #ammo.knife .reload { display: none; }
#ammo.knife .weapon-glyph svg { width: 40px; height: 20px; }
@keyframes bolt { from { opacity: .35; } to { opacity: .8; } }

/* ---- Speed ------------------------------------------------------------- */
/* A dark pill like the other panels: readable over bright sand. The bar is a
   transform (compositor only, no layout while bhopping). */
#speedo { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px; width: 116px; padding: 6px 12px 8px; border-radius: 10px; background: var(--panel); border: 1px solid rgba(255, 255, 255, .07); }
#speedo .value { font-size: 22px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#speedo .unit { font: 600 10px var(--font-ui); color: var(--ink-2); letter-spacing: .06em; }
#speedo .speed-bar { flex-basis: 100%; height: 3px; margin-top: 5px; border-radius: 2px; background: rgba(0, 0, 0, .45); overflow: hidden; }
#speedo .speed-bar i { display: block; height: 100%; width: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left center; }
#speedo.fast .value { color: var(--accent); }
#speedo.fast .speed-bar i { background: var(--accent); }
/* Spectating: the spectator bar (height --spectator-h, lobby-ui.js) owns the bottom edge. */
body.spectating #speedo { bottom: calc(var(--spectator-h, 50px) + 26px + var(--safe-b)); }

/* ---- Crosshair and hitmarker ------------------------------------------- */
#crosshair, #hitmarker { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair i { position: absolute; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); border-radius: 1px; display: none; }
#crosshair b { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); display: none; }
#crosshair.cross i { display: block; }
#crosshair.dot b { display: block; }
#hitmarker { opacity: 0; }
#hitmarker i { position: absolute; left: -1px; top: -1px; width: 2px; height: 9px; border-radius: 1px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); transform-origin: 1px 1px; }
#hitmarker i:nth-child(1) { transform: rotate(45deg) translateY(6px); }
#hitmarker i:nth-child(2) { transform: rotate(135deg) translateY(6px); }
#hitmarker i:nth-child(3) { transform: rotate(225deg) translateY(6px); }
#hitmarker i:nth-child(4) { transform: rotate(315deg) translateY(6px); }
#hitmarker.body { animation: hm-body .22s ease-out forwards; }
#hitmarker.head i { background: var(--accent); height: 12px; }
#hitmarker.head { animation: hm-pop .34s ease-out forwards; }
#hitmarker.kill i { background: var(--danger); width: 3px; height: 14px; }
#hitmarker.kill { animation: hm-kill .55s ease-out forwards; }
@keyframes hm-body { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hm-pop { 0% { opacity: 1; transform: scale(1.35); } 30% { transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }
@keyframes hm-kill { 0% { opacity: 1; transform: scale(1.5) rotate(0deg); } 25% { transform: scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1); } }

/* ---- Scope ------------------------------------------------------------- */
#scope { position: absolute; inset: 0; display: none; overflow: hidden; }
#scope .lens, #scope .reticle { position: absolute; left: 50%; top: 50%; width: min(94vh, 94vw); height: min(94vh, 94vw); transform: translate(-50%, -50%); border-radius: 50%; }
#scope .lens { box-shadow: 0 0 0 200vmax rgba(5, 7, 9, .97); background: radial-gradient(circle, transparent 58%, rgba(0, 0, 0, .18) 78%, rgba(0, 0, 0, .7) 96%, rgba(0, 0, 0, .92) 100%); }
/* Dark lines with a faint light halo, so the reticle reads on dark walls too. */
#scope .reticle .h, #scope .reticle .v { position: absolute; background: rgba(10, 10, 10, .9); box-shadow: 0 0 0 1px rgba(235, 235, 225, .28); }
#scope .reticle .h { left: 0; right: 0; top: 50%; height: 1px; transform: translateY(-.5px); }
#scope .reticle .v { top: 0; bottom: 0; left: 50%; width: 1px; transform: translateX(-.5px); }
#scope .reticle .h::before, #scope .reticle .h::after { content: ''; position: absolute; top: -1px; height: 3px; width: 30%; background: rgba(10, 10, 10, .92); box-shadow: 0 0 0 1px rgba(235, 235, 225, .2); }
#scope .reticle .h::before { left: 0; }
#scope .reticle .h::after { right: 0; }
#scope .reticle .v::after { content: ''; position: absolute; left: -1px; bottom: 0; width: 3px; height: 30%; background: rgba(10, 10, 10, .92); box-shadow: 0 0 0 1px rgba(235, 235, 225, .2); }

/* ---- Damage ------------------------------------------------------------ */
#dmgflash { position: absolute; inset: 0; opacity: 0; box-shadow: inset 0 0 14vmin 3vmin rgba(214, 28, 18, .72); }
#dmgflash.flash { animation: dmg-flash .5s ease-out; }
#dmgflash.low { opacity: .55; animation: dmg-low 1.1s ease-in-out infinite; }
@keyframes dmg-flash { 0% { opacity: var(--flash, .8); } 100% { opacity: 0; } }
@keyframes dmg-low { 0%, 100% { opacity: .28; } 50% { opacity: .6; } }
#dmgdir { position: absolute; left: 50%; top: 50%; width: 150px; height: 150px; transform: translate(-50%, -50%); opacity: 0; }
#dmgdir .arc { position: absolute; left: 50%; top: 0; width: 46px; height: 16px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse at 50% 0%, rgba(255, 70, 55, .95), transparent 70%); }

/* ---- Centre messages --------------------------------------------------- */
#msg { position: absolute; left: 0; right: 0; top: 36%; margin: 0 auto; width: fit-content; max-width: 90vw; font-size: 22px; font-weight: 700; letter-spacing: .08em; text-align: center; color: var(--accent); }
#bigmsg { position: absolute; left: 0; right: 0; top: 24%; margin: 0 auto; width: fit-content; max-width: calc(100vw - 24px); display: none; padding: 18px 30px; border-radius: 16px; background: var(--panel-2); text-align: center; font-size: 40px; font-weight: 700; letter-spacing: .08em; line-height: 1.15; color: var(--team, var(--accent)); }
#bigmsg .sub { display: block; font-size: 20px; color: var(--ink); }
#bigmsg .hint { display: block; margin-top: 6px; font: 500 14px var(--font-ui); color: var(--ink-2); letter-spacing: 0; }

/* Narrower than the spectator bar plus both panels: lift the panels above the bar. */
@media (max-width: 1100px) {
  body.spectating #vitals, body.spectating #ammo { bottom: calc(var(--spectator-h, 50px) + 26px + var(--safe-b)); }
  body.spectating #speedo { bottom: calc(var(--spectator-h, 50px) + 104px + var(--safe-b)); }
}

@media (max-width: 640px) {
  #topbar { min-width: 0; column-gap: 10px; padding: 5px 10px 8px; top: 8px; }
  #topbar .score { font-size: 24px; }
  #topbar .name { display: none; }
  /* Top stack on phones: score bar, net stats under it, then the killfeed. */
  #netstats { left: 0; right: 0; top: 70px; margin: 0 auto; width: fit-content; }
  /* An alert pill (e.g. RECONNECTING, menu.css) takes their place. */
  body.net-alert:not(.menu-open) #netstats { display: none; }
  #killfeed { top: 100px; right: 8px; max-width: calc(100vw - 16px); }
  .kf:nth-last-child(n+5) { display: none; }
  .kf { font-size: 12px; padding: 3px 8px; }
  .kf .who { max-width: 110px; }
  #vitals, #ammo { min-width: 0; padding: 8px 12px 10px; bottom: calc(10px + var(--safe-b)); }
  #vitals { left: 10px; } #ammo { right: 10px; }
  #vitals .hp-value { font-size: 30px; }
  #ammo .rounds { height: 14px; gap: 3px; }
  #ammo .rounds i { width: 4px; }
  #speedo { bottom: calc(86px + var(--safe-b)); }
  #msg { font-size: 16px; }
  #bigmsg { font-size: 28px; padding: 14px 18px; }
}
