* { 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%, #0c0a14 0%, #060409 55%, #000000 100%);
  border: 1px solid #1a1326;
  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(120, 60, 200, 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;
  text-align: center;
  padding: 14px 16px 0;
  background: linear-gradient(180deg, rgba(8,5,16,0.78), rgba(8,5,16,0));
}
.t-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 7px;
  text-shadow: 0 0 18px rgba(255,160,80,0.55);
}
.t-sub {
  font-size: 10px;
  letter-spacing: 3px;
  opacity: 0.62;
  margin-top: 5px;
}

/* ---------- Leaderboard (per-hole size ranking) ---------- */
#leaderboard {
  position: absolute;
  top: 92px; left: 12px;
  width: 188px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lb-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 9px;
  background: rgba(12,10,22,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  /* leader floats up: the order is set by `order`, animated by transform */
  transition: transform 0.45s cubic-bezier(.2,.9,.3,1), opacity 0.4s ease, border-color 0.3s;
}
.lb-row.leader {
  border-color: rgba(255,210,120,0.85);
  box-shadow: 0 0 18px rgba(255,190,90,0.35);
}
.lb-row.dead { opacity: 0.25; filter: grayscale(0.7); }
.lb-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 10px currentColor;
  background: currentColor;
}
.lb-name {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.5px;
  flex: 1;
}
.lb-size {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 15px;
  font-weight: 900;
  min-width: 30px;
  text-align: right;
  transition: transform 0.12s ease;
}
.lb-size.bump { transform: scale(1.45); }
.lb-crown {
  position: absolute;
  right: -6px; top: -9px;
  font-size: 15px;
  filter: drop-shadow(0 0 6px rgba(255,200,90,0.9));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lb-row.leader .lb-crown { opacity: 1; }

/* ---------- Arena-shrink meter ---------- */
#arena-readout {
  position: absolute;
  bottom: 56px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px;
  border-radius: 20px;
  background: rgba(14,9,20,0.6);
  border: 1px solid rgba(255,150,120,0.30);
}
.ar-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ffd0bd;
  transition: color 0.3s;
}
.ar-track {
  width: 150px; height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.16);
  overflow: hidden;
}
.ar-prog {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff8a3c, #ff3b6b);
  box-shadow: 0 0 12px rgba(255,80,90,0.8);
  transition: width 0.2s linear;
}
.ar-time {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  color: #ffd9c9;
  min-width: 34px;
  text-align: right;
}
#arena-readout.urgent { animation: arPulse 0.6s ease-in-out infinite; }
#arena-readout.urgent .ar-label { color: #ff5a5a; }
@keyframes arPulse {
  0%,100% { box-shadow: 0 0 0 rgba(255,70,70,0); }
  50% { box-shadow: 0 0 24px rgba(255,70,70,0.7); border-color: rgba(255,90,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: 6px;
  font-weight: 700;
  opacity: 0.85;
}
.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: 22px;
  font-weight: 900;
  letter-spacing: 10px;
  opacity: 0.95;
}

/* ---------- 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 the dark overlay hidden
   unless we explicitly un-hide it on an actual context-creation failure. */
.hidden { display: none !important; }
