:root {
  /* White-dominant base */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F6F4EF;
  --ink: #1B1E22;
  --ink-soft: #525960;
  --muted: #95999E;
  --line: #ECE6D8;
  --line-soft: #F4EEDF;

  /* WC 26 palette — used as washed accents */
  --coral: #F4A89A;
  --coral-soft: #FBE3DA;
  --coral-deep: #D87E6E;

  --purple: #C9B5DD;
  --purple-soft: #ECE2F2;
  --purple-deep: #8E72B4;

  --lime: #C3DE99;
  --lime-soft: #E6F0D2;
  --lime-deep: #5E8A37;

  --gold: #ECC76A;
  --gold-soft: #F8E7B5;
  --gold-ink: #6B5217;

  /* Prediction cell colours (Excel-style) */
  --cell-miss: #F9D3CB;
  --cell-miss-ink: #8A3A2A;
  --cell-outcome: #CDE6A8;
  --cell-outcome-ink: #3F5E1F;
  --cell-exact: #5BB070;
  --cell-exact-ink: #0E2415;
  --cell-empty: #FAF7F0;
  --cell-pending: #F5EFDF;

  --primary: var(--coral-deep);
  --primary-soft: var(--coral-soft);
  --primary-deep: #B5604F;

  --shadow-sm: 0 1px 2px rgba(20, 24, 28, 0.04);
  --shadow-md: 0 4px 14px rgba(20, 24, 28, 0.05);
  --shadow-lg: 0 8px 28px rgba(20, 24, 28, 0.08);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
}

/* Subtle WC 26 ornaments — washed pastel shapes in corners on white */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle 360px at 6% 4%,   var(--coral-soft)  0%, transparent 60%),
    radial-gradient(circle 340px at 96% 8%,  var(--purple-soft) 0%, transparent 60%),
    radial-gradient(circle 420px at 0% 70%,  var(--lime-soft)   0%, transparent 55%),
    radial-gradient(circle 320px at 100% 95%,var(--gold-soft)   0%, transparent 60%);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 64px;
  min-height: 100vh;
}

/* ===== Topbar ===== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 14px 0;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.brand-title {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-year { color: var(--coral-deep); font-weight: 800; }
.brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-top: 1px;
  text-transform: uppercase;
}
.who {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  flex-shrink: 0;
}
#whoami {
  font-weight: 700;
  color: var(--ink);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Tabs ===== */

.tabs {
  display: flex;
  gap: 0;
  margin-top: 10px;
}
.tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 8px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  min-height: auto;
  border-radius: 0;
}
.tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--primary);
}
.tabs button:hover { color: var(--ink); background: transparent; }

/* ===== Buttons / inputs ===== */

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 10px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  min-height: 40px;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button[type="submit"], button.primary {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
  font-weight: 600;
}
button[type="submit"]:hover:not(:disabled),
button.primary:hover:not(:disabled) {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
}
button.link {
  border: none;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  min-height: 0;
  font-weight: 500;
}
button.link:hover { background: transparent; color: var(--primary-deep); }

input[type="text"], input[type="number"] {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input[type="number"] {
  width: 54px;
  text-align: center;
  -moz-appearance: textfield;
  font-weight: 700;
  font-size: 16px;
  padding: 9px 6px;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ===== Login ===== */

.login {
  max-width: 380px;
  margin: 60px auto 0;
  padding: 0 16px;
}
.login-card {
  background: var(--surface);
  padding: 32px 24px 28px;
  border-radius: 18px;
  border: 1px solid var(--line);
  text-align: center;
  box-shadow: var(--shadow-md);
}
.login-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 30%, var(--coral) 0%, transparent 50%),
    radial-gradient(circle at 70% 30%, var(--purple) 0%, transparent 50%),
    radial-gradient(circle at 30% 70%, var(--lime) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, var(--gold) 0%, transparent 50%),
    var(--surface-2);
  box-shadow: var(--shadow-sm);
}
.login h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.login h2 .year { color: var(--coral-deep); }
.login .badge-row {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.login p.muted {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.45;
}
.login form { display: flex; gap: 8px; }
.login input { flex: 1; }

/* ===== View container ===== */

.view { padding: 12px 14px; }

/* ===== Day nav ===== */

.day-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
  padding: 10px 0 12px;
}
.day-arrow {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.day-arrow:disabled {
  color: var(--muted);
  background: transparent;
  border-color: var(--line-soft);
}
.day-current {
  height: 56px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.day-weekday {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.day-date {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-top: 1px;
}
.today-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--coral);
  color: #FFF;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* Inline day picker (when tapping the day chip) */
.day-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 12px;
  justify-content: center;
}
.day-pager button {
  padding: 6px 12px;
  min-height: 0;
  font-size: 13px;
  border-radius: 999px;
  font-weight: 500;
}
.day-pager button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

/* ===== Match card ===== */

.match {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.match-head .time { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.match-head .badges { display: flex; gap: 6px; align-items: center; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
}
.badge.group {
  background: var(--purple-soft);
  color: var(--purple-deep);
  border-color: transparent;
}
.badge.live {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}
.badge.done {
  background: var(--lime-soft);
  color: var(--lime-deep);
  border-color: transparent;
}
.badge.stage {
  background: var(--coral-soft);
  color: var(--coral-deep);
  border-color: transparent;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 14px;
}
.team {
  font-weight: 700;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: break-word;
}
.team.home { text-align: right; }
.team.away { text-align: left; }

.score {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.score .vs {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.actual {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  padding: 3px 12px;
  background: var(--lime-soft);
  border-radius: 10px;
  letter-spacing: -0.01em;
}
.actual.live { background: var(--gold-soft); }
.actual .sep { color: var(--muted); font-weight: 600; }

/* ===== Your pick row ===== */

.pick-row {
  padding: 12px 14px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
}
.pick-row .label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.pick-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pick-form .vs { color: var(--muted); font-weight: 500; }
.pick-form button {
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
}
.pick-display {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}
.pick-display.empty { color: var(--muted); font-weight: 500; font-size: 14px; }

.points-pill {
  display: inline-flex;
  align-items: center;
  background: var(--lime-soft);
  color: var(--lime-deep);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}
.points-pill.zero {
  background: var(--surface-2);
  color: var(--muted);
}
.points-pill.exact {
  background: var(--gold-soft);
  color: var(--gold-ink);
}
.pick-meta { font-size: 12px; color: var(--muted); }

/* ===== Others' picks accordion ===== */

.others { border-top: 1px solid var(--line-soft); }
.others-toggle {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.others-toggle:hover { background: var(--surface-2); }
.others-toggle .chev { transition: transform 0.2s; color: var(--muted); }
.others-toggle.open .chev { transform: rotate(180deg); }

.others-list {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px 12px;
  padding: 4px 14px 14px;
  font-size: 14px;
}
.others-list .o-name { color: var(--ink-soft); }
.others-list .o-pick {
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink);
  font-weight: 600;
}
.others-list .o-pts {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.others-list .o-pts.exact { color: var(--gold-ink); }
.others-list .o-pts.gain { color: var(--lime-deep); }

/* ===== Predictions overview (transposed: matches as columns, players as rows) ===== */

.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.pred-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}
.pred-table thead th {
  background: var(--surface-2);
  text-align: center;
  padding: 6px 2px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.pred-table thead th.player-col {
  text-align: left;
  padding-left: 10px;
  width: 78px;
  background: var(--surface-2);
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.match-head-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1.05;
}
.match-head-stack .team-abbr {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.match-head-stack .team-abbr.away { color: var(--ink-soft); }
.match-head-stack .time-mini {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.match-head-stack .actual-mini {
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--lime-soft);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
}
.match-head-stack .actual-mini.live {
  background: var(--gold-soft);
  color: var(--gold-ink);
  position: relative;
}
.match-head-stack .actual-mini.live::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold-ink);
  animation: pulse 1.4s ease-in-out infinite;
}
.match-head-stack .actual-mini.pending {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  box-shadow: none;
  font-size: 13px;
  padding: 2px 8px;
}

.pred-table tbody td {
  padding: 8px 2px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.pred-table tbody td.player-col {
  text-align: left;
  padding-left: 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pred-table tbody td.player-col.me {
  background: var(--coral-soft);
  color: var(--coral-deep);
}
.pred-table tbody tr:last-child td { border-bottom: none; }

.pred-cell { background: var(--cell-empty); color: var(--ink); }
.pred-cell.hidden { background: var(--cell-pending); color: var(--muted); font-weight: 500; }
.pred-cell.empty { background: var(--cell-empty); color: var(--muted); font-weight: 500; }
.pred-cell.miss { background: var(--cell-miss); color: var(--cell-miss-ink); }
.pred-cell.outcome { background: var(--cell-outcome); color: var(--cell-outcome-ink); }
.pred-cell.exact { background: var(--cell-exact); color: var(--cell-exact-ink); font-weight: 800; }

.pred-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 6px;
  padding: 4px 4px;
  justify-content: center;
}
.pred-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.pred-legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.pred-legend .swatch.exact { background: var(--cell-exact); }
.pred-legend .swatch.outcome { background: var(--cell-outcome); }
.pred-legend .swatch.miss { background: var(--cell-miss); }
.pred-legend .swatch.pending { background: var(--cell-pending); }

/* ===== Standings ===== */

.standings {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-top: 4px;
}
.standings table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.standings th, .standings td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  text-align: center;
}
.standings th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--surface-2);
  font-weight: 700;
}
.standings th:first-child, .standings td.rank {
  width: 32px;
  padding-left: 10px;
  text-align: left;
}
.standings th:nth-child(2), .standings td:nth-child(2) {
  text-align: left;
  padding-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.standings td.rank {
  font-weight: 700;
  color: var(--ink-soft);
}
.standings td.points {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.standings td.num, .standings th.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.standings tr:last-child td { border-bottom: none; }
.standings tr.me td { background: var(--coral-soft); }
.standings tr.me td.points { color: var(--coral-deep); }
.standings tr.top-1 td.rank { color: var(--gold-ink); }

/* ===== Empty + utility ===== */

.muted { color: var(--muted); font-size: 14px; }
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
}
.loading { text-align: center; color: var(--muted); padding: 36px 0; font-size: 14px; }

/* ===== Footer ===== */

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  z-index: 40;
}

/* ===== Toast ===== */

.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #FFF;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
.toast.show { opacity: 1; }

/* ===== Wider phones / desktop ===== */

@media (min-width: 520px) {
  body { font-size: 16px; }
  .view { padding: 14px 16px; }
  .day-current { height: 60px; }
  .day-date { font-size: 18px; }
  .team { font-size: 16px; }
  .brand-title { font-size: 17px; }
}
@media (min-width: 720px) {
  #app { max-width: 640px; }
  .login { margin-top: 80px; }
}
