* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #000000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 540px;
  height: 960px;
  /* Gritty steel-yard fallback so the frame reads dark before the canvas paints. */
  background: radial-gradient(120% 90% at 50% 38%, #1a140c 0%, #0a0805 55%, #000000 100%);
  border: 1px solid #2a1c0e;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.75), inset 0 0 70px rgba(0,0,0,0.5),
              0 0 40px rgba(255, 140, 40, 0.08);
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* ---------- HUD overlay ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 84px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px 0;
  background: linear-gradient(180deg, rgba(8,6,3,0.78), rgba(8,6,3,0));
}

.t-mid { padding-top: 4px; }
.t-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #ffb347;
  text-shadow: 0 0 18px rgba(255,130,40,0.55), 0 2px 3px rgba(0,0,0,0.8);
}
.t-sub {
  font-size: 11px;
  letter-spacing: 4px;
  opacity: 0.65;
  margin-top: 4px;
}

#alive-pod {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}
.alive-num {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 16px rgba(255,180,80,0.6);
  transition: transform 0.12s ease, color 0.2s ease;
}
.alive-num.bump { transform: scale(1.45); color: #ff5a2a; }
.alive-label {
  font-size: 9px;
  letter-spacing: 3px;
  font-weight: 800;
  opacity: 0.6;
  margin-top: 2px;
}

/* ---------- Live standings ---------- */
#standings {
  position: absolute;
  top: 96px; left: 12px;
  width: 158px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stand-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(10,8,5,0.42);
  transition: opacity 0.4s ease, transform 0.3s ease;
}
.stand-row.dead { opacity: 0.28; filter: grayscale(0.7); }
.stand-row.low .sr-bar-fill { box-shadow: 0 0 10px rgba(255,60,30,0.9); }
.sr-swatch {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
.sr-name {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  width: 42px;
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.sr-bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}
.sr-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  transition: width 0.18s linear, background 0.2s ease;
}

/* ---------- Arena shrink meter ---------- */
#arena-readout {
  position: absolute;
  top: 96px; right: 12px;
  width: 158px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 16px;
  background: rgba(14,9,4,0.6);
  border: 1px solid rgba(255,150,60,0.32);
}
.ar-label {
  font-size: 8px; font-weight: 900; letter-spacing: 2px; color: #ffc58a;
}
.ar-track {
  flex: 1 1 auto; height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.15);
  overflow: hidden;
}
.ar-prog {
  height: 100%; width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff8a3c, #ff3a1e);
  box-shadow: 0 0 12px rgba(255,80,30,0.85);
  transition: width 0.2s linear;
}
.ar-phase {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 8px; font-weight: 800; letter-spacing: 1px;
  color: #ffb38a; min-width: 40px; text-align: right;
}
#arena-readout.urgent { animation: arenaPulse 0.6s ease-in-out infinite; }
@keyframes arenaPulse {
  0%,100% { box-shadow: 0 0 0 rgba(255,80,30,0); }
  50% { box-shadow: 0 0 22px rgba(255,80,30,0.65); border-color: rgba(255,120,60,0.9); }
}

/* ---------- Hazard warning ---------- */
#hazard-warn {
  position: absolute;
  top: 132px; left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffd23a;
  text-shadow: 0 0 16px rgba(255,120,20,0.9);
  padding: 5px 14px;
  border-radius: 8px;
  background: rgba(40,16,4,0.6);
  border: 1px solid rgba(255,160,40,0.6);
  animation: warnFlash 0.5s steps(2, end) infinite;
}
@keyframes warnFlash { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Victory banner ---------- */
#victory-banner {
  position: absolute;
  top: 44%; left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(.2,1.3,.4,1);
}
#victory-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#victory-banner.hidden { display: none !important; }
.vb-sub {
  font-size: 12px;
  letter-spacing: 6px;
  font-weight: 700;
  opacity: 0.85;
}
.vb-name {
  font-size: 70px;
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  margin: 6px 0;
  color: #fff;
  text-shadow: 0 0 30px currentColor, 0 4px 8px rgba(0,0,0,0.7);
}
.vb-tag {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 12px;
  opacity: 0.95;
  color: #ffb347;
  text-shadow: 0 0 20px rgba(255,130,40,0.8);
}

/* ---------- Watermark / ticker ---------- */
#watermark {
  position: absolute;
  bottom: 30px; right: 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.55);
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.ticker {
  position: absolute;
  left: 0; right: 0;
  bottom: 8px;
  text-align: center;
  font-family: "SF Mono", "Menlo", "Courier New", monospace;
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.6;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

#boot-error {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  font-size: 14px;
  line-height: 1.6;
  color: #ff8a8a;
  background: rgba(8,6,3,0.95);
}

/* CRITICAL: an ID selector (#boot-error{display:flex}) would otherwise outrank
   a plain .hidden{display:none}. !important keeps the full-screen dark overlay
   hidden unless we explicitly un-hide it on an actual context-creation failure. */
.hidden { display: none !important; }

#stage.shaking { animation: quake 0.3s linear infinite; }
@keyframes quake {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(3px, -3px); }
  75% { transform: translate(-2px, -2px); }
}
