* { 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;
  /* Warm void fallback so the frame reads before the canvas paints. */
  background: radial-gradient(120% 90% at 50% 42%, #1a0a22 0%, #0a0410 55%, #000000 100%);
  border: 1px solid #2a1030;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.75), inset 0 0 70px rgba(0,0,0,0.45),
              0 0 40px rgba(255, 120, 40, 0.10);
  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: 78px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 14px 16px 0;
  background: linear-gradient(180deg, rgba(14,4,20,0.78), rgba(14,4,20,0));
}

.t-mid { text-align: center; }
.t-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 7px;
  background: linear-gradient(90deg, #ffd24a, #ff7a3c, #ff4fa0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(255,140,60,0.45);
}
.t-sub {
  font-size: 10px;
  letter-spacing: 4px;
  opacity: 0.7;
  margin-top: 4px;
  color: #ffd9c2;
}

/* ---------- Survivor standings panel ---------- */
#standings {
  position: absolute;
  top: 88px; left: 14px;
  width: 132px;
  padding: 8px 9px 9px;
  border-radius: 10px;
  background: rgba(16,8,24,0.55);
  border: 1px solid rgba(255,150,90,0.22);
  backdrop-filter: blur(2px);
}
.st-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.st-title {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: #ffcfa0;
}
.st-count {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 14px rgba(255,170,90,0.8);
  transition: transform 0.12s ease;
}
.st-count.bump { transform: scale(1.45); }
.st-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.st-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 7px rgba(0,0,0,0.5), inset 0 2px 3px rgba(255,255,255,0.55);
  transition: opacity 0.4s ease, filter 0.4s ease, transform 0.25s ease;
}
.st-dot.dead {
  opacity: 0.16;
  filter: grayscale(1) brightness(0.6);
  transform: scale(0.7);
}

/* ---------- Arena shrink meter ---------- */
#shrink-readout {
  position: absolute;
  top: 92px; right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 12px;
  background: rgba(16,8,24,0.55);
  border: 1px solid rgba(255,150,90,0.24);
}
.shrink-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ffcfa0;
}
.shrink-track {
  width: 96px; height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.14);
  overflow: hidden;
}
.shrink-prog {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff4fa0, #ff7a3c, #ffd24a);
  box-shadow: 0 0 12px rgba(255,140,60,0.85);
  transition: width 0.3s linear;
}
.shrink-pct {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  color: #ffe0c2;
}
#shrink-readout.urgent { animation: shrinkPulse 0.7s ease-in-out infinite; }
@keyframes shrinkPulse {
  0%,100% { box-shadow: 0 0 0 rgba(255,90,60,0); }
  50% { box-shadow: 0 0 22px rgba(255,90,60,0.6); border-color: rgba(255,120,90,0.85); }
}

/* ---------- Tremor warning ---------- */
#tremor-warn {
  position: absolute;
  top: 46%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #ffce4a;
  text-shadow: 0 0 24px rgba(255,90,40,0.95), 0 2px 6px rgba(0,0,0,0.8);
  animation: tremorBlink 0.4s steps(2,end) infinite;
}
@keyframes tremorBlink {
  0% { opacity: 1; }
  50% { opacity: 0.25; }
  100% { opacity: 1; }
}

/* ---------- 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;
  color: #ffe8d2;
}
.vb-name {
  font-size: 68px;
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  margin: 6px 0;
  text-shadow: 0 0 34px rgba(255,255,255,0.45);
}
.vb-tag {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 12px;
  opacity: 0.95;
  color: #fff;
}

/* ---------- 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.62;
  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(12,6,16,0.95);
}

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

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