:root {
  --k18-navy-950: #050911;
  --k18-navy-900: #090E17;
  --k18-navy-800: #0F172A;
  --k18-navy-700: #16223B;
  --k18-ice: #75B2DD;
  --k18-cyan: #38BDF8;
  --k18-gold: #F59E0B;
  --k18-gold-light: #FDE68A;
  --k18-emerald: #10B981;
  --k18-live: #EF4444;
  --k18-text: #F8FAFC;
  --k18-muted: #94A3B8;
  --safe-x: 48px;
  --safe-top: 18px;
  --safe-bottom: 16px;
  --stage-scale: 1;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--k18-text);
  background-color: #03060C;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Transparent Alpha-Channel Mode for OBS / vMix Camera Overlay */
html.mode-overlay,
body.mode-overlay {
  background: transparent !important;
}

#viewport-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #0D1628 0%, #03060C 100%);
}

body.mode-overlay #viewport-shell {
  background: transparent !important;
}

#tv-stage {
  position: relative;
  width: 1920px;
  height: 1080px;
  flex-shrink: 0;
  transform: scale(var(--stage-scale));
  transform-origin: center center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 14% 12%, rgba(117, 178, 221, 0.15) 0%, transparent 48%),
    radial-gradient(ellipse at 86% 85%, rgba(245, 158, 11, 0.10) 0%, transparent 45%),
    linear-gradient(160deg, #0B1323 0%, #090E17 56%, #050911 100%);
}

#tv-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(117, 178, 221, 0.038) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(117, 178, 221, 0.038) 1px, transparent 1px);
  background-size: 48px 48px;
}

body.mode-overlay #tv-stage {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

body.mode-overlay #tv-stage::before {
  display: none;
}

/* Full-Bleed LED Wall Preset */
#tv-stage.full-bleed {
  --safe-x: 28px;
  --safe-top: 0px;
  --safe-bottom: 0px;
}

.font-condensed {
  font-family: 'Roboto Condensed', 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.font-mono-tv {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
}

/* Single-line truncation keeping full text in DOM */
.truncate-1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-inline-size: 0;
}

/* Broadcast Glass Surfaces */
.broadcast-panel {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95) 0%, rgba(9, 14, 23, 0.98) 100%);
  border: 1px solid rgba(117, 178, 221, 0.28);
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.broadcast-subpanel {
  background: linear-gradient(145deg, rgba(20, 31, 56, 0.86) 0%, rgba(11, 18, 32, 0.95) 100%);
  border: 1px solid rgba(117, 178, 221, 0.20);
  border-radius: 14px;
}

/* Crisp High-Contrast Logo Containers */
.logo-plate-white,
.logo-plate-navy {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
}

.logo-plate-white {
  background: #FFFFFF;
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.34);
}

.logo-plate-navy {
  background: #132347;
  border: 1px solid rgba(117, 178, 221, 0.55);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.44);
}

.logo-plate-white img,
.logo-plate-navy img,
.logo-plate-white svg,
.logo-plate-navy svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* =========================================================================
   TOP BROADCAST HEADER
   ========================================================================= */
#broadcast-header {
  position: absolute;
  top: var(--safe-top);
  left: var(--safe-x);
  right: var(--safe-x);
  height: 88px;
  z-index: 30;
  background: rgba(9, 14, 23, 0.96);
  border: 1px solid rgba(117, 178, 221, 0.38);
  border-bottom: 2px solid rgba(117, 178, 221, 0.65);
  border-radius: 16px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

#tv-stage.full-bleed #broadcast-header {
  left: 0;
  right: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  padding: 0 32px;
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-inline-size: 0;
}

.hdr-crest {
  width: 62px;
  height: 62px;
  padding: 4px;
  flex-shrink: 0;
}

.hdr-kicker {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  background: rgba(117, 178, 221, 0.14);
  border: 1px solid rgba(117, 178, 221, 0.45);
  color: var(--k18-ice);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.hdr-title {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.05;
  color: #FFFFFF;
}

.hdr-scene-pill {
  padding: 8px 18px;
  border-radius: 12px;
  background: var(--k18-navy-800);
  border: 1px solid rgba(117, 178, 221, 0.42);
  color: var(--k18-ice);
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hdr-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Reserve top-right space when Sportal TV injects its own channel bug */
#broadcast-header.reserve-channel-bug {
  padding-right: 290px;
}

.segas-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--k18-navy-800);
  border: 1px solid rgba(245, 158, 11, 0.42);
}

.live-sportal-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(127, 29, 29, 0.85) 0%, #0F172A 85%);
  border: 1px solid rgba(239, 68, 68, 0.58);
}

.clock-pill {
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--k18-navy-800);
  border: 1px solid rgba(148, 163, 184, 0.35);
  text-align: right;
  min-width: 142px;
}

/* =========================================================================
   SCENE STAGE & VIEW TRANSITIONS
   ========================================================================= */
#scenes-root {
  position: absolute;
  top: calc(var(--safe-top) + 102px);
  left: var(--safe-x);
  right: var(--safe-x);
  bottom: calc(var(--safe-bottom) + 92px);
  view-transition-name: scene-stage;
}

#scenes-root.no-ribbon {
  bottom: var(--safe-bottom);
}

.tv-scene {
  position: absolute;
  inset: 0;
  display: none;
}

.tv-scene.is-active {
  display: grid;
}

.tv-scene.is-active-flex {
  display: flex;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* =========================================================================
   PERSISTENT LOWER RIBBON (SPONSORS OR NEWS TICKER)
   ========================================================================= */
#lower-ribbon {
  position: absolute;
  bottom: var(--safe-bottom);
  left: var(--safe-x);
  right: var(--safe-x);
  height: 78px;
  z-index: 30;
  background: rgba(7, 11, 20, 0.97);
  border: 1px solid rgba(117, 178, 221, 0.38);
  border-top: 2px solid rgba(117, 178, 221, 0.65);
  border-radius: 16px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.65);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

#tv-stage.full-bleed #lower-ribbon {
  left: 0;
  right: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding: 0 28px;
}

#lower-ribbon.is-hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

.ribbon-grand-list {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ribbon-badge-gold {
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, #F59E0B, #FBBF24);
  color: #090E17;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ribbon-grand-slot {
  width: 168px;
  height: 54px;
  padding: 5px 10px;
}

.ribbon-divider {
  width: 1px;
  height: 44px;
  background: rgba(148, 163, 184, 0.28);
  flex-shrink: 0;
}

.marquee-viewport {
  flex: 1;
  overflow: hidden;
  height: 54px;
  display: flex;
  align-items: center;
  min-inline-size: 0;
}

.marquee-track {
  display: flex;
  align-items: center;
  width: max-content;
}

@media (prefers-reduced-motion: no-preference) {
  .marquee-track {
    animation: ribbonScroll 32s linear infinite;
  }
}

@keyframes ribbonScroll {
  from { transform: translateX(0%); }
  to { transform: translateX(-50%); }
}

/* =========================================================================
   GRID & LAYOUT HELPERS FOR SCENES 1..6
   ========================================================================= */
.grid-12 {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.col-4 { grid-column: span 4 / span 4; min-inline-size: 0; }
.col-5 { grid-column: span 5 / span 5; min-inline-size: 0; }
.col-6 { grid-column: span 6 / span 6; min-inline-size: 0; }
.col-7 { grid-column: span 7 / span 7; min-inline-size: 0; }
.col-8 { grid-column: span 8 / span 8; min-inline-size: 0; }
.col-12 { grid-column: span 12 / span 12; min-inline-size: 0; }

/* Podium Accents */
.podium-row {
  border-radius: 14px;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.podium-1 {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.24) 0%, rgba(15, 23, 42, 0.94) 60%);
  border-left: 5px solid #FBBF24;
}

.podium-2 {
  background: linear-gradient(90deg, rgba(226, 232, 240, 0.18) 0%, rgba(15, 23, 42, 0.94) 60%);
  border-left: 5px solid #E2E8F0;
}

.podium-3 {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.22) 0%, rgba(15, 23, 42, 0.94) 60%);
  border-left: 5px solid #D97706;
}

.medal-rank {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 17px;
  flex-shrink: 0;
}

.medal-1 { background: linear-gradient(135deg, #FDE68A, #F59E0B); color: #090E17; }
.medal-2 { background: linear-gradient(135deg, #F8FAFC, #94A3B8); color: #090E17; }
.medal-3 { background: linear-gradient(135deg, #FBBF24, #B45309); color: #FFFFFF; }

/* Semantic Sticky Tables (Scene 3 Elite Start List) */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  container-type: inline-size;
  border-radius: 12px;
}

.tv-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 6px;
}

.tv-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.tv-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.tv-table thead th {
  background: #090E17;
  color: var(--k18-ice);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(117, 178, 221, 0.3);
}

.tv-table tbody tr {
  background: rgba(20, 31, 56, 0.82);
}

.tv-table tbody th,
.tv-table tbody td {
  padding: 9px 10px;
  font-size: 14.5px;
  vertical-align: middle;
  border-top: 1px solid rgba(117, 178, 221, 0.14);
  border-bottom: 1px solid rgba(117, 178, 221, 0.14);
}

.tv-table tbody tr > *:first-child {
  border-left: 3px solid var(--k18-cyan);
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
}

.tv-table tbody tr.is-female > *:first-child {
  border-left-color: var(--k18-gold);
}

.tv-table tbody tr > *:last-child {
  border-right: 1px solid rgba(117, 178, 221, 0.14);
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
}

/* Gentle Broadcast Pulse & Radar (Well under 3Hz WCAG 2.3.1 limit) */
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.86); }
}

@keyframes radarRing {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(2.4); opacity: 0; }
}

.live-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--k18-live);
  box-shadow: 0 0 12px var(--k18-live);
}

@media (prefers-reduced-motion: no-preference) {
  .live-dot {
    animation: livePulse 1.6s infinite ease-in-out;
  }
  .radar-pulse {
    transform-box: fill-box;
    transform-origin: center;
    animation: radarRing 1.8s infinite ease-out;
  }
}

/* =========================================================================
   TRANSPARENT CAMERA OVERLAY LAYER (ALPHA CHANNEL FOR OBS / vMIX)
   ========================================================================= */
#overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  display: none;
}

body.mode-overlay #broadcast-header,
body.mode-overlay #scenes-root,
body.mode-overlay #lower-ribbon {
  display: none !important;
}

body.mode-overlay #overlay-layer {
  display: block;
}

.ov-widget {
  position: absolute;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1), transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.ov-widget.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Overlay 1: Top-Left Scorebug */
#ov-bug {
  top: 44px;
  left: 56px;
  transform: translateY(-14px);
}

#ov-bug.is-visible {
  transform: translateY(0);
}

/* Overlay 2, 3, 4: Lower Thirds */
#ov-leaderboard,
#ov-spotlight,
#ov-sponsors {
  left: 56px;
  right: 56px;
  bottom: 48px;
}

/* =========================================================================
   SCENE 0: FULL-BLEED CINEMATIC INTRO OPENER & VIDEO PLAYOUT
   ========================================================================= */
#intro-stage {
  position: absolute;
  inset: 0;
  z-index: 36;
  display: none;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #12223E 0%, #060B14 68%, #03060C 100%);
}

#intro-stage.is-active {
  display: block;
}

.intro-act {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.65s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-act.is-visible {
  opacity: 1;
}

@keyframes kenBurnsSlow {
  0% { transform: scale(1.02) translate3d(0, 0, 0); }
  100% { transform: scale(1.11) translate3d(-1.2%, -1%, 0); }
}

.intro-photo-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.42;
  filter: contrast(1.08) saturate(1.12);
}

@media (prefers-reduced-motion: no-preference) {
  .intro-act.is-visible .intro-photo-bg {
    animation: kenBurnsSlow 9s ease-out forwards;
  }
}

.intro-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 9, 17, 0.94) 0%, rgba(5, 9, 17, 0.68) 52%, rgba(5, 9, 17, 0.88) 100%),
    linear-gradient(0deg, rgba(5, 9, 17, 0.96) 0%, transparent 42%, rgba(5, 9, 17, 0.78) 100%);
}

.intro-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: rgba(148, 163, 184, 0.18);
  z-index: 10;
}

.intro-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38BDF8, #75B2DD, #F59E0B);
}

