:root {
  --bg: #f4f7fb;
  --bg-strong: #eef3fb;
  --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 {
  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;
}

.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;
}

/* 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); }

.route-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.page-group {
  max-width: 430px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
}
.group-hero {
  margin-bottom: 14px;
}
.group-back {
  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;
}
.group-back:active { transform: scale(0.96); }
.group-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.group-picker-card {
  min-height: 92px;
  padding: 12px 10px;
  border-radius: 0;
  border: 1px solid rgba(21,58,138,0.08);
  background: rgba(255,255,255,0.92);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(27,59,114,0.08);
  transition: transform 0.12s ease;
}
.group-picker-card:active { transform: scale(0.96); }
.group-picker-card--active {
  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);
}
.group-picker-card strong {
  display: block;
  color: var(--blue-1);
  font-size: 22px;
  line-height: 1;
}
.group-picker-teams {
  margin-top: 8px;
  display: grid;
  gap: 3px;
}
.group-picker-team {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px 2px 3px;
  border-radius: 0;
  background: rgba(255,255,255,0.70);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}
.group-picker-team img {
  width: 18px;
  height: 12px;
  border-radius: 0;
  object-fit: cover;
  flex: none;
}
.group-picker-team-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-picker-team-rank {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  flex: none;
}
.group-poster {
  margin-top: 12px;
  padding: 12px;
  border-radius: 0;
  background:
    radial-gradient(circle at 90% 4%, rgba(255,215,116,0.26), transparent 20%),
    radial-gradient(circle at 8% 0%, rgba(88,164,255,0.18), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  border: 1px solid rgba(21,58,138,0.08);
  box-shadow: var(--shadow);
}
.group-poster__head {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.group-poster__eyebrow {
  color: var(--blue-1);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.02em;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gold-1);
}
.group-poster__head-left {
  flex: 1;
  min-width: 0;
}
.group-poster__head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: none;
}
.group-poster__sim-badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  background: rgba(132,144,168,0.10);
  border-radius: 0;
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.group-poster__teams {
  margin-top: 8px;
  margin-bottom: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.group-poster__team {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 0;
  background: rgba(255,255,255,0.80);
  border: 1px solid rgba(21,58,138,0.06);
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
}
.group-poster__team img {
  width: 22px;
  height: 14px;
  border-radius: 0;
  object-fit: cover;
  flex: none;
}
.group-poster__team span {
  flex: 1;
  min-width: 0;
}
.group-poster__team em {
  font-style: normal;
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 700;
  flex: none;
}
.group-poster__badge {
  width: 52px;
  height: 52px;
  border-radius: 0;
  display: grid;
  place-items: center;
  flex: none;
  color: #0f1d54;
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  box-shadow: 0 10px 20px rgba(239,185,56,0.22);
}
.group-team-crest {
  width: 34px;
  height: 22px;
  border-radius: 0;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid rgba(21,58,138,0.12);
  box-shadow: 0 2px 6px rgba(14,34,81,0.06);
  flex: none;
}
.group-match-list {
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid rgba(21,58,138,0.06);
  display: grid;
  gap: 5px;
}
.group-match-row {
  --row-bg: rgba(255,255,255,0.90);
  --row-border: rgba(21,58,138,0.07);
  --tag-bg: rgba(31,95,255,0.10);
  --tag-color: var(--blue-1);
  --score-bg: linear-gradient(135deg, rgba(21,58,138,0.08), rgba(31,95,255,0.08));
  --score-color: #0f1d54;
  display: grid;
  grid-template-columns: 46px minmax(70px, 1fr) 54px minmax(70px, 1fr) 40px;
  gap: 5px;
  align-items: center;
  min-height: 38px;
  padding: 6px 7px;
  border-radius: 0;
  background: var(--row-bg);
  border: 1px solid var(--row-border);
}
.group-match-row--control,
.group-match-row--closewin,
.group-match-row--rotate,
.group-match-row--tight {
  --row-bg: rgba(255,255,255,0.90);
  --row-border: rgba(21,58,138,0.07);
  --tag-bg: rgba(21,58,138,0.06);
  --tag-color: #52617f;
}
.group-match-row--bigwin { --row-bg: rgba(255, 248, 226, 0.94); --row-border: rgba(239,185,56,0.22); --tag-bg: rgba(239,185,56,0.22); --tag-color: #8a5a00; --score-bg: linear-gradient(135deg, rgba(239,185,56,0.96), rgba(255,215,116,0.92)); --score-color: #5c3a00; }
.group-match-row--upset { --row-bg: rgba(255, 238, 241, 0.95); --row-border: rgba(215,74,85,0.18); --tag-bg: rgba(215,74,85,0.14); --tag-color: #a72f3c; --score-bg: linear-gradient(135deg, rgba(215,74,85,0.18), rgba(215,74,85,0.10)); --score-color: #a72f3c; }
.group-match-row--collapse { --row-bg: rgba(255, 241, 232, 0.95); --row-border: rgba(224,97,48,0.18); --tag-bg: rgba(224,97,48,0.16); --tag-color: #a84316; --score-bg: linear-gradient(135deg, rgba(224,97,48,0.18), rgba(224,97,48,0.10)); --score-color: #a84316; }
.group-match-row--real { --row-bg: rgba(240, 250, 240, 0.94); --row-border: rgba(76,175,80,0.20); --tag-bg: rgba(76,175,80,0.16); --tag-color: #2d6a2d; --score-bg: linear-gradient(135deg, rgba(76,175,80,0.28), rgba(76,175,80,0.14)); --score-color: #1a4a1a; }
.group-match-time {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}
.group-match-team {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
  font-weight: 900;
  color: var(--text);
}
.group-match-team span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-match-team--away {
  justify-content: flex-end;
  text-align: right;
}
.group-match-score {
  min-height: 30px;
  border-radius: 0;
  display: grid;
  place-items: center;
  color: var(--score-color);
  background: var(--score-bg);
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
}
.group-match-tag {
  justify-self: end;
  min-width: 32px;
  padding: 3px 5px;
  border-radius: 0;
  background: var(--tag-bg);
  color: var(--tag-color);
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  font-weight: 900;
}
.group-table-wrap {
  margin-top: 10px;
  padding: 9px;
  border-radius: 0;
  background: rgba(21,58,138,0.05);
}
.group-section-title {
  color: var(--blue-1);
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 7px;
}
.group-table {
  display: grid;
  gap: 5px;
}
.group-table-header {
  display: grid;
  grid-template-columns: 22px 34px 1fr 38px 30px 74px;
  gap: 5px;
  padding: 0 7px 8px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(21,58,138,0.08);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.group-table-header span:nth-child(3) {
  visibility: hidden;
}
.group-table-header span:last-child {
  text-align: right;
}
.group-table-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-table-row {
  display: grid;
  grid-template-columns: 22px 34px 1fr 38px 30px 74px;
  gap: 5px;
  align-items: center;
  padding: 6px 7px;
  border-radius: 0;
  background: rgba(255,255,255,0.78);
  color: var(--text-soft);
  font-size: 11px;
}
.group-table-row .group-team-crest {
  width: 32px;
  height: 21px;
  border-radius: 0;
}
.group-table-row--qualified {
  background: linear-gradient(135deg, rgba(31,95,255,0.10), rgba(255,255,255,0.86));
  color: var(--text);
}
.group-table-row strong {
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-rank {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(21,58,138,0.08);
  color: var(--blue-1);
  font-weight: 900;
}
.group-table-row em {
  font-style: normal;
  text-align: right;
  font-size: 10px;
  color: var(--blue-1);
  font-weight: 800;
  line-height: 1.15;
}
.group-story {
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 0;
  background: linear-gradient(135deg, rgba(255,248,229,0.92), rgba(255,255,255,0.86));
  color: #6e4b13;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}
.group-actions {
  position: sticky;
  bottom: 10px;
  z-index: 8;
}
.group-result-topbar {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 0 0 8px;
}
.page-group .group-back {
  margin-bottom: 0;
  border-color: rgba(21,58,138,0.14);
  background: rgba(21,58,138,0.08);
  color: var(--blue-1);
}

/* ── AI Analysis Panel ──────────────────────────────────────────────── */
.group-ai-summary {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border-radius: 0;
  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);
}
.group-ai-summary__label {
  font-size: 13px;
  font-weight: 900;
  color: var(--blue-1);
  margin-bottom: 6px;
}
.group-ai-summary__text {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-soft);
}
.group-ai-summary__meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 800;
}
.ai-meta-tag--fav {
  background: linear-gradient(135deg, rgba(239,185,56,0.16), rgba(255,215,116,0.12));
  color: #8a5a00;
  border: 1px solid rgba(239,185,56,0.22);
}
.ai-meta-tag--dark {
  background: rgba(100,100,100,0.06);
  color: #555;
}
.ai-meta-tag--death {
  background: rgba(215,74,85,0.10);
  color: #a72f3c;
  border: 1px solid rgba(215,74,85,0.14);
}

/* Match row — clickable for AI analysis */
.group-match-row--has-ai {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.group-match-row--has-ai::after {
  content: '▾';
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--blue-1);
  opacity: 0.5;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.group-match-row--has-ai:hover {
  background: rgba(31,95,255,0.04);
}
.group-match-row--has-ai:hover::after {
  opacity: 0.9;
}
.group-match-row--ai-open::after {
  transform: translateY(-50%) rotate(180deg);
}

/* Expandable AI analysis detail */
.group-match-ai-detail {
  margin: -2px 0 5px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}
.group-match-ai-detail--open {
  max-height: 300px;
  margin: 2px 0 8px;
}
.ai-detail-body {
  padding: 8px 10px 8px 14px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-soft);
  border-left: 3px solid var(--blue-2);
  background: linear-gradient(90deg, rgba(31,95,255,0.03), transparent);
}
.ai-detail-key {
  margin: 0 0 4px;
  font-weight: 800;
  color: var(--blue-1);
  font-size: 12px;
}
.ai-detail-text {
  margin: 0 0 4px;
  color: var(--text-soft);
}
.ai-detail-alt {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 10px;
}
.ai-detail-alt-label {
  color: var(--text-faint);
  font-weight: 700;
}
.ai-alt-score {
  padding: 1px 5px;
  border-radius: 0;
  background: rgba(132,144,168,0.10);
  color: var(--text-faint);
  font-weight: 800;
  font-size: 10px;
}
.ai-upset-badge {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--danger);
  font-weight: 800;
}

/* Qualification probability in standings */
.group-qual-prob {
  font-style: normal;
  text-align: right;
  font-size: 11px;
  color: var(--blue-2);
  font-weight: 900;
  line-height: 1.15;
}

/* Share footer — appended during html2canvas */
.group-poster__share-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 12px 16px 10px;
  background: url('./assets/share-footer-bg.jpg') center/cover no-repeat, 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 canvas,
.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-preview .group-poster--share-preview {
  width: min(390px, 100%);
  margin: 0 auto;
  box-shadow: none;
}
.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;
}
