/* replay.css -- UHC replay viewer. Espectral brand: dark spacey, gold + cyan
   accents, glassmorphic surfaces, glow on focus, Press Start 2P logo. */

:root {
  color-scheme: dark;
  --bg:           #060a14;
  --bg-rgb:       6, 10, 20;
  --surface:      rgba(16, 22, 42, 0.65);
  --surface-up:   rgba(25, 32, 64, 0.55);
  --text:         #e8ecf4;
  --muted:        #7a90b8;
  --muted-2:      #5a6e92;
  --accent:       #ffd700;
  --accent-rgb:   255, 215, 0;
  --accent-cyan:  #00d4e8;
  --accent-cyan-rgb: 0, 212, 232;
  --border:       rgba(120, 145, 200, 0.18);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-border-bright: rgba(255, 255, 255, 0.12);
  --overworld:    #4ade80;
  --nether:       #ef4444;
  --the_end:      #a855f7;
  --red:          #ef4444;
  --green:        #4ade80;
  --yellow:       #facc15;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body:    'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-pixel:   'Press Start 2P', monospace;
  --radius-sm:    0.5rem;
  --radius-md:    0.75rem;
  --radius-lg:    1rem;
  --radius-pill:  9999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: auto; }
body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 215, 0, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(0, 212, 232, 0.06), transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.replay-app { display: flex; flex-direction: column; min-height: 100vh; width: 100vw; }

/* ── Titlebar (glassmorphic) ── */
.replay-titlebar {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0 1.25rem; height: 56px; flex-shrink: 0;
  background: rgba(var(--bg-rgb), 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--glass-border);
  position: relative; z-index: 10;
}
.replay-titlebar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.4), transparent);
}
.replay-back {
  font-family: var(--font-display); font-size: 0.82rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
  padding: 0.35rem 0.7rem; border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  transition: all 0.18s ease;
}
.replay-back:hover { color: var(--text); border-color: var(--glass-border-bright); background: rgba(255, 255, 255, 0.04); text-decoration: none; }
.replay-logo {
  font-family: var(--font-pixel); font-size: 0.78rem;
  color: var(--accent); letter-spacing: 0.06em;
  text-shadow: 0 0 16px rgba(var(--accent-rgb), 0.5);
  user-select: none;
}
.replay-logo span { color: var(--accent-cyan); text-shadow: 0 0 12px rgba(var(--accent-cyan-rgb), 0.5); margin: 0 0.25em; }
.replay-subtitle { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.replay-seed {
  display: inline-flex; align-items: center; gap: 0.45rem;
  color: var(--muted); font-size: 0.78rem; white-space: nowrap;
  padding: 0.3rem 0.7rem; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
}
.replay-seed-label { font-family: var(--font-pixel); font-size: 0.55rem; color: var(--muted-2); letter-spacing: 0.1em; }
.replay-seed code { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3); }
.replay-spacer { flex: 1; }
.replay-share-btn {
  background: var(--accent); color: var(--bg);
  border: 0; padding: 0.45rem 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer; font: inherit; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em;
  transition: all 0.18s ease;
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
}
.replay-share-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.35); }
.replay-share-btn:active { transform: translateY(0); }

/* ── Main row: map + sidebar ── */
.replay-main { display: flex; height: calc(100vh - 112px - 28px); min-height: 300px; }
.replay-map {
  flex: 7 1 0; position: relative; min-width: 0;
  background: #000;
  border-right: 1px solid var(--glass-border);
}
.replay-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.replay-canvas:active { cursor: grabbing; }

/* Leaflet wrapper */
.replay-leaflet { position: absolute; inset: 0; background: var(--bg); height: 100%; width: 100%; }
.replay-leaflet .leaflet-container { background: var(--bg); font-family: var(--font-body); outline: none; height: 100%; width: 100%; }
.replay-leaflet .leaflet-tile-pane { filter: saturate(1.1) brightness(1.05); }
.replay-leaflet .leaflet-control-attribution {
  background: rgba(var(--bg-rgb), 0.65) !important;
  color: var(--muted-2) !important;
  font-size: 0.65rem !important;
  border-radius: 4px 0 0 0;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.replay-leaflet .leaflet-control-attribution a { color: var(--muted) !important; }

/* Player marker (L.divIcon) */
.leaflet-replay-marker { background: transparent !important; border: 0 !important; }
.leaflet-replay-marker .marker-stack {
  position: relative; display: flex; flex-direction: column; align-items: center;
  pointer-events: auto;
}
.leaflet-replay-marker .marker-head {
  width: 18px; height: 18px; border-radius: 4px;
  background: rgba(var(--bg-rgb), 0.85);
  border: 1px solid var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.35), 0 2px 8px rgba(0,0,0,0.4);
  overflow: hidden; image-rendering: pixelated; display: block;
}
.leaflet-replay-marker.dead .marker-head { opacity: 0.4; border-color: var(--red); box-shadow: 0 0 8px rgba(239, 68, 68, 0.3); }
.leaflet-replay-marker .marker-head { position: relative; }
.replay-player-dead-mark {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.replay-player-dead-mark::before,
.replay-player-dead-mark::after {
  content: ''; position: absolute;
  width: 130%; height: 2px;
  background: #ef4444;
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}
.replay-player-dead-mark::before { transform: rotate(45deg); }
.replay-player-dead-mark::after { transform: rotate(-45deg); }
.leaflet-replay-marker .marker-head img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.leaflet-replay-marker .marker-name {
  margin-top: 2px;
  font-family: var(--font-display); font-size: 0.58rem; font-weight: 600;
  color: var(--text);
  background: rgba(var(--bg-rgb), 0.78);
  border: 1px solid var(--glass-border);
  padding: 0 5px; border-radius: var(--radius-pill);
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.leaflet-replay-marker:hover .marker-name,
.leaflet-replay-marker.selected .marker-name {
  opacity: 1;
  transform: translateY(0);
}
.leaflet-replay-marker.dead .marker-name { opacity: 0.5; }

/* Static markers (portals, gateways, persistent death heads) */
.leaflet-replay-marker.marker-static .marker-symbol {
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #fff;
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 8px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4);
  overflow: hidden; pointer-events: auto;
}
.leaflet-replay-marker.marker-static .marker-symbol-portal {
  background: rgba(0, 0, 0, 0.6); border-color: #c084fc;
}
.leaflet-replay-marker.marker-static .marker-symbol-portal img {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated; object-fit: cover;
}
.leaflet-replay-marker.marker-static .marker-symbol-gateway {
  background: rgba(168, 85, 247, 0.92); border-color: #d8b4fe;
}
.leaflet-replay-marker.marker-static .marker-symbol-death {
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.85);
  border-color: #94a3b8;
  position: relative;
}
.leaflet-replay-marker.marker-static .marker-symbol-death img {
  width: 100%; height: 100%; display: block;
  filter: grayscale(1); image-rendering: pixelated;
}
.leaflet-replay-marker.marker-static .marker-symbol-death::before,
.leaflet-replay-marker.marker-static .marker-symbol-death::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 120%; height: 2px;
  background: #ef4444;
  border-radius: 1px;
  box-shadow: 0 0 3px rgba(0,0,0,0.8);
  transform-origin: center;
}
.leaflet-replay-marker.marker-static .marker-symbol-death::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.leaflet-replay-marker.marker-static .marker-symbol-death::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}
.leaflet-replay-marker.marker-static .marker-symbol-icon {
  font-size: 0.62rem; line-height: 1; color: #fff;
}

/* ── Map controls: dim + zoom (glass chips) ── */
.replay-dim, .replay-zoom {
  display: flex; gap: 4px;
  background: rgba(var(--bg-rgb), 0.7);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 4px; z-index: 1000; position: absolute; pointer-events: auto !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.replay-dim { top: 14px; right: 14px; }
.replay-zoom { top: 14px; left: 14px; }
.replay-dim button, .replay-zoom button {
  background: transparent; border: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.78rem; font-weight: 600;
  padding: 6px 12px; border-radius: var(--radius-pill);
  cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.06em;
  transition: all 0.15s ease;
}
.replay-zoom button { width: 32px; height: 30px; padding: 0; font-size: 1.1rem; }
.replay-zoom button[data-reset] { width: auto; padding: 0 10px; font-size: 0.8rem; }
.replay-dim button:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.replay-zoom button:hover { color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.replay-dim button.active { color: #0a0a0a; font-weight: 700; text-shadow: none; }
.replay-dim button[data-dim="overworld"].active { background: var(--overworld); box-shadow: 0 0 12px rgba(74, 222, 128, 0.4); }
.replay-dim button[data-dim="nether"].active    { background: var(--nether); color: #fff; box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
.replay-dim button[data-dim="the_end"].active   { background: var(--the_end); color: #fff; box-shadow: 0 0 12px rgba(168, 85, 247, 0.4); }
.replay-dim button:disabled { opacity: 0.3; cursor: not-allowed; }
.replay-zoom-label {
  min-width: 64px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  padding: 0 8px;
}

/* Empty state */
.replay-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 3; }
.replay-empty span {
  background: rgba(var(--bg-rgb), 0.75);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 0.6rem 1.1rem; border-radius: var(--radius-pill);
  color: var(--text); font-size: 0.85rem;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

/* ── Sidebar (glass card) ── */
.replay-sidebar {
  flex: 3 1 0; min-width: 300px; max-width: 420px;
  background: rgba(var(--bg-rgb), 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  backdrop-filter: blur(20px) saturate(1.3);
  border-left: 1px solid var(--glass-border);
  display: flex; flex-direction: column; overflow: hidden;
  position: relative; z-index: 5;
}
.replay-sidebar-header {
  padding: 0.85rem 1rem 0.5rem;
  font-family: var(--font-pixel);
  font-size: 0.55rem; color: var(--accent);
  letter-spacing: 0.18em;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}
.replay-players {
  flex: 1; overflow-y: auto;
  padding: 0.25rem 0.6rem 0.6rem;
}
.replay-players::-webkit-scrollbar { width: 6px; }
.replay-players::-webkit-scrollbar-track { background: transparent; }
.replay-players::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb), 0.15); border-radius: var(--radius-pill); }
.replay-players::-webkit-scrollbar-thumb:hover { background: rgba(var(--accent-rgb), 0.3); }

.replay-player {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.7rem; margin: 2px 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: rgba(255, 255, 255, 0.015);
}
.replay-player:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--glass-border); transform: translateX(2px); }
.replay-player.selected { background: rgba(var(--accent-rgb), 0.08); border-color: rgba(var(--accent-rgb), 0.4); box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.12); }
.replay-player.hovered { background: rgba(var(--accent-cyan-rgb), 0.06); border-color: rgba(var(--accent-cyan-rgb), 0.2); }

.replay-player-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.replay-player-row1 { display: flex; align-items: center; gap: 0.5rem; }
.replay-player-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-player-team {
  font-size: 0.65rem; padding: 2px 7px;
  border-radius: var(--radius-pill);
  text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em;
}
.team-red    { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.team-blue   { background: rgba(59, 130, 246, 0.18); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.3); }
.team-green  { background: rgba(34, 197, 94, 0.18); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.3); }
.team-yellow { background: rgba(250, 204, 21, 0.18); color: #fde68a; border: 1px solid rgba(250, 204, 21, 0.3); }
.team-spec   { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }
.replay-player-dim {
  font-size: 0.6rem; padding: 1px 5px;
  border-radius: var(--radius-pill);
  text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em;
  flex-shrink: 0;
}
.replay-player-dim[data-dim="overworld"] { background: rgba(34, 197, 94, 0.18); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.3); }
.replay-player-dim[data-dim="nether"]    { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.replay-player-dim[data-dim="the_end"]   { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.3); }
.replay-player-dim[data-dim="unknown"]   { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }

.replay-player-status { font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.replay-player-status.dead { color: var(--red); font-weight: 600; }

.replay-player-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 2px;
}
.replay-player-hearts {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}
.replay-player-hearts .replay-heart {
  width: 8px;
  height: 8px;
}
.replay-bar.hp > div    { background: linear-gradient(90deg, #22c55e, var(--green)); }
.replay-bar.hp.med > div  { background: linear-gradient(90deg, #ca8a04, var(--yellow)); }
.replay-bar.hp.low > div  { background: linear-gradient(90deg, #b91c1c, var(--red)); }

/* ── Player head avatar (mc-heads.net) ── */
.replay-player-head-wrap {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 6px; overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.replay-player-head-wrap img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.replay-player-head-wrap.dead { opacity: 0.4; filter: grayscale(0.6); position: relative; }
.replay-player-head-wrap.dead::before,
.replay-player-head-wrap.dead::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 120%; height: 3px;
  background: #ef4444;
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
  transform-origin: center;
  z-index: 1;
}
.replay-player-head-wrap.dead::before { transform: translate(-50%, -50%) rotate(45deg); }
.replay-player-head-wrap.dead::after { transform: translate(-50%, -50%) rotate(-45deg); }
.replay-player-dead { opacity: 0.65; }


/* ── Detail panel (selected player) ── */
.replay-detail {
  border-top: 1px solid var(--glass-border);
  padding: 0.85rem 1rem 1rem;
  background: rgba(var(--bg-rgb), 0.45);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  max-height: 45%;
  overflow-y: auto;
}
.replay-detail-head {
  width: 56px; height: 56px;
  border-radius: var(--radius-md); overflow: hidden; margin-bottom: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border-bright);
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.15);
}
.replay-detail-head img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.replay-detail-val.dead { color: var(--red); }
.replay-detail h3 {
  margin: 0 0 0.6rem; font-family: var(--font-pixel); font-size: 0.5rem;
  color: var(--accent); letter-spacing: 0.18em;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}
.replay-detail-row {
  display: flex; justify-content: space-between;
  font-size: 0.85rem; padding: 4px 0;
  border-bottom: 1px solid var(--glass-border);
}
.replay-detail-row:last-child { border-bottom: 0; }
.replay-detail-label { color: var(--muted); }
.replay-detail-val   { color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 0.8rem; }
.replay-armor-slot, .replay-hand {
  display: inline-block; font-size: 0.7rem;
  padding: 2px 7px; margin: 2px 2px 0 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
}
.replay-effect {
  display: inline-block; font-size: 0.7rem;
  padding: 2px 8px; margin: 2px 2px 0 0;
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-pill);
}
.replay-empty-detail { color: var(--muted-2); font-size: 0.85rem; font-style: italic; text-align: center; padding: 0.5rem 0; }

/* ── Pixel-art hearts (inline SVG, 9x9 viewBox, 12x12 rendered) ── */
.replay-hearts {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin: 4px 0;
  font-family: var(--font-mono);
}
.replay-heart {
  width: 12px;
  height: 12px;
  display: inline-block;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
}
.replay-heart-full  { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAR0lEQVR4nK2OwQ0AIAgDT6dhHDbCkRzHbfClD5CfTfqgvZDCVxm4gVdZM/AhAqowZ3ow1qLf6wEc9bJ5bXKR5LgzgQmIYAQ2ggYrjl6h/kEAAAAASUVORK5CYII="); }
.replay-heart-half  { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAY0lEQVR4nK2OPRmAMBQDr7igGHg7RnDU4ggj7Ch4AmogLNCv/G3cluSGwK8kUAK13Qgajy4kUDaDaYJlAWAopcq9O11Nh/BG97m00gwhb9vr2LuzQricl5lkphhjPf3gFO/CDr+ZIfabpPv1AAAAAElFTkSuQmCC"); }
.replay-heart-empty { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAARklEQVR4nK2PwQ0AIAwCr24ha3T/EVyjjlFfvrSJD3mSAwJ8lUM6ZOWZQ06pLOgRtJelN2iA9YhyaoA1gBu4gSPpkJKOpws8/heB7Oo7JwAAAABJRU5ErkJggg=="); }
.replay-heart-text {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── DEAD badge (pulses) + fallback note ── */
.replay-dead-badge {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: #fff;
  background: var(--red);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  margin: 8px 0 6px;
  letter-spacing: 0.15em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
  animation: replay-pulse 2s ease-in-out infinite;
}
@keyframes replay-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
  50%      { box-shadow: 0 0 20px rgba(239, 68, 68, 0.7); }
}
.replay-fallback-note {
  color: var(--muted-2);
  font-size: 0.72rem;
  font-style: italic;
  margin: 4px 0 6px;
}

/* ── Bottom bar (timeline) — glassy frosted ── */
.replay-timeline {
  flex-shrink: 0; height: 56px;
  background: rgba(var(--bg-rgb), 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--glass-border);
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0 1.1rem;
  position: relative; z-index: 10;
}
.replay-timeline::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.3), transparent);
}
.replay-play-btn, .replay-speed-btn, .replay-loop-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  cursor: pointer; font: inherit; font-size: 0.85rem;
  height: 32px; padding: 0 12px;
  transition: all 0.15s ease;
}
.replay-play-btn { width: 36px; padding: 0; font-weight: 700; font-size: 0.95rem; }
.replay-play-btn:hover, .replay-speed-btn:hover, .replay-loop-btn:hover {
  border-color: var(--glass-border-bright);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}
.replay-speed-btn { min-width: 38px; font-variant-numeric: tabular-nums; font-weight: 600; }
.replay-speed-btn.active, .replay-loop-btn.active {
  background: var(--accent); color: var(--bg);
  border-color: var(--accent); font-weight: 700;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.3);
}
.replay-play-btn:hover { color: var(--accent); border-color: var(--accent); }

.replay-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.4) 0%, var(--glass-border) 0%);
  height: 6px; border-radius: var(--radius-pill); cursor: pointer;
  outline: none;
}
.replay-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%; cursor: pointer;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5);
  transition: all 0.15s ease;
}
.replay-slider::-webkit-slider-thumb:hover { transform: scale(1.15); box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.7); }
.replay-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%; cursor: pointer;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5);
}
.replay-time {
  font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted);
  font-variant-numeric: tabular-nums; min-width: 100px; text-align: right;
}

/* ── Toast (share link, errors) ── */
.replay-toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--accent); color: var(--bg);
  font-weight: 600; padding: 0.6rem 1.2rem;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.4);
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.replay-toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.replay-toast.error { background: var(--red); color: #fff; box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4); }

/* ── Loading / error overlay ── */
.replay-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1rem;
  background: rgba(var(--bg-rgb), 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10000;
}
.replay-overlay h2 {
  font-family: var(--font-pixel); color: var(--accent); margin: 0;
  font-size: 0.85rem; letter-spacing: 0.08em;
  text-shadow: 0 0 16px rgba(var(--accent-rgb), 0.5);
}
.replay-overlay p { color: var(--muted); margin: 0; font-size: 0.9rem; }
.replay-overlay button {
  background: var(--accent); color: var(--bg);
  border: 0; padding: 0.55rem 1.2rem;
  border-radius: var(--radius-pill);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
}
.replay-overlay button:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.4); }
.replay-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: replay-spin 0.8s linear infinite;
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.2);
}

/* ── Cursor containment (defense in depth) ── */
/* Once <body> is restored, .leaflet-container is bounded by .replay-map and
   the grab cursor stays inside the map area. This block is a safety net so
   even if a future layout regression leaks the grab cursor, the buttons
   still feel clickable and the chrome doesn't. */
.replay-dim button,
.replay-zoom button,
.replay-play-btn,
.replay-speed-btn,
.replay-loop-btn,
.replay-share-btn,
.replay-back {
  cursor: pointer !important;
}
.replay-dim,
.replay-zoom,
.replay-timeline,
.replay-titlebar,
.replay-sidebar,
.replay-sidebar-header,
.replay-players,
.replay-detail,
.replay-detail-head,
.replay-empty,
.replay-empty span {
  cursor: default;
}
.replay-dim button:disabled { cursor: not-allowed !important; }
@keyframes replay-spin { to { transform: rotate(360deg); } }


/* ── Team loadouts (scroll-down replay section) ── */
.replay-teams {
  width: 100%;
  flex-shrink: 0;
  padding: 24px;
  background: var(--bg);
  border-top: 1px solid var(--glass-border);
  color: var(--text);
}
.replay-teams * { min-width: 0; }
.replay-teams-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 18px;
}
.replay-teams-title {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-shadow: 0 0 16px rgba(var(--accent-rgb), 0.45);
  overflow: hidden;
  text-overflow: ellipsis;
}
.replay-teams-time {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(var(--accent-cyan-rgb), 0.32);
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-cyan-rgb), 0.08);
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 14px rgba(var(--accent-cyan-rgb), 0.12);
  white-space: nowrap;
}
.replay-teams-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.replay-team-card {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  box-shadow: inset 0 3px 0 rgba(255, 215, 0, 0.15), 0 12px 30px rgba(0, 0, 0, 0.26);
}
.replay-team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--glass-border);
  border-top: 2px solid var(--team-color, var(--accent));
}
.replay-team-name {
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  line-height: 1.6;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.35);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.replay-team-count {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  white-space: nowrap;
}
.replay-team-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
}
.loadout-player-card {
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}
.loadout-player-card:last-child { margin-bottom: 0; }
.loadout-player-card.dead { opacity: 0.6; }
.loadout-player-card.dead .loadout-item-icon { filter: grayscale(1); }
.loadout-player-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.replay-teams .replay-player-head-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  border-color: var(--glass-border-bright);
}
.replay-teams .replay-player-head-wrap.dead {
  opacity: 0.5;
  filter: grayscale(1);
}
.loadout-player-name {
  flex: 1;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loadout-player-card.dead .loadout-player-name {
  color: var(--muted-2);
  text-decoration: line-through;
}
.loadout-health {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.loadout-health .replay-hearts { margin: 0; }
.loadout-health .replay-heart {
  width: 8px;
  height: 8px;
}
.loadout-dead-skull {
  color: var(--red);
  font-size: 0.95rem;
  line-height: 1;
}
.loadout-section {
  margin-top: 8px;
}
.loadout-section-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
}
.loadout-armor-grid {
  display: flex;
  flex-direction: row;
  gap: 6px;
}
.loadout-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}
.loadout-slot.empty { border-color: rgba(255, 255, 255, 0.04); }
.loadout-slot.has-item { border-color: rgba(255, 255, 255, 0.12); }
.loadout-item-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  vertical-align: middle;
}
.loadout-item-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}
.loadout-item-count {
  position: absolute;
  right: -5px;
  bottom: -3px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.8);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  line-height: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.loadout-item-wrap.enchanted .loadout-item-icon,
.loadout-item-icon.enchanted {
  filter: drop-shadow(0 0 2px rgba(170, 100, 255, 0.8));
}
.loadout-player-card.dead .loadout-item-wrap.enchanted .loadout-item-icon,
.loadout-player-card.dead .loadout-item-icon.enchanted {
  filter: grayscale(1) drop-shadow(0 0 2px rgba(170, 100, 255, 0.8));
}
.loadout-items-grid,
.loadout-potions-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
}
.loadout-weapons-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.loadout-weapon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  min-width: 28px;
}
.loadout-weapon-item .loadout-item-icon {
  width: 24px;
  height: 24px;
}
.loadout-enchants {
  max-width: 100%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.65rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loadout-empty-text {
  color: var(--muted-2);
  font-size: 0.72rem;
  font-style: italic;
}
.loadout-potion-label {
  font-size: 0.6rem;
  color: var(--accent-cyan);
  margin-left: 3px;
  white-space: nowrap;
}
.loadout-potions-row .loadout-item-wrap {
  flex-direction: row;
  gap: 3px;
}
@media (max-width: 768px) {
  .replay-teams { padding: 18px 12px; }
  .replay-teams-header { align-items: flex-start; flex-direction: column; }
  .replay-teams-grid { grid-template-columns: 1fr; }
  .replay-team-body { gap: 10px; padding: 12px; }
  .loadout-player-card { width: 100%; }
  .loadout-section { display: block; }
  .replay-team-name { white-space: normal; }
}

/* ── Episode timeline bar ── */
.replay-episodes {
  flex-shrink: 0;
  display: flex;
  height: 28px;
  background: rgba(var(--bg-rgb), 0.6);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  padding: 0;
  overflow: hidden;
}
.replay-episode {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  border-left: 1px solid var(--glass-border);
  padding: 3px 2px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  user-select: none;
}
.replay-episode:first-child { border-left: none; }
.replay-episode:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.replay-episode.active {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.4);
}
.replay-episode-num { line-height: 1; }
.replay-episode-time {
  display: block;
  font-size: 0.52rem;
  color: var(--muted-2);
  font-family: var(--font-mono);
  margin-top: 1px;
  line-height: 1;
}
.replay-episode.active .replay-episode-time { color: var(--accent-cyan); }
@media (max-width: 768px) {
  .replay-episodes { height: auto; flex-wrap: wrap; }
  .replay-episode { min-width: 25%; }
}

/* ── Static marker click popups ── */
.replay-marker-popup .leaflet-popup-content-wrapper {
  background: rgba(8, 17, 26, 0.96);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  color: #e2e8f0;
}
.replay-marker-popup .leaflet-popup-tip {
  background: rgba(8, 17, 26, 0.96);
  border: 1px solid rgba(99, 102, 241, 0.35);
}
.replay-marker-popup .leaflet-popup-close-button {
  color: #64748b; font-size: 18px; padding: 6px 8px;
}
.replay-marker-popup .leaflet-popup-close-button:hover { color: #e2e8f0; }
.marker-popup {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  min-width: 180px;
}
.marker-popup-title {
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--accent);
 margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}
.marker-popup-row {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.25rem; line-height: 1.35;
}
.marker-popup-label {
  color: var(--muted-2); flex-shrink: 0; min-width: 70px;
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.marker-popup-val { color: #e2e8f0; word-break: break-word; }
.marker-popup-na { color: #475569; font-style: italic; }
.marker-popup-head {
  width: 20px; height: 20px; vertical-align: middle;
  image-rendering: pixelated; border-radius: 2px; margin-right: 2px;
}

/* Broken portal marker */
.marker-symbol-portal.broken {
  border-color: #6b7280;
  background: rgba(0, 0, 0, 0.8);
}
.marker-symbol-portal.broken::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}

/* ════════════════════════════════════════════════════════════════════════
   LIGHT THEME (Phases 2+3) — mirrors the espectral.uhce.top light palette.
   data-theme="light" on <html> (FOUC script + toggle in replay.html).
   Token names mirror this file's :root; hardcoded dark-only values get
   scoped overrides below. ════════════════════════════════════════════════ */
[data-theme='light'] {
  color-scheme: light;
  --bg:           #f4f6fb;
  --bg-rgb:       244, 246, 251;
  --surface:      rgba(255, 255, 255, 0.72);
  --surface-up:   rgba(238, 241, 248, 0.8);
  --text:         #161d33;
  --muted:        #5a6a8a;
  --muted-2:      #64748b;
  --accent:       #a16207;
  --accent-rgb:   161, 98, 7;
  --accent-cyan:  #0e7490;
  --accent-cyan-rgb: 14, 116, 144;
  --border:       rgba(23, 31, 51, 0.14);
  --glass-border: rgba(23, 31, 51, 0.09);
  --glass-border-bright: rgba(23, 31, 51, 0.18);
  --overworld:    #16a34a;
  --nether:       #dc2626;
  --the_end:      #7c3aed;
  --red:          #dc2626;
  --green:        #16a34a;
  --yellow:       #b45309;
}

[data-theme='light'] body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(161, 98, 7, 0.05), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(14, 116, 144, 0.04), transparent),
    var(--bg);
}

/* White-alpha fills / dark panels → dark-alpha over light surfaces */
[data-theme='light'] .replay-map { background: var(--bg); }
[data-theme='light'] .replay-back:hover { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-seed { background: rgba(23, 31, 51, 0.04); }
[data-theme='light'] .replay-dim button:hover:not(:disabled) { background: rgba(23, 31, 51, 0.07); }
[data-theme='light'] .replay-player { background: rgba(23, 31, 51, 0.02); }
[data-theme='light'] .replay-player:hover { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-player-head-wrap { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-detail-head { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-armor-slot,
[data-theme='light'] .replay-hand { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-play-btn,
[data-theme='light'] .replay-speed-btn,
[data-theme='light'] .replay-loop-btn { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-play-btn:hover,
[data-theme='light'] .replay-speed-btn:hover,
[data-theme='light'] .replay-loop-btn:hover { background: rgba(23, 31, 51, 0.08); }
[data-theme='light'] .replay-episode:hover { background: rgba(23, 31, 51, 0.04); }
[data-theme='light'] .loadout-player-card { background: rgba(23, 31, 51, 0.04); }
[data-theme='light'] .loadout-slot { background: rgba(23, 31, 51, 0.08); }
[data-theme='light'] .loadout-slot.empty { border-color: rgba(23, 31, 51, 0.06); }
[data-theme='light'] .loadout-slot.has-item { border-color: rgba(23, 31, 51, 0.16); }
[data-theme='light'] .loadout-item-count { background: rgba(23, 31, 51, 0.85); color: #fff; }
[data-theme='light'] .replay-team-card {
  box-shadow: inset 0 3px 0 rgba(161, 98, 7, 0.15), 0 12px 30px rgba(23, 31, 51, 0.1);
}

/* Washed-out light-on-dark text → darker variants */
[data-theme='light'] .team-red    { color: #dc2626; }
[data-theme='light'] .team-blue   { color: #2563eb; }
[data-theme='light'] .team-green  { color: #16a34a; }
[data-theme='light'] .team-yellow { color: #b45309; }
[data-theme='light'] .team-spec   { color: #64748b; }
[data-theme='light'] .replay-player-dim[data-dim="overworld"] { color: #16a34a; }
[data-theme='light'] .replay-player-dim[data-dim="nether"]    { color: #dc2626; }
[data-theme='light'] .replay-player-dim[data-dim="the_end"]   { color: #7c3aed; }
[data-theme='light'] .replay-player-dim[data-dim="unknown"]   { color: #64748b; }
[data-theme='light'] .replay-effect { color: #7c3aed; }
[data-theme='light'] .marker-symbol-portal { border-color: #9333ea; }
[data-theme='light'] .marker-symbol-gateway { border-color: #a855f7; }

/* Leaflet marker popups: dark panel → light panel */
[data-theme='light'] .replay-marker-popup .leaflet-popup-content-wrapper,
[data-theme='light'] .replay-marker-popup .leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-color: rgba(99, 102, 241, 0.4);
}
[data-theme='light'] .replay-marker-popup .leaflet-popup-content-wrapper {
  box-shadow: 0 4px 24px rgba(23, 31, 51, 0.18);
}
[data-theme='light'] .replay-marker-popup .leaflet-popup-close-button:hover { color: var(--text); }
[data-theme='light'] .marker-popup-val { color: var(--text); }
[data-theme='light'] .marker-popup-na { color: var(--muted-2); }

/* ── Theme toggle button (titlebar) ── */
.replay-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s ease;
}
.replay-theme-toggle:hover {
  color: var(--accent); border-color: var(--glass-border-bright);
  background: rgba(255, 255, 255, 0.07);
}
[data-theme='light'] .replay-theme-toggle { background: rgba(23, 31, 51, 0.05); }
[data-theme='light'] .replay-theme-toggle:hover { background: rgba(23, 31, 51, 0.08); }