/* Subsoccer · HEMLIBRA — shared styles for the screen (TV) and controller (phone).
   Brand colours come from content.js at runtime (--brand, --color-a, --color-b). */

/* --- Brand display font hook -------------------------------------------------
   The licensed HEMLIBRA font takes priority if you drop it in and uncomment:
   @font-face { font-family:'Hemlibra Display'; src:url('/assets/hemlibra.woff2') format('woff2'); font-weight:800; font-style:italic; }
   Otherwise we use Saira Condensed (the prototype's face) — self-hosted below so
   the booth works offline. Italic is synthesized from these upright weights.    */
@font-face { font-family: 'Saira Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/saira-condensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/saira-condensed-700.woff2') format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-style: normal; font-weight: 800; font-display: swap; src: url('/assets/fonts/saira-condensed-800.woff2') format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-style: normal; font-weight: 900; font-display: swap; src: url('/assets/fonts/saira-condensed-900.woff2') format('woff2'); }

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

:root {
  --brand: #E84A1A;
  --color-a: #E84A1A;
  --color-b: #3a4a5a;
  --ink: #14181f;
  --panel: #1b212b;
  --text: #f6f8fc;
  --muted: #9aa6bd;
  --live: #2bd17a;
  --warn: #ffb020;
  --display: 'Hemlibra Display', 'Saira Condensed', 'Haas Grot Disp', 'Helvetica Neue', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
}

html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; }

.display { font-family: var(--display); font-style: italic; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.01em; line-height: 0.95; }

/* ---------- Connection status pill (shared) ---------- */
.status { display: inline-flex; align-items: center; gap: 0.5em; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.status .dot { width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--warn); }
.status.reconnecting .dot { animation: pulse-dot 1.1s ease-in-out infinite; }
.status.live .dot { background: var(--live); animation: none; }
.status.live { color: var(--live); }
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(255,176,32,0.6); }
  70% { box-shadow: 0 0 0 0.6em rgba(255,176,32,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,176,32,0); }
}

/* ============================================================
   SCREEN (TV)
   ============================================================ */
.screen { display: flex; flex-direction: column; overflow: hidden; height: 100vh; height: 100dvh; }
.stage { position: relative; flex: 1; overflow: hidden; }

/* phase layers cross-fade */
.layer { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 0.45s ease; }
body[data-phase="idle"]    .layer-idle,
body[data-phase="welcome"] .layer-welcome,
body[data-phase="playing"] .layer-play,
body[data-phase="over"]    .layer-play { opacity: 1; }

/* ---- first-load preloader (orange splash + %) ---- */
.preloader { position: fixed; inset: 0; z-index: 9999; background: var(--brand);
  display: flex; align-items: center; justify-content: center; transition: opacity 0.5s ease; }
.preloader.hide { opacity: 0; pointer-events: none; }
/* same display face as the 3·2·1 countdown (preloaded, so it renders right away) */
.preloader-pct { font-family: var(--display); font-weight: 900; font-style: italic; color: #fff;
  font-size: clamp(3rem, 13vh, 9rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* ---- idle / attract ---- */
.attract { position: absolute; inset: 0; opacity: 0; transition: opacity 0.8s ease; display: flex; }
.attract.show { opacity: 1; }

/* holding page: full-bleed football photo (set via content.js adImage) with the
   copy overlaid on the left and a scrim so the white text stays readable */
.attract-ad { background-color: #0d1016; background-position: center; background-size: cover; background-repeat: no-repeat; }
.attract-ad::before { content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, rgba(0,0,0,0.66) 0%, rgba(0,0,0,0.4) 34%, rgba(0,0,0,0.05) 60%, transparent 78%); }
/* no left padding → the orange headline boxes bleed to the screen's left edge */
.ad-copy { position: relative; z-index: 2; flex: 0 1 66%; display: flex; flex-direction: column; justify-content: center;
  gap: clamp(0.8rem, 2vh, 1.8rem); padding: 6vh 5vw 6vh 0; }
.ad-headline { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase;
  font-size: clamp(2.4rem, 5.6vw, 6.4rem); line-height: 1.42; white-space: nowrap; }
.ad-headline span { background: var(--brand); color: #fff; padding: 0.06em 0.4em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.ad-body { padding-left: clamp(1rem, 2.6vw, 2.6rem); max-width: 36ch; font-size: clamp(1.4rem, 2.5vw, 2.7rem);
  font-weight: 700; line-height: 1.4; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,0.7); }
.ad-refs { padding-left: clamp(1rem, 2.6vw, 2.6rem); max-width: 46ch; font-size: clamp(0.7rem, 1vw, 0.95rem);
  color: rgba(255,255,255,0.8); text-shadow: 0 1px 6px rgba(0,0,0,0.7); }

.attract-film { background: #06080c; display: grid; place-items: center; }
.film-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* full-bleed embed (16:9 cover trick, so no YouTube letterboxing) */
.film-embed { position: absolute; inset: 0; overflow: hidden; background: #000; }
.film-iframe { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 100%; height: 100%; min-width: 177.78vh; min-height: 56.25vw; border: 0; pointer-events: none; }
.film-ph { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; color: var(--muted); }
.film-glyph { width: clamp(80px,12vh,140px); height: clamp(80px,12vh,140px); display: grid; place-items: center;
  border: 3px solid var(--brand); border-radius: 50%; color: var(--brand); font-size: clamp(2rem,5vh,3.4rem); padding-left: 0.15em; }
.film-cap { font-size: clamp(1rem,2vh,1.6rem); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

/* ---- welcome countdown ---- */
.layer-welcome { background: var(--brand); display: grid; place-items: center; }
.cdown-wrap { display: flex; flex-direction: column; align-items: center; gap: 3vh; }
.cdown-num { font-family: var(--display); font-style: italic; font-weight: 900; text-transform: uppercase;
  color: #fff; line-height: 1; text-shadow: 0 4px 32px rgba(0,0,0,0.25);
  min-height: 1.1em; text-align: center;
  font-size: clamp(5rem, 22vmin, 18rem); }
.cdown-num[data-step="go"] { font-size: clamp(3.4rem, 13vmin, 11rem); }
/* LET'S GO! sits in a white banner with brand-orange text + ball (matches the headline, inverted) */
.go-banner { display: inline-block; background: #fff; color: var(--brand); padding: 0.1em 0.34em; line-height: 1; }
/* football (lottie) that replaces the "O" in LET'S GO! — sized to match the letters */
.go-ball { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -0.28em; }
.go-ball svg { display: block; width: 100%; height: 100%; }
.cdown-num.pop { animation: cdown-pop 0.5s cubic-bezier(.15,1.4,.4,1) both; }
@keyframes cdown-pop {
  0%   { transform: scale(0.3) translateY(15%); opacity: 0; }
  60%  { transform: scale(1.12) translateY(-2%); opacity: 1; }
  100% { transform: scale(1)   translateY(0);   opacity: 1; }
}

/* ---- playing / over ---- */
/* the play layer is a full-bleed pitch photo; before a goal the split is invisible
   (transparent sides, no labels/divider) so it's "just the background" */
.layer-play { display: flex; overflow: hidden; background: #0d1117; }
/* full-bleed pitch photo on its own layer with a slow Ken Burns drift (GPU transform).
   It sits behind the sides, so GOAL! overlays the same moving photo. */
.play-bg { position: absolute; inset: 0; z-index: 0; background-position: center; background-size: cover; background-repeat: no-repeat;
  transform-origin: center; will-change: transform; animation: ken-burns 28s ease-in-out infinite alternate; }
@keyframes ken-burns { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.16) translate(-2.5%, -1.5%); } }
@media (prefers-reduced-motion: reduce) { .play-bg { animation: none; transform: scale(1.04); } }
.side { position: relative; flex: 1; overflow: hidden; background: transparent; }
.side > div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2vh; padding: 6vh 3vw; text-align: center; opacity: 0; transition: opacity 0.35s ease; pointer-events: none; }
.side[data-mode="neutral"] .side-neutral,
.side[data-mode="goal"]    .side-goal,
.side[data-mode="win"]     .side-win { opacity: 1; }

.side-neutral { background: transparent; }
.side-label { display: none; }   /* "just the background" while waiting for a goal */

/* centre prompt while waiting for the first goal — one line, gently breathing, hidden once a goal lands */
.play-prompt { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center;
  padding: 0 4vw; pointer-events: none; text-align: center; }
.play-prompt[hidden] { display: none; }
.play-prompt::before { content: ''; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(60% 28% at 50% 50%, rgba(0,0,0,0.55), rgba(0,0,0,0) 75%); }
.play-prompt-text { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; color: #fff;
  white-space: nowrap; font-size: clamp(1.2rem, 4vw, 4rem); line-height: 1.1; text-shadow: 0 3px 16px rgba(0,0,0,0.75);
  animation: prompt-breathe 2.6s ease-in-out infinite; }
@keyframes prompt-breathe { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.04); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .play-prompt-text { animation: none; } }

/* GOAL!: the scoring side takes over the whole screen as a full-bleed photo,
   with the GOAL! orange box + stat on the left (same language as the holding page) */
.side[data-mode="goal"] { position: absolute; inset: 0; z-index: 5; }
.side .side-goal { align-items: flex-start; justify-content: center; text-align: left; gap: clamp(1rem, 3vh, 2.4rem); padding: 6vh 6vw 6vh 0; }
.side .side-goal::after { content: ''; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.6), rgba(0,0,0,0.28) 38%, transparent 66%); }
.goal-word { position: relative; z-index: 1; font-family: var(--display); font-style: italic; font-weight: 800;
  text-transform: uppercase; color: #fff; background: var(--brand); padding: 0.02em 0.3em; line-height: 1.12;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: clamp(3.4rem, 12vw, 12rem); }
.goal-stat { position: relative; z-index: 1; padding-left: clamp(1rem, 2.6vw, 2.6rem); max-width: 28ch;
  font-family: var(--display); font-style: italic; font-weight: 700; text-transform: uppercase; color: #fff;
  font-size: clamp(1.3rem, 2.8vw, 2.8rem); line-height: 1.22; text-shadow: 0 2px 12px rgba(0,0,0,0.7); }
.goal-word.pop { animation: goal-pop 0.5s ease-out; }
/* Player 2 (right side) scores → mirror the GOAL! box + stat to the right edge */
#sideB .side-goal { align-items: flex-end; text-align: right; padding: 6vh 0 6vh 6vw; }
#sideB .side-goal::after { background: linear-gradient(270deg, rgba(0,0,0,0.6), rgba(0,0,0,0.28) 38%, transparent 66%); }
#sideB .goal-stat { padding-left: 0; padding-right: clamp(1rem, 2.6vw, 2.6rem); }
@keyframes goal-pop { 0% { transform: scale(0.7); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* THANKS FOR PLAYING!: winner's side takes over full-screen, solid orange, with a
   white banner headline (orange text) + white body, flush to the edge (mirror for P2) */
.side[data-mode="win"] { position: absolute; inset: 0; z-index: 5; }
.side .side-win { background: var(--brand); align-items: flex-start; justify-content: center; text-align: left;
  gap: clamp(1rem, 3vh, 2.4rem); padding: 6vh 6vw 6vh 0; }
.win-word { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; color: #fff;
  font-size: clamp(2.8rem, 9vw, 8.5rem); line-height: 1.42; white-space: nowrap; }
.win-word span { background: #fff; color: var(--brand); padding: 0.04em 0.34em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.win-body { padding-left: clamp(1rem, 2.6vw, 2.6rem); max-width: 34ch; font-family: var(--display); font-style: italic;
  font-weight: 700; text-transform: uppercase; color: #fff; font-size: clamp(1.2rem, 2.4vw, 2.4rem); line-height: 1.25; }
#sideB .side-win { align-items: flex-end; text-align: right; padding: 6vh 0 6vh 6vw; }
#sideB .win-body { padding-left: 0; padding-right: clamp(1rem, 2.6vw, 2.6rem); }

/* ---- bottom ticker ---- */
.ticker { flex: 0 0 auto; height: clamp(48px, 9vh, 100px); background: var(--brand); color: #fff;
  display: flex; align-items: stretch; overflow: hidden; }
.ticker-score { display: none; align-items: center; gap: 1.2vw; padding: 0 2vw; background: #000; white-space: nowrap; }
body[data-phase="playing"] .ticker-score,
body[data-phase="over"] .ticker-score,
body[data-phase="welcome"] .ticker-score { display: flex; }
.ts-team { display: inline-flex; align-items: center; gap: 0.6vw; font-family: var(--display); font-style: italic; font-weight: 800; }
.ts-name { font-size: clamp(0.9rem, 1.7vh, 1.6rem); text-transform: uppercase; opacity: 0.92; }
.ts-num { font-size: clamp(1.8rem, 5vh, 3.4rem); min-width: 1ch; text-align: center; }
.ts-a .ts-num { color: #fff; } .ts-b .ts-num { color: #fff; }
.ts-dash { align-self: center; font-size: clamp(1.2rem, 3vh, 2rem); opacity: 0.7; }

.ticker-marquee { flex: 1; overflow: hidden; display: flex; align-items: center; }
.marquee-track { display: inline-block; white-space: nowrap; will-change: transform;
  font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase;
  font-size: clamp(1.1rem, 5.5vh, 4rem); line-height: 1; letter-spacing: 0.04em; animation: marquee 30s linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }


/* ============================================================
   CONTROLLER (phone)
   ============================================================ */
.controller { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; background: #000;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* connection status: a floating pill shown only while reconnecting, hidden when live */
.cstatus { position: fixed; top: calc(0.5rem + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 40;
  color: var(--text); background: color-mix(in srgb, var(--warn) 22%, var(--panel));
  padding: 0.3rem 0.75rem; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.cstatus.live { display: none; }

/* deck: two player panels filling the full left/right of the viewport, with a
   narrow center cluster between them. No outer padding → panels reach the edges. */
.deck { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr clamp(104px, 28vw, 230px) 1fr; gap: clamp(6px, 2vw, 16px);
  padding: calc(0.5rem + env(safe-area-inset-top)) 0 calc(0.5rem + env(safe-area-inset-bottom)); }

.goal-btn { appearance: none; cursor: pointer; position: relative; min-width: 0; overflow: hidden; border-radius: 0;
  display: grid; align-content: center; justify-items: center; gap: 0.5rem; padding: 0.5rem;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 72%, #000));
  color: #fff; border: 1px solid color-mix(in srgb, var(--brand) 55%, #000);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--brand) 28%, transparent);
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.2s ease; }
.goal-btn .gb-name { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase;
  font-size: clamp(0.95rem, 5.4vw, 2.3rem); line-height: 1.1; letter-spacing: 0.02em;
  max-width: 96%; padding: 0.1em 0.32em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.goal-btn .gb-action { font-size: clamp(0.6rem, 2.6vw, 0.9rem); font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: rgba(255,255,255,0.78); }
.goal-btn:active, .goal-btn.tapped { transform: scale(0.96); filter: brightness(1.22); }
.goal-btn:disabled { cursor: default; opacity: 0.32; filter: saturate(0.25); box-shadow: none; }

.cluster { display: grid; align-content: center; justify-items: stretch; gap: clamp(10px, 2.2vh, 22px); min-width: 0; text-align: center; }

.match { justify-items: center; gap: 0.4rem; }   /* display toggled per phase below */
.match-clock { font-family: var(--display); font-style: italic; font-weight: 800; font-size: clamp(1.8rem, 9vw, 3.4rem);
  line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.match-clock.low { color: var(--warn); animation: pulse-soft 1s ease-in-out infinite; }
.match-score { font-family: var(--display); font-style: italic; font-weight: 700; font-size: clamp(1.1rem, 5vw, 1.7rem);
  color: var(--muted); display: inline-flex; gap: 0.35em; align-items: baseline; font-variant-numeric: tabular-nums; }
.match-score b { color: var(--text); display: inline-block; padding: 0.06em 0.16em 0; } .match-score i { font-style: italic; opacity: 0.55; }
.match-score b.bump { animation: score-bump 0.4s ease-out; }
@keyframes score-bump { 0% { transform: scale(1); } 40% { transform: scale(1.55); } 100% { transform: scale(1); } }

/* instant "+1" that floats up from a tapped player panel */
.plus-one { position: absolute; left: 50%; top: 42%; z-index: 3; pointer-events: none;
  font-family: var(--display); font-style: italic; font-weight: 800; color: #fff;
  font-size: clamp(2.6rem, 16vw, 6.5rem); line-height: 1; text-shadow: 0 6px 20px rgba(0,0,0,0.4);
  animation: plus-one 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes plus-one {
  0%   { opacity: 0; transform: translate(-50%, 10%) scale(0.5); }
  20%  { opacity: 1; transform: translate(-50%, -10%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

.btn { appearance: none; cursor: pointer; border-radius: 12px; font-family: var(--display); font-style: italic; font-weight: 800;
  letter-spacing: 0.05em; text-transform: uppercase; padding: 0.95rem 0.6rem; font-size: clamp(0.95rem, 4.4vw, 1.35rem);
  transition: transform 0.08s ease, filter 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); border: 1px solid var(--brand); color: #fff; box-shadow: 0 10px 28px color-mix(in srgb, var(--brand) 38%, transparent); }
.btn-primary:active { filter: brightness(1.1); }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,0.16); color: var(--muted); }
.btn-ghost:active { background: #0d1117; }
.btn-reset.armed { border-color: var(--warn); color: var(--warn); animation: pulse-soft 1s ease-in-out infinite; }

.pending { justify-self: center; font-size: 0.8rem; font-weight: 700; color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent); padding: 0.25rem 0.6rem; border-radius: 999px; }

/* phase-driven visibility of the cluster's pieces */
.only-idle, .only-over, .when-playing, .match, .btn-reset { display: none; }
body[data-phase="idle"] .only-idle,
body[data-phase="over"]  .only-over { display: block; }
body[data-phase="welcome"] .when-playing,
body[data-phase="playing"] .when-playing { display: block; }
body[data-phase="welcome"] .match,
body[data-phase="playing"] .match,
body[data-phase="over"]    .match { display: grid; }
body[data-phase="welcome"] .btn-reset,
body[data-phase="playing"] .btn-reset,
body[data-phase="over"]    .btn-reset { display: block; }

@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* fullscreen 3·2·1 countdown overlay (mirrors the big screen's welcome).
   Size is bounded by BOTH height and width (min(...)) so the big number can't
   overflow / get clipped on a narrow phone; overflow:hidden + high z-index keep
   it cleanly on top on mobile (iOS Chrome especially). */
.ccount { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  overflow: hidden; background: var(--brand); }
.ccount[hidden] { display: none; }
.ccount-num { font-family: var(--display); font-style: italic; font-weight: 800; color: #fff; line-height: 1;
  width: 100%; text-align: center; font-size: min(38vh, 50vw); }
.ccount-num[data-go="1"] { font-size: clamp(2.2rem, 13vw, 9rem); text-transform: uppercase; padding: 0 0.3em; }
.ccount-num.pop { animation: ccount-pop 0.42s cubic-bezier(0.16, 0.84, 0.3, 1) both; }
@keyframes ccount-pop { from { opacity: 0.15; transform: scale(1.5); } to { opacity: 1; transform: scale(1); } }

/* big-screen synced match clock (top-center, during play) */
.screen-clock { position: fixed; top: clamp(10px, 2.2vh, 26px); left: 50%; transform: translateX(-50%); z-index: 30;
  font-family: var(--display); font-style: italic; font-weight: 800; font-size: clamp(2rem, 6vh, 4.2rem);
  color: var(--text); background: rgba(0,0,0,0.36); padding: 0.05em 0.32em; border-radius: 12px;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em; text-shadow: 0 1px 8px rgba(0,0,0,0.5); }
.screen-clock[hidden] { display: none; }
.screen-clock.low { color: var(--warn); animation: pulse-soft 1s ease-in-out infinite; }
