:root {
  --sky: #7ec8e8;
  --sky-deep: #4a9fd4;
  --awning-red: #d62839;
  --awning-white: #fff8f0;
  --booth-wood: #8b5a2b;
  --gold: #f5c842;
  --water: #4fc3f7;
  --water-deep: #0288d1;
  --text: #1a2030;
  --text-muted: #5a6e7a;
  --panel-bg: rgba(255, 252, 245, 0.96);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  --radius: 16px;
}

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

body {
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: var(--sky);
  overflow-x: hidden;
}

/* ── Carnival background ── */
.carnival-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sky-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #5eb8e8 0%, #9ad4f0 35%, #c8e8f8 65%, #8fd49a 88%, #5cb368 100%);
}

.sun {
  position: absolute;
  top: 60px;
  right: 12%;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff9c4 0%, #ffeb3b 50%, #ffc107 100%);
  box-shadow: 0 0 40px rgba(255, 235, 59, 0.5);
  animation: sunPulse 4s ease-in-out infinite alternate;
}

@keyframes sunPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50px;
  animation: cloudDrift 30s linear infinite;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-1 {
  width: 80px;
  height: 28px;
  top: 12%;
  left: 8%;
}

.cloud-1::before { width: 40px; height: 40px; top: -20px; left: 12px; }
.cloud-1::after { width: 50px; height: 35px; top: -14px; right: 8px; }

.cloud-2 {
  width: 100px;
  height: 32px;
  top: 18%;
  right: 20%;
  animation-duration: 40s;
  animation-direction: reverse;
}

.cloud-2::before { width: 45px; height: 45px; top: -22px; left: 18px; }
.cloud-2::after { width: 55px; height: 38px; top: -16px; right: 10px; }

.cloud-3 {
  width: 70px;
  height: 24px;
  top: 8%;
  left: 45%;
  animation-duration: 35s;
}

.cloud-3::before { width: 35px; height: 35px; top: -18px; left: 10px; }
.cloud-3::after { width: 42px; height: 30px; top: -12px; right: 6px; }

@keyframes cloudDrift {
  from { transform: translateX(0); }
  to { transform: translateX(60px); }
}

.ferris-wheel {
  position: absolute;
  bottom: 22%;
  left: 4%;
  width: 120px;
  height: 120px;
  border: 6px solid rgba(214, 40, 57, 0.35);
  border-radius: 50%;
  opacity: 0.45;
  animation: ferrisSpin 20s linear infinite;
}

.ferris-wheel::before {
  content: '';
  position: absolute;
  inset: 20%;
  border: 3px dashed rgba(214, 40, 57, 0.3);
  border-radius: 50%;
}

.ferris-wheel::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px;
  background: var(--awning-red);
  border-radius: 50%;
}

@keyframes ferrisSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.bunting {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  height: 30px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--awning-red) 0 20px,
      transparent 20px 24px,
      var(--gold) 24px 44px,
      transparent 44px 48px,
      #43a047 48px 68px,
      transparent 68px 72px
    );
  opacity: 0.5;
  mask-image: linear-gradient(180deg, black, transparent);
}

.fair-lights {
  position: absolute;
  bottom: 30%;
  left: 0;
  right: 0;
  height: 20px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 40px,
    rgba(245, 200, 66, 0.6) 40px 44px,
    transparent 44px 80px,
    rgba(255, 45, 85, 0.5) 80px 84px
  );
  animation: lightsTwinkle 1.5s ease-in-out infinite alternate;
}

@keyframes lightsTwinkle {
  from { opacity: 0.4; }
  to { opacity: 0.9; }
}

.grass {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18%;
  background: linear-gradient(180deg, #6bc96e 0%, #3d9e45 100%);
}

.awning-stripes {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: repeating-linear-gradient(
    90deg,
    var(--awning-red) 0,
    var(--awning-red) 28px,
    var(--awning-white) 28px,
    var(--awning-white) 56px
  );
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

.site-nav {
  position: relative;
  z-index: 10;
  max-width: 1100px;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 0;
}

.site-nav-link {
  display: inline-flex;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2a4060;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.header,
.container {
  position: relative;
  z-index: 1;
}

.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0.5rem;
}

.logo {
  font-size: 2.8rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.header h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #1a3050;
}

.tagline {
  font-size: 0.95rem;
  color: #3a5570;
  margin-top: 0.2rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2.5rem;
}

.panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 2px solid rgba(214, 40, 57, 0.15);
}

.panel h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
  color: #1a3050;
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 1.5rem;
}

.team-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: rgba(79, 195, 247, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(2, 136, 209, 0.15);
}

.team-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.team-name {
  flex: 1;
  font-weight: 500;
}

.remove-team-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.remove-team-btn:hover {
  color: var(--awning-red);
}

.empty-teams {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.team-list-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.import-section {
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.import-label,
.duration-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.import-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.import-tab {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.import-tab.active {
  background: rgba(214, 40, 57, 0.1);
  border-color: var(--awning-red);
  color: var(--awning-red);
}

.import-panel {
  display: none;
}

.import-panel.active {
  display: block;
}

.import-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.import-row input,
.add-team-row input,
textarea#yahoo-teams {
  flex: 1;
  min-width: 120px;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

textarea#yahoo-teams {
  width: 100%;
  margin-bottom: 0.5rem;
  resize: vertical;
}

.add-team-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.duration-section {
  margin-bottom: 1.25rem;
}

.duration-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.duration-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  background: white;
  color: var(--text-muted);
  cursor: pointer;
}

.duration-btn.active {
  border-color: var(--water-deep);
  background: rgba(79, 195, 247, 0.15);
  color: var(--water-deep);
}

.setup-actions,
.results-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--water-deep) 0%, #01579b 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(2, 136, 209, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ── Race panel ── */
.race-panel {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 1.25rem;
  align-items: start;
}

.race-panel.hidden {
  display: none !important;
}

.race-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.race-status {
  font-weight: 600;
  font-size: 1rem;
  color: #1a3050;
}

.race-timer {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.05em;
  color: var(--water-deep);
  min-width: 4rem;
  text-align: right;
}

.race-timer.urgent {
  color: var(--awning-red);
  animation: timerPulse 0.6s ease-in-out infinite alternate;
}

@keyframes timerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.race-stage {
  position: relative;
  overflow: visible;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 14px;
}

.countdown-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 5rem;
  color: var(--gold);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.countdown-num.pop {
  animation: countdownPop 0.5s ease-out;
}

@keyframes countdownPop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.wind-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  border-radius: 14px;
  overflow: hidden;
}

.wind-overlay:not(.hidden) {
  animation: windFlash 0.4s ease-out;
}

.wind-streaks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -12deg,
    transparent 0 20px,
    rgba(255, 255, 255, 0.25) 20px 24px,
    transparent 24px 48px
  );
  animation: windSweep 0.6s linear infinite;
}

.wind-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.08em;
  color: white;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

@keyframes windSweep {
  from { transform: translateX(-30px); }
  to { transform: translateX(30px); }
}

@keyframes windFlash {
  from { background: rgba(200, 230, 255, 0.4); }
  to { background: transparent; }
}

.race-panel.windy .fp-scene {
  animation: boothShake 0.3s ease-in-out infinite alternate;
}

@keyframes boothShake {
  from { transform: translateX(-1px); }
  to { transform: translateX(1px); }
}

/* ── First-person 3D arena ── */
.fp-arena {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  min-height: 480px;
}

.fp-scene {
  flex: 1;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #6ec8f0 0%, #a8dff5 35%, #c4a882 72%, #8b5a2b 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.08), 0 10px 30px rgba(0, 0, 0, 0.2);
  min-height: 480px;
}

.fp-sky {
  position: absolute;
  inset: 0 0 45%;
  background: linear-gradient(180deg, #4aa8d8 0%, #8fd4f5 100%);
  z-index: 0;
}

.fp-booth-sign {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.sign-bulb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: bulbBlink 1s ease-in-out infinite alternate;
}

.sign-bulb:last-child { animation-delay: 0.5s; }

@keyframes bulbBlink {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.fp-lanes {
  position: absolute;
  left: 2%;
  right: 2%;
  top: 32px;
  bottom: 64px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  z-index: 2;
  overflow: visible;
  width: auto;
}

.fp-lane {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.fp-lane.surging {
  filter: brightness(1.08);
}

.lane-3d.wind-hit {
  animation: laneWobble 0.35s ease-in-out infinite alternate;
}

@keyframes laneWobble {
  from { transform: rotateZ(-1.5deg); }
  to { transform: rotateZ(1.5deg); }
}

.lane-name {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  font-size: 0.58rem;
  font-weight: 700;
  text-align: center;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.lane-3d {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 0;
  padding-top: 4px;
}

.lane-finish-announce {
  flex-shrink: 0;
  width: 100%;
  min-height: 13px;
  margin-bottom: 2px;
  text-align: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: transparent;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 7;
}

.lane-finish-announce.visible {
  color: var(--gold);
  animation: finishAnnouncePop 2.8s ease-out forwards;
}

.lane-finish-announce.place-gold {
  color: #ffd54f;
  font-size: 0.64rem;
  text-shadow: 0 0 8px rgba(255, 213, 79, 0.8), 0 1px 4px rgba(0, 0, 0, 0.6);
}

.lane-finish-announce.place-silver {
  color: #e0e0e0;
  text-shadow: 0 0 6px rgba(224, 224, 224, 0.6), 0 1px 4px rgba(0, 0, 0, 0.5);
}

.lane-finish-announce.place-bronze {
  color: #ffab40;
  text-shadow: 0 0 6px rgba(255, 171, 64, 0.5), 0 1px 4px rgba(0, 0, 0, 0.5);
}

@keyframes finishAnnouncePop {
  0% { opacity: 0; transform: scale(0.6); }
  12% { opacity: 1; transform: scale(1.15); }
  22% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

.lane-platform {
  flex-shrink: 0;
  width: 100%;
  height: 6px;
  margin-top: 2px;
  background: linear-gradient(180deg, #9a6b42, #6d4522);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tube-assembly {
  position: relative;
  width: 100%;
  flex-shrink: 0;
}

.tube-cap {
  position: relative;
  z-index: 6;
  width: 100%;
  height: 12px;
  margin: 0;
  border-radius: 50% / 100% 100% 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(220, 235, 245, 0.9) 55%, rgba(180, 200, 215, 0.75) 100%);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: none;
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.95),
    0 2px 5px rgba(0, 0, 0, 0.15);
}

.tube-cap::after {
  content: '';
  position: absolute;
  inset: 4px 8px auto;
  height: 4px;
  border-radius: 50%;
  background: rgba(79, 195, 247, 0.25);
}

.tube {
  position: relative;
  width: 100%;
  height: clamp(110px, calc(240px - var(--lane-count, 8) * 7px), 190px);
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.08) 0%, rgba(255, 255, 255, 0.35) 45%, rgba(0, 0, 0, 0.08) 100%);
  border-radius: 4px 4px 2px 2px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  overflow: hidden;
  box-shadow:
    inset 4px 0 10px rgba(0, 0, 0, 0.12),
    inset -4px 0 10px rgba(0, 0, 0, 0.12),
    0 6px 12px rgba(0, 0, 0, 0.18);
}

.finish-bell {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.55rem;
  z-index: 7;
  line-height: 1;
}

.finish-bell.ringing { animation: bellRing 0.5s ease-in-out 3; }

@keyframes bellRing {
  0%, 100% { transform: translate(-50%, -50%) rotate(0); }
  25% { transform: translate(-50%, -50%) rotate(12deg); }
  75% { transform: translate(-50%, -50%) rotate(-12deg); }
}

.tube-base-target {
  position: relative;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin: 3px auto 0;
  z-index: 4;
}

.tube-base-target .target-ring {
  position: absolute;
  inset: 0;
  border: 3px solid var(--awning-red);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tube-base-target .target-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: var(--awning-red);
  border-radius: 50%;
}

.tube-base-target.target-hit .target-ring,
.fp-lane.column-hit .tube-base-target .target-ring {
  animation: targetHit 0.35s ease-out;
}

.water-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(180deg, var(--team-color, var(--water)) 0%, var(--water-deep) 100%);
  opacity: 0.92;
  transition: height 0.12s ease-out;
  z-index: 1;
}

.water-surface {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0%;
  height: 7px;
  background: rgba(255, 255, 255, 0.55);
  z-index: 2;
  transition: bottom 0.12s ease-out;
  animation: surfaceRipple 1s ease-in-out infinite;
}

@keyframes surfaceRipple {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.8; }
}

.float-object {
  position: absolute;
  left: 50%;
  bottom: 0%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  line-height: 1;
  z-index: 4;
  transition: bottom 0.12s ease-out;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  animation: floatBob 2.4s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

.float-object--sailboat,
.float-object--speedboat {
  font-size: 1rem;
}

.float-object--whale {
  font-size: 1.25rem;
}

.float-object--starfish,
.float-object--shell {
  font-size: 0.95rem;
}

@keyframes floatBob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-5deg); }
  50% { transform: translateX(-50%) translateY(-3px) rotate(5deg); }
}

.fp-lane.finished .float-object {
  animation: floatCelebrate 0.8s ease-out, floatBob 2.4s ease-in-out 0.8s infinite;
}

@keyframes floatCelebrate {
  0%, 100% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.35) rotate(8deg); }
  70% { transform: translateX(-50%) scale(1.15) rotate(-4deg); }
}

.hit-popup {
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  z-index: 5;
  animation: popupFloat 0.9s ease-out forwards;
  pointer-events: none;
}

@keyframes popupFloat {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-28px); }
}

.gun-station {
  position: relative;
  width: 100%;
  height: 40px;
  min-height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-top: auto;
  padding-bottom: 2px;
}

.gun-station::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(180deg, #9a6b42, #6d4522);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 0;
}

.lane-gun {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 30px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 3px;
}

.lane-gun .squirt-gun {
  transform: rotate(-52deg);
  transform-origin: 50% 85%;
}

/* ── CSS squirt gun ── */
.squirt-gun {
  position: relative;
  width: 44px;
  height: 36px;
  transform-style: preserve-3d;
}

.squirt-gun--lane {
  width: 36px;
  height: 28px;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35));
}

.gun-tank {
  position: absolute;
  left: 2px;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a80, #e53935 55%, #b71c1c);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.25);
}

.gun-body {
  position: absolute;
  left: 18px;
  top: 14px;
  width: 18px;
  height: 12px;
  background: linear-gradient(180deg, #ff7043, #e64a19);
  border-radius: 3px;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.gun-barrel {
  position: absolute;
  left: 30px;
  top: 15px;
  width: 22px;
  height: 8px;
  background: linear-gradient(180deg, #ffa726, #ef6c00);
  border-radius: 2px 6px 6px 2px;
}

.gun-nozzle {
  position: absolute;
  left: 50px;
  top: 16px;
  width: 6px;
  height: 6px;
  background: #37474f;
  border-radius: 50%;
}

.gun-handle {
  position: absolute;
  left: 20px;
  top: 24px;
  width: 10px;
  height: 14px;
  background: linear-gradient(90deg, #5d4037, #795548);
  border-radius: 2px 2px 4px 4px;
  transform: skewX(-8deg);
}

.gun-trigger {
  position: absolute;
  left: 28px;
  top: 28px;
  width: 6px;
  height: 8px;
  background: #ffca28;
  border-radius: 2px;
}

.squirt-gun.firing {
  animation: squirtRecoilLane 0.32s ease-out;
}

.squirt-gun--lane.firing {
  animation: squirtRecoilLane 0.32s ease-out;
}

@keyframes squirtRecoilLane {
  0% { transform: rotate(-52deg) translateY(0); }
  35% { transform: rotate(-52deg) translateY(2px) translateX(-2px); }
  100% { transform: rotate(-52deg) translateY(0); }
}

.squirt-gun.firing-weak {
  animation: squirtWeakLane 0.2s ease-out;
}

.squirt-gun--lane.firing-weak {
  animation: squirtWeakLane 0.2s ease-out;
}

@keyframes squirtWeakLane {
  0%, 100% { transform: rotate(-52deg); }
  50% { transform: rotate(-52deg) translateX(-2px); }
}

@keyframes squirtRecoil {
  0% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(2px) rotate(-6deg); }
  100% { transform: translateY(0) rotate(-2deg); }
}

@keyframes squirtWeak {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-3deg); }
}

.fp-counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: linear-gradient(180deg, #b8885c 0%, #7a5230 55%, #5c3d22 100%);
  border-top: 4px solid #d4a76a;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
  z-index: 3;
  overflow: visible;
}

.bunting-rope {
  position: absolute;
  top: 2px;
  left: 3%;
  width: 94%;
  height: 22px;
  z-index: 2;
  pointer-events: none;
}

.bunting-flags {
  position: absolute;
  top: 10px;
  left: 4%;
  right: 4%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 1;
  pointer-events: none;
}

.bunting-flag {
  width: 13px;
  height: 20px;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  transform-origin: top center;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
  animation: flagSway 3s ease-in-out infinite;
}

.bunting-flag:nth-child(odd) {
  animation-direction: alternate-reverse;
}

@keyframes flagSway {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

/* U-shaped hang — lowest in the center */
.bunting-flag:nth-child(1),
.bunting-flag:nth-child(17) { margin-top: 0; }
.bunting-flag:nth-child(2),
.bunting-flag:nth-child(16) { margin-top: 2px; }
.bunting-flag:nth-child(3),
.bunting-flag:nth-child(15) { margin-top: 5px; }
.bunting-flag:nth-child(4),
.bunting-flag:nth-child(14) { margin-top: 8px; }
.bunting-flag:nth-child(5),
.bunting-flag:nth-child(13) { margin-top: 11px; }
.bunting-flag:nth-child(6),
.bunting-flag:nth-child(12) { margin-top: 14px; }
.bunting-flag:nth-child(7),
.bunting-flag:nth-child(11) { margin-top: 17px; }
.bunting-flag:nth-child(8),
.bunting-flag:nth-child(10) { margin-top: 20px; }
.bunting-flag:nth-child(9) { margin-top: 22px; }

.bunting-flag:nth-child(1) { background: #e53935; animation-delay: 0s; }
.bunting-flag:nth-child(2) { background: #f5c842; animation-delay: 0.1s; }
.bunting-flag:nth-child(3) { background: #43a047; animation-delay: 0.2s; }
.bunting-flag:nth-child(4) { background: #1e88e5; animation-delay: 0.3s; }
.bunting-flag:nth-child(5) { background: #8e24aa; animation-delay: 0.4s; }
.bunting-flag:nth-child(6) { background: #fb8c00; animation-delay: 0.5s; }
.bunting-flag:nth-child(7) { background: #00acc1; animation-delay: 0.6s; }
.bunting-flag:nth-child(8) { background: #fdd835; animation-delay: 0.7s; }
.bunting-flag:nth-child(9) { background: #e53935; animation-delay: 0.8s; }
.bunting-flag:nth-child(10) { background: #5c6bc0; animation-delay: 0.9s; }
.bunting-flag:nth-child(11) { background: #43a047; animation-delay: 1s; }
.bunting-flag:nth-child(12) { background: #ff7043; animation-delay: 1.1s; }
.bunting-flag:nth-child(13) { background: #1e88e5; animation-delay: 1.2s; }
.bunting-flag:nth-child(14) { background: #f5c842; animation-delay: 1.3s; }
.bunting-flag:nth-child(15) { background: #8e24aa; animation-delay: 1.4s; }
.bunting-flag:nth-child(16) { background: #26a69a; animation-delay: 1.5s; }
.bunting-flag:nth-child(17) { background: #d81b60; animation-delay: 1.6s; }

.spray-burst {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transform-origin: bottom center;
}

.spray-burst.spray-hit,
.spray-burst.spray-bullseye {
  opacity: 1;
  width: 14px;
  height: 52px;
  margin-left: -7px;
  background: linear-gradient(180deg, rgba(180, 230, 255, 0.95) 0%, rgba(79, 195, 247, 0.75) 45%, transparent 100%);
  border-radius: 40% 40% 15% 15%;
  animation: sprayShootUp 0.4s ease-out forwards;
}

.spray-burst.spray-bullseye {
  width: 20px;
  height: 68px;
  margin-left: -10px;
  background: linear-gradient(180deg, #fff 0%, rgba(180, 230, 255, 0.95) 30%, rgba(79, 195, 247, 0.6) 70%, transparent 100%);
}

@keyframes sprayShootUp {
  from { transform: scaleY(0.15); opacity: 0.8; }
  to { transform: scaleY(1); opacity: 0; }
}

.droplets {
  position: absolute;
  bottom: 65%;
  left: 0;
  right: 0;
  height: 50px;
  pointer-events: none;
}

.droplet {
  position: absolute;
  bottom: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(79, 195, 247, 0.85);
  animation: dropletFly 0.55s ease-out forwards;
}

@keyframes dropletFly {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-40px); opacity: 0; }
}


.fp-lane.finished .tube-cap {
  animation: capCelebrate 0.8s ease-out;
}

@keyframes capCelebrate {
  0%, 100% { box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.15); }
  50% { box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.9), 0 0 16px var(--gold), 0 2px 6px rgba(0, 0, 0, 0.15); }
}

.firework-burst {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 30;
}

.firework-particle {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
  animation: fireworkParticle 1.1s ease-out forwards;
}

@keyframes fireworkParticle {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--fx), var(--fy)) scale(0.2);
    opacity: 0;
  }
}

@keyframes targetHit {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
  100% { transform: scale(1); }
}

/* ── Side clown ── */
.fp-clown {
  flex: 0 0 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 0.35rem;
  z-index: 8;
}

.clown-figure {
  position: relative;
  width: 110px;
  height: 185px;
  animation: clownBounce 2.2s ease-in-out infinite;
}

.clown-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.22));
}

.clown-wave-arm {
  transform-origin: 86px 128px;
  animation: clownWave 1.2s ease-in-out infinite;
}

@keyframes clownBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes clownWave {
  0%, 100% { transform: rotate(8deg); }
  50% { transform: rotate(-22deg); }
}

.clown-bubble {
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.65rem;
  background: white;
  border: 2.5px solid var(--awning-red);
  border-radius: 14px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--awning-red);
  text-align: center;
  max-width: 112px;
  line-height: 1.25;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  animation: bubblePop 0.3s ease-out;
  position: relative;
}

.clown-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--awning-red);
}

.clown-bubble::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: white;
  z-index: 1;
}

@keyframes bubblePop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.fp-clown.clown-bullseye .clown-figure { animation: clownJump 0.5s ease-out; }
.fp-clown.clown-wind .clown-wave-arm { animation: clownWaveFast 0.35s ease-in-out infinite; }
.fp-clown.clown-finish .clown-figure { animation: clownJump 0.55s ease-out 2; }
.fp-clown.clown-start .clown-shoe--l,
.fp-clown.clown-start .clown-shoe--r { animation: clownTap 0.45s ease-in-out infinite alternate; }

@keyframes clownJump {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

@keyframes clownWaveFast {
  0%, 100% { transform: rotate(20deg); }
  50% { transform: rotate(-32deg); }
}

@keyframes clownTap {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: confettiFall 1.8s ease-out forwards;
  z-index: 25;
  pointer-events: none;
}

@keyframes confettiFall {
  from { transform: translateY(0) rotate(0deg); opacity: 1; }
  to { transform: translateY(320px) rotate(540deg); opacity: 0; }
}

.race-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-block {
  background: rgba(79, 195, 247, 0.12);
  border-radius: 12px;
  padding: 0.85rem;
  border: 1px solid rgba(2, 136, 209, 0.18);
}

.sidebar-block h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  color: var(--water-deep);
  margin-bottom: 0.6rem;
}

.live-positions,
.live-standings {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.position-chip,
.standing-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  background: white;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.position-chip.leader {
  background: rgba(245, 200, 66, 0.3);
  border-color: var(--gold);
  font-weight: 600;
}

.position-chip.finished {
  opacity: 0.55;
}

.position-chip.moved-up {
  animation: chipUp 0.4s ease-out;
}

.position-chip.moved-down {
  animation: chipDown 0.4s ease-out;
}

@keyframes chipUp {
  from { background: rgba(76, 175, 80, 0.35); }
}

@keyframes chipDown {
  from { background: rgba(244, 67, 54, 0.25); }
}

.position-rank,
.pick-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.95rem;
  color: var(--water-deep);
  min-width: 1.2rem;
}

.standing-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.draft-order {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.draft-order li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  background: rgba(79, 195, 247, 0.1);
  border-radius: 8px;
  font-size: 1rem;
}

.pick-badge {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: var(--water-deep);
  min-width: 1.75rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 48, 80, 0.92);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--water);
  z-index: 100;
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .race-panel:not(.hidden) {
    display: grid;
    grid-template-columns: 1fr;
  }

  .race-stage {
    order: 0;
  }

  .race-sidebar {
    order: 1;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-block {
    flex: 1;
    min-width: 140px;
  }

  .fp-arena {
    flex-direction: column;
    min-height: 380px;
  }

  .fp-scene {
    min-height: 380px;
  }

  .fp-lanes {
    top: 30px;
    bottom: 58px;
  }

  .tube {
    height: clamp(85px, calc(180px - var(--lane-count, 8) * 9px), 140px);
  }

  .fp-clown {
    flex-direction: row;
    flex: none;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
  }

  .clown-bubble {
    margin-bottom: 0;
    max-width: 140px;
  }

  .clown-figure {
    width: 64px;
    height: 100px;
  }
}

@media (max-width: 480px) {
  .tube {
    height: clamp(100px, calc(200px - var(--lane-count, 8) * 6px), 150px);
  }

  .countdown-num {
    font-size: 3.5rem;
  }

  .fp-clown {
    display: none;
  }
}
