/* ==========================================================================
   STICK ARENA RESKIN — IN-GAME HUD (#screen-game)
   Clones the Stick Arena: Ballistick in-match HUD: dripping heart + glossy
   red HP bar (top-left), gold pixel placement card with your rank emblem +
   handle + "1st" (top-center — SA shows only your own standing), left-aligned
   kill feed, red death tint.
   Loads after styles.css / prestige.css; every rule is scoped under
   #screen-game so equal-or-higher specificity wins without !important.
   Markup contract (from index.html + js/game.js):
     .hud-heart.low                       (toggled when hp < 30)
     .health-shell > i > b#hud-health-fill (JS drives transform: scaleX)
     #damage-vignette                     (JS drives inline opacity)
     .hud-placement-name > #hud-rank(.rank-badge) + #hud-leader, then #hud-place
     .kill-feed-item > .kf-killer / .kf-victim / .kf-rankup
   ========================================================================== */

/* --- Shared pixel outline stacks ------------------------------------------
   Silkscreen has no hinting; a 4/8-direction text-shadow stack is the SA
   "black contour" look used throughout the reference HUD. */
#screen-game .hud-block b,
#screen-game #hud-leader,
#screen-game .kill-feed-item,
#screen-game .respawn-banner span {
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000,
    0 2px 3px rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   Top-left: dripping heart + glossy red HP bar
   ========================================================================== */
#screen-game .hud-top-left {
  top: 14px;
  left: 14px;
  gap: 10px;
}
#screen-game .hud-heart {
  width: 38px;
  height: auto;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 4px rgba(0, 0, 0, 0.35));
}
#screen-game .health-shell {
  position: relative;
}
/* Bar frame: thick dark casing over a deep well, like the SA chrome. */
#screen-game .health-shell i {
  width: min(240px, calc(100vw - 200px));
  height: 18px;
  border: 3px solid #0d141d;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--sa-well-line) 0%, var(--sa-well-deep) 100%);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.75),
    0 1px 0 rgba(255, 255, 255, 0.16),
    0 2px 5px rgba(0, 0, 0, 0.5);
}
/* Glossy red fill (JS scales it via transform: scaleX — do not animate
   transform here or the HP value fights the animation). */
#screen-game .health-shell b {
  background: linear-gradient(180deg, #ff5a4e 0%, #c01f16 52%, #8c130c 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.42),
    inset 0 -2px 0 rgba(0, 0, 0, 0.38);
  transition: transform 120ms ease-out;
}
/* "100 HP" rides on the bar, right side, pixel white with black shadow. */
#screen-game .health-shell span {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  font-family: var(--sa-pixel);
  font-size: 9px;
  color: #ffffff;
  letter-spacing: 0.06em;
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000;
  white-space: nowrap;
}
/* Low-HP: styles.css pulses the heart; echo it on the bar casing with a
   brightness throb (filter only — never transform). */
#screen-game .hud-heart.low ~ .health-shell i {
  animation: sa-health-low 0.55s ease-in-out infinite alternate;
}
@keyframes sa-health-low {
  from { filter: brightness(1); }
  to   { filter: brightness(1.5); }
}

/* ==========================================================================
   Placement: your rank emblem + handle + giant gold pixel ordinal (SA shows
   only your own standing; the full board is a Shift/Tab hold away)
   ========================================================================== */
#screen-game .hud-placement {
  top: 64px;
  gap: 2px;
}
#screen-game .hud-placement-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#screen-game #hud-rank {
  display: inline-grid;
  place-items: center;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.65));
}
#screen-game #hud-rank:empty { display: none; }
#screen-game #hud-rank .rank-badge { display: inline-flex; }
#screen-game #hud-leader {
  font-family: var(--sa-pixel);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #fdf3d0;
}
#screen-game #hud-place {
  font-family: var(--sa-pixel);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: 0.02em;
  color: var(--sa-gold);
  -webkit-text-stroke: 1px var(--sa-gold-outline);
  text-shadow:
    2px 0 0 var(--sa-gold-outline),
    -2px 0 0 var(--sa-gold-outline),
    0 2px 0 var(--sa-gold-outline),
    0 -2px 0 var(--sa-gold-outline),
    2px 2px 0 var(--sa-gold-outline),
    -2px -2px 0 var(--sa-gold-outline),
    2px -2px 0 var(--sa-gold-outline),
    -2px 2px 0 var(--sa-gold-outline),
    0 4px 5px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Top bar: compact dark translucent chips with a steel edge
   ========================================================================== */
#screen-game .game-topbar {
  top: 10px;
  gap: 8px;
}
#screen-game .hud-block {
  min-width: 106px;
  padding: 5px 12px 6px;
  border: 2px solid var(--sa-steel-600);
  border-radius: var(--sa-radius);
  background: rgba(8, 12, 18, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3),
    0 3px 8px rgba(0, 0, 0, 0.45);
}
#screen-game .hud-block span {
  font-family: var(--sa-pixel);
  font-size: 7px;
  letter-spacing: 0.16em;
  color: var(--sa-steel-300);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
#screen-game .hud-block b {
  font-family: var(--sa-pixel);
  font-weight: 700;
  font-size: 18px;
  color: #ffffff;
}
#screen-game .hud-room-block b {
  font-size: 11px;
  letter-spacing: 0.2em;
}
#screen-game .hud-room-block small {
  font-family: var(--sa-pixel);
  font-size: 7px;
  color: var(--sa-chat-dim);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ==========================================================================
   Kill feed: left column under the HP bar (SA entry/kill messages)
   ========================================================================== */
#screen-game .kill-feed {
  top: 68px;
  left: 14px;
  right: auto;
  /* Cap the width so the feed never slides under the centered leaderboard:
     board left edge = 50vw - 180px, feed right edge = 14px + width. */
  width: min(320px, calc(50vw - 200px));
  gap: 3px;
}
#screen-game .kill-feed-item {
  padding: 4px 9px;
  border-left: 0;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  font-family: var(--sa-chunky);
  font-weight: 800;
  font-size: 12px;
  line-height: 1.3;
  color: #ffffff;
  text-align: left;
  /* animation: kill-feed-life inherited from styles.css — keeps 5s fade */
}
#screen-game .kill-feed-item .kf-killer { color: var(--sa-chat-red); }
#screen-game .kill-feed-item .kf-victim { color: var(--sa-chat-text); }
#screen-game .kill-feed-item .kf-rankup {
  color: var(--sa-gold);
  text-shadow: 1px 1px 0 rgba(10, 8, 2, 0.85);
}

/* ==========================================================================
   Damage vignette: SA red flash (JS drives inline opacity per hit)
   ========================================================================== */
#screen-game .damage-vignette {
  background:
    radial-gradient(ellipse at center,
      rgba(200, 20, 20, 0) 38%,
      rgba(200, 20, 20, 0.28) 68%,
      rgba(200, 20, 20, 0.45) 100%),
    linear-gradient(rgba(200, 20, 20, 0.10), rgba(200, 20, 20, 0.10));
}

/* ==========================================================================
   Respawn banner: red wash + giant pixel "DOWN"
   ========================================================================== */
#screen-game .respawn-banner {
  gap: 10px;
  background: rgba(140, 12, 10, 0.42);
}
#screen-game .respawn-banner strong {
  font-family: var(--sa-pixel);
  font-weight: 700;
  font-size: 46px;
  letter-spacing: 0.12em;
  color: #ff4a3c;
  text-shadow:
    2px 2px 0 #1a0300,
    -2px 2px 0 #1a0300,
    2px -2px 0 #1a0300,
    -2px -2px 0 #1a0300,
    0 0 18px rgba(255, 60, 40, 0.45),
    0 5px 7px rgba(0, 0, 0, 0.6);
}
#screen-game .respawn-banner span {
  font-family: var(--sa-pixel);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #ffffff;
}

/* ==========================================================================
   Bottom-left: weapon chip + score
   ========================================================================== */
#screen-game .hud-bottom-left {
  left: 14px;
  bottom: 14px;
  width: auto;
  min-width: 212px;
  max-width: calc(100vw - 28px);
  padding: 8px 12px 9px;
  border: 2px solid var(--sa-steel-600);
  border-radius: var(--sa-radius);
  background: rgba(8, 12, 18, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3),
    0 4px 10px rgba(0, 0, 0, 0.5);
}
#screen-game .weapon-shell {
  margin-top: 0;
  align-items: baseline;
  gap: 14px;
}
#screen-game .weapon-shell span {
  font-family: var(--sa-chunky);
  font-weight: 800;
  font-size: 14px;
  color: #ffffff;
  text-shadow: 0 1px 2px #000, 1px 1px 0 #000, -1px 1px 0 #000;
}
#screen-game .weapon-shell b {
  font-family: var(--sa-pixel);
  font-weight: 700;
  font-size: 13px;
  color: var(--sa-gold);
  text-shadow:
    1px 1px 0 var(--sa-gold-outline),
    -1px 1px 0 var(--sa-gold-outline),
    0 2px 2px rgba(0, 0, 0, 0.6);
}
#screen-game .hud-score {
  margin-top: 4px;
  font-family: var(--sa-pixel);
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--sa-steel-300);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* ==========================================================================
   In-game chat: dark translucent list + input that wakes on focus
   ========================================================================== */
#screen-game .ingame-chat-shell {
  left: 14px;
  bottom: 102px;
  width: min(400px, calc(100vw - 28px));
}
#screen-game .ingame-chat-list {
  max-height: 120px;
  padding: 6px 8px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
#screen-game .ingame-chat-list .chat-row {
  padding: 2px 0;
  border: 0;
  font-size: 9px;
  line-height: 1.55;
}
#screen-game .ingame-chat-list .chat-name {
  font-family: var(--sa-pixel);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 0 #000;
  /* name colors come from inline styles (per-player) — do not override */
}
#screen-game .ingame-chat-list .chat-text {
  font-family: var(--sa-pixel);
  font-size: 9px;
  color: #e8eef5;
  text-shadow: 1px 1px 0 #000;
}
#screen-game .ingame-chat-list .chat-rank-badge svg {
  vertical-align: -3px;
}
#screen-game .ingame-chat-form input {
  height: 30px;
  padding: 5px 9px;
  border: 2px solid var(--sa-well-line);
  border-radius: 5px;
  background: rgba(11, 15, 21, 0.65);
  box-shadow: var(--sa-bevel-well);
  color: #ffffff;
  font-family: var(--sa-pixel);
  font-size: 9px;
  transition: background 120ms ease;
}
#screen-game .ingame-chat-form input:focus {
  outline: none;
  border-color: var(--sa-bar-lo);
  background: rgba(11, 15, 21, 0.95);
}
#screen-game .ingame-chat-form input::placeholder {
  color: var(--sa-chat-dim);
}
#screen-game .ingame-chat-form button {
  border: 2px solid var(--sa-btn-border);
  border-radius: 5px;
  background: linear-gradient(180deg, var(--sa-steel-400) 0%, var(--sa-steel-500) 55%, var(--sa-steel-600) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  color: #eef4fa;
  font-family: var(--sa-chunky);
  font-weight: 800;
  font-size: 10px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}
#screen-game .ingame-chat-form button:active {
  transform: translateY(1px);
}

/* ==========================================================================
   Pause overlay: SA beveled steel card
   ========================================================================== */
#screen-game .pause-overlay {
  background: rgba(4, 7, 10, 0.72);
}
#screen-game .pause-card {
  padding: 22px 24px;
  border: var(--sa-frame);
  border-radius: var(--sa-radius);
  background: linear-gradient(180deg, var(--sa-steel-600) 0%, var(--sa-steel-700) 55%, var(--sa-steel-800) 100%);
  box-shadow: var(--sa-bevel-panel), 0 22px 65px rgba(0, 0, 0, 0.55);
  color: #e8eef5;
}
#screen-game .pause-card .panel-kicker {
  color: var(--sa-gold);
  font-family: var(--sa-pixel);
  font-size: 9px;
  letter-spacing: 0.14em;
}
#screen-game .pause-card h2 {
  font-family: var(--sa-chunky);
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#screen-game .pause-card p {
  color: var(--sa-steel-200);
}

/* ==========================================================================
   Small viewports: stack the HUD vertically on the left so the centered
   leaderboard never collides with the kill feed.
   ========================================================================== */
@media (max-width: 760px) {
  #screen-game .game-topbar { top: 6px; }
  #screen-game .hud-block { min-width: 92px; padding: 4px 8px 5px; }
  #screen-game .hud-block b { font-size: 14px; }
  #screen-game .hud-top-left { top: 50px; left: 8px; }
  #screen-game .hud-heart { width: 30px; }
  #screen-game .health-shell i { width: min(180px, calc(100vw - 140px)); height: 15px; }
  #screen-game .health-shell span { font-size: 8px; right: 5px; }
  #screen-game .hud-placement { top: 72px; }
  #screen-game #hud-leader { font-size: 9px; }
  #screen-game #hud-place { font-size: 24px; }
  #screen-game .kill-feed { top: 118px; left: 8px; width: calc(100vw - 16px); }
  #screen-game .kill-feed-item { font-size: 10px; }
  #screen-game .hud-bottom-left { left: 8px; bottom: 8px; min-width: 0; }
  #screen-game .ingame-chat-shell { left: 8px; bottom: 86px; width: min(300px, calc(100vw - 16px)); }
  #screen-game .ingame-chat-list { max-height: 70px; }
  #screen-game .respawn-banner strong { font-size: 32px; }
}

/* Reduced motion: stop the low-HP bar throb (styles.css already handles the
   heart pulse and the feed/vignette timings). */
@media (prefers-reduced-motion: reduce) {
  #screen-game .hud-heart.low ~ .health-shell i { animation: none !important; }
}
