:root {
  color-scheme: dark;
  --ink: #09051c;
  --paper: #f7f2df;
  --pink: #ff3fa4;
  --cyan: #19e6e8;
  --yellow: #ffe33d;
  --purple: #7225d8;
  --muted: rgba(247, 242, 223, 0.66);
  --panel: rgba(13, 8, 40, 0.82);
  --border: rgba(247, 242, 223, 0.16);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

.ambient,
.vhs-noise,
.grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ambient {
  overflow: hidden;
  z-index: 0;
  background:
    radial-gradient(circle at 11% 18%, rgba(25, 230, 232, .16), transparent 25%),
    radial-gradient(circle at 88% 30%, rgba(255, 63, 164, .18), transparent 30%),
    linear-gradient(145deg, #080419 0%, #14072f 49%, #080419 100%);
}

.sun {
  position: absolute;
  width: min(40vw, 610px);
  aspect-ratio: 1;
  left: 50%;
  top: 58%;
  translate: -50% -50%;
  border-radius: 50%;
  opacity: .22;
  background: repeating-linear-gradient(to bottom, var(--pink) 0 11px, transparent 11px 18px);
  filter: blur(.2px) drop-shadow(0 0 70px rgba(255, 63, 164, .45));
}

.grid {
  top: 64%;
  height: 52%;
  transform: perspective(390px) rotateX(62deg) scale(1.8);
  transform-origin: center top;
  background-image:
    linear-gradient(rgba(25, 230, 232, .17) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 230, 232, .17) 1px, transparent 1px);
  background-size: 70px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

.vhs-noise {
  z-index: 10;
  opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  animation: noise .2s steps(2) infinite;
}

.shape { position: absolute; opacity: .75; }
.shape--triangle {
  left: 5vw; top: 22vh; width: 0; height: 0;
  border-left: 35px solid transparent; border-right: 35px solid transparent; border-bottom: 60px solid var(--yellow);
  rotate: -14deg; filter: drop-shadow(8px 8px 0 var(--purple));
}
.shape--circle {
  right: 5.5vw; bottom: 22vh; width: 75px; aspect-ratio: 1; border: 14px solid var(--cyan); border-radius: 50%;
  box-shadow: 8px 8px 0 var(--pink);
}
.shape--zigzag {
  right: 8vw; top: 15vh; width: 88px; height: 28px; rotate: 12deg;
  background: linear-gradient(135deg, transparent 0 25%, var(--yellow) 25% 50%, transparent 50% 75%, var(--yellow) 75%);
  background-size: 38px 38px;
}

.stage {
  position: relative;
  z-index: 2;
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(24px, 3.2vh, 50px) clamp(24px, 5vw, 84px) 88px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.hero { text-align: center; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--cyan); font-size: clamp(10px, .85vw, 14px); font-weight: 900; letter-spacing: .22em;
}
.eyebrow__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 14px var(--pink); animation: blink 1.2s steps(2) infinite; }

h1 {
  margin: 8px 0 2px;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(45px, 7vw, 106px);
  line-height: .9;
  letter-spacing: -.055em;
  text-transform: uppercase;
  text-shadow: 5px 5px 0 var(--purple), 10px 10px 0 rgba(25, 230, 232, .45);
}
h1 span {
  color: var(--yellow);
  -webkit-text-stroke: 1px rgba(9, 5, 28, .3);
}
.subtitle { margin: 9px 0 0; color: var(--muted); font-size: clamp(11px, 1vw, 16px); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(60px, 7vw, 100px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 2vw, 30px);
  min-height: 0;
  padding: clamp(22px, 3.6vh, 52px) 0;
}

.team {
  position: relative;
  min-width: 0;
  padding: clamp(22px, 3vw, 46px);
  border: 2px solid color-mix(in srgb, var(--accent), transparent 66%);
  border-radius: 28px 28px 44px 44px;
  clip-path: polygon(4% 0, 96% 0, 100% 7%, 100% 93%, 96% 100%, 4% 100%, 0 93%, 0 7%);
  background:
    radial-gradient(circle at 27px 27px, #0a061c 0 3px, rgba(255,255,255,.35) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 27px) 27px, #0a061c 0 3px, rgba(255,255,255,.35) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at 27px calc(100% - 27px), #0a061c 0 3px, rgba(255,255,255,.35) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 27px) calc(100% - 27px), #0a061c 0 3px, rgba(255,255,255,.35) 3.5px 5px, transparent 5.5px),
    linear-gradient(155deg, color-mix(in srgb, var(--accent), #2b2350 82%), #17112f 42%, #0e0921 100%);
  box-shadow: 0 30px 80px rgba(3, 1, 14, .55), inset 0 2px 0 rgba(255,255,255,.19), inset 0 -8px 18px rgba(0,0,0,.28);
  transition: border-color .25s, transform .25s, box-shadow .25s;
}

.team::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, transparent 0 8px, rgba(255,255,255,.018) 8px 9px),
    linear-gradient(125deg, rgba(255,255,255,.13), transparent 34%);
}
.team--leaders { --accent: var(--pink); --accent-soft: rgba(255, 63, 164, .3); }
.team--staff { --accent: var(--cyan); --accent-soft: rgba(25, 230, 232, .25); }
.team.is-leading { border-color: var(--accent); box-shadow: 0 32px 90px var(--accent-soft), inset 0 2px 0 rgba(255,255,255,.22), inset 0 -8px 18px rgba(0,0,0,.28); }
.team.is-scoring { animation: teamHit .48s cubic-bezier(.18,.7,.2,1); }

.team__tape {
  position: absolute; z-index: 3; top: 7px; right: clamp(15px, 3vw, 44px); padding: 7px 16px;
  transform: rotate(2deg); background: var(--yellow); color: var(--ink); font-size: 10px; font-weight: 900; letter-spacing: .16em;
  box-shadow: 4px 4px 0 rgba(0,0,0,.4);
}
.team--staff .team__tape { right: auto; left: clamp(15px, 3vw, 44px); transform: rotate(-2deg); background: var(--cyan); }
.team__tape span { color: var(--pink); }

.team__topline { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.team__number { font-family: "Arial Black", Impact, sans-serif; color: var(--accent); font-size: 16px; letter-spacing: .14em; }
.team__status {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 8px 14px;
  border: 2px solid var(--accent); border-radius: 4px; color: var(--paper);
  background: rgba(7,4,20,.72); box-shadow: 4px 4px 0 color-mix(in srgb, var(--accent), transparent 20%);
  font-size: clamp(11px, .9vw, 14px); font-weight: 900; letter-spacing: .11em; text-transform: uppercase; white-space: nowrap;
  transform: rotate(1.5deg);
}
.team--staff .team__status { transform: rotate(-1.5deg); }
.team__status::before { content: "▶"; color: var(--accent); font-size: .72em; }
.team.is-leading .team__status {
  color: var(--ink); background: var(--accent); border-color: var(--paper); box-shadow: 5px 5px 0 var(--paper), 0 0 24px var(--accent-soft);
  animation: statusPulse 1.25s ease-in-out infinite alternate;
}
.team.is-leading .team__status::before { color: var(--ink); }
.team[data-rank="tied"] .team__status { border-color: var(--yellow); box-shadow: 4px 4px 0 var(--yellow); }
.team[data-rank="tied"] .team__status::before { color: var(--yellow); }

.team h2 {
  position: relative;
  z-index: 2;
  margin: clamp(14px, 2vh, 24px) 0 0;
  min-height: 1.15em;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(21px, 2.6vw, 42px);
  line-height: 1.05;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  outline: none;
}
.team h2:focus { color: var(--yellow); text-decoration: underline 3px var(--accent); text-underline-offset: 7px; }

.score-wrap {
  position: relative; z-index: 2; height: clamp(140px, 21vh, 232px); margin: 9px 0 12px;
  display: grid; place-items: center; overflow: hidden; border: 3px solid rgba(5,3,16,.75); border-radius: 14px;
  background: linear-gradient(180deg, rgba(2,1,9,.9), rgba(15,8,28,.92));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08), inset 0 14px 30px rgba(0,0,0,.55), 0 7px 0 rgba(255,255,255,.045);
}
.score-wrap::before,
.score-wrap::after {
  content: ""; position: absolute; z-index: 4; top: 10px; bottom: 10px; width: 7px; border-radius: 2px; background: var(--accent); opacity: .68;
}
.score-wrap::before { left: 10px; }
.score-wrap::after { right: 10px; }
.cassette-window {
  position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1.7fr 1fr; align-items: center;
  padding: 0 clamp(18px, 2vw, 34px); overflow: hidden;
}
.reel {
  position: relative; z-index: 2; justify-self: center; width: clamp(58px, 6vw, 88px); aspect-ratio: 1; border-radius: 50%;
  border: 6px solid rgba(247,242,223,.82); background:
    radial-gradient(circle, #09051c 0 19%, transparent 20%),
    repeating-conic-gradient(from 0deg, rgba(247,242,223,.95) 0 10deg, transparent 10deg 32deg),
    radial-gradient(circle, transparent 0 50%, rgba(247,242,223,.72) 51% 66%, transparent 67%);
  box-shadow: 0 0 0 5px rgba(0,0,0,.55), 0 0 24px var(--accent-soft);
  animation: reelSpin 3.8s linear infinite;
}
.team--staff .reel { animation-direction: reverse; }
.reel i { position: absolute; inset: 36%; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.tape-run {
  position: relative; align-self: stretch; display: block; min-width: 0;
}
.tape-run::before,
.tape-run::after {
  content: ""; position: absolute; left: -32%; right: -32%; height: 4px;
  background: repeating-linear-gradient(90deg, #28100a 0 12px, #8a3f19 12px 17px, #28100a 17px 30px);
  background-size: 30px 4px; opacity: .95; animation: tapeTravel .65s linear infinite;
  box-shadow: 0 0 7px rgba(220,95,29,.28);
}
.tape-run::before { top: 28%; }
.tape-run::after { bottom: 28%; animation-direction: reverse; }
.team.is-scoring .reel { animation-duration: .42s; }
.team.is-scoring .tape-run::before,
.team.is-scoring .tape-run::after { animation-duration: .16s; }
.score, .score-glow {
  grid-area: 1 / 1;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(88px, min(11vw, 18vh), 190px);
  line-height: .8;
  letter-spacing: -.08em;
  font-variant-numeric: tabular-nums;
}
.score { position: relative; z-index: 3; min-width: 1.45em; padding: 0 .08em; color: var(--paper); cursor: pointer; text-align: center; text-shadow: 4px 4px 0 var(--accent), 0 0 42px var(--accent-soft); }
.score-glow { position: relative; z-index: 2; translate: 6px 6px; color: transparent; -webkit-text-stroke: 3px var(--accent); opacity: .45; filter: blur(8px); }
.score.is-bumping { animation: scoreBump .42s cubic-bezier(.16,.76,.2,1); }

.quick-actions {
  position: relative; z-index: 2; display: grid; grid-template-columns: .8fr 1.2fr 1fr; gap: 9px;
  margin: 0 clamp(2px, 1vw, 14px); padding: 10px clamp(10px, 1.5vw, 20px) 5px;
  clip-path: polygon(7% 0, 93% 0, 100% 100%, 0 100%);
  background: rgba(5,3,16,.46); border-top: 1px solid rgba(255,255,255,.16);
}
.score-button {
  min-height: clamp(44px, 6vh, 62px); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.055); font-weight: 900; font-size: clamp(14px, 1.2vw, 19px);
  transition: transform .12s, background .12s, border-color .12s;
}
.score-button:hover { background: rgba(255,255,255,.13); border-color: var(--accent); }
.score-button:active { transform: translateY(2px) scale(.98); }
.score-button--main { background: var(--accent); color: var(--ink); border-color: var(--accent); box-shadow: 0 10px 30px var(--accent-soft); }
.score-button--main:hover { background: color-mix(in srgb, var(--accent), white 12%); }
.score-button--minus { color: var(--muted); }
.score-button span { margin-right: 8px; }
.score-button small { display: inline-grid; place-items: center; min-width: 23px; height: 23px; border: 1px solid currentColor; border-radius: 4px; font-size: 10px; opacity: .6; }

.versus { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.versus__line { width: 1px; height: clamp(48px, 9vh, 100px); background: linear-gradient(transparent, rgba(247,242,223,.28), transparent); }
.versus__badge {
  display: grid; place-items: center; width: clamp(55px, 6vw, 82px); aspect-ratio: 1; border-radius: 50%;
  border: 4px solid var(--yellow); background: var(--pink); color: white; font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(19px, 2vw, 30px); rotate: -8deg; box-shadow: 6px 6px 0 var(--cyan), 0 0 40px rgba(255,63,164,.42);
}

.footer-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; color: rgba(247,242,223,.42); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.footer-bar p { margin: 0; text-align: center; }
.footer-bar p span { color: var(--pink); }
.sync-status { display: inline-block; margin-left: 7px; padding: 3px 6px; border: 1px solid currentColor; border-radius: 3px; color: var(--yellow); font-size: 8px; letter-spacing: .1em; }
.sync-status[data-state="online"] { color: var(--cyan); box-shadow: 0 0 10px rgba(25,230,232,.3); }
.sync-status[data-state="connecting"] { color: var(--yellow); animation: blink 1.2s steps(2) infinite; }
.sync-status[data-state="offline"] { color: var(--pink); }
.counter-strip { text-align: right; font-family: monospace; }
.equalizer { display: flex; align-items: flex-end; gap: 3px; height: 20px; }
.equalizer i { display: block; width: 3px; height: 50%; background: var(--cyan); animation: eq .9s ease-in-out infinite alternate; }
.equalizer i:nth-child(2n) { animation-delay: -.5s; height: 90%; }
.equalizer i:nth-child(3n) { animation-delay: -.2s; height: 30%; background: var(--pink); }

.control-dock {
  position: fixed; z-index: 20; left: 50%; bottom: 14px; translate: -50% 0;
  display: flex; align-items: stretch; padding: 6px; gap: 4px; border: 1px solid rgba(255,255,255,.18); border-radius: 14px;
  background: rgba(9,5,28,.88); box-shadow: 0 18px 55px rgba(0,0,0,.6); backdrop-filter: blur(18px);
  transition: translate .3s ease, opacity .3s ease;
}
.control-dock.is-hidden { translate: -50% 130%; opacity: 0; pointer-events: none; }
.dock-button {
  min-width: 70px; min-height: 52px; padding: 6px 10px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.dock-button:hover { background: rgba(255,255,255,.1); color: white; }
.dock-button span { font-size: 20px; line-height: 1; }
.dock-button small { font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.dock-button.is-active span { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); }
.dock-button--danger:hover { color: var(--pink); }
.dock-handle { width: 38px; border: 0; border-left: 1px solid var(--border); background: transparent; cursor: pointer; color: var(--muted); font-size: 20px; }
.show-controls {
  position: fixed; z-index: 19; left: 50%; bottom: 8px; translate: -50% 130%; opacity: 0;
  width: 54px; height: 28px; border: 1px solid var(--border); border-radius: 20px 20px 0 0; background: rgba(9,5,28,.88); cursor: pointer;
  transition: translate .3s ease, opacity .3s ease;
}
.show-controls.is-visible { translate: -50% 0; opacity: .48; }
.show-controls:hover { opacity: 1; }

.modal {
  width: min(560px, calc(100% - 32px)); padding: 36px; border: 1px solid rgba(255,255,255,.22); border-radius: 20px;
  background: #140a31; color: var(--paper); box-shadow: 0 40px 120px rgba(0,0,0,.75);
}
.modal::backdrop { background: rgba(5,2,16,.78); backdrop-filter: blur(8px); }
.modal[open] { animation: modalIn .25s ease-out; }
.modal--compact { max-width: 430px; text-align: center; }
.modal h2 { margin: 6px 0 24px; font-family: "Arial Black", Impact, sans-serif; font-size: clamp(25px, 4vw, 38px); text-transform: uppercase; }
.modal p { color: var(--muted); line-height: 1.6; }
.modal__close { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); cursor: pointer; font-size: 25px; }
.modal__sticker { display: inline-block; margin-bottom: 10px; padding: 6px 12px; background: var(--yellow); color: var(--ink); rotate: -2deg; font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.modal__sticker--pink { background: var(--pink); color: white; }
.key-grid { display: grid; grid-template-columns: 46px 1fr; align-items: center; gap: 9px 14px; text-align: left; }
kbd { display: grid; place-items: center; height: 36px; border: 1px solid rgba(255,255,255,.3); border-bottom-width: 4px; border-radius: 6px; background: rgba(255,255,255,.08); font-weight: 900; }
.key-grid span { color: rgba(247,242,223,.82); font-size: 13px; font-weight: 700; }
.modal__hint { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12px; }
.modal label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.modal input { width: 100%; height: 80px; border: 2px solid var(--cyan); border-radius: 10px; outline: none; background: #080419; color: white; text-align: center; font-family: "Arial Black", Impact, sans-serif; font-size: 42px; }
.modal__confirm, .modal__danger, .modal__secondary { min-height: 48px; padding: 0 22px; border: 0; border-radius: 8px; cursor: pointer; font-weight: 900; }
.modal__confirm { width: 100%; margin-top: 12px; background: var(--cyan); color: var(--ink); }
.modal__actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }
.modal__danger { background: var(--pink); color: white; }
.modal__secondary { background: rgba(255,255,255,.1); }

.toast {
  position: fixed; z-index: 50; top: 22px; left: 50%; translate: -50% -160%; opacity: 0;
  padding: 12px 20px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(9,5,28,.9); box-shadow: 0 15px 45px rgba(0,0,0,.4);
  color: white; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; transition: .28s ease;
}
.toast.is-visible { translate: -50% 0; opacity: 1; }
.confetti-layer { position: fixed; z-index: 30; inset: 0; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; width: 8px; height: 15px; background: var(--color); animation: confetti 1.3s cubic-bezier(.2,.65,.28,1) forwards; }

@keyframes noise { 0% { transform: translate(0); } 25% { transform: translate(1%, -1%); } 50% { transform: translate(-1%, 1%); } 75% { transform: translate(1%, 1%); } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes eq { to { height: 18%; } }
@keyframes teamHit { 40% { transform: translateY(-4px) scale(1.015); } }
@keyframes scoreBump { 0% { transform: scale(.85); filter: brightness(2.2); } 65% { transform: scale(1.09); } 100% { transform: scale(1); } }
@keyframes reelSpin { to { transform: rotate(360deg); } }
@keyframes tapeTravel { to { background-position-x: 30px; } }
@keyframes statusPulse { to { transform: rotate(-1deg) translateY(-2px); filter: brightness(1.12); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes confetti { 0% { translate: 0 0; rotate: 0; opacity: 1; } 100% { translate: var(--x) var(--y); rotate: var(--r); opacity: 0; } }

@media (max-width: 800px), (max-height: 650px) {
  body { overflow: auto; }
  .stage { min-height: 100dvh; padding: 22px 16px 90px; }
  .scoreboard { grid-template-columns: 1fr 44px 1fr; gap: 7px; padding: 25px 0; }
  .team { padding: 18px 12px; border-radius: 10px 24px 10px 24px; }
  .team--staff { border-radius: 24px 10px 24px 10px; }
  .team__tape { display: none; }
  .team__topline { align-items: flex-start; }
  .team__status { min-height: 30px; padding: 6px 9px; font-size: 9px; box-shadow: 3px 3px 0 color-mix(in srgb, var(--accent), transparent 20%); }
  .team h2 { font-size: clamp(16px, 3.8vw, 28px); }
  .score-wrap { height: clamp(110px, 22vh, 190px); }
  .score, .score-glow { font-size: clamp(84px, 18vw, 180px); }
  .score-button small { display: none; }
  .versus__line { height: 38px; }
  .footer-bar { grid-template-columns: auto 1fr; }
  .counter-strip { display: none; }
  .control-dock { max-width: calc(100% - 16px); }
  .dock-button { min-width: 51px; padding: 5px; }
  .dock-button small { display: none; }
}

@media (max-width: 540px) {
  .scoreboard { grid-template-columns: 1fr; align-items: stretch; }
  .versus { flex-direction: row; justify-content: center; }
  .versus__line { width: 70px; height: 1px; }
  .team h2 { font-size: 23px; }
  .score-wrap { height: 130px; }
  .score, .score-glow { font-size: 112px; }
  .subtitle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
