  :root {
    --bg: #0a1322;
    --bg-soft: #0f1d33;
    --surface: #122340;
    --surface-alt: #16294b;
    --surface-elevated: #182f55;
    --text: #eaf3ff;
    --text-soft: #8aa6c8;
    --text-muted: #6f88a8;
    --border: #233f6a;
    --border-soft: #1a2f50;
    --primary: #3aa3f5;
    --primary-hover: #1f8de0;
    --primary-soft: rgba(58, 163, 245, 0.12);
    --secondary: #1c3960;
    --secondary-hover: #264d80;
    --accent: #7dd3fc;
    --warning: #f59e0b;
    --success-bg: #0f3147;
    --error-bg: #3f1822;
    --ring: rgba(58, 163, 245, 0.28);
    --gold: #f0c850;
    --silver: #b0c4d8;
    --bronze: #cd7f32;
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.12);
    --warm-surface: rgba(26, 34, 53, 0.6);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18), 0 1px 1px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 8px 24px rgba(2, 8, 20, 0.32), 0 2px 6px rgba(2, 8, 20, 0.22);
    --shadow-lg: 0 24px 48px rgba(2, 8, 20, 0.38), 0 4px 12px rgba(2, 8, 20, 0.22);
  }
  * { box-sizing: border-box; }
  html, body { min-height: 100%; }
  body {
    font-family: "Plus Jakarta Sans", sans-serif;
    margin: 0;
    background:
      radial-gradient(1200px 650px at -12% -25%, rgba(58, 163, 245, 0.12), transparent 60%),
      radial-gradient(1100px 580px at 118% -28%, rgba(14, 116, 200, 0.10), transparent 58%),
      linear-gradient(180deg, #07111f 0%, #0a1a2f 40%, var(--bg) 100%);
    color: var(--text);
    letter-spacing: 0.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  nav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(8, 17, 30, 0.72);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    color: var(--text);
    padding: 12px 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
    column-gap: 12px;
  }
  nav > * { min-width: 0; }
  nav a { color: var(--text); text-decoration: none; font-weight: 700; }
  .container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
  .card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-md);
    animation: fade-up 260ms ease-out both;
    min-width: 0;
  }
  .grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
  .btn {
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 9px 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.005em;
    transition: background 140ms ease, transform 120ms ease, box-shadow 140ms ease;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 1px 2px rgba(2, 8, 20, 0.32);
  }
  .btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 4px 10px rgba(2, 8, 20, 0.42); }
  .btn:active { transform: translateY(0); }
  .btn.secondary {
    background: var(--secondary);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  }
  .btn.secondary:hover { background: var(--secondary-hover); }
  .btn.danger {
    background: #c0392b;
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 1px 2px rgba(2, 8, 20, 0.32);
  }
  .btn.danger:hover { background: #a92e22; }
  .leagues-table th:last-child,
  .leagues-table td:last-child {
    text-align: right;
    width: 1%;
    white-space: nowrap;
  }
  .leagues-table td .inline-form { display: inline-block; margin-left: 6px; }
  .leagues-table td .inline-form:first-child { margin-left: 0; }
  .copy-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
  }
  .copy-btn:hover {
    color: var(--text);
    background: var(--primary-soft);
    border-color: rgba(58, 163, 245, 0.30);
  }
  .copy-btn .icon-check { display: none; }
  .copy-btn.copy-btn-success {
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.35);
    background: var(--green-dim);
  }
  .copy-btn.copy-btn-success .icon-copy { display: none; }
  .copy-btn.copy-btn-success .icon-check { display: inline-block; }
  .messages { list-style: none; padding: 0; }
  .messages li {
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--primary);
    background: var(--bg-soft);
    font-size: 0.94rem;
  }
  .messages li.success { background: var(--success-bg); }
  .messages li.error { background: var(--error-bg); }
  table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    overflow: hidden;
  }
  .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-scroll table { min-width: 100%; }
  .scroll-hint { position: relative; }
  .scroll-hint .scroll-hint-cue { display: none; }
  @media (max-width: 760px) {
    .scroll-hint::after {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      width: 44px;
      pointer-events: none;
      background: linear-gradient(to right, rgba(23, 52, 89, 0) 0%, var(--surface-alt) 80%);
      border-top-right-radius: 10px;
      border-bottom-right-radius: 10px;
    }
    .scroll-hint .scroll-hint-cue {
      display: flex;
      align-items: center;
      justify-content: center;
      position: absolute;
      top: 0;
      right: 4px;
      bottom: 0;
      width: 22px;
      pointer-events: none;
      color: var(--accent);
      font-size: 1.6rem;
      font-weight: 800;
      line-height: 1;
      animation: scroll-hint-bounce 1.4s ease-in-out infinite;
    }
  }
  @keyframes scroll-hint-bounce {
    0%, 100% { transform: translateX(0); opacity: 0.85; }
    50%      { transform: translateX(-6px); opacity: 1; }
  }
  th, td {
    border-bottom: 1px solid var(--border-soft);
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    overflow-wrap: anywhere;
  }
  tbody tr:last-child td { border-bottom: 0; }
  th {
    background: rgba(58, 163, 245, 0.06);
    color: var(--text-muted);
    font-family: "Plus Jakarta Sans", sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.74rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
  }
  tr:hover td { background: rgba(58, 163, 245, 0.05); }
  .numeric-cell, .status-cell { white-space: nowrap; }

  /* Medal / highlight rows */
  .rank-gold td { background: rgba(240, 200, 80, 0.08); }
  .rank-silver td { background: rgba(176, 196, 216, 0.06); }
  .rank-bronze td { background: rgba(205, 127, 50, 0.06); }
  .rank-medal {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 800;
  }
  .rank-medal::before {
    font-size: 1rem;
    line-height: 1;
  }
  .rank-gold .rank-medal { color: var(--gold); }
  .rank-gold .rank-medal::before { content: "\1F947"; }
  .rank-silver .rank-medal { color: var(--silver); }
  .rank-silver .rank-medal::before { content: "\1F948"; }
  .rank-bronze .rank-medal { color: var(--bronze); }
  .rank-bronze .rank-medal::before { content: "\1F949"; }
  tr.rank-you td {
    background: rgba(58, 163, 245, 0.12);
    font-weight: 600;
  }
  tr.rank-you td:first-child {
    box-shadow: inset 2px 0 0 var(--primary);
  }
  .player-team {
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
  }
  .player-manager {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.25;
    margin-top: 2px;
  }

  .badge {
    background: rgba(125, 211, 252, 0.12);
    border: 1px solid rgba(125, 211, 252, 0.35);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
  }
  .nav-left { justify-self: start; }
  .nav-menu { display: flex; align-items: center; gap: 4px; justify-self: center; flex-wrap: wrap; }
  .nav-menu a {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--text-soft);
    font-weight: 500;
    font-size: 0.92rem;
    transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
  }
  .nav-menu a:hover {
    color: var(--text);
    background: rgba(58, 163, 245, 0.08);
  }
  .nav-menu a.brand {
    color: var(--text);
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-right: 6px;
  }
  .nav-menu a.is-active {
    color: var(--text);
    background: var(--primary-soft);
    border-color: rgba(58, 163, 245, 0.30);
  }
  .nav-right { display: flex; align-items: center; gap: 10px; justify-self: end; }
  .nav-right > a {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--text-soft);
    font-weight: 500;
    font-size: 0.92rem;
    transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
  }
  .nav-right > a:hover {
    color: var(--text);
    background: rgba(58, 163, 245, 0.08);
  }
  .nav-right > a.is-active {
    color: var(--text);
    background: var(--primary-soft);
    border-color: rgba(58, 163, 245, 0.30);
  }
  .nav-divider {
    width: 1px;
    height: 22px;
    background: var(--border-soft);
    margin: 0 4px;
  }
  .league-switcher { display: flex; align-items: center; }
  .league-switcher select {
    width: auto;
    min-width: 170px;
    padding: 7px 30px 7px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    background-color: var(--bg-soft);
    border-color: var(--border-soft);
  }
  .league-switcher select:hover { border-color: var(--border); }
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .nav-user {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }
  .inline-form { margin: 0; }
  input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 0.94rem;
    font-family: inherit;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
  }
  input:hover, select:hover, textarea:hover {
    border-color: var(--border);
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
    background: var(--surface);
  }
  input::placeholder, textarea::placeholder { color: var(--text-muted); }
  label { display: block; color: var(--text-soft); margin-bottom: 6px; font-size: 0.88rem; font-weight: 500; }
  .form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
  }
  .form-row .form-field { flex: 0 1 280px; min-width: 0; }
  .form-row .form-field input { width: 100%; }
  .form-row .btn { flex: 0 0 auto; }
  h1, h2, h3, h4 {
    margin-top: 0;
    font-family: "Plus Jakarta Sans", sans-serif;
    letter-spacing: -0.01em;
    color: var(--text);
    font-weight: 700;
  }
  h1 { font-size: 1.65rem; line-height: 1.2; }
  h2 { font-size: 1.3rem; line-height: 1.25; }
  h3 { font-size: 1.05rem; line-height: 1.3; }
  p, li { color: var(--text-soft); overflow-wrap: anywhere; line-height: 1.55; }
  strong { color: var(--text); font-weight: 600; }
  code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; border: 1px solid var(--border-soft); }
  .page-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
  }
  .page-header-copy {
    display: grid;
    gap: 6px;
    min-width: 0;
  }
  .page-header h1,
  .page-header h2,
  .page-header h3,
  .page-header p {
    margin: 0;
  }
  .page-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
  }
  .page-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    min-width: 0;
  }
  .page-header-meta p { margin: 0; }
  .page-meta-badge {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(46, 168, 255, 0.22);
    background: rgba(46, 168, 255, 0.08);
    color: var(--text-soft);
  }
  .badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .login-card {
    max-width: 460px;
    margin: 40px auto;
  }
  .field-spacer { margin-top: 12px; }
  .btn-block {
    width: 100%;
    margin-top: 16px;
  }
  .auth-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    max-width: 960px;
    margin: 40px auto;
  }
  .auth-card {
    margin-bottom: 0;
  }
  .auth-card-intro {
    margin: 0 0 18px;
  }
  .errorlist {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    color: #ffd5dc;
    font-size: 0.92rem;
  }
  .errorlist li {
    margin: 0;
  }
  .helptext {
    margin-top: 8px;
    color: var(--text-soft);
    font-size: 0.83rem;
  }
  .helptext ul {
    margin: 6px 0 0 18px;
    padding: 0;
  }

  /* Stat cards */
  .stat-card {
    text-align: center;
    padding: 20px 14px;
  }
  .stat-card h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    margin: 0 0 8px;
    font-weight: 600;
  }
  .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.02em;
  }
  .stat-value.accent { color: var(--accent); }
  .stat-value.gold { color: var(--gold); }

  /* Empty states */
  .empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-soft);
  }
  .empty-state-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
    opacity: 0.7;
  }
  .empty-state p {
    margin: 4px 0;
    font-size: 0.95rem;
  }

  /* Badge card */
  .badge-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }
  .badge-card-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    width: 42px;
    text-align: center;
  }
  .badge-card-body h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
  }
  .badge-card-body p {
    margin: 0;
    font-size: 0.88rem;
  }
  .badge-card.badge-earned {
    border-color: rgba(125, 211, 252, 0.32);
    background: linear-gradient(150deg, rgba(125, 211, 252, 0.06), var(--surface));
  }
  .badge-card.badge-locked {
    opacity: 0.5;
  }

  /* Your badges inline list */
  .your-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .your-badge-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(125, 211, 252, 0.1);
    border: 1px solid rgba(125, 211, 252, 0.3);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--accent);
  }
  .your-badge-item .badge-emoji {
    font-size: 1.1rem;
  }

  @keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @media (max-width: 960px) {
    nav { grid-template-columns: 1fr; row-gap: 10px; }
    .nav-left { display: none; }
    .nav-menu, .nav-right { justify-self: center; }
    .nav-menu { justify-content: center; }
  }
  @media (max-width: 760px) {
    nav { padding: 12px 14px; }
    .container {
      margin: 16px auto;
      padding: 0 12px;
    }
    .card {
      padding: 14px;
      margin-bottom: 12px;
    }
    .nav-menu {
      width: 100%;
      justify-content: center;
      flex-wrap: wrap;
      overflow: visible;
      padding-bottom: 0;
      gap: 6px;
    }
    .nav-menu a {
      max-width: 100%;
      text-align: center;
    }
    .nav-menu a.brand {
      flex: 1 0 100%;
      margin-right: 0;
      margin-bottom: 2px;
    }
    .nav-right {
      width: 100%;
      justify-content: center;
      flex-wrap: wrap;
      row-gap: 10px;
      text-align: center;
    }
    .page-header {
      gap: 8px;
    }
    .page-header-meta { gap: 8px; }
    .page-meta-badge { width: 100%; justify-content: center; }
    th, td { padding: 9px 8px; }
    th { font-size: 0.76rem; letter-spacing: 0.04em; }
    .table-scroll table {
      min-width: 440px;
    }
    .table-scroll.table-wide table {
      min-width: 560px;
    }
    .login-card {
      margin: 20px auto;
    }
    .stat-value { font-size: 1.6rem; }
  }
  @media (max-width: 560px) {
    .page-meta-badge { justify-content: flex-start; }
    .table-scroll table {
      min-width: 380px;
    }
    .table-scroll.table-wide table {
      min-width: 500px;
    }
  }

  /* Used coins */
  .used-coins-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .used-coins-round {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .used-coins-label {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 80px;
  }
  .used-coins-values {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .used-coin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    box-shadow: 0 1px 2px rgba(2, 8, 20, 0.32);
  }

  .predictions-table tr.prediction-hit td { background: rgba(52, 211, 153, 0.08); }
  .predictions-table tr.prediction-miss td { background: rgba(244, 63, 94, 0.06); }

  /* Countdown ticker */
  .countdown-card { text-align: center; }
  .countdown-label {
    font-family: "Plus Jakarta Sans", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    color: var(--text-soft);
    margin-bottom: 10px;
  }
  .countdown-clock {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
  }
  .countdown-segment {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 68px;
    justify-content: center;
  }
  .countdown-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
  }
  .countdown-unit {
    font-size: 0.85rem;
    color: var(--text-soft);
    font-weight: 700;
  }
  .countdown-meta {
    margin-top: 12px;
    color: var(--text-soft);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  .countdown-meta .team-flag { vertical-align: middle; }
  .countdown-meta-sep { opacity: 0.6; }
  .countdown-card.countdown-soon .countdown-value { color: var(--warning); }
  .countdown-card.countdown-expired .countdown-value { color: var(--text-soft); }
  @media (max-width: 560px) {
    .countdown-clock { gap: 8px; }
    .countdown-segment { min-width: 56px; padding: 6px 8px; }
    .countdown-value { font-size: 1.5rem; }
  }

  /* Mobile layout for predictions page */
  @media (max-width: 600px) {
    .predictions-stats {
      flex-direction: column;
      align-items: flex-start;
      gap: 4px;
    }
    .predictions-stats-sep {
      display: none;
    }
    .predictions-table {
      min-width: 0 !important;
    }
    .predictions-table thead {
      display: none;
    }
    .predictions-table tbody tr {
      display: block;
      border: 1px solid var(--border);
      border-radius: 8px;
      margin-bottom: 12px;
      padding: 4px 0;
    }
    .predictions-table tbody tr td {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 14px;
      text-align: right;
      border: none;
    }
    .predictions-table tbody tr td::before {
      content: attr(data-label);
      font-weight: 600;
      text-transform: uppercase;
      font-size: 0.78rem;
      letter-spacing: 0.04em;
      color: var(--text-secondary);
      text-align: left;
      margin-right: 12px;
    }
    .predictions-table tbody tr td[colspan] {
      display: block;
      text-align: center;
    }
    .predictions-table tbody tr td[colspan]::before {
      display: none;
    }
  }
