* { 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;
  background: radial-gradient(120% 90% at 50% 38%, #0a1014 0%, #04060a 55%, #000000 100%);
  border: 1px solid #15303a;
  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(0, 200, 160, 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: 104px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 18px 0;
  background: linear-gradient(180deg, rgba(4,8,12,0.78), rgba(4,8,12,0));
}

.stat { width: 132px; text-align: center; }
.stat-pads { text-align: center; }
.stat-num {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.12s ease;
}
.stat-num.bump { transform: scale(1.35); }
.stat-lbl {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 800;
  opacity: 0.72;
  margin-top: 4px;
}
.stat-survivors .stat-num { color: #7fffd0; text-shadow: 0 0 16px rgba(60,255,180,0.8); }
.stat-survivors .stat-lbl { color: #9fffe0; }
.stat-pads .stat-num { color: #ffe27a; text-shadow: 0 0 16px rgba(255,210,70,0.8); }
.stat-pads .stat-lbl { color: #ffe9a8; }

.t-mid { flex: 1; text-align: center; padding-top: 10px; }
.t-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 4px;
  opacity: 0.96;
}
.t-sub {
  font-size: 10px;
  letter-spacing: 3px;
  opacity: 0.6;
  margin-top: 4px;
}

/* ---------- Big phase + countdown ---------- */
#phase-readout {
  position: absolute;
  top: 120px; left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 280px;
}
#phase-label {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 8px;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
#phase-count {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 96px;
  font-weight: 900;
  line-height: 0.95;
  margin-top: 2px;
  transition: color 0.15s ease, transform 0.15s ease;
}
#phase-count.tick { animation: countPop 0.5s ease-out; }
@keyframes countPop {
  0% { transform: scale(1.5); }
  100% { transform: scale(1); }
}
#phase-hint {
  font-size: 12px;
  letter-spacing: 4px;
  font-weight: 800;
  opacity: 0.85;
  margin-top: 2px;
}

/* SAFE styling — green/calm */
#phase-readout.safe #phase-label { color: #6dffb0; text-shadow: 0 0 22px rgba(60,255,170,0.85); }
#phase-readout.safe #phase-count { color: #b6ffe0; text-shadow: 0 0 26px rgba(80,255,180,0.7); }
#phase-readout.safe #phase-hint { color: #9fffd6; }

/* DANGER styling — red/alarm */
#phase-readout.danger #phase-label { color: #ff5a5a; text-shadow: 0 0 26px rgba(255,40,40,0.95); }
#phase-readout.danger #phase-count { color: #ff9a8a; text-shadow: 0 0 26px rgba(255,60,40,0.8); }
#phase-readout.danger #phase-hint { color: #ffb0a0; }
#phase-readout.danger { animation: dangerPulse 0.5s ease-in-out infinite; }
@keyframes dangerPulse {
  0%,100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

/* ---------- Victory banner ---------- */
#victory-banner {
  position: absolute;
  top: 46%; 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: 66px;
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  margin: 8px 0;
  color: #fff;
  text-shadow: 0 0 34px currentColor;
}
.vb-tag {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 12px;
  opacity: 0.95;
  color: #ffe27a;
  text-shadow: 0 0 26px rgba(255,210,80,0.9);
}

/* ---------- 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,10,20,0.95);
}

/* CRITICAL: an ID selector (#boot-error{display:flex}) would otherwise outrank
   a plain .hidden{display:none}. !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.3s 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); }
}
