/*
  Match card for the Telegram Mini App.

  Built dark-first on top of a looping stadium plate. Everything is laid out
  with logical properties (inline-start/end, margin-inline) so switching the
  document to dir="rtl" for Arabic flips the whole card without a second
  stylesheet.
*/

:root {
  --brand: #FF073B;          /* BetJordan red, sampled from the logo */
  --brand-dim: #b8062c;
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, .72);
  --ink-3: rgba(255, 255, 255, .45);
  --panel: rgba(12, 14, 18, .62);
  --panel-line: rgba(255, 255, 255, .10);
  --home: #FF073B;
  --draw: #8b8f98;
  --away: #34d0ff;
  --win: #2fd07a;
  --loss: #ff4d5e;
  --pad: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #05060a;
  color: var(--ink);
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* ---------- background plate ---------- */

.stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; }

.bg-poster,
.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The video fades in only once it can actually play, so the first paint is
   always the poster rather than a black rectangle. */
.bg-video { opacity: 0; transition: opacity .6s ease; }
.bg-video.ready { opacity: 1; }

.bg-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5,6,10,.82) 0%, rgba(5,6,10,.55) 26%, rgba(5,6,10,.72) 62%, rgba(5,6,10,.95) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .bg-video { display: none; }
}

/* ---------- card ---------- */

.card {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--pad)
           calc(env(safe-area-inset-bottom, 0px) + 24px);
}

.loading { display: flex; justify-content: center; padding: 40vh 0; }

.spinner {
  width: 26px; height: 26px;
  border: 2px solid rgba(255,255,255,.18);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.league {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.kickoff { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ---------- teams ---------- */

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
  margin-bottom: 18px;
}

.team { text-align: center; min-width: 0; }

.crest {
  width: 62px; height: 62px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--panel-line);
  backdrop-filter: blur(6px);
}
.crest img { width: 42px; height: 42px; object-fit: contain; }

.tname {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.versus { display: grid; justify-items: center; gap: 2px; padding-top: 12px; }
.vs { font-size: 11px; letter-spacing: .14em; color: var(--ink-3); }
.pnum { font-size: 15px; font-weight: 700; }
.versus .pnum:first-child { color: var(--home); }
.versus .pnum:last-child { color: var(--away); }

/* ---------- probability bar ---------- */

.probs { margin-bottom: 18px; }

.probbar {
  display: flex;
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
}
.seg { display: block; height: 100%; transition: width .5s ease; }
.seg-home { background: var(--home); }
.seg-draw { background: var(--draw); }
.seg-away { background: var(--away); }

.problegend {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-3);
}
.problegend b { color: var(--ink); font-weight: 600; margin-inline-start: 3px; }

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-inline-end: 5px;
}
.dot-home { background: var(--home); }
.dot-draw { background: var(--draw); }
.dot-away { background: var(--away); }

/* ---------- pick ---------- */

.pick {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(14px);
}

.pick-label {
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.pick-value { font-size: 19px; font-weight: 700; line-height: 1.2; }

.conf { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

.conf-track {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
}
.conf-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dim), var(--brand));
  transition: width .5s ease;
}
.conf-num { font-size: 12px; font-weight: 600; color: var(--ink-2); }

.pick-extra { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.pick-extra div + div { margin-top: 4px; }

/* ---------- generic block ---------- */

.block {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(14px);
}

.block h2 {
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- comparison bars ---------- */

.bars { display: grid; gap: 11px; }

.bar-row { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 8px; }
.bar-val { font-size: 12px; font-weight: 600; }
.bar-val.h { color: var(--home); text-align: end; }
.bar-val.a { color: var(--away); text-align: start; }

.bar-mid { position: relative; }
.bar-name {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
  margin-bottom: 4px;
}
.bar-track { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.08); }
.bar-track i { display: block; height: 100%; transition: width .55s ease; }
.bar-track .h { background: var(--home); }
.bar-track .a { background: var(--away); }

/* ---------- form ---------- */

.formrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.formrow + .formrow { margin-top: 10px; }
.fname { font-size: 13px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; gap: 4px; flex-shrink: 0; }

.chip {
  width: 20px; height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #06070a;
}
.chip.W { background: var(--win); }
.chip.D { background: var(--draw); }
.chip.L { background: var(--loss); }

/* ---------- season stats ---------- */

.stats { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 10px; align-items: center; }
.stat-l { text-align: end; font-size: 14px; font-weight: 600; }
.stat-r { text-align: start; font-size: 14px; font-weight: 600; }
.stat-k {
  text-align: center;
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ---------- h2h ---------- */

.h2h-sum { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.h2h-list { display: grid; gap: 6px; }
.h2h-item { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-2); }
.h2h-item b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- cta ---------- */

.cta { text-align: center; padding-top: 6px; }

.brand { height: 26px; width: auto; margin-bottom: 14px; opacity: .96; }

.btn {
  display: block;
  padding: 15px 18px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(255, 7, 59, .32);
  transition: transform .12s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.985); box-shadow: 0 6px 18px rgba(255, 7, 59, .28); }
.btn[aria-disabled="true"] { background: rgba(255,255,255,.12); box-shadow: none; }

.disclaimer { margin: 12px 0 0; font-size: 10px; color: var(--ink-3); }

.error { text-align: center; padding: 30vh 0; color: var(--ink-3); font-size: 14px; }
