/* =====================================================================
   Components. Every value comes from tokens.css.
   Naming: .block, .block__element, .block--modifier
   ===================================================================== */

/* ---------- Button ---------- */
.btn {
  --btn-h: var(--control-md);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--btn-h); padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: var(--text-base); font-weight: var(--weight-semibold); line-height: 1; white-space: nowrap;
  text-decoration: none; user-select: none;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--sm { --btn-h: var(--control-sm); padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); gap: var(--space-1); }
.btn--lg { --btn-h: var(--control-lg); padding: 0 var(--space-6); font-size: var(--text-md); }
.btn--block { width: 100%; }
.btn--icon { width: var(--btn-h); padding: 0; }

.btn--primary {
  background-color: var(--accent); color: var(--on-accent);
  background-image: var(--grad-button);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn--primary:hover:not(:disabled) { background-color: var(--accent-hover); filter: brightness(1.08); }
.btn--secondary { background-color: var(--bg-surface); border-color: var(--border-default); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.btn--secondary:hover:not(:disabled) { background-color: var(--bg-hover); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn--danger { background-color: var(--danger-solid); color: #fff; }
.btn--danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn--danger-soft { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.btn--danger-soft:hover:not(:disabled) { border-color: var(--danger-text); }
.btn .icon { width: 18px; height: 18px; }
.btn--sm .icon { width: 16px; height: 16px; }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }
.field__hint { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-tertiary); }
.form { display: flex; flex-direction: column; gap: var(--space-5); }

.input, .select {
  height: var(--control-md); width: 100%; padding: 0 var(--space-3);
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--text-disabled); }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus-visible, .select:focus-visible, .input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.select--sm { height: var(--control-sm); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group__prefix { position: absolute; left: var(--space-3); color: var(--text-tertiary); pointer-events: none; }
.input-group .input { padding-left: var(--space-8); }
.select-wrap { position: relative; display: block; }
.select { appearance: none; -webkit-appearance: none; padding-right: var(--space-8); cursor: pointer; }
.select-wrap .icon { position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-tertiary); pointer-events: none; }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: var(--radius-full); background: linear-gradient(90deg, var(--g-600), var(--g-400) var(--fill, 0%), var(--bg-inset) var(--fill, 0%)); }
.range::-moz-range-track { height: 6px; border-radius: var(--radius-full); background: var(--bg-inset); }
.range::-moz-range-progress { height: 6px; border-radius: var(--radius-full); background: var(--grad-accent); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: var(--bg-raised); border: 2px solid var(--accent); box-shadow: var(--shadow-sm); transition: transform var(--dur-fast) var(--ease-out); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-raised); border: 2px solid var(--accent); }
.range:hover::-webkit-slider-thumb { transform: scale(1.1); }
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1); background: var(--bg-inset); border-radius: var(--radius-md); }
.segmented__item { height: calc(var(--control-md) - 8px); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-sm); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.segmented__item:hover { color: var(--text-primary); }
.segmented__item[aria-pressed="true"] { background: var(--bg-raised); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.segmented--block { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); width: 100%; }

/* ---------- Option tiles (single choice with description) ---------- */
.tiles { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: var(--space-1); text-align: left;
  padding: var(--space-3) var(--space-4); padding-right: var(--space-8);
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.tile:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.tile__title { font-weight: var(--weight-semibold); }
.tile__desc { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-tertiary); }
.tile__check { position: absolute; top: var(--space-3); right: var(--space-3); width: 16px; height: 16px; color: var(--accent-text); opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-out); }
.tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-subtle); }
.tile[aria-pressed="true"] .tile__check { opacity: 1; transform: none; }

/* ---------- Card ---------- */
.card {
  background: linear-gradient(180deg, var(--card-sheen), transparent 140px) var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--card-radius);
  box-shadow: var(--shadow-xs), inset 0 1px 0 var(--border-highlight);
  padding: var(--card-pad); min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card--flush > .card__header { padding: var(--card-pad) var(--card-pad) 0; }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); min-height: var(--control-sm); }
.card__title { font-size: var(--text-md); line-height: var(--leading-md); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.card__subtitle { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-tertiary); }
.card__footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }
.card__footer > .btn--ghost:first-child { margin-right: auto; }   /* a quiet link-like action sits on the left */
.card--accent { border-color: var(--accent-subtle-border); background: linear-gradient(180deg, var(--accent-subtle), var(--bg-surface) 70%); }

/* ---------- Stat (KPI) ---------- */
.stat { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.stat__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.stat__icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--bg-subtle); color: var(--text-secondary); }
.stat__icon--accent { background: var(--accent-subtle); color: var(--accent-text); }
.stat__icon--warning { background: var(--warning-bg); color: var(--warning-text); }
.stat__icon--info { background: var(--info-bg); color: var(--info-text); }
.stat__icon--danger { background: var(--danger-bg); color: var(--danger-text); }
.stat__value { font-family: var(--font-display); font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-bold); letter-spacing: var(--tracking-snug); font-variant-numeric: tabular-nums; margin-top: var(--space-2); }
.stat__meta { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Flag (from js/flags.js) ---------- */
.flag { display: inline-block; width: 18px; height: 12px; flex-shrink: 0; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18); vertical-align: -1px; }
.flag__svg { display: block; width: 100%; height: 100%; }

/* ---------- Badge & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-full); border: 1px solid var(--border-default); background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge .icon { width: 12px; height: 12px; stroke-width: 2.25; }
.badge--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.badge--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.badge--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.badge--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.badge--sm { height: 18px; padding: 0 var(--space-2); font-size: var(--text-xs); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pos { display: inline-grid; place-items: center; min-width: 30px; height: 20px; padding: 0 var(--space-1); border-radius: var(--radius-xs); font-size: 11px; font-weight: var(--weight-bold); letter-spacing: 0.02em; }
.pos--GK { background: var(--warning-bg); color: var(--warning-text); }
.pos--DF { background: var(--info-bg); color: var(--info-text); }
.pos--MF { background: var(--success-bg); color: var(--success-text); }
.pos--FW { background: var(--danger-bg); color: var(--danger-text); }

.result { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: var(--radius-xs); font-size: 11px; font-weight: var(--weight-bold); }
.result--W { background: var(--success-solid); color: #fff; }
.result--D { background: var(--warning-solid); color: #3b2405; }
.result--L { background: var(--danger-solid); color: #fff; }
.results { display: inline-flex; gap: 3px; }

.skill { display: inline-grid; place-items: center; width: 30px; height: 22px; border-radius: var(--radius-xs); font-size: var(--text-sm); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.skill--1 { color: var(--text-disabled); }
.skill--2 { color: var(--text-secondary); }
.skill--3 { color: var(--success-text); background: var(--success-bg); }
.skill--4 { color: var(--warning-text); background: var(--warning-bg); font-weight: var(--weight-bold); }

.status-icon { display: inline-flex; align-items: center; gap: 2px; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.status-icon .icon { width: 14px; height: 14px; stroke-width: 2.25; }

/* ---------- Meter & progress ---------- */
.meter { height: 6px; border-radius: var(--radius-full); background: var(--bg-inset); overflow: hidden; }
.meter__fill { display: block; height: 100%; border-radius: inherit; background: var(--grad-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.meter--info .meter__fill { background: var(--grad-info); }
.meter--warning .meter__fill { background: var(--grad-warning); }
.meter--danger .meter__fill { background: var(--grad-danger); }
.meter--muted .meter__fill { background: var(--border-strong); }
.meter--lg { height: 8px; }
.meter-row { display: grid; grid-template-columns: minmax(96px, 128px) 1fr 40px; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.meter-row__value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); font-weight: var(--weight-medium); }

.versus { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: var(--space-3); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.versus__label { grid-column: 1 / -1; display: flex; justify-content: center; margin-bottom: calc(var(--space-2) * -1); }
.versus__bar { display: flex; gap: 2px; height: 6px; }
.versus__bar span { display: block; height: 100%; border-radius: var(--radius-full); }
.versus__bar .h { background: var(--home); }
.versus__bar .a { background: var(--away); }
.versus__val:last-child { text-align: right; }
.versus__val { font-weight: var(--weight-semibold); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table th, .table td { padding: 0 var(--space-3); text-align: left; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: var(--card-pad); }
.table th:last-child, .table td:last-child { padding-right: var(--card-pad); }
.table th { height: 36px; font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-tertiary); border-bottom: 1px solid var(--border-default); background: var(--bg-surface); position: sticky; top: 0; z-index: 1; }
.table td { height: 44px; border-bottom: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
.table tbody tr:not(.standings__zone):not(.table__group):hover { background: var(--bg-hover); }   /* group headers aren't rows you can pick */
.table .num { text-align: right; }
.table .center { text-align: center; }
.table .cluster { flex-wrap: nowrap; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-me td { background: var(--accent-subtle); }
.table tr.is-me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table--compact td { height: 36px; }
.table--sticky-first th:first-child, .table--sticky-first td:first-child { position: sticky; left: 0; z-index: 2; background: var(--bg-surface); }
.table--sticky-first tbody tr:not(.standings__zone):not(.table__group):hover td:first-child { background: var(--bg-raised); }
.th-sort { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.th-sort:hover { color: var(--text-primary); }
.th-sort[aria-sort] { color: var(--text-primary); }
.th-sort .icon { width: 12px; height: 12px; stroke-width: 2.5; }
.num .th-sort { flex-direction: row-reverse; }

/* ---------- Feed (news) ---------- */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed__item { display: grid; grid-template-columns: 28px 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); }
.feed__item:first-child { padding-top: 0; }
.feed__item:last-child { border-bottom: 0; padding-bottom: 0; }
.feed__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--bg-subtle); color: var(--text-tertiary); }
.feed__icon .icon { width: 16px; height: 16px; }
.feed__icon--success { background: var(--success-bg); color: var(--success-text); }
.feed__icon--warning { background: var(--warning-bg); color: var(--warning-text); }
.feed__icon--danger { background: var(--danger-bg); color: var(--danger-text); }
.feed__icon--info { background: var(--info-bg); color: var(--info-text); }
.feed__text { font-size: var(--text-sm); line-height: var(--leading-sm); }
.feed__meta { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-tertiary); margin-top: 2px; }

/* ---------- Definition list rows ---------- */
.kv { display: flex; flex-direction: column; }
.kv__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 40px; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); }
.kv__row:last-child { border-bottom: 0; }
.kv__key { color: var(--text-secondary); }
.kv__val { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }

/* ---------- Action list (upgrade rows) ---------- */
.action-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); }
.action-row:first-child { padding-top: 0; }
.action-row:last-child { border-bottom: 0; padding-bottom: 0; }
.action-row__title { font-weight: var(--weight-semibold); }
.action-row__desc { font-size: var(--text-sm); color: var(--text-tertiary); }

/* ---------- Crest ---------- */
.crest { --size: 32px; display: inline-block; width: var(--size); height: calc(var(--size) * 1.2); flex-shrink: 0; }
.crest__svg .ink, .face svg .ink { stroke: var(--iso-ink); }   /* crests and faces share the illustrations' ink */
.crest__svg { display: block; width: 100%; height: 100%; overflow: visible; }
.crest--xs { --size: 20px; }
.crest--sm { --size: 24px; }
.crest--md { --size: 32px; }
.crest--lg { --size: 48px; }
.crest--xl { --size: 64px; }
.team { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; font-weight: var(--weight-medium); }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-12) var(--space-6); }
.empty__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bg-subtle); color: var(--text-tertiary); margin-bottom: var(--space-2); }
.empty__title { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.empty__text { color: var(--text-secondary); max-width: 360px; }
.empty .btn { margin-top: var(--space-3); }

/* ---------- Callout ---------- */
.callout { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--bg-subtle); font-size: var(--text-sm); color: var(--text-secondary); }
.callout .icon { width: 18px; height: 18px; margin-top: 1px; }
.callout--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.callout--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.callout--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.callout--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; align-items: center; justify-content: center; padding: var(--space-4); background: var(--bg-overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade-in var(--dur-base) var(--ease-out); }
.modal { width: min(560px, 100%); max-height: calc(100vh - var(--space-8)); overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl), inset 0 1px 0 var(--border-highlight); padding: var(--space-6); animation: modal-in var(--dur-slow) var(--ease-out); }
.modal--sm { width: min(440px, 100%); }
.modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.modal__title { font-size: var(--text-lg); line-height: var(--leading-lg); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.modal__desc { color: var(--text-secondary); margin-top: var(--space-1); }
.modal__header .btn--icon { margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 0; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6); }
@media (max-width: 639px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 88vh; padding: var(--space-5); animation-name: sheet-in; }
  .modal__footer { flex-direction: column-reverse; }
  .modal__footer .btn { width: 100%; }
}

/* ---------- Toast ---------- */
.toast-region { position: fixed; bottom: calc(var(--tabbar-height) + var(--space-6) + env(safe-area-inset-bottom)); left: 50%; z-index: var(--z-toast); display: grid; justify-items: center; width: max-content; max-width: calc(100vw - 2 * var(--space-4)); transform: translateX(-50%); pointer-events: none; }   /* feedback rises just above the tab bar, like a phone's banner */
.toast { display: flex; align-items: center; gap: var(--space-3); max-width: 100%; padding: 6px var(--space-4) 6px 6px; border-radius: var(--radius-full); background: color-mix(in srgb, var(--bg-raised) 84%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); border: 1px solid var(--border-subtle); color: var(--text-primary); box-shadow: var(--shadow-lg); font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1.3; animation: toast-in 460ms cubic-bezier(0.2, 1.35, 0.4, 1); pointer-events: auto; cursor: pointer; touch-action: none; }
.toast__icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-full); background: var(--success-bg); color: var(--success-text); }
.toast--danger .toast__icon { background: var(--danger-bg); color: var(--danger-text); }
.toast .icon { width: 16px; height: 16px; }
.toast.is-leaving { animation: toast-out 220ms var(--ease-in) forwards; }

/* ---------- Pick list (slot picker rows) ---------- */
.pick { display: grid; grid-template-columns: 1fr 112px; align-items: center; gap: var(--space-4); width: 100%; padding: var(--space-2) var(--space-3); min-height: 52px; border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; text-align: left; transition: background-color var(--dur-fast) var(--ease-out); }
.pick:hover { background: var(--bg-hover); }
.pick[aria-current="true"] { background: var(--accent-subtle); border-color: var(--accent-subtle-border); }

/* ---------- Tooltip ----------
   Any element with data-tip, on hover or keyboard focus. One floating element placed by
   js/tooltip.js sits above everything, so scrolling tables, cards and panels never clip it. */
th[data-tip], .status-icon[data-tip] { cursor: help; }
.tooltip { position: fixed; top: 0; left: 0; z-index: var(--z-toast); width: max-content; max-width: min(260px, calc(100vw - 16px)); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); background: var(--bg-inverse); color: var(--text-inverse); box-shadow: var(--shadow-md); font-size: var(--text-xs); line-height: var(--leading-xs); font-weight: var(--weight-medium); pointer-events: none; opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.tooltip.is-on { opacity: 1; }

/* ---------- Bell + popover ---------- */
.bell { position: relative; }

/* ---------- Tabs (sub-pages of a section) ---------- */
.tabs { display: flex; gap: var(--space-1); flex-basis: 100%; margin-top: var(--space-1); border-bottom: 1px solid var(--border-default); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs__item { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-3); border: 0; background: none; color: var(--text-secondary); font-weight: var(--weight-medium); white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.tabs__item:hover { color: var(--text-primary); background: var(--bg-hover); }
.tabs__item[aria-current="page"] { color: var(--text-primary); font-weight: var(--weight-semibold); }
.tabs__item[aria-current="page"]::after { content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
/* Page tabs (a section's pages): first on the page, flush under the title bar and sticky like a
   native segmented header, so switching tab never moves them; only the content below changes. */
.tabs--page { position: sticky; top: var(--topbar-height); z-index: calc(var(--z-sticky) - 1); margin: calc(-1 * var(--content-top)) calc(-1 * var(--page-pad)) 0; padding: 0 max(0px, calc(var(--page-pad) - var(--space-3))); background: var(--bg-topbar); backdrop-filter: var(--topbar-blur); -webkit-backdrop-filter: var(--topbar-blur); border-bottom-color: var(--border-subtle); scroll-padding-inline: var(--page-pad); }
.content > .tabs--page { animation: none; }
.tabs--page .activity-dot--inline { align-self: flex-start; margin: 14px 0 0 calc(-1 * var(--space-1)); }
.tabs--page .tabs__item { height: 48px; border-radius: 0; }
.tabs--page .tabs__item:hover { background: none; }
.tabs--page .tabs__item .icon { color: var(--text-tertiary); }
.tabs--page .tabs__item[aria-current="page"] .icon { color: var(--accent-text); }

.tabs--page .tabs__item[aria-current="page"]::after { height: 3px; border-radius: 3px 3px 0 0; }
@media (max-width: 639px) {
  .tabs--page { gap: 0; }
  .tabs--page .tabs__item { flex: 1 0 auto; justify-content: center; height: 44px; padding: 0 var(--space-4); font-size: var(--text-base); font-weight: var(--weight-medium); }   /* quiet and roomy; a row that runs past the screen fades at the edge */
  .tabs--page .tabs__item[aria-current="page"] { font-weight: var(--weight-semibold); }
  .tabs--page .tabs__item[aria-current="page"]::after { height: 2px; left: var(--space-4); right: var(--space-4); }
  .tabs--page .activity-dot--inline { margin-top: 12px; }
}
/* When the tabs run past the screen, the row fades at the edge that has more */
.tabs--page.has-more-right { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent); }
.tabs--page.has-more-left { -webkit-mask-image: linear-gradient(90deg, transparent, #000 56px); mask-image: linear-gradient(90deg, transparent, #000 56px); }
.tabs--page.has-more-left.has-more-right { -webkit-mask-image: linear-gradient(90deg, transparent, #000 56px, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(90deg, transparent, #000 56px, #000 calc(100% - 56px), transparent); }
/* Swiping between page tabs: the page under the tabs follows the finger, settles, and the next tab slides in. */
.content.is-swiping, .content.swipe-in--next, .content.swipe-in--prev { overflow-x: clip; }
.content.is-swiping > :not(.tabs--page) { transform: translateX(var(--swipe-x, 0)); }
.content.is-settling > :not(.tabs--page) { transition: transform 200ms var(--ease-out); }
.content.swipe-in--next > :not(.tabs--page) { animation: swipe-in-next 240ms var(--ease-out) both; }
.content.swipe-in--prev > :not(.tabs--page) { animation: swipe-in-prev 240ms var(--ease-out) both; }
@keyframes swipe-in-next { from { transform: translateX(24%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes swipe-in-prev { from { transform: translateX(-24%); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .content.swipe-in--next > *, .content.swipe-in--prev > * { animation: none; } }

/* ---------- Member rows (a person in a list with a per-row control) ---------- */
.members { display: flex; flex-direction: column; }
.member { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.member:first-child { padding-top: 0; }
.member:last-child { border-bottom: 0; padding-bottom: 0; }
.member__main { min-width: 0; }
.member__name { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-weight: var(--weight-semibold); }
.member__link { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; border-radius: var(--radius-xs); }
.member__link:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.member__meta { margin-top: 2px; font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-tertiary); }
.member .select-wrap { width: 168px; }
@media (max-width: 479px) { .member { grid-template-columns: minmax(0, 1fr); } .member .select-wrap { width: 100%; } }

/* ---------- Animations ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(140%) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(120%) scale(0.96); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.is-leaving { animation-duration: 1ms; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Assistant chat ---------- */
.chat-overlay { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--bg-overlay); animation: fade-in var(--dur-base) var(--ease-out); }
.chat { position: fixed; top: var(--space-3); right: var(--space-3); bottom: var(--space-3); z-index: calc(var(--z-overlay) + 1); width: min(420px, calc(100vw - 2 * var(--space-3))); display: flex; flex-direction: column; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl), inset 0 1px 0 var(--border-highlight); overflow: hidden; animation: chat-in var(--dur-slow) var(--ease-out); }
@keyframes chat-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.chat__header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.chat__header .btn { margin-left: auto; }
.chat__header .btn ~ .btn { margin-left: calc(var(--space-3) * -1 + var(--space-1)); }   /* the header's buttons sit together on the right */
.chat__thread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-5) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); background: var(--bg-canvas); }
.chat__empty { margin: auto; color: var(--text-tertiary); font-size: var(--text-sm); text-align: center; }
.chat-day { display: flex; justify-content: center; margin: var(--space-2) 0 calc(-1 * var(--space-2)); }
.chat-day span { padding: 2px var(--space-3); border-radius: var(--radius-full); background: var(--bg-subtle); color: var(--text-tertiary); font-size: var(--text-xs); line-height: var(--leading-xs); }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); max-width: 88%; }
.chat-bubble { display: flex; flex-direction: column; overflow: hidden; border-radius: 20px 20px 20px 6px; background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--text-primary); font-size: var(--text-sm); line-height: var(--leading-sm); box-shadow: var(--shadow-xs); }
.chat-bubble__body { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3) var(--space-4); }
.chat-bubble__body > p { margin: 0; }
.chat-bubble__lead { color: var(--text-secondary); }
.chat-bubble__title { font-weight: var(--weight-semibold); }
.chat-bubble__text { color: var(--text-primary); }
.chat-bubble__title + .chat-bubble__text { margin-top: calc(-1 * var(--space-1) + 2px); }   /* the title and its text read as one block */
/* the action is the bubble's own footer: one shape, full width, a 44px tap target */
.chat-bubble__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3) 0 var(--space-4); border: 0; border-top: 1px solid var(--border-subtle); background: none; color: var(--accent-text); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold); text-align: left; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out); }
.chat-bubble__foot:hover { background: var(--bg-hover); }
.chat-line { flex-direction: row; align-items: center; gap: var(--space-2); max-width: 100%; min-height: 44px; padding: 0 var(--space-3); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); text-align: left; cursor: pointer; }   /* news in passing: one line and a chevron */
.chat-line > .icon { margin-left: auto; color: var(--text-tertiary); flex: none; }
.chat-line:hover { background: var(--bg-hover); }
.chat-line .crest { flex: none; }
.chat-bubble__foot:active { background: var(--bg-inset); }
.chat-bubble__foot.is-closed { justify-content: flex-start; gap: var(--space-2); color: var(--text-tertiary); font-weight: var(--weight-medium); cursor: default; }
.chat-bubble__foot.is-closed:hover { background: none; }
.chat-bubble__flag { display: inline-block; margin-right: var(--space-2); vertical-align: 1px; padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--warning-bg); color: var(--warning-text); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.chat-msg--high .chat-bubble { border-color: var(--warning-border); box-shadow: inset 3px 0 0 var(--warning-solid), var(--shadow-xs); }
.chat__quick { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-subtle); overflow-x: auto; scrollbar-width: none; }
.chat-quick { flex-shrink: 0; height: var(--control-sm); padding: 0 var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-full); background: var(--bg-surface); color: var(--text-primary); font-size: var(--text-sm); white-space: nowrap; transition: background-color var(--dur-fast) var(--ease-out); }
.chat-quick:hover { background: var(--bg-hover); }
.chat-avatar { display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: 0.04em; }
/* Drawn portraits (js/faces.js): a round frame; the SVG brings its own backdrop */
.face { display: inline-block; flex-shrink: 0; width: 36px; height: 36px; border-radius: var(--radius-full); overflow: hidden; box-shadow: 0 0 0 1px var(--border-subtle); }
.face > svg { display: block; width: 100%; height: 100%; }
.face--sm { width: 28px; height: 28px; }
.face--lg { width: 48px; height: 48px; }
.face--xl { width: 72px; height: 72px; }
/* A face that shows his mood: a ring in the mood's colour around it (none when content), the
   expression inside says the rest. */
.face--mood { box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--face-ring, transparent); }
.face--calm { box-shadow: 0 0 0 1px var(--border-subtle); }
.face--joy, .face--happy { --face-ring: var(--success-solid); }
.face--sad { --face-ring: var(--warning-solid); }
.face--angry { --face-ring: var(--danger-solid); }
.player-head { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
/* Stat tiles: a row of small numbers with a label and a note (player season stats) */
.stat-tiles { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.stat-tile { flex: 1 1 0; display: grid; gap: 2px; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--bg-inset); min-width: 0; }
.stat-tile__label { font-size: var(--text-xs); color: var(--text-tertiary); }
.stat-tile__value { font-size: var(--text-lg); line-height: var(--leading-lg); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.stat-tile__sub { font-size: var(--text-xs); color: var(--text-secondary); line-height: var(--leading-xs); }
.stat-tile { min-width: 72px; }   /* three in a row on a phone, four on wider screens */
/* new messages type in one after another; the typing dots stay until the last one has arrived */
.chat-msg.is-new { animation: msg-in var(--dur-slow) var(--ease-out) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; border-radius: 20px 20px 20px 6px; background: var(--bg-surface); border: 1px solid var(--border-subtle); overflow: hidden; animation-name: typing-life; animation-timing-function: linear; animation-fill-mode: forwards; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); animation: typing-dot 1s var(--ease-in-out) infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: 0.4; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes typing-life { 0%, 97% { opacity: 1; max-height: 40px; } 100% { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; } }
/* Conversation: rows with one avatar per run of messages, a "new" divider, the typing row, and the jump pill */
.chat-row { display: flex; align-items: flex-start; gap: var(--space-2); }
.chat-row--cont { margin-top: calc(-1 * var(--space-5) + var(--space-2)); }   /* 8px inside a run, 20px between runs */
.chat-row__avatar { flex: 0 0 28px; }
.chat-row .chat-msg { flex: 1; min-width: 0; max-width: 100%; align-items: stretch; }
.chat-row--cont .chat-bubble { border-top-left-radius: 6px; }
.chat-row.is-new { animation: msg-in var(--dur-slow) var(--ease-out) both; }
.chat-row--typing .chat-typing { animation: msg-in var(--dur-base) var(--ease-out) both; }
.chat-new { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-2) 0 0; color: var(--accent-text); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.chat-new::before, .chat-new::after { content: ""; flex: 1; height: 1px; background: var(--accent); opacity: 0.4; }
.chat__status { color: var(--text-tertiary); }
.chat__status.is-typing { color: var(--accent-text); font-weight: var(--weight-medium); }
.chat__jump { position: absolute; left: 50%; bottom: calc(var(--control-sm) + var(--space-8) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2; display: inline-flex; align-items: center; gap: var(--space-1); height: var(--control-sm); padding: 0 var(--space-3); border: 1px solid var(--accent-subtle-border); border-radius: var(--radius-full); background: var(--bg-raised); color: var(--accent-text); font-size: var(--text-xs); font-weight: var(--weight-semibold); box-shadow: var(--shadow-md); cursor: pointer; }
.chat__jump[hidden] { display: none; }
.chat__quick.is-waiting .chat-quick:not(.chat-quick--skip) { opacity: 0.45; }
.chat-quick--skip { border-color: var(--accent-subtle-border); color: var(--accent-text); font-weight: var(--weight-semibold); }
.chat-quick[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .chat-msg.is-new, .chat-row.is-new { animation: none; } .chat-typing { display: none; } }
@media (max-width: 639px) { .chat { inset: 0; width: auto; border-radius: 0; border: 0; } }
/* dashboard preview of the chat */

/* Form: the last five results as dots (win, draw, loss) */
.form-dots { display: inline-flex; align-items: center; gap: 4px; }
.form-dot { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); }
.form-dot--W { background: var(--success-solid); }
.form-dot--L { background: var(--danger-solid); }

/* ---------- End-of-season moment ---------- */
.modal--finale { max-width: 760px; padding: 0; overflow-x: hidden; overflow-y: auto; background: var(--moment-bg); color: var(--moment-text); border-color: var(--moment-line); }
.finale { position: relative; display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-10) var(--space-8) var(--space-8); }
.finale__hero { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); }
.finale__cup { width: 128px; height: 128px; filter: drop-shadow(0 0 28px var(--moment-glow)); animation: finale-rise 900ms var(--ease-out) both, finale-float 4s 900ms ease-in-out infinite alternate; }
.finale__crest .crest__svg { width: 88px; height: 106px; animation: finale-rise 900ms var(--ease-out) both; }
.finale__eyebrow { margin-top: var(--space-3); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--moment-muted); }
.finale__headline { margin: 0; font-family: var(--font-display); font-size: clamp(44px, 9vw, 76px); line-height: 1; font-weight: var(--weight-bold); letter-spacing: 0.02em; text-transform: uppercase; animation: finale-pop 700ms 250ms var(--ease-out) both; }
.finale--title .finale__headline { background: linear-gradient(180deg, var(--trophy-hi), var(--trophy-lo)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 12px var(--moment-glow)); }
.finale--down .finale__headline { color: var(--moment-muted); }
.finale__sub { max-width: 520px; margin: 0; color: var(--moment-muted); font-size: var(--text-md); line-height: var(--leading-md); animation: finale-rise 600ms 450ms var(--ease-out) both; }
.finale__stats { display: flex; flex-wrap: wrap; gap: 1px; margin: 0 calc(-1 * var(--space-8)); border-top: 1px solid var(--moment-line); border-bottom: 1px solid var(--moment-line); overflow: hidden; background: var(--moment-line); animation: finale-rise 600ms 600ms var(--ease-out) both; }
.finale__stat { flex: 1 1 96px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-4) var(--space-2); background: var(--moment-panel); text-align: center; }
.finale__value { font-family: var(--font-display); font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.finale__label { font-size: var(--text-xs); color: var(--moment-muted); }
.finale__podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: var(--space-3); animation: finale-rise 600ms 750ms var(--ease-out) both; }
.podium { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0; text-align: center; }
.podium__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.podium__pts { font-size: var(--text-xs); color: var(--moment-muted); }
.podium__step { display: grid; place-items: center; width: 100%; margin-top: var(--space-2); border-radius: var(--radius-md) var(--radius-md) 0 0; background: rgba(255, 255, 255, 0.07); font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--moment-muted); }
.podium--1 .podium__step { height: 72px; background: linear-gradient(180deg, var(--trophy-hi), var(--trophy-lo)); color: var(--trophy-base); }
.podium--2 .podium__step { height: 52px; }
.podium--3 .podium__step { height: 38px; }
.podium.is-me .podium__name { color: var(--trophy-hi); }
.finale__story { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); animation: finale-rise 600ms 900ms var(--ease-out) both; }
.finale__story li { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--moment-muted); }
.finale__story b { color: var(--moment-text); }
.finale__story .icon { flex-shrink: 0; color: var(--trophy-hi); }
.finale__changes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--moment-line); }
.finale__changes .eyebrow { margin-bottom: var(--space-2); color: var(--moment-muted); }
.finale__changes .kv__row { border-color: var(--moment-line); }
.finale__changes .kv__key, .finale__changes .field__hint, .finale__changes .text-tertiary { color: var(--moment-muted); }
.finale__foot { position: sticky; bottom: calc(-1 * var(--space-8)); z-index: 3; display: flex; justify-content: center; margin: 0 calc(-1 * var(--space-8)) calc(-1 * var(--space-8)); padding: var(--space-8) var(--space-8) var(--space-6); background: var(--moment-foot); }   /* always in view: no scrolling to start the next season */
.finale__foot .btn { min-width: 240px; }
.finale__confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.finale__confetti i { position: absolute; top: -20px; width: 8px; height: 13px; border-radius: 2px; opacity: 0.9; animation: confetti-fall linear 1 both; }
@keyframes confetti-fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(980px) rotate(var(--spin)); opacity: 0.2; } }
@keyframes finale-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes finale-pop { 0% { opacity: 0; transform: scale(0.7); } 60% { opacity: 1; transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes finale-float { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@media (max-width: 639px) {
  .modal--finale { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; overflow-y: auto; }
  .finale { padding: var(--space-8) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); gap: var(--space-5); }
  .finale__stats { margin: 0 calc(-1 * var(--space-5)); }
  .finale__changes { grid-template-columns: minmax(0, 1fr); }
  .finale__foot { bottom: calc(-1 * (var(--space-6) + env(safe-area-inset-bottom))); margin: 0 calc(-1 * var(--space-5)) calc(-1 * (var(--space-6) + env(safe-area-inset-bottom))); padding: var(--space-6) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom)); }
  .finale__foot .btn { width: 100%; min-width: 0; }
}

/* The European Cup draw: a live show on the cup stage (navy, stars, gold), full screen on a phone */
.modal--draw { animation: fade-in var(--dur-slow) var(--ease-out); }
.modal--draw { width: min(760px, 100%); max-width: 760px; padding: 0; overflow-x: hidden; overflow-y: auto; background-color: var(--cup-bg); background-image: var(--cup-glow), var(--cup-stars); color: var(--cup-text); border-color: var(--cup-line); }
.draw { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-8) var(--space-8) 0; }
.draw__head { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; }
.draw__live { display: inline-flex; align-items: center; gap: var(--space-2); height: 24px; padding: 0 var(--space-3); border-radius: var(--radius-full); background: var(--danger-solid); color: var(--on-solid); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.draw__live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: draw-pulse 1.2s ease-in-out infinite; }
.draw.is-done .draw__live { background: var(--cup-panel); color: var(--cup-gold); box-shadow: inset 0 0 0 1px var(--cup-line); }
.draw__eyebrow { display: inline-flex; align-items: center; gap: var(--space-1); margin-top: var(--space-3); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--cup-gold); }
.draw__title { margin: 0; font-family: var(--font-display); font-size: clamp(32px, 7vw, 48px); line-height: 1.05; font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: 0.02em; }
.draw__rule { margin: var(--space-1) 0 0; max-width: 440px; font-size: var(--text-sm); color: var(--cup-muted); }
.draw__stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: var(--space-5); }
.draw__pots { display: flex; justify-content: center; gap: var(--space-4); }
.draw__pot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.draw__bowl { position: relative; width: 112px; height: 112px; border-radius: 50%; background: var(--draw-bowl); box-shadow: inset 0 0 0 1px var(--cup-line), inset 0 -10px 24px var(--cup-panel); overflow: hidden; margin-bottom: var(--space-2); }
.draw__bowl::before { content: ''; position: absolute; top: 10%; left: 20%; width: 34%; height: 16%; border-radius: 50%; background: var(--cup-line); transform: rotate(-24deg); }   /* glass shine */
.draw__ball { position: absolute; width: 20px; height: 20px; border-radius: 50%; background: var(--draw-ball); box-shadow: var(--shadow-sm); animation: draw-jiggle 2.4s ease-in-out infinite alternate; transition: opacity var(--dur-base), transform var(--dur-base); }
.draw__ball.is-gone { opacity: 0; transform: translateY(-40px) scale(0.6); }
.draw__pot.is-shaking .draw__bowl { animation: draw-shake 420ms ease-in-out; }
.draw__pot-name { font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--cup-text); }
.draw__pot-left { font-size: var(--text-xs); color: var(--cup-muted); font-variant-numeric: tabular-nums; }
.draw__reveal { display: flex; align-items: center; justify-content: center; min-height: 148px; padding: var(--space-4); border-radius: var(--radius-lg); background: var(--cup-panel); box-shadow: inset 0 0 0 1px var(--cup-line); text-align: center; }
.draw__hint { font-size: var(--text-sm); color: var(--cup-muted); }
.draw__big-ball { width: 64px; height: 64px; border-radius: 50%; background: var(--draw-ball); box-shadow: var(--shadow-lg); animation: draw-ball-in 420ms var(--ease-out) both; }
.draw-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0; animation: draw-open 360ms var(--ease-out) both; }
.draw-card .crest { margin-bottom: var(--space-1); }
.draw-card__name { max-width: 100%; font-family: var(--font-display); font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-bold); overflow-wrap: anywhere; }
.draw-card__meta { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); color: var(--cup-muted); }
.draw-card.is-me .draw-card__name, .draw-card.is-opp .draw-card__name { color: var(--cup-gold); }
.draw-card.is-me, .draw-card.is-opp { animation: draw-open 360ms var(--ease-out) both, draw-glow 1.6s ease-in-out both; }
.draw-result { display: grid; grid-template-columns: auto auto auto; justify-content: center; align-items: center; gap: var(--space-3); animation: draw-open 400ms var(--ease-out) both; }
.draw-result { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); width: 100%; }
.draw-result__team { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0; max-width: 100%; font-weight: var(--weight-semibold); }
.draw-result__team.is-me { color: var(--cup-gold); }
.draw-result__where { font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--cup-muted); }
.draw.is-done .draw__pots { display: none; }
.draw.is-done .draw__stage { grid-template-columns: minmax(0, 1fr); }
.draw-result__vs { font-size: var(--text-2xl); font-family: var(--font-display); font-weight: var(--weight-bold); color: var(--cup-gold); }
.draw-result p { grid-column: 1 / -1; margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--cup-muted); }
.draw-result b { color: var(--cup-text); }
.draw__ties { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.draw__ties--one { grid-template-columns: minmax(0, 280px); justify-content: center; }
.draw-tie { display: grid; gap: 2px; padding: var(--space-2) var(--space-3) var(--space-3); border-radius: var(--radius-md); background: var(--cup-panel); box-shadow: inset 0 0 0 1px var(--cup-line); scroll-margin: var(--space-8); }
.draw-tie.is-mine { background: var(--cup-mine); box-shadow: inset 0 0 0 1px var(--cup-gold); }
.draw-tie__n { font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--cup-muted); }
.draw-tie__team { display: flex; align-items: center; gap: var(--space-2); min-width: 0; height: 26px; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.draw-tie__team .flag { flex-shrink: 0; margin-left: auto; }
.draw-tie__team.is-filled { animation: draw-slot 360ms var(--ease-out) both; }
.draw-tie__team.is-me { color: var(--cup-gold); font-weight: var(--weight-bold); }
.draw-tie__q { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--cup-line); font-size: var(--text-xs); color: var(--cup-muted); }
.draw__foot { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: center; gap: var(--space-3); margin: 0 calc(-1 * var(--space-8)); padding: var(--space-8) var(--space-8) var(--space-6); background: var(--cup-foot); }
.draw__foot .btn { min-width: 160px; }
.draw__foot .btn--ghost { color: var(--cup-text); }
@keyframes draw-pulse { 50% { opacity: 0.25; } }
@keyframes draw-jiggle { from { transform: translate(0, 0); } to { transform: translate(2px, -3px); } }
@keyframes draw-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-4deg); } }
@keyframes draw-ball-in { from { opacity: 0; transform: translateY(40px) scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes draw-open { from { opacity: 0; transform: scale(0.6) rotateX(70deg); } to { opacity: 1; transform: none; } }
@keyframes draw-glow { 0%, 100% { filter: none; } 40% { filter: drop-shadow(0 0 18px var(--moment-glow)); } }
@keyframes draw-slot { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (max-width: 639px) {
  .modal--draw { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .draw { gap: var(--space-4); padding: calc(var(--space-6) + env(safe-area-inset-top)) var(--space-4) 0; }
  .draw__stage { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .draw__bowl { width: 88px; height: 88px; }
  .draw__ball { width: 16px; height: 16px; }
  .draw__reveal { min-height: 120px; }
  .draw__ties { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .draw__foot { margin: 0 calc(-1 * var(--space-4)); padding: var(--space-6) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .draw__foot .btn { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .draw__ball, .draw__live i { animation: none; } }

/* Activity dot: something new to look at (e.g. a transfer offer), gone once seen */
.activity-dot { position: absolute; top: -2px; right: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger-solid); box-shadow: 0 0 0 2px var(--bg-tabbar); }
.activity-dot--inline { position: static; display: inline-block; margin-left: var(--space-2); vertical-align: 2px; box-shadow: none; }

/* Chip: a small rounded shortcut (e.g. back to your own league) */
.chip { display: inline-flex; align-items: center; gap: var(--space-1); height: 32px; padding: 0 var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-full); background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out); }
.chip:hover { background: var(--bg-hover); }
.chip > .icon { color: var(--accent-text); }
/* A row of filter chips: one is on; scrolls sideways on a phone instead of wrapping. */
.chips { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { flex-shrink: 0; font-weight: var(--weight-medium); }
.chip.is-on { background: var(--accent-subtle); border-color: var(--accent-subtle-border); color: var(--accent-text); }
.chip__count { font-size: var(--text-xs); font-variant-numeric: tabular-nums; color: var(--text-tertiary); }
.chip.is-on .chip__count { color: var(--accent-text); }

/* Potential (POT): a compact badge, coloured by how high it is */
/* Match rating: 1–10, 6 is an ordinary game */
.mrating { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 20px; padding: 0 var(--space-1); border-radius: var(--radius-sm); background: var(--bg-inset); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; line-height: 1; }
.mrating--top { background: var(--accent); color: var(--on-accent); }
.mrating--good { background: var(--success-bg); color: var(--success-text); }
.mrating--low { background: var(--warning-bg); color: var(--warning-text); }
.mrating--poor { background: var(--danger-bg); color: var(--danger-text); }
.rating-run { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.rating-run__list { display: flex; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.rating-run__list li { flex: 1 1 0; display: flex; }
.rating-run__list .mrating { flex: 1; height: 28px; font-size: var(--text-sm); }
.rating-run__list li:last-child .mrating { box-shadow: inset 0 0 0 2px var(--border-strong); }
.pot { --pot-c: var(--text-secondary); position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: 2px; height: 18px; padding: 0 6px 0 4px; overflow: hidden; border-radius: var(--radius-full); color: var(--pot-c); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; vertical-align: -3px;
  background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--pot-c) calc(var(--pot-tint) / 2), transparent) 0 3px, transparent 3px 5px), var(--bg-surface); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pot-c) 28%, transparent); }
/* every shade comes from the pill's own colour, so each tier reads the same in both themes */
.pot__fill { position: absolute; inset: 0 auto 0 0; z-index: -1; background: color-mix(in srgb, var(--pot-c) var(--pot-tint), var(--bg-surface)); }   /* how far he has come */
.pot__icon { width: 11px; height: 11px; stroke-width: 2.5; }
.pot--range { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pot-c) 18%, transparent); }
.pot--range .pot__fill { background: color-mix(in srgb, var(--pot-c) calc(var(--pot-tint) * 0.7), var(--bg-surface)); }
.pot--mid { --pot-c: var(--info-text); }
.pot--high { --pot-c: var(--success-text); }
.pot--elite { --pot-c: var(--warning-text); }
/* rating now and potential on one bar */
.pot-bar { position: relative; height: 10px; border-radius: var(--radius-full); background: var(--bg-inset); overflow: hidden; }
.pot-bar__now { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--grad-accent); }
.pot-bar__pot { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: inherit; background: repeating-linear-gradient(90deg, var(--warning-solid) 0 3px, transparent 3px 5px); opacity: 0.8; }
