/* ============================================================
   Voxel World Cup Final — broadcast chrome & matchday programme
   ============================================================ */
:root {
  --ink: #f2efe6;
  --ink-dim: #9aa7bf;
  --night: #070b18;
  --navy: #0d1526;
  --glass: rgba(10, 16, 30, 0.72);
  --hairline: rgba(242, 239, 230, 0.14);
  --esp: #e05545;
  --arg: #8fcdee;
  --gold: #ffd166;
  --font-disp: "Futura", "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  --font-body: "Helvetica Neue", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: var(--night); }
body { font-family: var(--font-body); color: var(--ink); -webkit-font-smoothing: antialiased; }

#glcanvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#glcanvas:active { cursor: grabbing; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--night); z-index: 99; letter-spacing: .3em; color: var(--ink-dim); font-size: 12px; transition: opacity .5s; }
#loading.gone { opacity: 0; pointer-events: none; }

/* ---------- glass & dock ---------- */
.glass { background: var(--glass); backdrop-filter: blur(8px) saturate(1.1); border: 1px solid rgba(255,255,255,.09); border-radius: 10px; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#hud > * { pointer-events: auto; }
#glcanvas { z-index: 1; }

/* scorebug */
#scorebug {
  position: absolute; top: 14px; left: 14px;
  display: flex; align-items: stretch; gap: 0;
  font-family: var(--font-disp); font-weight: 700; letter-spacing: .06em;
  overflow: hidden; min-width: 240px;
}
.sb-tab { width: 7px; }
.sb-home { background: var(--esp); } .sb-away { background: var(--arg); }
.sb-short { padding: 10px 10px; font-size: 15px; align-self: center; }
.sb-score { padding: 10px 6px; font-size: 19px; background: rgba(255,255,255,.06); min-width: 64px; text-align: center; }
.sb-clock { margin-left: auto; display: flex; flex-direction: column; justify-content: center; padding: 4px 12px; border-left: 1px solid var(--hairline); line-height: 1.05; }
.sb-clock b { font-size: 15px; }
.sb-clock i { font-style: normal; font-size: 9px; color: var(--ink-dim); letter-spacing: .2em; }

/* team sheets */
#sheetsToggle { position: absolute; top: 14px; left: 274px; padding: 8px 10px; }
#teamsheets { position: absolute; top: 58px; left: 14px; width: 330px; max-height: 46vh; overflow: auto; padding: 12px 14px; font-size: 13px; }
#teamsheets h3 { margin: 0 0 8px; font-family: var(--font-disp); font-weight: 600; font-size: 11px; letter-spacing: .18em; color: var(--ink-dim); }
.ts-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ts-cols ol { list-style: none; margin: 0; padding: 0; }
.ts-cols li { padding: 2.5px 4px; border-bottom: 1px solid rgba(255,255,255,.05); }
.ts-cols li b { color: var(--gold); margin-right: 6px; font-size: 11px; }
.ts-cols li i { font-style: normal; color: var(--arg); font-size: 10px; margin-right: 4px; }
.ts-head { font-family: var(--font-disp); letter-spacing: .1em; color: var(--tc, var(--ink)); border-bottom: 2px solid var(--tc, var(--ink)) !important; }

/* feed */
#feedbox { position: absolute; right: 14px; top: 14px; width: 300px; max-height: 52vh; display: flex; flex-direction: column; overflow: hidden; }
#feedbox h4 { margin: 0; padding: 9px 12px; font-family: var(--font-disp); font-size: 10px; letter-spacing: .22em; color: var(--ink-dim); border-bottom: 1px solid var(--hairline); }
#feedlist { list-style: none; margin: 0; padding: 6px 8px; overflow-y: auto; scrollbar-width: thin; }
.feed-item { display: grid; grid-template-columns: 34px 22px 1fr; gap: 4px; align-items: start; padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,.05); animation: feedin .35s ease-out; font-size: 12.5px; line-height: 1.35; }
@keyframes feedin { from { opacity: 0; transform: translateY(-6px); } }
.feed-item time { color: var(--gold); font-size: 11px; padding-top: 1px; }
.feed-item p { margin: 0; }
.feed-item.goal p b { color: #ffe9a8; }
.feed-item.save { background: rgba(120,190,255,.07); }
.feed-item.foul { background: rgba(255,160,80,.06); }
.feed-item.phase { background: rgba(255,255,255,.05); font-weight: 600; }
.feed-item.champ { background: linear-gradient(90deg, rgba(255,209,102,.16), transparent); }

/* goal banner + toasts */
#goalfx { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 40; }
#goalfxText {
  font-family: var(--font-disp); font-weight: 800; font-size: clamp(42px, 9vw, 110px);
  letter-spacing: .08em; color: #fff; text-shadow: 0 4px 40px rgba(0,0,0,.7), 0 0 90px rgba(255,220,130,.55);
  opacity: 0; transform: scale(.7);
}
#goalfx.flash #goalfxText { animation: goalslam 1.65s cubic-bezier(.16,1,.3,1) forwards; }
@keyframes goalslam { 0% { opacity: 0; transform: scale(1.9); letter-spacing: .4em; } 18% { opacity: 1; transform: scale(1); letter-spacing: .08em; } 82% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

#toasts { position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast { background: var(--glass); border: 1px solid var(--hairline); padding: 9px 18px; border-radius: 999px; font-size: 13px; opacity: 1; transition: all .4s; }
.toast.gone { opacity: 0; transform: translateY(8px); }

/* dock */
#dock { position: absolute; bottom: 54px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.dock-group { display: flex; gap: 6px; }
.dock-sep { width: 1px; align-self: stretch; background: var(--hairline); margin: 0 2px; }
.dock-btn {
  pointer-events: auto; cursor: pointer; user-select: none;
  background: rgba(255,255,255,.05); color: var(--ink);
  border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  font-family: var(--font-disp); font-size: 12px; letter-spacing: .04em;
  padding: 8px 11px; transition: background .15s, border-color .15s;
}
.dock-btn:hover { background: rgba(255,255,255,.13); }
.dock-btn.on { background: rgba(255,209,102,.16); border-color: rgba(255,209,102,.55); }
.preset-btn.on { background: rgba(140,200,255,.17); border-color: rgba(140,200,255,.6); }
.spd-btn { min-width: 38px; }

/* timeline */
#timelinebar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); width: min(720px, 92vw); padding: 10px 14px; display: flex; align-items: center; gap: 14px; }
#timeline { position: relative; flex: 1; display: flex; align-items: center; gap: 12px; }
#tlTrack { position: relative; flex: 1; height: 18px; border-radius: 999px; background: rgba(255,255,255,.08); cursor: pointer; touch-action: none; }
#tlPlayhead { position: absolute; top: 50%; left: 0; width: 4px; height: 22px; background: var(--gold); border-radius: 2px; transform: translate(-50%, -50%); box-shadow: 0 0 10px rgba(255,209,102,.8); pointer-events: none; }
.tlm { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); cursor: pointer; }
.tl-goal { background: var(--gold); width: 12px; height: 12px; z-index: 2; }
.tl-save { background: #7fd0ff; }
.tl-foul { background: #ffa050; }
.tl-halftime, .tl-fulltime { background: #cfd6e4; width: 7px; height: 7px; }
#tlLive { font-size: 11px; letter-spacing: .12em; color: var(--ink-dim); cursor: pointer; white-space: nowrap; padding: 4px 8px; border-radius: 6px; }
#tlLive.on { color: #7dffb0; }
#tlReviewChip { position: absolute; right: 0; top: -34px; font-size: 11px; background: rgba(127,208,255,.14); border: 1px solid rgba(127,208,255,.5); padding: 5px 10px; border-radius: 7px; white-space: nowrap; }
#tlMarkers { position: absolute; inset: 0; pointer-events: none; }
.tlm { pointer-events: auto; }

/* replay bars */
.lbar { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 45; transition: height .45s ease; pointer-events: none; }
#letterboxTop { top: 0; } #letterboxBot { bottom: 0; }
.lbar.shown { height: 56px; }
#replayBadge { position: fixed; top: 70px; right: 22px; z-index: 46; font-family: var(--font-disp); letter-spacing: .3em; font-size: 13px; color: #fff; background: rgba(180,40,40,.85); padding: 7px 14px; border-radius: 6px; animation: badgepulse 1.1s infinite alternate; }
@keyframes badgepulse { from { opacity: .75; } to { opacity: 1; } }

/* flyover titles */
#flytitle { position: fixed; inset: 0; display: grid; place-items: center; z-index: 44; pointer-events: none;
  font-family: var(--font-disp); font-weight: 300; font-size: clamp(26px, 5vw, 54px); letter-spacing: .42em; color: #fff; text-shadow: 0 2px 30px rgba(0,0,0,.75);
  opacity: 0; transition: opacity .7s ease; text-align: center; padding: 0 6vw; }
#flytitle.visible { opacity: 1; }

/* help dialog */
dialog#helpDlg { background: var(--navy); color: var(--ink); border: 1px solid var(--hairline); border-radius: 14px; max-width: 460px; padding: 22px 26px; }
dialog::backdrop { background: rgba(3,5,12,.66); }
#helpDlg h2 { font-family: var(--font-disp); font-weight: 600; letter-spacing: .06em; }
#helpDlg ul { padding-left: 18px; line-height: 1.65; font-size: 14px; }
#helpDlg kbd { background: rgba(255,255,255,.12); border: 1px solid var(--hairline); border-radius: 4px; padding: 1px 6px; font-family: monospace; }

/* ============================================================
   Matchday programme (pre-match interlude — panoramic journey)
   ============================================================ */
#programme { position: fixed; inset: 0; z-index: 60; overflow: hidden;
  background:
    radial-gradient(1200px 700px at 88% -10%, rgba(120,50,60,.32), transparent 60%),
    radial-gradient(1000px 800px at -10% 110%, rgba(60,90,140,.28), transparent 62%),
    linear-gradient(148deg, #060a16 0%, #0a1122 48%, #101a33 100%);
  transition: opacity .72s ease, visibility .72s;
}
#programme.leaving { opacity: 0; pointer-events: none; }
.prog-rail { display: flex; height: 100%; will-change: transform; cursor: grab; }
.prog-rail:active { cursor: grabbing; }
.prog-panel { flex: 0 0 100vw; height: 100%; display: grid; place-items: center; position: relative; }
.pp-inner { max-width: 520px; padding: 0 8vw; }
.pp-inner.center { text-align: center; }

.kicker { font-family: var(--font-disp); font-size: 11px; letter-spacing: .34em; color: var(--ink-dim); margin: 0 0 18px; }
.prog-panel h1 { font-family: var(--font-disp); font-weight: 250; font-size: clamp(44px, 7.4vw, 96px); line-height: .98; letter-spacing: .05em; margin: 0 0 10px; }
.prog-panel h1 em { font-style: normal; font-weight: 250; color: var(--gold); }
.prog-panel h2 { font-family: var(--font-disp); font-weight: 250; font-size: clamp(30px, 4.6vw, 54px); line-height: 1.05; letter-spacing: .03em; margin: 0 0 14px; }
.prog-panel .sub { font-family: var(--font-disp); font-weight: 250; letter-spacing: .5em; font-size: clamp(15px, 2.4vw, 24px); color: var(--ink); margin: 8px 0 26px; }
.prog-panel .sub i { font-style: normal; color: var(--ink-dim); }
.prog-panel .fine { color: var(--ink-dim); font-size: 13.5px; line-height: 1.7; max-width: 420px; }
.hairline { height: 1px; background: linear-gradient(90deg, var(--hairline), transparent); margin: 26px 0; }

.crest { position: absolute; right: 7vw; top: 50%; transform: translateY(-50%); display: grid; grid-template-columns: repeat(7, 13px); gap: 3px; opacity: .5; }
.crest i { width: 13px; height: 13px; background: rgba(242,239,230,.10); animation: crestpulse 3s ease-in-out infinite; animation-delay: calc(var(--d) * -0.22s); }
@keyframes crestpulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

.road-list { list-style: none; padding: 0; margin: 0; }
.road-list li { padding: 12px 0; border-bottom: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 4px; }
.road-list b { font-family: var(--font-disp); font-weight: 400; letter-spacing: .22em; }
.road-list span { color: var(--ink-dim); font-size: 13.5px; }

.kit-row { display: flex; gap: 40px; margin: 8px 0 4px; }
.kit-row figure { margin: 0; text-align: center; }
.kit-row figcaption { color: var(--ink-dim); font-size: 12px; letter-spacing: .14em; margin-top: 10px; }
.kit { display: block; width: 74px; height: 86px; clip-path: polygon(24% 0, 76% 0, 100% 16%, 84% 30%, 84% 100%, 16% 100%, 16% 30%, 0 16%); }
.kit.esp { background: repeating-linear-gradient(180deg, #c8372f 0 10px, #b02e28 10px 20px); border-top: 6px solid #f2c14e; }
.kit.arg { background: repeating-linear-gradient(90deg, #79B8DD 0 12px, #EDF2F7 12px 24px); }

.ground-stats { list-style: none; display: grid; grid-template-columns: repeat(4, auto); gap: 26px; padding: 0; margin: 6px 0 10px; }
.ground-stats b { display: block; font-family: var(--font-disp); font-weight: 250; font-size: 40px; color: var(--gold); }
.ground-stats span { color: var(--ink-dim); font-size: 11.5px; letter-spacing: .12em; }

.enter-btn {
  pointer-events: auto; cursor: pointer; margin-top: 20px;
  background: transparent; color: var(--gold);
  border: 1px solid rgba(255,209,102,.55); border-radius: 999px;
  font-family: var(--font-disp); letter-spacing: .22em; font-size: 14px;
  padding: 15px 36px; transition: all .25s;
}
.enter-btn:hover { background: rgba(255,209,102,.12); transform: translateY(-2px); }
.tip { margin-top: 14px; letter-spacing: .06em; }

.prog-nav { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; }
.prog-nav button { background: transparent; color: var(--ink); border: 1px solid var(--hairline); border-radius: 50%; width: 42px; height: 42px; font-size: 17px; cursor: pointer; }
.prog-nav button:hover { border-color: rgba(255,255,255,.4); }
#progDots { display: flex; gap: 8px; }
#progDots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.22); cursor: pointer; transition: all .25s; }
#progDots i.on { background: var(--gold); transform: scale(1.25); }
.prog-progress { position: absolute; bottom: 12px; left: 10vw; right: 10vw; height: 2px; background: rgba(255,255,255,.08); }
.prog-progress i { display: block; height: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); transition: transform .18s linear; }

/* body scroll lock while programme open handled by html/body overflow hidden already */

/* ============================================================
   Ceremonies
   ============================================================ */
#ceremony { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center;
  background: radial-gradient(900px 600px at 50% 115%, rgba(20,28,55,.88), rgba(5,8,16,.94)), rgba(5,8,16,.58);
  backdrop-filter: blur(3px); transition: opacity .5s; }
#ceremony.hidden { display: none !important; }
.cer-scene { text-align: center; max-width: 560px; padding: 30px 40px; opacity: 0; transform: translateY(26px) scale(.985); transition: all .6s cubic-bezier(.16,1,.3,1); }
.cer-scene.in { opacity: 1; transform: none; }
.cer-scene .kicker { color: var(--gold); }
.big-score { font-family: var(--font-disp); font-weight: 250; font-size: clamp(36px, 7vw, 76px); letter-spacing: .06em; margin: 0; }
.big-score em { font-style: normal; color: var(--gold); }
.big-score i { font-style: normal; color: var(--ink-dim); margin: 0 10px; }
.stat-row { display: grid; grid-template-columns: 60px 1fr 60px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.stat-row span { color: var(--ink-dim); letter-spacing: .12em; font-size: 11px; text-transform: uppercase; }
.stat-row b:first-child { color: var(--esp); }
.stat-row b:last-child { color: var(--arg); }
.trophy { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; margin: 14px 0; }
.trophy i { background: linear-gradient(#f5cf6b, #caa23a); display: block; }
.trophy i:nth-child(1) { width: 44px; height: 30px; clip-path: polygon(18% 0, 82% 0, 68% 100%, 32% 100%); order: 3; }
.trophy i:nth-child(2) { width: 74px; height: 54px; clip-path: polygon(24% 0, 76% 0, 100% 62%, 88% 100%, 12% 100%, 0 62%); order: 2; }
.trophy i:nth-child(3) { width: 26px; height: 12px; order: 1; border-radius: 50%; }
.pens-cols { display: flex; gap: 40px; justify-content: center; margin-top: 22px; }
.pens-cols figure { margin: 0; }
.pens-cols figcaption { font-family: var(--font-disp); letter-spacing: .2em; color: var(--tc); margin-bottom: 10px; font-size: 13px; }
.pens-cols div { display: flex; gap: 7px; }
.pens-cols i { width: 13px; height: 13px; border-radius: 3px; background: rgba(255,255,255,.12); }
.pens-cols i.ok { background: #7dffb0; box-shadow: 0 0 10px rgba(125,255,176,.5); }
.pens-cols i.no { background: #ff7d7d; }

/* ============================================================
   Responsive / mobile
   ============================================================ */
@media (max-width: 900px) {
  #feedbox { width: 240px; max-height: 38vh; }
  #sheetsToggle { left: 256px; }
}
@media (max-width: 720px) {
  #scorebug { left: 8px; top: 8px; min-width: 0; transform-origin: top left; transform: scale(.86); }
  #sheetsToggle { position: absolute; top: 8px; right: 8px; left: auto; }
  #teamsheets { position: fixed; inset: auto 8px 96px 8px; width: auto; max-height: 44vh; z-index: 30; }
  #feedbox { display: none; }
  #dock { bottom: 52px; flex-wrap: wrap; justify-content: center; width: calc(100vw - 20px); gap: 5px; padding: 6px; }
  .preset-btn { font-size: 10.5px; padding: 7px 8px; }
  #replayBtn { font-size: 11px; }
  #timelinebar { bottom: 8px; width: calc(100vw - 20px); }
  .prog-panel .pp-inner { padding: 0 9vw; }
  .crest { display: none; }
  #replayBadge { top: 12px; right: 12px; font-size: 10px; }
}
@media (max-width: 720px) and (orientation: landscape) {
  #feedbox { display: block; width: 190px; max-height: 30vh; font-size: 11px; }
}
