:root {
  --wc-dark: #08243d;
  --wc-green: #155b2d;
  --wc-green-dark: #0f4322;
  --wc-gold: #f6c400;
  --wc-orange: #d97706;
  --app-bg: #eef1f4;
  --card-bg: #ffffff;
  --text-primary: #1a1a1a;
  --text-muted: #6c757d;
  --line-soft: #e7eaee;
  --shadow-soft: 0 10px 26px rgba(8, 36, 61, 0.08);
  --shadow-hover: 0 16px 34px rgba(8, 36, 61, 0.15);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  background: #20252a;
  min-height: 100vh;
  margin: 0;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  background: var(--app-bg);
  min-height: 100vh;
}

/* ── Header ──────────────────────────────── */

.wc-header {
  background: var(--wc-green-dark);
  color: white;
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  margin-bottom: 1rem;
  z-index: 100;
  text-align: center;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08), 0 10px 22px rgba(8, 36, 61, 0.22);
}

.wc-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.1rem;
}

.wc-header .subtitle {
  font-size: 0.78rem;
  opacity: 0.8;
  margin: 0;
}

/* ── Today widget ─────────────────────────── */

.today-widget {
  background: white;
  margin: 1rem;
  border: 1px solid rgba(8, 36, 61, 0.06);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-soft);
}

.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
}

.match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-top: 1px solid #f0f0f0;
}

.match-row:first-of-type {
  border-top: none;
}

.match-teams {
  font-size: 0.88rem;
  font-weight: 500;
}

.match-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Ranking cards ────────────────────────── */

.ranking-section {
  padding: 0 1rem;
}

.ranking-card {
  background: white;
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 1px 0 rgba(8, 36, 61, 0.04), var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 80px;
  cursor: pointer;
  transition:
    background-color 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    box-shadow 220ms var(--ease-out),
    transform 220ms var(--ease-out);
  border: 1px solid rgba(8, 36, 61, 0.06);
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
  will-change: transform;
}

.ranking-card:hover {
  transform: translateY(-3px);
  border-color: rgba(8, 36, 61, 0.14);
  box-shadow: var(--shadow-hover);
}

.ranking-card:active {
  transform: translateY(-1px) scale(0.995);
}

.ranking-card:focus-visible {
  outline: 3px solid rgba(246, 196, 0, 0.55);
  outline-offset: 3px;
}

.rank-medal {
  font-size: 1.5rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.player-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid #f4f6f8;
  box-shadow: 0 4px 12px rgba(8, 36, 61, 0.16);
  transition: transform 220ms var(--ease-out), border-color 220ms var(--ease-out);
}

.ranking-card:hover .player-avatar {
  transform: scale(1.05);
  border-color: rgba(246, 196, 0, 0.72);
}

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

.player-name {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
  color: var(--text-primary);
}

.player-stats {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin: 0;
}

.player-pts {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--wc-dark);
  white-space: nowrap;
  flex-shrink: 0;
}

.rank-1 { border-left: 4px solid var(--wc-gold); }
.rank-2 { border-left: 4px solid #aeb6bf; }
.rank-3 { border-left: 4px solid #b76524; }

/* ── Winner banner ───────────────────────── */

.winner-banner {
  background: #f7c600;
  color: #1a1a1a;
  text-align: center;
  padding: 1.1rem 1.25rem;
  margin: 0 1rem 0.65rem;
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: inset 0 -3px 0 rgba(217, 119, 6, 0.16), var(--shadow-soft);
}

.winner-banner-title,
.winner-banner-debt {
  margin: 0;
}

.winner-banner-debt {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── WhatsApp button ─────────────────────── */

.whatsapp-btn {
  display: block;
  margin: 0.75rem 1rem 0;
  background: #25d366;
  color: white;
  text-align: center;
  padding: 0.875rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(37, 211, 102, 0.24);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), background-color 200ms var(--ease-out);
}

.whatsapp-btn:hover {
  color: white;
  background: #1fbd5b;
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(37, 211, 102, 0.34);
}

.whatsapp-btn:active {
  transform: translateY(0);
  color: white;
}

/* ── Footer ──────────────────────────────── */

.page-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* ── Offcanvas ───────────────────────────── */

.offcanvas.offcanvas-bottom {
  max-width: 480px;
  left: 50%;
  transform: translate(-50%, 105%);
  border-radius: 18px 18px 0 0;
  height: 90vh;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 -22px 55px rgba(8, 36, 61, 0.28);
  transition: transform 360ms var(--ease-out), visibility 360ms var(--ease-out);
}

.offcanvas.offcanvas-bottom.show,
.offcanvas.offcanvas-bottom.showing {
  transform: translate(-50%, 0);
}

.offcanvas-header {
  background: var(--wc-green-dark);
  color: white;
  border-radius: 18px 18px 0 0;
  padding: 1rem 1.1rem;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.offcanvas-header .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
  opacity: 0.85;
  transition: opacity 160ms ease, transform 160ms ease;
}

.offcanvas-header .btn-close:hover {
  opacity: 1;
  transform: rotate(90deg);
}

.offcanvas-player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.offcanvas-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.offcanvas-player-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.1rem;
}

.offcanvas-player-pts {
  font-size: 0.78rem;
  opacity: 0.85;
  margin: 0;
}

.offcanvas-body {
  overflow-y: auto;
  padding: 0.5rem 1rem 2rem;
  background: #fbfcfd;
}

.group-header {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.85rem 0 0.3rem;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 0.1rem;
}

.match-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f3f3f3;
  transition: background-color 160ms ease, padding-left 160ms ease;
}

.match-result-row:hover {
  background: #f6f8fa;
  padding-left: 0.25rem;
}

.match-score-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.team-flag {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(8, 36, 61, 0.12);
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(8, 36, 61, 0.12);
}

.pred-score {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.real-score {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: 0.15rem;
  white-space: nowrap;
}

.match-kickoff {
  flex-basis: 100%;
  color: var(--text-muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.pill {
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-pending  { background: #eceff3; color: #555; }
.pill-exact    { background: #dbeee0; color: #155724; }
.pill-outcome  { background: #fff1bf; color: #7a5704; }
.pill-wrong    { background: #eceff3; color: #333; }

.offcanvas-backdrop.show {
  opacity: 0.62;
}

/* ── Responsive tweaks ───────────────────── */

@media (min-width: 480px) {
  body {
    padding: 0;
  }
}

@media (max-width: 479px) {
  .offcanvas.offcanvas-bottom {
    left: 0;
    transform: translateY(105%);
    max-width: 100%;
  }

  .offcanvas.offcanvas-bottom.show,
  .offcanvas.offcanvas-bottom.showing {
    transform: translateY(0);
  }
}

/* ── Desktop layout (768px+) ─────────────── */

@media (min-width: 768px) {
  body {
    background: #071f2f;
    background-attachment: fixed;
  }

  #app {
    max-width: 1140px;
    background: transparent;
  }

  .wc-header {
    border-radius: 0 0 10px 10px;
    background: var(--wc-green-dark);
  }

  #winner-banner .winner-banner {
    margin: 1.25rem 1.25rem 0;
  }

  /* Two-column grid */
  #desktop-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.25rem;
    padding: 1.25rem;
    align-items: start;
  }

  /* Left sidebar */
  #left-panel {
    background: var(--app-bg);
    border-radius: 16px;
    overflow: hidden;
    padding-bottom: 0.5rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  }

  #left-panel .today-widget {
    margin: 1rem 1rem 0.75rem;
  }

  #left-panel .ranking-section {
    padding: 0 1rem;
  }

  #left-panel .whatsapp-btn {
    margin: 0.75rem 1rem 0;
  }

  #left-panel .page-footer {
    padding-bottom: 1rem;
  }

  /* Active ranking card on desktop */
  .ranking-card.card-active {
    background: #f3f7fb;
    border-color: rgba(8, 36, 61, 0.32);
    box-shadow: inset 0 0 0 2px var(--wc-dark), var(--shadow-hover);
  }

  /* Right detail panel */
  #right-panel {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 92px);
    overflow-y: auto;
    border-radius: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  }

  #desktop-detail {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    min-height: 240px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    animation: detailIn 280ms var(--ease-out);
  }

  /* Player detail header */
  .dd-header {
    background: var(--wc-green-dark);
    color: white;
    padding: 1.5rem 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  }

  .dd-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
  }

  .dd-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 0.2rem;
  }

  .dd-pts {
    font-size: 0.9rem;
    opacity: 0.85;
    margin: 0;
  }

  /* Stats row */
  .dd-stats {
    display: flex;
    border-bottom: 1px solid #eee;
  }

  .dd-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    border-right: 1px solid #eee;
  }

  .dd-stat:last-child {
    border-right: none;
  }

  .dd-stat-num {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.3rem;
  }

  .dd-stat-lbl {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
  }

  /* Match list inside desktop panel */
  .dd-matches {
    padding: 0 1.25rem 1.5rem;
  }

  @keyframes detailIn {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Placeholder */
  .dd-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
    gap: 0.5rem;
  }

  .dd-placeholder-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #f7c600;
    box-shadow: inset 0 -3px 0 rgba(217, 119, 6, 0.16), 0 12px 24px rgba(8, 36, 61, 0.12);
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.5rem;
  }

  .dd-placeholder-title {
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
  }

  .dd-placeholder-text {
    font-size: 0.92rem;
    max-width: 320px;
    margin: 0;
  }
}

/* Hide right panel on mobile */
@media (max-width: 767px) {
  #right-panel {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Today widget predictions ───────────── */

.tw-match-block {
  padding: 0.6rem 0;
  border-top: 1px solid #f0f0f0;
}

.tw-match-block:first-of-type {
  border-top: none;
  padding-top: 0;
}

.tw-match-header,
.tw-match-teams,
.tw-pred-row {
  display: flex;
  align-items: center;
}

.tw-match-header {
  align-items: flex-start;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.tw-match-teams {
  gap: 0.35rem;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
}

.tw-flag {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(8, 36, 61, 0.1);
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.tw-match-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.tw-carousel {
  overflow: hidden;
}

.tw-carousel-track {
  display: flex;
  transition: transform 300ms ease;
}

.tw-pred-page {
  min-width: 100%;
}

.tw-pred-row {
  gap: 0.5rem;
  padding-left: 0.25rem;
  font-size: 0.78rem;
}

.tw-pred-medal {
  flex-shrink: 0;
  width: 1.2rem;
  font-size: 0.85rem;
}

.tw-pred-name {
  flex: 1;
  color: var(--text-muted);
}

.tw-pred-score {
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.tw-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.tw-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line-soft);
  transition: background-color 200ms ease;
}

.tw-dot-active {
  background: var(--wc-green);
}

/* ── Group filter tabs ───────────────────── */

.group-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.75rem 0 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfcfd;
}

.gf-tab {
  padding: 0.28rem 0.65rem;
  border: 1.5px solid var(--line-soft);
  border-radius: 20px;
  background: white;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.gf-tab:hover {
  border-color: var(--wc-green);
  color: var(--wc-green);
}

.gf-tab-active {
  border-color: var(--wc-green);
  background: var(--wc-green);
  color: white;
}
