:root {
  --bg:       #0a1628;
  --surface:  #0f2040;
  --border:   #1e3a5f;
  --accent:   #00c2a8;
  --gold:     #f5c518;
  --text:     #e8edf5;
  --muted:    #7a92b3;
  --danger:   #e55353;
  --radius:   8px;
  --font:     -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 960px; margin: 0 auto; padding: 0 1rem; }

/* ── League portal ── */
.portal-page {
  min-height: 100vh;
}
.portal-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.portal-grid {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}
.portal-tile {
  min-height: min(52vh, 420px);
  background: linear-gradient(145deg, #10284f, var(--surface));
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .22);
  transition: transform .16s, border-color .16s, box-shadow .16s;
}
.portal-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 24px 70px rgba(0, 194, 168, .12);
  text-decoration: none;
  transform: translateY(-3px);
}
.portal-tile span {
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.22;
}
.portal-tile-league2 {
  background: linear-gradient(145deg, #362309, #0f2040);
}

/* ── League pages ── */
.league-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.5rem 0;
  padding: 1.5rem;
}
.league-hero h1 {
  font-size: 1.8rem;
  line-height: 1.25;
  margin: .25rem 0 .45rem;
}
.league-hero p {
  color: var(--muted);
  font-size: .95rem;
}
.league2-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.league2-rule-panel {
  min-width: 0;
}
.league2-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.league2-group-card {
  background: #0c1c30;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.league2-group-title {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--gold);
  font-weight: 800;
  padding: .7rem .85rem;
}
.league2-group-table tbody td {
  padding: .55rem .65rem;
}
.league2-member-sub,
.league2-me-meta {
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.45;
}
.league2-me-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem 1rem;
}

/* ── Nav ── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; max-width: 960px; margin: 0 auto; padding: 0 1rem;
}
.nav-logo {
  font-size: 1.1rem; font-weight: 700; color: var(--gold); letter-spacing: .03em;
}
.nav-links { display: flex; gap: 1rem; align-items: center; }
.nav-links a { color: var(--muted); font-size: .9rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.btn-nav {
  background: var(--accent); color: #000; border: none; border-radius: var(--radius);
  padding: .35rem .85rem; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.btn-nav:hover { opacity: .88; }

/* ── Hero / round card ── */
.round-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
}
.round-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.round-name  { font-size: 1.2rem; font-weight: 700; margin-top: .2rem; }
.round-badge {
  font-size: .7rem; font-weight: 600; padding: .2rem .5rem;
  border-radius: 4px; margin-left: .5rem; vertical-align: middle;
}
.badge-open     { background: #0d4429; color: #3dd68c; }
.badge-upcoming { background: #1e2f4a; color: var(--muted); }
.badge-closed   { background: #3a1f1f; color: #e88; }
.badge-scored   { background: #2a1f00; color: var(--gold); }

.countdown { text-align: right; }
.countdown-label { font-size: .75rem; color: var(--muted); }
.countdown-time  { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold); }

/* ── Section heading ── */
.section-title {
  font-size: 1rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin: 1.5rem 0 .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Leaderboard table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  background: var(--surface); color: var(--muted);
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  padding: .6rem .75rem; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
thead th.num { text-align: right; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:hover { background: #ffffff08; }
tbody td { padding: .65rem .75rem; vertical-align: middle; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
tbody td.total { text-align: right; font-weight: 700; color: var(--gold); }
.rank { color: var(--muted); font-size: .8rem; width: 2rem; }
.rank-1 { color: var(--gold); }
.rank-2 { color: #bbb; }
.rank-3 { color: #cd7f32; }
.squad-name { font-weight: 600; }

/* ── Empty state ── */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--muted); font-size: .95rem;
}

/* ── Auth card ── */
.auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 420px;
  padding: 2rem;
}
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .3rem; }
.auth-sub   { font-size: .9rem; color: var(--muted); margin-bottom: 1.75rem; }
.auth-hint  { font-size: .78rem; color: var(--muted); margin-top: .45rem; line-height: 1.45; }

/* ── Form ── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
input[type="email"],
input[type="text"],
input[type="number"],
input[type="password"],
select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem .85rem; font-size: .95rem; font-family: inherit;
  transition: border-color .15s;
  -webkit-appearance: none;
}
input:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: .6; }

.btn {
  width: 100%; padding: .7rem 1rem; border: none; border-radius: var(--radius);
  font-size: .95rem; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  margin-top: .5rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ── Messages ── */
.msg {
  font-size: .85rem; padding: .6rem .85rem; border-radius: var(--radius);
  margin-bottom: 1rem;
}
.msg-error   { background: #3a1212; color: #f28b8b; border: 1px solid #6b2020; }
.msg-success { background: #0d3020; color: #6ee08c; border: 1px solid #1b5c38; }
.msg-info    { background: #0d2040; color: #70b4f0; border: 1px solid #1e3f6e; }

/* ── OTP input ── */
.otp-input {
  letter-spacing: .25em; font-size: 1.3rem; text-align: center; font-weight: 700;
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Footer ── */
footer {
  text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: .8rem;
  border-top: 1px solid var(--border); margin-top: 3rem;
}

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.3);
  border-top-color: #000; border-radius: 50%;
  animation: spin .6s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard ── */
.dash-greeting {
  margin: 1.5rem 0 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.pick-counter {
  font-size: .8rem;
  color: var(--muted);
  margin-left: .6rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.pick-actions {
  margin-top: 1.25rem;
  max-width: 360px;
}

/* ── Confederation groups ── */
.confed-group  { margin-bottom: 1.25rem; }
.confed-label  {
  font-size: .72rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: .5rem;
}

/* ── Team grid ── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: .45rem;
}

.team-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .35rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s;
  width: 100%;
  font-family: inherit;
}
.team-card:hover {
  border-color: var(--accent);
  background: #0d2038;
}
.team-card-selected {
  border-color: var(--accent);
  background: #062218;
}
.team-card-used {
  opacity: .3;
}
.team-card-used,
.team-card[data-disabled="1"] {
  cursor: not-allowed;
}
.team-card[data-disabled="1"] .team-info {
  cursor: pointer;
}
.team-code {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .05em;
}
.team-card-selected .team-code { color: #3dd68c; }
.team-name {
  display: block;
  font-size: .68rem;
  color: var(--muted);
  margin-top: .15rem;
  line-height: 1.25;
}
.team-fixture {
  display: block;
  min-height: 2.4em;
  margin-top: .35rem;
  color: var(--text);
  font-size: .68rem;
  line-height: 1.2;
}
.team-info {
  display: inline-block;
  margin-top: .35rem;
  color: var(--accent);
  font-size: .68rem;
}

/* ── History cards ── */
.history-card {
  background: #0c1c30;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: .65rem;
}
.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .55rem;
}
.history-round-label { font-weight: 600; font-size: .9rem; }
.points-badge {
  background: #2a1f00;
  color: var(--gold);
  font-size: .8rem;
  font-weight: 700;
  padding: .18rem .5rem;
  border-radius: 4px;
}
.history-teams  { display: flex; flex-wrap: wrap; gap: .4rem; }
.history-team {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  padding: .2rem .5rem;
  color: var(--text);
}
.history-team.submitted {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Admin ── */
.admin-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto minmax(120px, .6fr) auto minmax(120px, .8fr) auto minmax(140px, .8fr) auto;
  align-items: center;
  gap: .75rem;
  margin: 1rem 0 1.5rem;
}
.admin-toolbar label {
  margin-bottom: 0;
  white-space: nowrap;
}
.admin-actions {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(140px, 220px);
  gap: .75rem;
  margin-top: 1rem;
}
.score-input {
  max-width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .62);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: relative;
}
.modal-close {
  position: absolute;
  top: .65rem;
  right: .75rem;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: .85rem;
}
.schedule-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 0;
  border-top: 1px solid var(--border);
}
.schedule-main { font-weight: 700; font-size: .9rem; }
.schedule-sub { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.schedule-time {
  color: var(--gold);
  font-weight: 700;
  font-size: .85rem;
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .portal-wrap { align-items: stretch; }
  .portal-grid { grid-template-columns: 1fr; }
  .league2-rule-grid { grid-template-columns: 1fr; }
  .portal-tile { min-height: 34vh; }
  .round-card { flex-direction: column; align-items: flex-start; }
  .countdown  { text-align: left; }
  .auth-card  { padding: 1.5rem; }
  .team-grid  { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .admin-toolbar,
  .admin-actions { grid-template-columns: 1fr; }
}
