/* ═══════════════════════════════════════════════════════════════════════════
   Single Match Prediction — Design Tokens (consistent with group-stage)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f4f7fb;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --card-border: rgba(27, 59, 114, 0.08);
  --text: #12213f;
  --text-soft: #52617f;
  --text-faint: #8490a8;
  --blue-1: #153a8a;
  --blue-2: #1f5fff;
  --blue-3: #58a4ff;
  --gold-1: #efb938;
  --gold-2: #ffd774;
  --gold-soft: rgba(239, 185, 56, 0.14);
  --danger: #d74a55;
  --shadow: 0 18px 40px rgba(27, 59, 114, 0.10);
  --shadow-strong: 0 22px 52px rgba(14, 34, 81, 0.18);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #ffffff;
  color: var(--text);
  min-height: 100vh;
}
button { font: inherit; }

.app-shell { min-height: 100vh; }
.app-loading {
  display: grid;
  place-items: center;
}
.loading-screen {
  text-align: center;
  padding: 40px 24px;
}
.loading-mark { font-size: 40px; margin-bottom: 12px; }
.loading-title { font-size: 24px; font-weight: 800; color: var(--blue-1); }
.loading-sub { margin-top: 8px; font-size: 14px; color: var(--text-soft); }

/* ── Page layout ──────────────────────────────────────────────────────── */

.page {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.hero {
  position: relative;
  overflow: hidden;
  background: transparent;
  border-bottom: 1px solid rgba(21,58,138,0.10);
}
.hero::before {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31,95,255,0.18), transparent 62%);
}
.hero-home {
  padding: 18px 12px 16px 2px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 0;
  background: rgba(21,58,138,0.06);
  color: var(--blue-1);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.hero h1 {
  margin: 10px 0 4px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 900;
}
.hero p {
  margin: 0;
  color: var(--text-faint);
  line-height: 1.5;
  font-size: 13px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 0;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-1));
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(21,58,138,0.22);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.primary-button:active { transform: scale(0.96); box-shadow: 0 6px 16px rgba(21,58,138,0.16); }
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid rgba(21,58,138,0.12);
  border-radius: 0;
  background: rgba(255,255,255,0.92);
  color: var(--blue-1);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.secondary-button:active { transform: scale(0.96); }

.page-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 0;
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(21,58,138,0.06);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.back-chip {
  margin-bottom: 12px;
  border-color: rgba(21,58,138,0.10);
  background: rgba(21,58,138,0.07);
  color: var(--blue-1);
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid rgba(21,58,138,0.14);
  border-radius: 0;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.back-chip:active { transform: scale(0.96); }

/* ── Match section titles ─────────────────────────────────────────────── */

.match-section {
  margin-top: 18px;
}
.match-section__title {
  font-size: 16px;
  font-weight: 900;
  color: var(--blue-1);
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(21,58,138,0.08);
  margin-bottom: 6px;
}
.match-section__title em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 600;
}

/* ── Collapsible date group ──────────────────────────────────────────── */

.date-group {
  margin-top: 8px;
}
.date-group__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  background: rgba(255,255,255,0.70);
  border: 1px solid rgba(21,58,138,0.06);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}
.date-group__header:hover {
  background: rgba(31,95,255,0.04);
}
.date-group__header:active {
  transform: scale(0.98);
}
.date-group__header--open {
  border-bottom-color: transparent;
  background: rgba(31,95,255,0.04);
}
.date-group__date {
  flex: none;
  color: var(--blue-1);
}
.date-group__badge {
  flex: none;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 0;
}
.date-group__badge--played {
  background: rgba(76,175,80,0.12);
  color: #2d6a2d;
}
.date-group__badge--ready {
  background: rgba(31,95,255,0.08);
  color: var(--blue-2);
}
.date-group__badge--pending {
  background: rgba(132,144,168,0.08);
  color: var(--text-faint);
}
.date-group__count {
  flex: 1;
  font-style: normal;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 600;
  text-align: right;
}
.date-group__chevron {
  flex: none;
  font-size: 12px;
  color: var(--text-faint);
  transition: transform 0.2s ease;
}
.date-group__header--open .date-group__chevron {
  transform: rotate(180deg);
  color: var(--blue-1);
}
.date-group__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.date-group__body--open {
  max-height: 2000px;
}
.date-group__body .match-picker-list {
  padding: 8px 0 4px;
}

/* ── "Show all dates" toggle ─────────────────────────────────────────── */

.date-list-toggle {
  margin-top: 12px;
}
.date-list-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border: 1px dashed rgba(21,58,138,0.14);
  border-radius: 0;
  background: rgba(255,255,255,0.70);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.date-list-toggle__btn:hover {
  background: rgba(31,95,255,0.04);
}
.date-list-toggle__btn:active {
  transform: scale(0.98);
}
.date-list-toggle__btn--open {
  border-bottom: none;
}
.date-list-toggle__chevron {
  font-size: 11px;
  color: var(--text-faint);
}
.date-list-toggle__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
.date-list-toggle__body--open {
  max-height: 8000px;
}

/* ── Match picker card ────────────────────────────────────────────────── */

.match-picker-list {
  display: grid;
  gap: 8px;
}
.match-picker-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 0;
  border: 1px solid rgba(21,58,138,0.08);
  background: rgba(255,255,255,0.92);
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(27,59,114,0.06);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  text-align: left;
  width: 100%;
}
.match-picker-card:active {
  transform: scale(0.97);
}
.match-picker-card--selected {
  border-color: rgba(31,95,255,0.38);
  background: linear-gradient(180deg, rgba(237,244,255,0.98), rgba(255,255,255,0.96));
  box-shadow: 0 16px 30px rgba(31,95,255,0.14);
}
.match-picker-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.match-picker-team img {
  width: 36px;
  height: 24px;
  border-radius: 0;
  object-fit: cover;
  border: 1px solid rgba(21,58,138,0.12);
  box-shadow: 0 2px 6px rgba(14,34,81,0.06);
}
/* Deferred images: keep layout stable without src */
.img-deferred {
  background: rgba(132,144,168,0.06);
}
.match-picker-team__name {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.match-picker-team__rank {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 700;
}
.match-picker-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: none;
}
.match-picker-vs__label {
  font-size: 20px;
  font-weight: 950;
  color: var(--blue-1);
  line-height: 1;
}
.match-picker-vs__meta {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 700;
  white-space: nowrap;
}
.match-picker-vs__group {
  font-size: 9px;
  padding: 1px 6px;
  background: rgba(239,185,56,0.16);
  color: #8a5a00;
  font-weight: 800;
}

/* Played match: show actual score instead of VS */
.match-picker-vs--played .match-picker-vs__score {
  font-size: 22px;
  font-weight: 950;
  color: #0f1d54;
  line-height: 1;
  background: linear-gradient(135deg, rgba(76,175,80,0.12), rgba(76,175,80,0.06));
  padding: 4px 10px;
}
.match-picker-card--played {
  background: rgba(240,250,240,0.92);
  border-color: rgba(76,175,80,0.16);
}

/* AI predicted badge inside VS block */
.match-picker-vs__ai-badge {
  font-size: 9px;
  color: var(--blue-2);
  font-weight: 800;
  white-space: nowrap;
}

/* ── Prediction card (single match detail) ─────────────────────────────── */

.match-prediction-card {
  margin-top: 12px;
  padding: 16px 14px 12px;
  border-radius: 0;
  background:
    radial-gradient(circle at 90% 4%, rgba(255,215,116,0.22), transparent 18%),
    radial-gradient(circle at 8% 0%, rgba(88,164,255,0.16), transparent 20%),
    linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  border: 1px solid rgba(21,58,138,0.08);
  box-shadow: var(--shadow);
}
.match-prediction-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.match-prediction-card__eyebrow {
  color: var(--blue-1);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.02em;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--gold-1);
}
.match-prediction-card__badge {
  width: 48px;
  height: 48px;
  border-radius: 0;
  display: grid;
  place-items: center;
  flex: none;
  color: #0f1d54;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  box-shadow: 0 10px 20px rgba(239,185,56,0.22);
}

/* VS block */
.match-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 0;
}
.match-vs__team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.match-vs__team img {
  width: 64px;
  height: 42px;
  border-radius: 0;
  object-fit: cover;
  border: 1px solid rgba(21,58,138,0.14);
  box-shadow: 0 4px 12px rgba(14,34,81,0.08);
  background: #fff;
}
.match-vs__team-name {
  font-size: 17px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.match-vs__team-rank {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 700;
}
.match-vs__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: none;
  min-width: 80px;
}
.match-vs__score-digits {
  font-size: 48px;
  font-weight: 950;
  color: #0f1d54;
  line-height: 1;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, rgba(31,95,255,0.08), rgba(21,58,138,0.06));
  padding: 8px 16px;
  border-radius: 0;
}
.match-vs__score-label {
  font-size: 11px;
  color: var(--blue-1);
  font-weight: 800;
}
.match-vs__score-conf {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 700;
}

/* AI analysis section */
.match-ai-detail {
  margin-top: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(88,164,255,0.06), rgba(31,95,255,0.03));
  border: 1px solid rgba(31,95,255,0.10);
}
.match-ai-detail__header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 900;
  color: var(--blue-1);
}
.match-ai-detail__row {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.5;
}
.match-ai-detail__label {
  flex: none;
  min-width: 56px;
  font-weight: 800;
  color: var(--text-soft);
}
.match-ai-detail__value {
  flex: 1;
  color: var(--text);
  font-weight: 600;
}
.match-ai-detail__analysis {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(21,58,138,0.06);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-soft);
}

/* Alternative scores */
.match-alt-scores {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(21,58,138,0.06);
}
.match-alt-scores__label {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 800;
  margin-bottom: 6px;
}
.match-alt-scores__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* ── Alternative scores grid ──────────────────────────────────────────── */
.match-alt-scores__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}
.match-alt-score-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 0;
  background: rgba(132,144,168,0.06);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
}
.match-alt-score-row__flag {
  width: 18px;
  height: 12px;
  border-radius: 0;
  object-fit: cover;
  border: 1px solid rgba(21,58,138,0.08);
  flex: none;
}
.match-alt-score-row__team {
  font-weight: 700;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 52px;
  flex: none;
  text-align: center;
}
.match-alt-score-row__score {
  font-weight: 900;
  color: var(--text);
  flex: none;
  min-width: 32px;
  text-align: center;
}
.match-alt-score-row__prob {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 700;
  flex: none;
  margin-left: auto;
  min-width: 36px;
  text-align: right;
}
.match-alt-score-row--main {
  background: rgba(31,95,255,0.06);
  border: 1px solid rgba(31,95,255,0.14);
}
.match-alt-score-row--main .match-alt-score-row__score {
  color: var(--blue-1);
}

/* Upset warning */
.match-upset-warn {
  margin-top: 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--danger);
  background: rgba(215,74,85,0.06);
  font-size: 12px;
  font-weight: 800;
  color: var(--danger);
}

/* ── Actions ──────────────────────────────────────────────────────────── */

.match-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  position: sticky;
  bottom: 10px;
  z-index: 8;
}

/* ── Share footer (appended during html2canvas) ───────────────────────── */

.match-share-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding: 12px 16px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  min-height: 76px;
}
.share-footer-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.share-footer-brand-top {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--blue-1);
}
.share-footer-desc {
  margin: 0;
  font-size: 9px;
  color: var(--text-faint);
  font-weight: 600;
}
.share-footer-logo {
  font-size: 16px;
}
.share-footer-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.04em;
}
.share-footer-qr-img {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 0;
}

/* ── Share overlay ────────────────────────────────────────────────────── */

.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
}
.share-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 18, 48, 0.54);
  backdrop-filter: blur(8px);
}
.share-preview {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(390px, calc(100vw - 20px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  display: grid;
  justify-items: center;
}
.share-generating {
  width: 100%;
  padding: 38px 16px;
  border-radius: 0;
  background: rgba(255,255,255,0.92);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}
.share-export-image {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: 0 16px 34px rgba(14,34,81,0.14);
  -webkit-touch-callout: default;
  user-select: auto;
}
.share-save-hint {
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.78);
  text-align: center;
}

/* ── Filter chips ─────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-chip {
  padding: 5px 12px;
  border: 1px solid rgba(21,58,138,0.12);
  border-radius: 0;
  background: rgba(255,255,255,0.80);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s ease;
}
.filter-chip--active {
  border-color: var(--blue-2);
  background: rgba(31,95,255,0.08);
  color: var(--blue-1);
}
.filter-chip:active { transform: scale(0.95); }

/* ── Match count badge ────────────────────────────────────────────────── */

.match-count {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 10px;
}
