/* ── Display font: Russo One (self-hosted, bold/sporty) ─────────────────────── */
@font-face {
  font-family: 'Russo One'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/russo-one-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Russo One'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/russo-one-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+A720-A7FF;
}
@font-face {
  font-family: 'Russo One'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/russo-one-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}

/* ── Neon Night — CSS custom properties ─────────────────────────────────────── */
:root {
  --font-display: 'Russo One', system-ui, sans-serif;
}
/* Russo One has no CJK/Arabic/Devanagari glyphs — use the device's native font
   consistently for those languages (avoids mixing it with the Latin "2026"). */
html[lang="ja"], html[lang="ko"], html[lang="ar"], html[lang="hi"] {
  --font-display: system-ui, 'Noto Sans', sans-serif;
}
:root {
  /* Base palette */
  --bg:        #0a0a18;
  --bg-end:    #0e1230;
  --fg:        #fff;
  --panel:     rgba(18, 22, 48, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);

  /* Neon accents */
  --cyan:      #00e5ff;
  --magenta:   #ff2e87;
  --gold:      #ffd200;

  /* Legacy aliases kept for game.js / fx.js compatibility */
  --accent:    var(--gold);
  --accent2:   var(--magenta);

  /* Team colours — overridden per-game by applyPalette() */
  --team1:     #1769ff;
  --team2:     #ffffff;

  /* Glows */
  --glow-cyan:    0 0 18px rgba(0, 229, 255, 0.55), 0 0 48px rgba(0, 229, 255, 0.20);
  --glow-magenta: 0 0 18px rgba(255, 46, 135, 0.55), 0 0 48px rgba(255, 46, 135, 0.20);
  --glow-gold:    0 0 22px rgba(255, 210, 0, 0.55),  0 0 60px rgba(255, 180, 0, 0.25);
  --glow-red:     0 0 24px rgba(255, 46,  99, 0.5);

  /* Safe-area bottom */
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

/* ── Reset + base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px / 1.4 system-ui, sans-serif;
  overflow: hidden;
}
/* Safe-area offsets */
body {
  padding-top:   env(safe-area-inset-top);
  padding-left:  env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
html { overflow-x: hidden; }

/* ── App shell ──────────────────────────────────────────────────────────────── */
#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
}

/* Neon Night background gradient applied to the entire app */
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 229, 255, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(255, 46, 135, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-end) 100%);
  pointer-events: none;
  z-index: 0;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}
.hidden { display: none !important; }

/* Screen entrance transitions — fade everywhere; menu screens also rise.
   The match screen (live 3D) and result screen (fixed-position confetti) get a
   plain fade so no ancestor transform interferes. */
.screen:not(.hidden) { animation: scr-fade 0.26s ease both; }
#screen-select:not(.hidden),
#screen-bracket:not(.hidden) { animation: scr-rise 0.32s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
@keyframes scr-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scr-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen:not(.hidden) { animation: none !important; }
}

/* ── Mute button ────────────────────────────────────────────────────────────── */
#mute-btn {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 51;
  background: none;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.4));
}

/* ── Fatal error (e.g. WebGL unavailable) ───────────────────────────────────── */
#fatal-error {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  background: var(--bg);
  text-align: center;
}
.fatal-error-inner { max-width: 420px; }
.fatal-error-icon { font-size: 46px; margin-bottom: 16px; }
#fatal-error p {
  margin: 0;
  color: #cfe6ff;
  font: 600 16px / 1.5 system-ui, sans-serif;
}

/* ── In-match banner overlay ────────────────────────────────────────────────── */
.banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
  font-weight: 900;
  font-size: clamp(30px, 12vw, 64px);
  line-height: 1.08;
  color: var(--gold);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.4), var(--glow-gold);
  pointer-events: none;
  z-index: 45;
  overflow-wrap: break-word;
}

/* ── Language toggle (select screen top corner) ─────────────────────────────── */
.lang-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
}
.lang-btn {
  background: transparent;
  border: 1.5px solid rgba(0, 229, 255, 0.30);
  color: rgba(255, 255, 255, 0.45);
  font: 700 11px / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .15s, background .15s;
}
.lang-btn.lang-active,
.lang-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.10);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}
.lang-sep {
  font: 600 11px / 1 system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.20);
}

/* ── Common buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px 24px;
  min-height: 56px;
  background: linear-gradient(135deg, var(--cyan) 0%, #0096c7 45%, var(--magenta) 100%);
  color: #fff;
  font: 900 18px / 1 system-ui, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 229, 255, 0.30),
              0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: transform .12s, box-shadow .12s;
}
.btn-primary:hover {
  box-shadow: 0 6px 32px rgba(0, 229, 255, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.12) inset,
              var(--glow-cyan);
}
.btn-primary:active {
  transform: scale(.97);
  box-shadow: 0 2px 12px rgba(0, 229, 255, 0.30);
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px 24px;
  min-height: 52px;
  background: var(--panel);
  color: #fff;
  font: 700 16px / 1 system-ui, sans-serif;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-secondary:hover {
  background: rgba(0, 229, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.40);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.15);
}
.btn-secondary:active {
  background: rgba(0, 229, 255, 0.14);
  border-color: rgba(0, 229, 255, 0.55);
}

/* Min tap targets */
.btn-primary, .btn-secondary, .team-btn { min-height: 48px; }

/* ── SELECT screen ──────────────────────────────────────────────────────────── */
#screen-select {
  overflow: hidden;
  background: transparent; /* app::before handles the base gradient */
}

.select-header {
  position: relative;
  flex-shrink: 0;
  padding: 20px 20px 14px;
  background: linear-gradient(180deg, rgba(10, 10, 24, 0.97) 65%, transparent);
  text-align: center;
}
/* Neon divider under the header */
.select-header::after {
  content: '';
  display: block;
  height: 1.5px;
  background: linear-gradient(90deg,
    transparent,
    var(--cyan),
    var(--magenta),
    transparent);
  margin-top: 14px;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

/* Bold sporty display font on the big/fun bits (headings, banners, CTAs) */
.banner, .gtable-header, .keeper-title, .intro-round-label, .result-headline,
.hud-round, .opp-kick-cue, .bracket-round, .board-header, .gboard-results-label,
.ctx-name, .btn-primary {
  font-family: var(--font-display);
}

.title-logo {
  font-family: var(--font-display);
  font-size: clamp(28px, 9vw, 46px);
  font-weight: 400;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--cyan) 0%, var(--gold) 50%, var(--magenta) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.5)) drop-shadow(0 2px 0 rgba(0, 0, 0, 0.9));
}

.tagline {
  font-size: 13px;
  opacity: .55;
  margin: 6px 0 10px;
  letter-spacing: .02em;
}

.pick-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: .80;
}

/* ── Opponent kick prompt (tap to watch the computer's shot) ────────────────── */
.opp-kick-prompt {
  position: absolute;
  inset: 0;
  z-index: 46;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 24px;
  text-align: center;
  cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(255, 46, 99, 0.18) 0%, rgba(5, 8, 22, 0.55) 70%);
  animation: scr-fade 0.2s ease both;
}
.opp-kick-cue {
  font: 900 clamp(26px, 8vw, 46px) / 1.1 system-ui, sans-serif;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 46, 99, 0.7), 0 3px 0 rgba(0, 0, 0, 0.4);
}
.opp-kick-tap {
  font: 800 clamp(14px, 4.2vw, 20px) / 1 system-ui, sans-serif;
  letter-spacing: .08em;
  color: #ff90ab;
  animation: tap-pulse 1s ease-in-out infinite;
}
@keyframes tap-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ── Keeper select ──────────────────────────────────────────────────────────── */
.keeper-select {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  padding: 20px 16px 26px;
  gap: 10px;
  overflow-y: auto;
}
.keeper-title {
  font: 900 clamp(18px, 6vw, 26px) / 1 system-ui, sans-serif;
  letter-spacing: .08em;
  color: var(--gold);
  text-align: center;
  text-shadow: var(--glow-gold);
}
.keeper-grid { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 460px; }
.keeper-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 18px;
  padding: 12px;
  cursor: pointer;
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.keeper-card:hover, .keeper-card:active {
  border-color: var(--cyan);
  box-shadow: 0 0 22px rgba(0, 229, 255, .35);
  transform: translateY(-2px);
}
.keeper-art-wrap { width: 100%; height: clamp(150px, 34vw, 220px); display: flex; align-items: center; justify-content: center; }
.keeper-art { max-width: 92%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .55)); }
.keeper-name { font: 800 19px system-ui; color: #fff; }

/* Career stats strip on the home screen */
.career-strip {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.career-strip span {
  font: 700 12px/1 system-ui, sans-serif;
  color: #cfe6ff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
}

/* Visitor topbar: local time + country (left), language picker (right) */
/* Persistent top bar (every screen except the live match) */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 46px 7px 8px; /* right pad clears the fixed mute button */
  background: linear-gradient(180deg, rgba(5, 8, 22, 0.92) 0%, rgba(5, 8, 22, 0.55) 70%, transparent 100%);
}
#restart-btn {
  flex-shrink: 0;
  background: rgba(0, 229, 255, 0.10);
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: var(--cyan);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  padding: 4px 9px;
  cursor: pointer;
}
#restart-btn:active { transform: scale(.94); }
.visitor-info {
  flex: 1;
  font-size: 12px;
  opacity: .8;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Clear the fixed top bar on the screens that show it */
#screen-select, #screen-bracket, #screen-result { padding-top: 42px; }
.lang-select {
  background: rgba(0, 229, 255, 0.08);
  color: #cfe6ff;
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 8px;
  padding: 5px 8px;
  font: 700 12px system-ui, sans-serif;
  max-width: 48vw;
}
.lang-select option { background: #0a0a18; color: #cfe6ff; }

/* Suggested nation (from the visitor's country) */
.pick-suggest {
  margin-top: 10px;
  background: rgba(255, 210, 0, 0.10);
  border: 1px solid rgba(255, 210, 0, 0.5);
  color: #ffe680;
  border-radius: 999px;
  padding: 7px 16px;
  font: 800 14px system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 210, 0, 0.25);
}
.team-suggested {
  outline: 2px solid var(--gold);
  box-shadow: 0 0 14px rgba(255, 210, 0, 0.45);
}

.select-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 80px;
  -webkit-overflow-scrolling: touch;
}

.group-section { margin-bottom: 16px; }

.group-label {
  font: 700 10px / 1 system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(0, 229, 255, 0.55);
  padding: 10px 6px 6px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.12);
  margin-bottom: 6px;
}

.team-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.team-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  min-height: 52px;
  background: var(--panel);
  border: 1.5px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  text-align: start;   /* logical: left in LTR, right in RTL (Arabic) */
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.team-btn:hover, .team-btn:active {
  background: rgba(0, 229, 255, 0.10);
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.20);
}
.team-flag {
  font-size: 24px;
  flex-shrink: 0;
}
.team-name {
  font: 600 13px / 1.2 system-ui, sans-serif;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-rating {
  font: 700 12px / 1 system-ui, sans-serif;
  opacity: .50;
  flex-shrink: 0;
  margin-inline-start: auto;   /* logical: pushes to the row's end in both LTR/RTL */
}

/* ── GROUP CTX / BRACKET / MATCH INTRO shared screen ───────────────────────── */
#screen-bracket {
  overflow: hidden;
  background: transparent;
}

/* ── Group ctx card ─────────────────────────────────────────────────────────── */
.ctx-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 32px 28px 40px;
  text-align: center;
  gap: 14px;
}

.ctx-flag {
  font-size: 96px;
  line-height: 1;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.7))
          drop-shadow(0 0 20px rgba(0, 229, 255, 0.20));
}

.ctx-name {
  font: 900 clamp(24px, 8vw, 40px) / 1 system-ui, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.15);
}

.ctx-group {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.10);
  border: 1px solid rgba(0, 229, 255, 0.30);
  padding: 6px 18px;
  border-radius: 20px;
}

.ctx-groupmates {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.ctx-mate {
  font: 600 14px / 1.4 system-ui, sans-serif;
  opacity: .70;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
}

.ctx-sub {
  font-size: 16px;
  font-weight: 600;
  opacity: .80;
  line-height: 1.55;
}

.ctx-continue { margin-top: 10px; }

/* ── Bracket view ───────────────────────────────────────────────────────────── */
.bracket-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 14px 24px;
  overflow: hidden;
}

.bracket-header {
  text-align: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.bracket-round {
  font: 900 clamp(18px, 6vw, 28px) / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.40));
}

.bracket-pairs {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.bracket-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  font-size: 13px;
}

.bracket-pair.player-pair {
  background: rgba(0, 229, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.40);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.16);
}

.bracket-team {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 600 13px / 1.2 system-ui, sans-serif;
}

.bracket-team.is-player {
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.50);
}

.bracket-vs {
  font: 700 11px / 1 system-ui, sans-serif;
  opacity: .35;
  flex-shrink: 0;
}

/* ── Match intro card ───────────────────────────────────────────────────────── */
.intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 24px 20px 32px;
  text-align: center;
  gap: 18px;
}

.intro-round-label {
  font: 900 12px / 1 system-ui, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.10);
  border: 1px solid rgba(0, 229, 255, 0.30);
  padding: 6px 18px;
  border-radius: 20px;
}

.intro-matchup {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.intro-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 8px;
}

.intro-flag {
  font-size: clamp(56px, 18vw, 90px);
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.6))
          drop-shadow(0 0 18px rgba(0, 229, 255, 0.15));
  line-height: 1;
}

.intro-tname {
  font: 700 13px / 1.2 system-ui, sans-serif;
  opacity: .75;
  text-align: center;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.intro-vs {
  font: 900 18px / 1 system-ui, sans-serif;
  opacity: .35;
  flex-shrink: 0;
  color: var(--magenta);
}

.intro-tap {
  font: 600 13px / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.btn-kick {
  font-size: 22px !important;
  letter-spacing: .08em;
  padding: 18px 24px !important;
  min-height: 64px !important;
  border-radius: 18px !important;
}

/* ── MATCH canvas ───────────────────────────────────────────────────────────── */
#screen-match {
  background: #000;
  justify-content: center;
  align-items: center;
  /* relative so the absolute canvases fill it; full height so overlays
     (banners, outcome) get a real box to center in instead of collapsing to 0 */
  position: relative;
  height: 100%;
}

/* Both canvases fill the match screen absolutely stacked */
#stage3d,
#stage-ui {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}

/* 3D canvas behind, UI overlay on top */
#stage3d { z-index: 1; }
#stage-ui { z-index: 2; }

/* #match-hud sits above both canvases */
#match-hud { z-index: 20; }

/* Legacy alias kept in case any old reference survives */
#stage { display: block; touch-action: none; }

/* ── Match HUD ──────────────────────────────────────────────────────────────── */
#match-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top, 0px), 16px) 16px max(env(safe-area-inset-bottom, 0px), 16px);
}

.hud-top {
  text-align: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72) 0%, transparent 100%);
  padding: 12px 16px 20px;
  border-radius: 0 0 16px 16px;
}

.hud-round {
  font: 900 11px / 1 system-ui, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: .90;
  margin-bottom: 4px;
}

.hud-matchup {
  font: 700 15px / 1.3 system-ui, sans-serif;
  color: #fff;
}

.hud-shootout-score {
  text-align: center;
  background: rgba(0, 0, 0, 0.60);
  backdrop-filter: blur(8px);
  padding: 10px 20px;
  border-radius: 16px;
  margin: 0 auto;
  min-width: 180px;
  border: 1px solid var(--panel-border);
}

.hud-score-you, .hud-score-opp {
  font: 900 22px / 1 system-ui, sans-serif;
  color: #fff;
  letter-spacing: .04em;
}

.hud-score-sep {
  font: 700 18px / 1 system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.45);
  margin: 0 8px;
}

.hud-dots {
  font-size: 16px;
  letter-spacing: .12em;
  margin-top: 4px;
  color: var(--cyan);
}
.hud-dots-opp { color: var(--magenta); }

.hud-bottom {
  text-align: center;
  padding: 16px 16px max(env(safe-area-inset-bottom, 0px), 12px);
}

.hud-moment {
  font: 700 11px / 1 system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .85;
  margin-top: 4px;
}
.hud-moment-attack { color: var(--gold); }
.hud-moment-defend { color: var(--cyan); }
.hud-moment-opponent { color: #ff6aa0; }

.hud-live-score {
  font: 900 23px / 1 system-ui, sans-serif;
  color: #fff;
  letter-spacing: .06em;
  margin-top: 6px;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.45), 0 2px 4px rgba(0, 0, 0, 0.7);
}

/* ── RESULTS BOARD ──────────────────────────────────────────────────────────── */
.board-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 14px 24px;
  gap: 14px;
  overflow: hidden;
}

.board-header {
  font: 900 clamp(14px, 5vw, 22px) / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--cyan);
  text-align: center;
  flex-shrink: 0;
  padding-bottom: 12px;
  border-bottom: 1.5px solid rgba(0, 229, 255, 0.25);
  text-shadow: var(--glow-cyan);
}

.board-rows {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.board-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 13px;
}

.board-team {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 600 13px / 1.2 system-ui;
}
/* Logical: both teams align toward the centre score in LTR and RTL alike. */
.board-team-a { text-align: end; }
.board-team-b { text-align: start; }

.board-score {
  font: 900 16px / 1 system-ui, sans-serif;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.40);
  border-radius: 6px;
  padding: 5px 10px;
  flex-shrink: 0;
  white-space: nowrap;
  border: 1px solid var(--panel-border);
}

.board-pens {
  font-size: 11px;
  opacity: .55;
  font-weight: 400;
}

/* ── GROUP TABLE ─────────────────────────────────────────────────────────────── */
.gtable-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 14px 24px;
  gap: 14px;
  overflow: hidden;
}

/* Combined standings + results board (scrolls if tall) */
.gboard-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 14px 24px;
  gap: 12px;
  overflow-y: auto;
}
.gboard-results-label {
  font: 800 12px system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: .8;
  text-align: center;
  margin-top: 4px;
}
.gboard-continue { margin-top: 8px; flex-shrink: 0; }

.gtable-header {
  font: 900 clamp(14px, 5vw, 22px) / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
  flex-shrink: 0;
  padding-bottom: 12px;
  border-bottom: 1.5px solid rgba(255, 210, 0, 0.25);
  text-shadow: var(--glow-gold);
}

.gtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.gtable th {
  font: 700 11px / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: rgba(0, 229, 255, 0.60);
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(0, 229, 255, 0.15);
}
.gtable th.gtable-team-col { text-align: start; }

.gtable td {
  padding: 10px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font: 600 14px / 1 system-ui;
}
.gtable td.gtable-team-col {
  text-align: start;
  white-space: nowrap;
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gtable-pts { font-weight: 900; color: var(--gold); }

.gtable-player td {
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
}
.gtable-player .gtable-pts { color: var(--gold); }

/* Classic 10-column standings (# Team P W D L GF GA GD Pts) — compact for mobile */
.gtable-classic { font-size: 12px; table-layout: fixed; }
.gtable-classic th {
  font-size: 9.5px;
  letter-spacing: .02em;
  padding: 6px 1px;
}
.gtable-classic td {
  padding: 8px 1px;
  font: 700 12px / 1 system-ui;
}
.gtable-classic th:not(.gtable-team-col),
.gtable-classic td:not(.gtable-team-col) { width: 7%; }
.gtable-classic .gtable-team-col { width: auto; }
.gtable-classic td.gtable-team-col {
  /* normal table cell (NOT flex — a flex <td> drops out of fixed-table sizing
     and collapses), with ellipsis for long names */
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}
.gtable-classic .gtable-tn { margin-inline-start: 5px; font-weight: 700; }

/* Fixtures list (dates · times · stadiums) */
.fx-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.fx-row {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 11px;
}
.fx-row.fx-player {
  border-color: rgba(0, 229, 255, 0.40);
  background: rgba(0, 229, 255, 0.06);
}
.fx-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}
.fx-when {
  font: 800 14px / 1 system-ui, sans-serif;
  color: var(--gold);
  text-align: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  padding: 4px 9px;
  white-space: nowrap;
}
.fx-sub {
  text-align: center;
  font: 600 10.5px / 1.3 system-ui, sans-serif;
  color: rgba(207, 230, 255, 0.62);
  letter-spacing: .03em;
  margin-top: 5px;
}

/* ── QUALIFICATION VERDICT ──────────────────────────────────────────────────── */
.verdict-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 32px 28px 40px;
  text-align: center;
  gap: 16px;
}

.verdict-flag {
  font-size: 80px;
  line-height: 1;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.7))
          drop-shadow(0 0 18px rgba(0, 229, 255, 0.20));
}

.verdict-name {
  font: 900 clamp(20px, 7vw, 34px) / 1 system-ui, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.verdict-pos {
  font: 700 12px / 1 system-ui, sans-serif;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(255, 210, 0, 0.10);
  border: 1px solid rgba(255, 210, 0, 0.28);
  padding: 6px 18px;
  border-radius: 20px;
}

.verdict-result {
  font: 900 clamp(22px, 7vw, 36px) / 1.1 system-ui, sans-serif;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.verdict-qual {
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
.verdict-dnq {
  color: var(--magenta);
  text-shadow: var(--glow-magenta);
}

.verdict-sub {
  font-size: 15px;
  opacity: .68;
  line-height: 1.5;
}

/* ── RESULT screen ──────────────────────────────────────────────────────────── */
#screen-result {
  overflow-y: auto;
  background: transparent;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px calc(28px + var(--safe-b));
  gap: 14px;
  text-align: center;
  min-height: 100%;
}

.result-flag {
  font-size: clamp(64px, 20vw, 100px);
  line-height: 1;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.6))
          drop-shadow(0 0 24px rgba(0, 229, 255, 0.15));
}

.result-nation {
  font: 900 clamp(22px, 7vw, 36px) / 1 system-ui, sans-serif;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.result-headline {
  font: 900 clamp(18px, 6vw, 28px) / 1.2 system-ui, sans-serif;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin: 8px 0;
}

.result-won {
  color: var(--gold);
  text-shadow: var(--glow-gold);
}
.result-lost {
  color: var(--magenta);
  text-shadow: var(--glow-magenta);
}

.result-path { font-size: clamp(28px, 9vw, 44px); line-height: 1.3; }
.result-path-label { font-size: 13px; opacity: .48; margin-top: 2px; letter-spacing: .04em; }

.result-stats {
  font: 600 14px / 1 system-ui, sans-serif;
  opacity: .50;
  letter-spacing: .04em;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 7px 18px;
  border-radius: 18px;
  margin: 4px 0;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: auto;
  padding-top: 16px;
}

/* Share bar — the growth lever on the result screen */
.share-bar {
  width: 100%;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
}
.share-bar-label {
  display: block;
  font: 800 12px / 1 system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: .9;
  margin-bottom: 10px;
}
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.share-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--panel);
  color: #fff;
  font: 800 14px / 1 system-ui, sans-serif;
  letter-spacing: .02em;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.share-btn:hover {
  background: rgba(0, 229, 255, 0.10);
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.18);
}
.share-btn:active { transform: scale(0.96); }
.share-btn-wide { flex: 1 1 46%; }
.share-btn[data-share="image"] {
  background: linear-gradient(135deg, var(--gold) 0%, #ff8c00 45%, var(--magenta) 100%);
  color: #000;
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(255, 180, 0, 0.40);
}

/* Start-screen footer + About link */
.site-footer {
  width: 100%;
  text-align: center;
  padding: 18px 0 calc(14px + var(--safe-b));
  margin-top: 18px;
}
.about-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font: 600 13px / 1 system-ui, sans-serif;
  letter-spacing: .04em;
  cursor: pointer;
  padding: 8px 12px;
  transition: color .15s;
}
.about-link:hover { color: var(--cyan); }

/* About / disclaimer modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 4, 12, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modal-fade .18s ease;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #11163a, #080a1c);
  border: 1.5px solid rgba(0, 229, 255, 0.30);
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 229, 255, 0.10);
  padding: 28px 24px 24px;
}
.modal-close {
  position: absolute;
  top: 10px;
  inset-inline-end: 12px;
  width: 38px;
  height: 38px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: #fff; }
.modal-title {
  font: 900 22px / 1.2 var(--font-display);
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  margin: 0 28px 16px 0;
}
.modal-line {
  font: 400 14px / 1.55 system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.86);
  margin: 0 0 12px;
}
.modal-credits { color: var(--cyan); text-decoration: none; }
.modal-credits:hover { text-decoration: underline; }

/* ── "Scores & tables" entry button (start screen) ── */
.view-scores {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 8px auto 4px; padding: 10px 18px;
  background: rgba(0, 229, 255, 0.08); color: var(--cyan);
  font: 800 14px / 1 system-ui, sans-serif; letter-spacing: .04em;
  border: 1.5px solid rgba(0, 229, 255, 0.4); border-radius: 12px;
  cursor: pointer; transition: background .15s, box-shadow .15s;
}
.view-scores:hover { background: rgba(0, 229, 255, 0.16); box-shadow: 0 0 16px rgba(0, 229, 255, 0.2); }

/* ── Tournament (spectator: tables / results / schedule) ── */
#screen-tournament { overflow-y: auto; }
.t-wrap { max-width: 680px; margin: 0 auto; padding: 8px 0 40px; }
.t-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.t-close {
  width: 42px; height: 42px; flex: 0 0 auto;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 11px;
  color: #fff; font-size: 20px; cursor: pointer;
}
.t-close:hover { border-color: rgba(0, 229, 255, 0.45); }
.t-title { font: 900 24px / 1 var(--font-display, system-ui); color: #fff; margin: 0; flex: 1; }
.t-asof { font-size: 12px; color: var(--muted, #9aa3cc); }
.t-tabs {
  display: flex; gap: 8px; margin-bottom: 18px;
  position: sticky; top: 0; z-index: 2;
  background: linear-gradient(180deg, var(--bg, #0a0a18) 72%, transparent); padding: 6px 0;
}
.t-tab {
  flex: 1; min-height: 44px;
  background: var(--panel); color: var(--muted, #9aa3cc);
  font: 800 13px / 1 system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--panel-border); border-radius: 11px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.t-tab.is-active { color: #001018; background: var(--cyan); border-color: transparent; box-shadow: 0 0 18px rgba(0, 229, 255, 0.3); }
.t-panel { display: none; }
.t-panel.is-active { display: block; animation: t-fade .2s ease; }
@keyframes t-fade { from { opacity: 0; } to { opacity: 1; } }
.t-group { margin-bottom: 22px; }
.t-group-head {
  font: 800 13px / 1 system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase;
  color: var(--cyan); margin-bottom: 10px;
}
.t-match {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px 10px;
  padding: 9px 12px; border: 1px solid var(--panel-border); border-radius: 10px;
  background: rgba(255, 255, 255, 0.02); margin-bottom: 7px;
}
.t-side { display: flex; align-items: center; gap: 7px; font-size: 14px; min-width: 0; }
.t-a { justify-content: flex-end; text-align: end; }
.t-b { justify-content: flex-start; }
.t-tn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-mid { font: 900 16px / 1 system-ui, sans-serif; color: #fff; min-width: 46px; text-align: center; }
.t-when { grid-column: 1 / -1; text-align: center; font-size: 11.5px; color: var(--muted, #9aa3cc); letter-spacing: .03em; }
.t-empty { color: var(--muted, #9aa3cc); text-align: center; padding: 30px 0; }
/* qualified rows in the standings */
.gtable-qual td { background: rgba(37, 211, 102, 0.08); }
.gtable-qual td:first-child { box-shadow: inset 3px 0 0 #25d366; }
