/* ── PI FIFA Contest 2026 — Global Styles ─────────────────────── */
:root {
  --navy:   #1F3864;
  --gold:   #BF9000;
  --lgold:  #FFF2CC;
  --green:  #375623;
  --lgreen: #E2EFDA;
  --red:    #C00000;
  --grey:   #F2F2F2;
  --white:  #FFFFFF;
  --text:   #1a1a1a;
  --muted:  #6c757d;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.12);
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0f2f5;
  color: var(--text);
  min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
  background: var(--navy);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar .brand {
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar .brand span { color: var(--white); font-weight: 400; }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  background: rgba(255,255,255,.12);
  color: var(--white);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: .8rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-login, .btn-logout {
  border: 1px solid rgba(255,255,255,.4);
  background: transparent;
  color: var(--white);
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
}
.btn-login:hover  { background: rgba(255,255,255,.15); }
.btn-logout:hover { background: rgba(255,0,0,.2); }

/* ── Page layout ─────────────────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, var(--navy) 0%, #2c4f8f 100%);
  color: var(--white);
  padding: 32px 24px 24px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 1.6rem; margin-bottom: 4px; }
.page-header p  { opacity: .8; font-size: .95rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px 48px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--lgold);
}

/* ── Deadline banner ─────────────────────────────────────────────── */
.deadline-banner {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.deadline-banner.open   { background: var(--lgreen); color: var(--green); border-left: 4px solid var(--green); }
.deadline-banner.locked { background: #fce4ec;        color: var(--red);   border-left: 4px solid var(--red); }

/* ── Group pick grid ─────────────────────────────────────────────── */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.group-card {
  background: var(--white);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 16px;
}
.group-card h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.pick-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pick-row label { font-size: .8rem; color: var(--muted); width: 52px; flex-shrink: 0; }
.pick-row select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: .875rem;
  background: var(--white);
}
.pick-row select:focus { outline: none; border-color: var(--navy); }
.pick-row select:disabled { background: var(--grey); cursor: not-allowed; }

/* ── Third-place qualifier picks ────────────────────────────────── */
.third-place-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.third-place-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 10px 12px;
}
.third-place-rank {
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  width: 48px;
  flex-shrink: 0;
}
.third-place-card select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: .85rem;
  background: var(--white);
}
.third-place-card select:focus { outline: none; border-color: var(--navy); }
.third-place-card select:disabled { background: var(--grey); cursor: not-allowed; }

/* ── KO bracket table ───────────────────────────────────────────── */
.team-label.tbd  { color: var(--muted); font-style: italic; }
.score-sep       { font-weight: 700; color: var(--muted); text-align: center; }
.round-heading   { font-size: .9rem; font-weight: 700; margin-bottom: 8px; color: var(--navy); }

/* Penalty selector — shown only for drawn matches */
.pens-cell  { white-space: nowrap; padding-left: 8px; }
.pens-label { font-size: .7rem; color: var(--muted); display: block; margin-bottom: 3px; }
.pens-btn {
  padding: 3px 8px;
  font-size: .75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  margin: 2px 2px 2px 0;
  transition: background .15s, color .15s;
}
.pens-btn:hover   { border-color: var(--navy); }
.pens-btn.selected { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.pens-header { font-size: .8rem; color: var(--muted); }
@media (max-width: 640px) {
  .pens-header { display: none; }
  .pens-cell   { display: block; padding: 4px 0 0 0; }
}
.ko-section { margin-bottom: 24px; }
.ko-section h3 {
  font-size: .9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--white);
  background: var(--navy);
  padding: 6px 12px;
  border-radius: 4px 4px 0 0;
  margin-bottom: 0;
}
.ko-table { width: 100%; border-collapse: collapse; }
.ko-table th, .ko-table td {
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  font-size: .875rem;
  text-align: center;
}
.ko-table th  { background: var(--grey); font-weight: 600; font-size: .8rem; }
.ko-table td.match-label { font-weight: 600; color: var(--navy); background: #f8f9ff; }
.ko-table td.team-label  { text-align: left; font-size: .85rem; color: var(--muted); font-style: italic; }
.ko-table input[type=number] {
  width: 52px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
  font-size: .9rem;
}
.ko-table input:focus    { outline: none; border-color: var(--navy); }
.ko-table input:disabled { background: var(--grey); }

/* ── Submit button ───────────────────────────────────────────────── */
.btn-submit {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 11px 32px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: 8px;
}
.btn-submit:hover    { background: #2c4f8f; }
.btn-submit:disabled { background: #aaa; cursor: not-allowed; }

/* ── Leaderboard ─────────────────────────────────────────────────── */
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #e8e8e8;
  font-size: .9rem;
}
.lb-table th { background: var(--navy); color: var(--white); font-weight: 600; font-size: .8rem; text-align: left; }
.lb-table tr:hover td { background: #f8f9ff; }
.rank-badge {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--grey);
  text-align: center;
  line-height: 28px;
  font-weight: 700;
  font-size: .85rem;
}
.rank-badge.gold   { background: #ffd700; color: #7a5800; }
.rank-badge.silver { background: #c0c0c0; color: #4a4a4a; }
.rank-badge.bronze { background: #cd7f32; color: var(--white); }

/* ── Teams grid ─────────────────────────────────────────────────── */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.team-card {
  background: var(--white);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.team-group-badge {
  background: var(--navy);
  color: var(--gold);
  font-weight: 700;
  font-size: .8rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.team-info .name   { font-weight: 600; font-size: .9rem; }
.team-info .meta   { font-size: .75rem; color: var(--muted); }
.ranking-pill {
  margin-left: auto;
  background: var(--lgold);
  color: var(--gold);
  font-weight: 700;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ── Toast / alert ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: var(--white);
  font-size: .9rem;
  box-shadow: var(--shadow);
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── Auth overlay ───────────────────────────────────────────────── */
.auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.auth-overlay.show { display: flex; }
.auth-box {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.auth-box h2 { color: var(--navy); margin-bottom: 8px; }
.auth-box p  { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.btn-ms-login {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .15s;
}
.btn-ms-login:hover { background: #2c4f8f; }

/* ── Rules page ─────────────────────────────────────────────────── */
.rules-section { margin-bottom: 20px; }
.rules-section h3 { font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.rules-section ul { padding-left: 20px; }
.rules-section li { margin-bottom: 6px; font-size: .9rem; line-height: 1.6; }
.score-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.score-table th, .score-table td {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  font-size: .875rem;
  text-align: center;
}
.score-table th { background: var(--navy); color: var(--white); }
.score-table tr:nth-child(even) td { background: var(--grey); }

/* ── Fixtures ─────────────────────────────────────────────────────── */
.fixture-table { width: 100%; border-collapse: collapse; }
.fixture-table th, .fixture-table td { padding: 7px 10px; border-bottom: 1px solid #eee; font-size: .85rem; }
.fixture-table th { background: var(--grey); font-size: .8rem; font-weight: 600; }
.match-id { font-weight: 600; color: var(--navy); }
.match-type { font-size: .75rem; padding: 2px 7px; border-radius: 10px; }
.type-1v3 { background: #fce4ec; color: var(--red); }
.type-1v2 { background: var(--lgreen); color: var(--green); }
.type-2v2 { background: var(--lgold); color: var(--gold); }

@media (max-width: 640px) {
  .nav-links { display: none; }
  .groups-grid { grid-template-columns: 1fr; }
  .teams-grid  { grid-template-columns: 1fr; }
}
