/* ════════════════════════════════════════════════════════
   Material Design 3 — Quiniela Mundial 2026
   ════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────── */
:root {
  /* Primary — FIFA Blue */
  --md-primary:           #003087;
  --md-on-primary:        #ffffff;
  --md-primary-container: #d6e3ff;
  --md-on-primary-cont:   #001946;

  /* Secondary — Red */
  --md-secondary:         #c41e3a;
  --md-on-secondary:      #ffffff;
  --md-secondary-cont:    #ffdad7;

  /* Surface */
  --md-background:        #f5f5f7;
  --md-surface:           #ffffff;
  --md-surface-var:       #e4e5ef;
  --md-on-surface:        #1a1b22;
  --md-on-surface-var:    #45464e;
  --md-outline:           #75767e;
  --md-outline-var:       #c5c6d0;

  /* State */
  --correct:    #1b5e20;
  --correct-bg: #e8f5e9;
  --wrong:      #b71c1c;
  --wrong-bg:   #ffebee;
  --pending:    #37474f;
  --pending-bg: #eceff1;

  /* Medals */
  --gold:   #f59e0b;
  --silver: #94a3b8;
  --bronze: #c2773e;

  /* Elevation */
  --el1: 0 1px 3px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.07);
  --el2: 0 3px 6px rgba(0,0,0,.12), 0 6px 16px rgba(0,0,0,.09);
  --el3: 0 6px 14px rgba(0,0,0,.15), 0 12px 28px rgba(0,0,0,.11);

  /* Shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 28px;
  --r-full: 999px;

  --header-h: 112px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) { :root { --dark-by-default: 1; } }

html.dark {
  --md-primary:           #adc6ff;
  --md-on-primary:        #002e6e;
  --md-primary-container: #00429b;
  --md-on-primary-cont:   #d6e3ff;

  --md-secondary:         #ffb4ab;
  --md-on-secondary:      #690005;

  --md-background:        #131318;
  --md-surface:           #1e1f26;
  --md-surface-var:       #44464e;
  --md-on-surface:        #e4e3ea;
  --md-on-surface-var:    #c5c6d0;
  --md-outline:           #8f9099;
  --md-outline-var:       #44464e;

  --correct:    #81c784;
  --correct-bg: #1b3a1d;
  --wrong:      #ef9a9a;
  --wrong-bg:   #3a1515;
  --pending:    #b0bec5;
  --pending-bg: #263238;

  --el1: 0 1px 3px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.28);
  --el2: 0 3px 6px rgba(0,0,0,.40), 0 6px 16px rgba(0,0,0,.33);
  --el3: 0 6px 14px rgba(0,0,0,.45), 0 12px 28px rgba(0,0,0,.38);
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--md-background);
  color: var(--md-on-surface);
  min-height: 100vh;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: var(--el3);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title p {
  font-size: 11px;
  font-weight: 400;
  opacity: .75;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  border: none;
  background: rgba(255,255,255,.14);
  color: var(--md-on-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, transform .15s;
}
.icon-btn:hover  { background: rgba(255,255,255,.24); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.spinning .material-icons-round { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Nav Tabs ─────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  border-top: 1px solid rgba(255,255,255,.18);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(255,255,255,.65);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.tab-btn .material-icons-round { font-size: 18px; }
.tab-btn:hover  { color: #fff; background: rgba(255,255,255,.1); }
.tab-btn.active { color: #fff; border-bottom-color: #fff; }

/* ── Views ────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ── Section Header ───────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--md-on-surface);
}

.trophyColor { color: var(--gold); }

.section-sub {
  font-size: 12px;
  color: var(--md-on-surface-var);
  font-weight: 400;
}

/* ── Standing Cards ───────────────────────────────────── */
.standings-list { display: flex; flex-direction: column; gap: 10px; }

.standing-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--md-surface);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--el1);
  transition: transform .18s, box-shadow .18s;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.standing-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--p-color, var(--md-primary));
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.standing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--el2);
}

.rank-badge {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.rank-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-on-surface-var);
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: .5px;
}

.p-info { flex: 1; min-width: 0; }

.p-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--md-on-surface);
}

.p-stats {
  display: flex;
  gap: 12px;
  margin-top: 5px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
}
.stat .material-icons-round { font-size: 13px; }
.stat.s-correct { color: var(--correct); }
.stat.s-wrong   { color: var(--wrong); }
.stat.s-pending { color: var(--md-on-surface-var); }

.points-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: var(--r-lg);
  flex-shrink: 0;
  position: relative;
}
.points-num {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  color: var(--md-on-surface);
}
.points-lbl {
  font-size: 10px;
  font-weight: 500;
  color: var(--md-on-surface-var);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Top 3 highlight */
.standing-card.top-1 .points-num { color: var(--gold); }
.standing-card.top-2 .points-num { color: var(--silver); }
.standing-card.top-3 .points-num { color: var(--bronze); }

/* ── Match Cards ──────────────────────────────────────── */
.match-card {
  background: var(--md-surface);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--el1);
  transition: box-shadow .18s;
}
.match-card:hover { box-shadow: var(--el2); }

.match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--md-surface-var);
}

.match-num {
  font-size: 11px;
  font-weight: 500;
  color: var(--md-on-surface-var);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-full);
  letter-spacing: .4px;
  text-transform: uppercase;
}
.badge-scheduled { background: var(--md-outline-var); color: var(--md-on-surface-var); }
.badge-live      { background: #e53935; color: #fff; animation: blink 1.4s ease-in-out infinite; }
.badge-finished  { background: var(--md-primary); color: var(--md-on-primary); }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:.6; } }

.match-body { padding: 14px 16px 10px; }

.match-teams {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  align-items: center;
  gap: 4px;
}

.team {
  display: flex;
  align-items: center;
  gap: 8px;
}
.team.home { flex-direction: row; }
.team.away { flex-direction: row-reverse; text-align: right; }

.team-flag { font-size: 28px; line-height: 1; }

.team-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  line-height: 1.2;
}

.team.winner .team-name {
  font-weight: 700;
  color: var(--md-primary);
}

.score-box {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  color: var(--md-on-surface-var);
  letter-spacing: -.5px;
}
.score-box.live    { color: #e53935; }
.score-box.final   { color: var(--md-primary); }
.score-box.vs-txt  { font-size: 16px; font-weight: 500; }

.draw-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--pending-bg);
  color: var(--pending);
  border-radius: var(--r-full);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  margin: 6px auto 0;
  display: flex;
  justify-content: center;
}

/* ── Picks Grid ───────────────────────────────────────── */
.picks-section {
  border-top: 1px solid var(--md-outline-var);
  padding: 10px 16px 14px;
}

.picks-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--md-on-surface-var);
  margin-bottom: 8px;
}

.picks-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pick-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 5px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--pending-bg);
  color: var(--pending);
  transition: transform .15s;
}
.pick-chip:hover { transform: scale(1.04); }
.pick-chip.correct { background: var(--correct-bg); color: var(--correct); }
.pick-chip.wrong   { background: var(--wrong-bg);   color: var(--wrong); }

.pick-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pick-icon { font-size: 15px; line-height: 1; }

/* ── Snackbar ─────────────────────────────────────────── */
.snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--md-on-surface);
  color: var(--md-surface);
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--el3);
  z-index: 1000;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.snackbar.show { transform: translateX(-50%) translateY(0); }

/* ── Empty/Loading State ──────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--md-on-surface-var);
}
.loading-state .material-icons-round {
  font-size: 52px;
  opacity: .35;
  margin-bottom: 12px;
  display: block;
}

/* ── Live dot ─────────────────────────────────────────── */
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf50;
  margin-right: 4px;
  animation: blink 2s ease-in-out infinite;
  vertical-align: middle;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  .header-title h1 { font-size: 17px; }
  .team-flag { font-size: 22px; }
  .team-name { font-size: 12px; }
  .score-box { font-size: 24px; }
  .match-teams { grid-template-columns: 1fr 60px 1fr; }
  .tab-btn span:last-child { font-size: 13px; }
}

@media (max-width: 360px) {
  .tab-btn span:not(.material-icons-round) { display: none; }
}

/* ── Phase Headers ────────────────────────────────────── */
.phase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--md-on-surface-var);
  text-transform: uppercase;
  letter-spacing: .9px;
  border-bottom: 1px solid var(--md-outline-var);
  margin-bottom: 14px;
}
.phase-header:first-child { padding-top: 4px; }
.phase-icon { font-size: 16px; color: var(--md-primary); }

/* ── TBD Match Cards ──────────────────────────────────── */
.match-card.match-tbd { opacity: .55; }
.badge-tbd { background: var(--md-surface-var); color: var(--md-on-surface-var); }
.tbd-slot {
  flex: 1;
  text-align: center;
  font-size: 22px;
  color: var(--md-outline);
  font-weight: 300;
}
.tbd-right { text-align: right; }

/* ── Penalty advance note ────────────────────────────── */
.pen-advance {
  font-size: 11px;
  font-style: italic;
  font-weight: 400;
  opacity: .85;
}

/* ── Match header actions ────────────────────────────── */
.match-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.participant-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--md-primary-container);
  color: var(--md-on-primary-cont);
  border-radius: var(--r-full);
  padding: 4px 12px 4px 6px;
  font-size: 12px;
  font-weight: 600;
}
.participant-chip.hidden { display: none; }

.chip-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 8px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
}

.picks-open-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--md-outline);
  background: none;
  color: var(--md-on-surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s;
}
.picks-open-btn:hover { background: var(--md-surface-var); }
.picks-open-btn .material-icons-round { font-size: 15px; }
.picks-open-btn.hidden { display: none; }

/* ── Picks Overlay ────────────────────────────────────── */
.picks-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 16px 12px 32px;
  -webkit-overflow-scrolling: touch;
}
.picks-overlay.hidden { display: none; }

.picks-overlay-inner {
  background: var(--md-surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  padding: 24px 20px 28px;
  box-shadow: var(--el3);
  margin: auto;
}

.picks-overlay-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--md-outline-var);
}
.picks-ball { font-size: 42px; flex-shrink: 0; line-height: 1; }
.picks-overlay-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--md-on-surface);
  margin-bottom: 6px;
}
.picks-overlay-header p {
  font-size: 13px;
  color: var(--md-on-surface-var);
  line-height: 1.5;
}

.picks-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--md-on-surface-var);
  margin-bottom: 12px;
  margin-top: 20px;
}

/* ── Participant selector grid ────────────────────────── */
.participant-select-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 380px) {
  .participant-select-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}

.participant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 10px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
  background: var(--md-background);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.participant-card:hover { background: var(--md-surface-var); transform: translateY(-1px); }
.participant-card.selected {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}

.participant-avatar {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.participant-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--md-on-surface);
  text-align: center;
  line-height: 1.1;
}

/* ── Picks form ───────────────────────────────────────── */
#picks-form.hidden { display: none; }

.ko-pick-card {
  background: var(--md-background);
  border-radius: var(--r-md);
  padding: 14px 12px;
  margin-bottom: 10px;
}

.ko-pick-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-on-surface-var);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

.ko-team-btns {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: center;
  gap: 6px;
}

.ko-vs {
  font-size: 11px;
  font-weight: 700;
  color: var(--md-outline);
  text-align: center;
}

.ko-team-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border-radius: var(--r-md);
  border: 2px solid var(--md-outline-var);
  background: var(--md-surface);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
  width: 100%;
}
.ko-team-btn:hover { border-color: var(--md-primary); transform: scale(1.02); }
.ko-team-btn.selected {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}

.ko-btn-flag { font-size: 26px; line-height: 1; }
.ko-btn-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-on-surface);
  text-align: center;
  line-height: 1.2;
}

/* ── Overlay footer ───────────────────────────────────── */
.overlay-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--md-outline-var);
}

.save-ko-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border-radius: var(--r-full);
  border: none;
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .18s, transform .15s;
}
.save-ko-btn:disabled { opacity: .38; cursor: not-allowed; }
.save-ko-btn:not(:disabled):hover  { opacity: .9; }
.save-ko-btn:not(:disabled):active { transform: scale(.97); }
.save-ko-btn .material-icons-round { font-size: 20px; }

.skip-ko-btn {
  background: none;
  border: none;
  color: var(--md-on-surface-var);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px;
  text-align: center;
  text-decoration: underline;
  width: 100%;
}
