@font-face {
  font-family: "Shrikhand";
  src: url("/fonts/shrikhand-latin-400.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Outfit";
  src: url("/fonts/outfit-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --sky: #000F52;
  --sky-2: #001A8F;
  --blue: #0063FF;
  --sun: #FFC93C;
  --tangerine: #FF7A2F;
  --bubblegum: #FF6FB5;
  --ink: #F3F6FF;
  --ink-soft: #B9C6F5;
  --line: rgba(185, 198, 245, 0.22);
  --display: "Shrikhand", "Cooper Black", Georgia, serif;
  --body: "Outfit", system-ui, sans-serif;
  --frame: 22px;
}

* { box-sizing: border-box; }

html { background: var(--sky); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--body);
  background:
    radial-gradient(1200px 520px at 50% -120px, rgba(0, 99, 255, 0.45), transparent 70%),
    var(--sky);
  padding: 0 16px env(safe-area-inset-bottom);
}

.sprite { position: absolute; }

a { color: var(--sun); }

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

/* ------------------------------------------------------------------ */
/* Masthead                                                            */
/* ------------------------------------------------------------------ */

.masthead {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 0 8px;
  text-align: center;
}

.brand { display: inline-block; }
.brand img { display: block; width: 168px; height: auto; }

.title {
  margin: 18px 0 0;
  font: 400 clamp(3.2rem, 11vw, 7rem)/0.95 var(--display);
  letter-spacing: 0.01em;
  color: var(--ink);
  /* stacked 70s shadow: sunshine, tangerine, bubblegum */
  text-shadow:
    0.035em 0.035em 0 var(--sun),
    0.07em 0.07em 0 var(--tangerine),
    0.105em 0.105em 0 var(--bubblegum);
}

.tagline {
  margin: 20px auto 0;
  max-width: 36ch;
  color: var(--ink-soft);
  font-size: 1.125rem;
}

/* ------------------------------------------------------------------ */
/* Stage: the video sits inside a 70s rainbow arch                     */
/* ------------------------------------------------------------------ */

main { max-width: 1080px; margin: 0 auto; }

.stage-wrap {
  position: relative;
  margin-top: 40px;
  padding: calc(var(--frame) * 4) calc(var(--frame) * 4) 0;
}

.rainbow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.rainbow i {
  position: absolute;
  inset: calc(var(--n) * var(--frame)) calc(var(--n) * var(--frame)) 0;
  border-radius: 999px 999px 0 0 / 360px 360px 0 0;
  background: var(--c);
}
.rainbow i:nth-child(1) { --n: 0; --c: var(--bubblegum); }
.rainbow i:nth-child(2) { --n: 1; --c: var(--tangerine); }
.rainbow i:nth-child(3) { --n: 2; --c: var(--sun); }
.rainbow i:nth-child(4) { --n: 3; --c: var(--blue); }

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #00092F;
  border: 4px solid var(--sky);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  overflow: hidden;
}

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #00092F;
}

/* HUD */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
body[data-state="live"] .hud { opacity: 1; }

.badge, .hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 15, 82, 0.72);
  backdrop-filter: blur(6px);
}
.live-badge { background: var(--bubblegum); color: #2A0018; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #2A0018; animation: pulse 1.6s ease-in-out infinite; }
.hud-viewers { margin-left: auto; }

@keyframes pulse { 50% { opacity: 0.25; } }

/* Overlays: one per state */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    repeating-radial-gradient(circle at 50% 120%, rgba(0, 99, 255, 0.16) 0 26px, transparent 26px 52px),
    #00092F;
}
.overlay h2 {
  margin: 10px 0 6px;
  font: 400 clamp(1.4rem, 3.6vw, 2.4rem)/1.1 var(--display);
  color: var(--sun);
}
.overlay p { margin: 0; max-width: 46ch; color: var(--ink-soft); }

body[data-state="loading"] .overlay-loading,
body[data-state="offline"] .overlay-offline,
body[data-state="reconnecting"] .overlay-wobble { display: flex; }

.overlay-wobble { background: rgba(0, 9, 47, 0.82); }
.overlay-tap { display: flex; background: rgba(0, 9, 47, 0.55); }
.overlay-tap[hidden] { display: none; }
body:not([data-state="live"]) .overlay-tap { display: none; }

.mascot { flex-shrink: 0; width: min(300px, 46%); height: auto; aspect-ratio: 240 / 150; animation: bob 4s ease-in-out infinite; }
.mascot.small { width: min(180px, 30%); }
.rotor { transform-box: fill-box; transform-origin: center; animation: spin 0.18s linear infinite; }

@keyframes bob { 50% { transform: translateY(-12px) rotate(-2deg); } }
@keyframes spin { 50% { transform: scaleX(0.2); } }

.big-button {
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--sun);
  color: var(--sky);
  font-weight: 700;
  font-size: 1.15rem;
  cursor: pointer;
}

/* Floating reactions */
.reactions-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.reaction {
  position: absolute;
  bottom: -40px;
  font-size: 2.2rem;
  animation: float-up 3.2s ease-out forwards;
}
.reaction.mine { filter: drop-shadow(0 0 8px var(--sun)); }

@keyframes float-up {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  12% { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { transform: translateY(-360px) translateX(var(--drift)) scale(0.9); opacity: 0; }
}

/* ------------------------------------------------------------------ */
/* Controls                                                            */
/* ------------------------------------------------------------------ */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  position: relative;
  background: var(--sky-2);
  border: 4px solid var(--sky);
  border-top: 0;
  border-radius: 0 0 28px 28px;
}

.react-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.react {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.react:hover { background: rgba(255, 255, 255, 0.16); }
.react:active { transform: scale(0.88); }
.react:disabled { opacity: 0.35; cursor: default; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tool {
  padding: 9px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: none;
  font-weight: 600;
  cursor: pointer;
}
.tool:hover { border-color: var(--sun); }
.tool:disabled { opacity: 0.4; cursor: default; border-color: var(--line); }

.toast {
  min-height: 1.6em;
  margin: 10px 0 0;
  text-align: center;
  color: var(--sun);
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Flight log                                                          */
/* ------------------------------------------------------------------ */

.logbook {
  max-width: 760px;
  margin: 40px auto 0;
}
.logbook-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.logbook h2 { margin: 0; font: 400 2rem/1.1 var(--display); color: var(--sun); }
.viewers-line { margin: 0; color: var(--ink-soft); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 18px 0 0;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}
.stats div { padding: 14px 0; }
.stats div + div { padding-left: 18px; border-left: 2px solid var(--line); }
.stats dt { color: var(--ink-soft); font-size: 0.95rem; }
.stats dd { margin: 2px 0 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.recent { list-style: none; margin: 12px 0 0; padding: 0; }
.recent li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}
.recent li strong { color: var(--ink); font-weight: 600; }

.footer {
  max-width: 1080px;
  margin: 56px auto 0;
  padding: 24px 0 32px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ------------------------------------------------------------------ */
/* Small screens                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 720px) {
  :root { --frame: 9px; }
  .stage { border-radius: 18px 18px 0 0; }
  .controls { border-radius: 0 0 18px 18px; padding: 12px; }
  .stage-wrap { padding-left: 0; padding-right: 0; }
  .rainbow i { border-radius: 999px 999px 0 0 / 200px 200px 0 0; }
  .react { width: 42px; height: 42px; font-size: 1.3rem; }
  .stats { grid-template-columns: 1fr; }
  .stats div + div { padding-left: 0; border-left: 0; border-top: 2px solid var(--line); }
  .hud-viewers { margin-left: 0; }
  .overlay p { font-size: 0.95rem; }
  body:not([data-state="live"]) .stage { aspect-ratio: 1 / 1; }
  .mascot { width: 62%; }
  .mascot.small { width: 44%; }
}

@media (prefers-reduced-motion: reduce) {
  .mascot, .rotor, .dot { animation: none; }
  .reaction { animation-duration: 0.01s; }
}
