:root {
  --bg: #0b0f14;
  --bg2: #121821;
  --card: #161d28;
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #f3f6fb;
  --muted: #9aa7b8;
  --accent: #f5c542;
  --accent-2: #3ddc97;
  --danger: #ff6b6b;
  --warn: #ffb020;
  --ok: #3ddc97;
  --pick: #7aa2ff;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 58px;
  --topbar-h: 56px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
body { overscroll-behavior-y: contain; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: linear-gradient(180deg, #0d131c 0%, var(--bg) 40%);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  min-height: calc(var(--topbar-h) + var(--safe-top));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #c9921a);
  color: #1a1200; font-weight: 800; display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.week-select-wrap select {
  appearance: none;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px 28px 8px 10px;
  font-size: 13px;
  max-width: 120px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.icon-btn, .back-btn, .ghost-btn, .primary-btn, .tab {
  font: inherit; cursor: pointer; border: 0;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--bg2); color: var(--text); font-size: 18px;
  border: 1px solid var(--card-border);
}
.main {
  flex: 1;
  padding: 12px 12px calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 100%;
  overflow-x: hidden;
}
.view[hidden] { display: none !important; }
.status-line {
  color: var(--muted);
  font-size: 13px;
  margin: 0 2px 10px;
  min-height: 1.2em;
}
.status-line.is-error { color: var(--danger); }
.match-list { display: flex; flex-direction: column; gap: 10px; }
.match-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px;
  width: 100%;
  text-align: left;
  color: inherit;
  display: block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.match-card:active { transform: scale(0.995); }
.card-top {
  display: flex; justify-content: space-between; gap: 8px;
  align-items: flex-start; margin-bottom: 8px;
}
.card-meta { font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.06);
}
.badge-live { background: rgba(255, 80, 80, 0.18); color: #ff8e8e; }
.badge-fin { background: rgba(61, 220, 151, 0.14); color: var(--ok); }
.badge-sched { background: rgba(122, 162, 255, 0.14); color: var(--pick); }
.badge-pending { background: rgba(255, 196, 80, 0.16); color: #ffd27a; }
.badge-ht { background: rgba(255, 160, 80, 0.16); color: #ffb070; }
.badge-post, .badge-cancel { background: rgba(255,255,255,0.08); color: var(--muted); }
.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin: 6px 0 10px;
}
.team {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.team.away { justify-content: flex-end; text-align: right; }
.team img {
  width: 28px; height: 28px; border-radius: 50%;
  background: #0a0e14; object-fit: contain; flex-shrink: 0;
}
.team-name {
  font-size: 13px; font-weight: 600; line-height: 1.25;
  overflow-wrap: anywhere; word-break: break-word;
}
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 800; font-size: 18px; letter-spacing: 0.02em;
  min-width: 54px; text-align: center;
}
.card-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.pick-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(122, 162, 255, 0.14);
  color: #c9d8ff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px; font-weight: 700;
}
.conf {
  font-size: 12px; color: var(--muted);
}
.risk-LOW { color: var(--ok); }
.risk-MED, .risk-MEDIUM { color: var(--warn); }
.risk-HIGH, .risk-NO_DATA { color: var(--danger); }

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(11, 15, 20, 0.96);
  border-top: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  z-index: 30;
}
.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 600;
}
.tab-active {
  color: var(--text);
  background: rgba(245, 197, 66, 0.12);
}

.back-btn {
  background: transparent;
  color: var(--accent);
  padding: 6px 0 12px;
  font-size: 14px;
  font-weight: 600;
}
.detail-root, .standings-root, .coupons-root {
  display: flex; flex-direction: column; gap: 12px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px;
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--accent);
}
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13px; }
.kv span:last-child { color: var(--muted); text-align: right; }
.form-row, .h2h-row, .inj-row {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 13px; padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.form-row:last-child, .h2h-row:last-child, .inj-row:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.pill {
  display: inline-block; min-width: 22px; text-align: center;
  border-radius: 6px; padding: 2px 6px; font-weight: 700; font-size: 11px;
}
.pill-W { background: rgba(61,220,151,.18); color: var(--ok); }
.pill-D { background: rgba(255,255,255,.08); color: var(--muted); }
.pill-L { background: rgba(255,107,107,.18); color: var(--danger); }

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.standings-table th, .standings-table td {
  padding: 8px 4px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
}
.standings-table th { color: var(--muted); font-weight: 600; font-size: 11px; }
.standings-table td.num, .standings-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.standings-table tr.is-home td { background: rgba(122,162,255,0.08); }
.standings-table tr.is-away td { background: rgba(245,197,66,0.08); }
.team-cell { max-width: 140px; overflow-wrap: anywhere; }

.coupon-toolbar { margin-bottom: 10px; }
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #d4a017);
  color: #1a1200;
  font-weight: 700;
  border-radius: 12px;
  padding: 10px 14px;
  width: 100%;
}
.ghost-btn {
  background: transparent;
  color: var(--muted);
  padding: 10px;
  width: 100%;
}
.coupon-card .coupon-head {
  display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.coupon-card .coupon-name { font-weight: 700; font-size: 14px; }
.coupon-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; }
.coupon-matches { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.coupon-match {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  font-size: 12px;
  align-items: center;
}

.error-card {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  width: min(440px, calc(100% - 24px));
  background: #2a1518;
  border: 1px solid rgba(255,107,107,0.35);
  border-radius: 16px;
  padding: 14px;
  z-index: 50;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.error-title { font-weight: 700; margin-bottom: 6px; }
.error-body { color: #ffc9c9; font-size: 13px; margin-bottom: 12px; overflow-wrap: anywhere; }
.noscript {
  padding: 24px; text-align: center; color: var(--danger);
}
.empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.skeleton {
  height: 88px; border-radius: var(--radius);
  background: linear-gradient(90deg, #141a24 0%, #1b2431 50%, #141a24 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (min-width: 481px) {
  .app { border-left: 1px solid var(--card-border); border-right: 1px solid var(--card-border); }
}


/* --- Mobile V2 polish extensions --- */
.match-no {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
}
.league-name {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.card-meta { align-items: baseline; }
.score { min-width: 64px; }
.badge-ht { background: rgba(255, 176, 32, 0.18); color: var(--warn); }
.badge-post, .badge-cancel { background: rgba(255,255,255,0.08); color: var(--muted); }
.conf-high { color: var(--ok); }
.conf-med { color: var(--warn); }
.conf-low { color: var(--danger); }
.conf-pending { color: var(--muted); }
.result-flag {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
}
.result-hit { background: rgba(61,220,151,.16); color: var(--ok); }
.result-miss { background: rgba(255,107,107,.16); color: var(--danger); }
.match-card.is-hit { border-color: rgba(61,220,151,.35); }
.match-card.is-miss { border-color: rgba(255,107,107,.35); }
.toolbar-row { margin-bottom: 8px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
}
.chip-active {
  color: var(--text);
  background: rgba(245,197,66,0.14);
  border-color: rgba(245,197,66,0.35);
}
.search-wrap { display: block; margin-bottom: 10px; }
.search-wrap input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}
.guarantee-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.ghost-btn.compact { padding: 10px 8px; width: 100%; border: 1px solid var(--card-border); border-radius: 12px; }
.live-root { display: flex; flex-direction: column; gap: 12px; }
.detail-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}
.detail-section summary {
  list-style: none;
  cursor: pointer;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  user-select: none;
}
.detail-section summary::-webkit-details-marker { display: none; }
.detail-section-body { padding: 0 12px 12px; }
.subhead { margin: 12px 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5,8,12,0.92);
  display: grid;
  place-items: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}
.login-gate[hidden] { display: none !important; }
.login-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.login-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 6px;
}
.login-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0;
}
body.view-detail-open { overflow: auto; }
.team-logo-fallback {
  width: 28px; height: 28px; border-radius: 50%;
  background: #0a0e14; display: inline-block; flex-shrink: 0;
}
.week-select-wrap select { max-width: 148px; }

/* --- Astra F01–F08 / design polish --- */
.match-no {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1;
}
.score.is-live { color: var(--text); }
.live-dot {
  color: #ff4d4d;
  margin: 0 2px;
  animation: livePulse 1.2s ease-in-out infinite;
  display: inline-block;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}
.detail-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 10px;
  margin: 0 -2px 0;
  scrollbar-width: none;
}
.detail-tabs::-webkit-scrollbar { display: none; }
.detail-tab {
  flex: 0 0 auto;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.detail-tab.active {
  color: var(--text);
  background: rgba(245,197,66,0.16);
  border-color: rgba(245,197,66,0.4);
}
.detail-tab-panels { display: flex; flex-direction: column; gap: 12px; }
.detail-hero .match-no { font-size: 22px; }

/* --- Startup splash (visual only; never blocks boot) --- */
.startup-splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #0d131c 0%, #0b0f14 55%, #0b0f14 100%);
  color: var(--text);
  opacity: 1;
  transition: opacity 0.28s ease;
  pointer-events: none;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.startup-splash.is-done { opacity: 0; }
.startup-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.startup-mark {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-size: 28px;
  box-shadow: 0 12px 40px rgba(245, 197, 66, 0.22);
  animation: splashPop 0.7s ease-out both;
}
.startup-title {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.startup-sub {
  font-size: 13px;
  color: var(--muted);
}
@keyframes splashPop {
  0% { transform: scale(0.86); opacity: 0.55; }
  60% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .startup-mark { animation: none; }
  .startup-splash { transition: none; }
}


/* --- Final product polish --- */
body.auth-gated #app,
body.auth-gated .tabbar { display: none !important; }
.text-btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}
.hero-teams { margin: 10px 0 12px; }
.hero-team { flex-direction: column; gap: 8px; }
.team.away.hero-team { align-items: flex-end; }
.team.home.hero-team { align-items: flex-start; }
.hero-logo, .detail-hero .team img.hero-logo {
  width: 52px; height: 52px; border-radius: 50%;
  background: #0a0e14; object-fit: contain; flex-shrink: 0;
  opacity: 1; /* fix washed-out logos */
  filter: none;
}
.team img { opacity: 1; }
.hero-score { font-size: 26px; min-width: 72px; }
.hero-kick { text-align: center; }
.detail-tabs {
  padding-left: 2px;
  padding-right: 2px;
  scroll-padding-inline: 12px;
  mask-image: linear-gradient(90deg, transparent 0, #000 8px, #000 calc(100% - 8px), transparent 100%);
}
.detail-tab { padding: 8px 14px; }
.venue-photo-wrap {
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
}
.venue-photo {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  opacity: 1;
}
.coupon-preview-selected {
  border-color: rgba(245, 197, 66, 0.45);
  box-shadow: 0 0 0 1px rgba(245, 197, 66, 0.18), 0 10px 28px rgba(0,0,0,0.25);
}
.notif-compact .ghost-btn.compact { width: auto; padding: 8px 12px; }
.standings-table th, .standings-table td { white-space: nowrap; }
.standings-table td.team-cell { white-space: normal; }
.detail-root {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
