/* ————————————————————————————————————————————————
   EuroLeague Fantasy — Live league tracker.
   Visual world pinned to the official Fantasy Challenge app:
   orange→red gradient, deep navy, white rounded cards,
   jerseys with dorsal numbers on a wooden court.
   ———————————————————————————————————————————————— */

@font-face {
  font-family: 'Open Sans';
  src: url('fonts/OpenSans-400-latin.woff2') format('woff2');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2212;
}
@font-face {
  font-family: 'Open Sans';
  src: url('fonts/OpenSans-400-greek.woff2') format('woff2');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0370-03FF, U+1F00-1FFF;
}

:root {
  --orange-1: #ff8c1a;
  --orange-2: #f0421c;
  --navy: #211a4d;
  --navy-deep: #181140;
  --ink: #241d56;
  --gray: #82869e;
  --line: #e8e9f2;
  --ground: #f3f4f8;
  --green: #12a94f;
  --live: #e5231b;
  --cap: #e8ff3b;
  --wood-1: #eed9b4;
  --wood-2: #e9d0a4;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(30, 24, 82, 0.08);
  --font: 'Open Sans', 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  min-height: 100vh;
  caret-color: var(--orange-2);
}

::selection { background: var(--orange-2); color: #fff; }

:focus-visible { outline: 3px solid rgba(240, 66, 28, 0.55); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9cbdc; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }
* { scrollbar-width: thin; scrollbar-color: #c9cbdc transparent; }

.muted { color: var(--gray); font-size: 0.78rem; }

/* ———— topbar ———— */

.topbar {
  background:
    linear-gradient(112deg, var(--orange-1) 0%, var(--orange-2) 62%, #dc2f16 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(240, 66, 28, 0.35);
}

.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.1rem clamp(1rem, 3vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }

.brand-mark { width: 40px; height: 40px; color: #fff; flex: none; }

.brand-league {
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.round-pill {
  background: var(--navy);
  border-radius: 12px;
  overflow: hidden;
  text-align: center;
  min-width: 168px;
  box-shadow: 0 6px 16px rgba(24, 17, 64, 0.35);
  flex: none;
}

.rp-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.rp-top i { width: 1px; height: 0.9em; background: rgba(255, 255, 255, 0.35); }

.rp-bottom {
  background: rgba(255, 255, 255, 0.12);
  color: #ffd9a3;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.28rem 0.9rem;
}

.rp-bottom.is-live { background: var(--green); color: #fff; }
.rp-bottom.is-open { background: #1e8a44; color: #fff; }

/* ———— layout & cards ———— */

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.25rem clamp(0.75rem, 3vw, 1.5rem) 2.5rem;
  display: grid;
  gap: 1.1rem;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  min-width: 0; /* keep wide scroll-strips from inflating the wrap's grid track */
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 1.1rem 0.75rem;
  flex-wrap: wrap;
}

.card-head h2 {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.head-side { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }

.card-note, .pending-text { padding: 0.8rem 1.1rem 1rem; color: var(--gray); font-size: 0.82rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
}

.chip-live { background: var(--green); color: #fff; }
.chip-live .dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; }

/* segmented sort toggle (official-style navy-on-pill) */
.seg {
  display: inline-flex;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}

.seg-btn {
  border: 0;
  background: none;
  color: var(--gray);
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.26rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}

.seg-btn.is-active { background: var(--navy); color: #fff; }

.btn-primary, .btn-ghost {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 10px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  transition: filter 120ms ease-out, background 120ms ease-out;
}

.btn-primary { background: var(--navy); color: #fff; border: 1px solid var(--navy); }
.btn-primary:hover { filter: brightness(1.18); }

.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 0.32rem 0.8rem; }
.btn-ghost:hover { background: var(--ground); }

.btn-primary:active, .btn-ghost:active { transform: translateY(1px); }

/* ———— games strip ———— */

.games-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(168px, 1fr);
  gap: 0.7rem;
  padding: 0 1.1rem 0.65rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 1.1rem; /* snap after the strip's padding, not at the wall */
  /* Firefox: slim standard scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #dfe1ec transparent;
}

.games-strip:hover { scrollbar-color: #c9cbdc transparent; }

/* Chromium/Safari: real custom bar. The standard scrollbar-* props must be
   reset to auto here, otherwise the ::-webkit rules below are ignored. */
@supports selector(::-webkit-scrollbar) {
  .games-strip, .games-strip:hover { scrollbar-width: auto; scrollbar-color: auto; }

  .games-strip::-webkit-scrollbar { height: 4px; }
  .games-strip::-webkit-scrollbar-track { background: transparent; margin: 0 1.1rem; }

  .games-strip::-webkit-scrollbar-thumb {
    background: #dfe1ec;
    border-radius: 999px;
  }

  .games-strip:hover::-webkit-scrollbar-thumb { background: #c9cbdc; }
  .games-strip::-webkit-scrollbar-thumb:hover { background: var(--gray); }
}

.game {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.7rem 0.55rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.28rem 0.5rem;
  align-items: center;
  scroll-snap-align: start;
  background: #fff;
}

.game .team {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 0;
}

.game .team img { width: 20px; height: 20px; object-fit: contain; flex: none; }

.game .score { font-weight: 800; font-size: 0.9rem; text-align: right; font-variant-numeric: tabular-nums; }

.game .team.losing, .game .score.losing { color: var(--gray); font-weight: 600; }

.game .status {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gray);
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  padding-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.game.is-live .status { color: var(--live); }
.game.is-live .status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; }
.game.is-final .status { color: var(--ink); }

/* ———— token card ———— */

.token-body { padding: 0 1.1rem 1.1rem; max-width: 46rem; }

.steps { list-style-position: inside; display: grid; gap: 0.3rem; margin-bottom: 0.9rem; font-size: 0.88rem; color: var(--ink); }

.token-form { display: flex; gap: 0.6rem; }

.token-form input {
  flex: 1;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
}

.token-form input:focus { outline: none; border-color: var(--orange-2); background: #fff; }
.token-form input::placeholder { color: var(--gray); }

.token-status { margin-top: 0.55rem; font-size: 0.8rem; min-height: 1.2em; }
.token-status.ok { color: var(--green); font-weight: 700; }
.token-status.err { color: var(--live); font-weight: 700; }

/* ———— standings ———— */

.standings { list-style: none; }

.standings > li { border-top: 1px solid var(--line); }
.standings > li:first-child { border-top: 0; }

.srow {
  width: 100%;
  display: grid;
  grid-template-columns: 2rem 2.4rem 2.6rem minmax(0, 1fr) auto auto 1.4rem;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.1rem;
  background: none;
  border: 0;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.srow:hover { background: #f8f8fc; }

li.open .srow { background: #f4f3fb; }

.s-pos { font-size: 1.05rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

/* gold / silver / bronze discs for the podium spots */
.s-pos.medal {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  font-size: 0.92rem;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(30, 24, 82, 0.22);
}

.s-pos.medal-1 { background: linear-gradient(160deg, #ffd75e, #e6a817); color: #5b4300; }
.s-pos.medal-2 { background: linear-gradient(160deg, #eceef5, #b6bccd); color: #474c60; }
.s-pos.medal-3 { background: linear-gradient(160deg, #e8a56b, #b96a32); color: #4c2708; }

.s-delta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.s-delta.up { color: var(--green); }
.s-delta.down { color: var(--live); }
.s-delta.flat { color: var(--gray); }

.s-delta svg { width: 8px; height: 8px; }

.s-jersey { width: 34px; height: 40px; object-fit: contain; justify-self: center; }

.s-jersey-fallback {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ground);
  color: var(--gray);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  justify-self: center;
}

.s-names { min-width: 0; }

.s-team {
  font-weight: 800;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s-owner {
  color: var(--gray);
  font-size: 0.76rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.s-meta {
  display: block;
  color: var(--gray);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.you-chip {
  background: var(--cap);
  color: var(--navy);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 6px;
  padding: 0.06rem 0.4rem;
}

.s-pts { text-align: right; min-width: 3.6rem; }

.s-pts small {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gray);
  text-transform: uppercase;
}

.s-pts b { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.s-pts.total b { color: var(--navy); font-size: 1.08rem; }

.live-ink, .s-pts b.live-ink { color: var(--live); }

.s-chev { color: var(--gray); transition: transform 180ms ease-out; justify-self: end; }
.s-chev svg { width: 14px; height: 14px; display: block; }
li.open .s-chev { transform: rotate(180deg); }

/* value restamp: one damped settle when a number changes */
@keyframes restamp {
  0% { color: var(--live); transform: scale(1.12); }
  100% { transform: scale(1); }
}
.just-updated { display: inline-block; animation: restamp 600ms cubic-bezier(0.16, 1, 0.3, 1); }

/* ———— court view ———— */

/* Smooth open/close: grid-rows 0fr→1fr animates the height, inner slides in.
   Steady-state renders carry .reveal already; the click handler adds it a
   frame later so the expansion is animated. */
.courtview {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 340ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 260ms ease;
}

.courtview.reveal { grid-template-rows: 1fr; opacity: 1; }

.courtview-inner {
  overflow: hidden;
  min-height: 0;
  transform: translateY(-10px);
  transition: transform 340ms cubic-bezier(0.22, 1, 0.36, 1);
}

.courtview.reveal .courtview-inner { transform: none; }

.court-stage {
  background: linear-gradient(112deg, var(--orange-1) 0%, var(--orange-2) 78%);
  padding: clamp(0.75rem, 2.5vw, 1.5rem) clamp(0.5rem, 2vw, 1.25rem) 0;
}

.court-title {
  color: #fff;
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.court-title .rt {
  background: var(--navy);
  border-radius: 8px;
  padding: 0.2rem 0.7rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.court {
  position: relative;
  max-width: 660px;
  margin: 0 auto;
  aspect-ratio: 550 / 356;
  background: url('img/playing_field.png') center / 100% 100% no-repeat;
}

.unit {
  position: absolute;
  transform: translate(-50%, 0);
  width: 118px;
  display: grid;
  justify-items: center;
  z-index: 1;
}

.unit .jersey { position: relative; width: 80px; height: 80px; margin-bottom: -6px; z-index: 1; }

.unit .jersey img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 5px rgba(60, 30, 0, 0.25)); }

.unit .dorsal {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.unit .capbadge {
  position: absolute;
  right: -7px;
  top: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cap);
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.unit .hurt {
  position: absolute;
  left: -6px;
  top: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--live);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unit .hurt svg { width: 10px; height: 10px; }

/* the player card: navy name plate, green rule, two stacked-value cells.
   Sits ABOVE the jersey — the jersey bottom tucks behind the plate. */
.unit .pcard {
  position: relative;
  z-index: 2;
  width: 100%;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 3px 9px rgba(25, 15, 60, 0.35);
  display: grid;
}

.unit .plate {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.18rem 0.4rem;
  border-bottom: 2px solid #17c05b;
}

.unit .pl-pos { font-size: 0.62rem; font-weight: 700; opacity: 0.7; }

.unit .pl-name {
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 92px;
}

.unit .plate-info {
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.2rem 0.3rem;
}

.unit .plate-info i { width: 1px; height: 1.4em; background: var(--line); }

.unit .cell {
  display: grid;
  justify-items: center;
  line-height: 1.1;
  min-width: 0;
}

.unit .cell b {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.unit .cell b.live-ink { color: var(--live); }

.unit .cell small {
  font-size: 0.56rem;
  font-weight: 700;
  color: var(--gray);
  white-space: nowrap;
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* bench zone — official layout: 6th+coach column, bench 2×2 in a lighter panel */

.bench-stage {
  background: var(--navy);
  padding: 1.1rem clamp(0.75rem, 3vw, 1.75rem) 1.25rem;
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.bench-zones {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(1rem, 3.5vw, 2rem);
}

.bench-col {
  display: grid;
  gap: 0.7rem;
  justify-items: center;
  align-content: start;
  padding-top: 0.6rem; /* aligns its label with the panel's label */
}

.bench-col h3, .bench-panel h3 {
  color: #b9b4d8;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bench-panel {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 0.6rem 0.9rem 0.9rem;
  display: grid;
  gap: 0.55rem;
  justify-items: center;
}

.bench-grid {
  display: grid;
  grid-template-columns: repeat(2, 118px);
  gap: 0.9rem 0.8rem;
}

.bench-stage .unit { position: static; transform: none; width: 118px; }

.bench-note {
  color: #b9b4d8;
  font-size: 0.74rem;
  text-align: center;
}

.bench-total {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.bench-total b { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.bench-total b.live-ink { color: #ff9a8a; }

.court-msg {
  padding: 1.5rem 1rem 1.75rem;
  text-align: center;
  color: #fff;
  font-weight: 700;
  background: var(--navy);
  font-size: 0.85rem;
}

/* ———— loading skeletons ———— */

#skeletons { display: grid; gap: 1.1rem; }

.skel {
  display: block;
  background: linear-gradient(90deg, #eef0f6 25%, #f7f8fb 45%, #eef0f6 65%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: 8px;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.skel-title { width: 170px; height: 14px; }

.skel-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(168px, 1fr);
  gap: 0.7rem;
  padding: 0 1.1rem 1rem;
  overflow: hidden;
}

.skel-game { height: 88px; border-radius: 12px; }

.skel-rows { padding: 0 1.1rem 1rem; display: grid; gap: 0.6rem; }
.skel-row { height: 42px; border-radius: 10px; }

@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ———— footer ———— */

.foot-note { color: var(--gray); font-size: 0.78rem; max-width: 56rem; padding: 0 0.25rem; }

.problems { list-style: none; padding: 0 0.25rem; }
.problems li { color: var(--live); font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0; }

@media (prefers-reduced-motion: reduce) {
  .just-updated { animation: none; }
  .courtview, .courtview-inner { transition: none; }
  .s-chev { transition: none; }
}

/* ———— small screens ———— */

@media (max-width: 720px) {
  .topbar-inner { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .round-pill { align-self: stretch; }

  .srow { grid-template-columns: 1.6rem 2rem minmax(0, 1fr) auto 1.2rem; gap: 0.5rem; padding: 0.55rem 0.75rem; }
  .s-pos.medal { width: 1.5rem; height: 1.5rem; font-size: 0.8rem; }
  .s-jersey, .s-jersey-fallback { display: none; }
  .s-pts:not(.total) { display: none; }
  /* when sorting by round, the round column is the one that stays */
  .sort-round .s-pts:not(.total) { display: block; }
  .sort-round .s-pts.total { display: none; }
  .s-team { font-size: 0.92rem; }

  .court { aspect-ratio: 550 / 500; }
  .unit { width: 96px; }
  .unit .jersey { width: 60px; height: 60px; }
  .unit .dorsal { font-size: 1rem; }
  .unit .pl-name { max-width: 66px; font-size: 0.66rem; }
  .unit .cell b { font-size: 0.7rem; }
  .unit .cell small { font-size: 0.52rem; }

  .bench-zones { gap: 0.75rem; }
  .bench-panel { padding: 0.5rem 0.5rem 0.7rem; }
  .bench-grid { grid-template-columns: repeat(2, 96px); gap: 0.7rem 0.55rem; }
  .bench-stage .unit { width: 96px; }
}
