* { 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;
  /* Molten fallback so the frame reads warm/dark before the canvas paints. */
  background: radial-gradient(120% 90% at 50% 95%, #2a0703 0%, #120302 45%, #000000 100%);
  border: 1px solid #2a0a04;
  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, 90, 20, 0.12);
  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: 86px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px 0;
  background: linear-gradient(180deg, rgba(18,4,2,0.78), rgba(18,4,2,0));
}

.t-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 5px;
  color: #ffd9a8;
  text-shadow: 0 0 18px rgba(255,120,40,0.65);
}
.t-sub {
  font-size: 11px;
  letter-spacing: 3px;
  opacity: 0.7;
  margin-top: 4px;
  color: #ffb27a;
}

.tb-right { text-align: right; }
.surv-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ffcaa0;
  opacity: 0.85;
}
.surv-count {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  color: #fff1d8;
  text-shadow: 0 0 16px rgba(255,150,60,0.8);
  transition: transform 0.12s ease;
}
.surv-count.bump { transform: scale(1.35); }

/* ---------- Standings (highest climbers) ---------- */
#standings {
  position: absolute;
  top: 96px; left: 14px;
  width: 184px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(20,6,3,0.5);
  border: 1px solid rgba(255,140,60,0.18);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.2s ease;
}
.stand-row.leader { border-color: rgba(255,210,120,0.7); box-shadow: 0 0 14px rgba(255,170,70,0.4); }
.stand-row.dead { opacity: 0.28; filter: grayscale(0.7); }
.stand-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex: 0 0 auto;
}
.stand-name { flex: 1; }
.stand-h {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  opacity: 0.9;
}

/* ---------- Lava rise meter ---------- */
#lava-readout {
  position: absolute;
  bottom: 34px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px;
  border-radius: 20px;
  background: rgba(26,7,3,0.6);
  border: 1px solid rgba(255,130,50,0.35);
}
.lava-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ffcf9c;
}
.lava-track {
  width: 150px; height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}
.lava-prog {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff7a18, #ffd24a);
  box-shadow: 0 0 12px rgba(255,140,40,0.9);
  transition: width 0.2s linear;
}
.lava-time {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  color: #ffe2b8;
  min-width: 38px;
  text-align: right;
}
#lava-readout.urgent { animation: lavaPulse 0.6s ease-in-out infinite; }
@keyframes lavaPulse {
  0%,100% { box-shadow: 0 0 0 rgba(255,120,40,0); }
  50% { box-shadow: 0 0 24px rgba(255,120,40,0.7); border-color: rgba(255,170,90,0.9); }
}

/* ---------- 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: 5px;
  font-weight: 700;
  opacity: 0.85;
  color: #ffd9a8;
}
.vb-name {
  font-size: 70px;
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  margin: 6px 0;
  color: #fff;
  text-shadow: 0 0 30px currentColor;
}
.vb-tag {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 12px;
  opacity: 0.95;
  color: #ffe2b8;
  text-shadow: 0 0 22px rgba(255,150,60,0.9);
}

/* ---------- Watermark / ticker ---------- */
#watermark {
  position: absolute;
  bottom: 64px; right: 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255,235,210,0.55);
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.ticker {
  position: absolute;
  left: 0; right: 0;
  bottom: 10px;
  text-align: center;
  font-family: "SF Mono", "Menlo", "Courier New", monospace;
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.6;
  color: #ffcaa0;
  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,4,2,0.95);
}

/* CRITICAL: an ID selector (#boot-error{display:flex}) would otherwise outrank
   a plain .hidden{display:none}, leaving the full-screen 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(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -2px); }
}
