/* ==================== VARIABLES ==================== */
:root {
  --green: #009c3b;
  --green-dark: #007a2e;
  --yellow: #ffdf00;
  --blue: #002776;
  --blue-light: #1a3a8a;
  --white: #ffffff;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666;
  --red: #dc3545;
  --orange: #fd7e14;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ==================== RESET ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
input, button, select, textarea { font-family: inherit; font-size: 1rem; }
a { cursor: pointer; color: var(--green); text-decoration: underline; }
button { cursor: pointer; border: none; outline: none; }

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }

/* ==================== BUTTONS ==================== */
.btn-primary {
  background: var(--green);
  color: white;
  padding: .75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 1rem;
  transition: background .2s, transform .1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--green);
  border: 2px solid var(--green);
  padding: .6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: all .2s;
}
.btn-secondary:hover { background: var(--green); color: white; }

.btn-danger {
  background: var(--red);
  color: white;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .875rem;
  transition: opacity .2s;
}
.btn-danger:hover { opacity: .85; }

.btn-icon {
  background: rgba(255,255,255,.15);
  color: white;
  padding: .4rem .8rem;
  border-radius: 20px;
  font-size: .8rem;
  transition: background .2s;
}
.btn-icon:hover { background: rgba(255,255,255,.25); }

.btn-full { width: 100%; }

/* ==================== INPUTS ==================== */
.form-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: white;
  transition: border-color .2s;
  color: var(--text);
}
.form-input:focus { outline: none; border-color: var(--green); }
.form-input::placeholder { color: #aaa; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.form-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ==================== SCREENS ==================== */
.screen { min-height: 100vh; }

/* ==================== AUTH SCREEN ==================== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 40%, var(--green) 100%);
  padding: 1rem;
}

.auth-card {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo .logo-icon { font-size: 3rem; margin-bottom: .5rem; }
.auth-logo h1 { font-size: 1.5rem; color: var(--blue); font-weight: 800; }
.auth-logo p { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  padding: .75rem;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
}
.auth-tab.active { color: var(--green); border-bottom-color: var(--green); }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.error-box {
  background: #ffeaea;
  border: 1px solid #ffcdd2;
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .875rem;
}
.success-box {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  color: var(--green-dark);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .875rem;
}

/* ==================== APP HEADER ==================== */
.app-header {
  background: var(--blue);
  color: white;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,139,.3);
}
.header-title { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .4rem; }
.header-user { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.header-user-name { font-weight: 600; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================== NAV TABS ==================== */
.nav-tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 99;
  overflow-x: auto;
}
.nav-tab {
  flex: 1;
  min-width: 70px;
  padding: .75rem .25rem;
  text-align: center;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  white-space: nowrap;
}
.nav-tab.active { color: var(--green); border-bottom-color: var(--green); }
.nav-tab.admin-tab { color: var(--orange); }
.nav-tab.admin-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ==================== CONTENT ==================== */
.app-content { padding: 1rem; max-width: 680px; margin: 0 auto; }
.tab-content { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ==================== SECTION HEADERS ==================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 .75rem;
}
.section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.section-badge {
  background: var(--blue);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 20px;
}

/* ==================== GAME CARD ==================== */
.game-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
  overflow: hidden;
  transition: box-shadow .2s, transform .15s;
}
.game-card:hover { box-shadow: var(--shadow-lg); }
.game-card.has-pick { border-left: 4px solid var(--green); }
.game-card.finished { opacity: .85; }
.game-card-header {
  background: var(--bg);
  padding: .4rem .75rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.game-card-body {
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}
.game-card-body.no-click { cursor: default; }

.team-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
}
.team-flag { font-size: 1.6rem; }
.team-name { font-size: .78rem; font-weight: 700; text-align: center; color: var(--text); }

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  min-width: 80px;
}
.score-result {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: 2px;
}
.score-pick {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.score-vs {
  font-size: 1rem;
  font-weight: 700;
  color: var(--border);
}

/* Status badges */
.status-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.status-upcoming { background: #e3f2fd; color: #1565c0; }
.status-live { background: #ffebee; color: var(--red); animation: pulse 1.5s infinite; }
.status-finished { background: #f5f5f5; color: #666; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* Points badge on game card */
.pick-points-badge {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .6rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 700;
}
.pts-8 { background: #fff8e1; color: #f57f17; }
.pts-5 { background: #e8f5e9; color: #2e7d32; }
.pts-3 { background: #e3f2fd; color: #1565c0; }
.pts-1 { background: #fce4ec; color: #c62828; }
.pts-0 { background: #f5f5f5; color: #666; }

.multiplier-badge {
  background: var(--yellow);
  color: var(--blue);
  font-size: .7rem;
  font-weight: 800;
  padding: .1rem .35rem;
  border-radius: 4px;
  margin-left: .2rem;
}

/* ==================== MULTIPLIER STATUS BOX ==================== */
.mult-status-box {
  background: white;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  border-left: 4px solid var(--yellow);
}
.mult-status-title { font-size: .75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: .5rem; }
.mult-status-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.mult-chip {
  display: flex;
  align-items: center;
  gap: .3rem;
  background: var(--bg);
  border-radius: 20px;
  padding: .25rem .6rem;
  font-size: .78rem;
  font-weight: 600;
}
.mult-chip .chip-icon { font-size: .9rem; }
.mult-chip.available { color: var(--green-dark); }
.mult-chip.used { color: var(--text-muted); text-decoration: line-through; opacity: .6; }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .15s ease;
}
.modal-sheet {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
  padding-bottom: env(safe-area-inset-bottom, 1rem);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: .75rem auto .5rem;
}
.modal-header {
  padding: .5rem 1rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: var(--bg);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body { padding: 0 1rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

/* Pick inputs in modal */
.pick-input-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: center;
}
.pick-team-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  flex: 1;
}
.pick-team-flag { font-size: 2rem; }
.pick-team-name { font-size: .85rem; font-weight: 700; text-align: center; }
.pick-score-input {
  width: 60px;
  height: 60px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--blue);
  background: white;
}
.pick-score-input:focus { border-color: var(--green); outline: none; }
.pick-vs { font-size: .9rem; font-weight: 700; color: var(--text-muted); }

/* Multiplier selector in modal */
.mult-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.mult-section-title { font-size: .8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: .5rem; display: flex; align-items: center; justify-content: space-between; }
.mult-buttons { display: flex; gap: .5rem; }
.mult-btn {
  flex: 1;
  padding: .6rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--border);
  background: white;
  color: var(--text-muted);
  transition: all .15s;
}
.mult-btn.active { border-color: var(--green); background: var(--green); color: white; }
.mult-btn:disabled { opacity: .35; cursor: not-allowed; }
.mult-btn.x2-active { border-color: var(--blue); background: var(--blue); color: white; }
.mult-btn.x3-active { border-color: var(--orange); background: var(--orange); color: white; }
.mult-info { font-size: .78rem; color: var(--text-muted); margin-top: .4rem; line-height: 1.4; }
.mult-info.warn { color: var(--orange); }

/* ==================== MY PICKS / LEADERBOARD ==================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: .6rem .4rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--blue); }
.stat-label { font-size: .65rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-top: .1rem; }

.leaderboard-table {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.lb-header {
  display: grid;
  grid-template-columns: 40px 1fr 50px 50px 50px 50px;
  padding: .6rem .75rem;
  background: var(--blue);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  gap: .3rem;
}
.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr 50px 50px 50px 50px;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: .3rem;
  transition: background .15s;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--bg); }
.lb-row.current-user { background: #e8f5e9; font-weight: 700; }
.lb-rank { font-weight: 800; font-size: .9rem; color: var(--text-muted); text-align: center; }
.lb-rank.top-1 { color: #f57f17; }
.lb-rank.top-2 { color: #607d8b; }
.lb-rank.top-3 { color: #8d6e63; }
.lb-name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { font-weight: 800; font-size: .95rem; color: var(--blue); text-align: center; }
.lb-count { font-size: .82rem; text-align: center; color: var(--text-muted); }

/* ==================== ADMIN ==================== */
.admin-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}
.admin-section-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--bg);
  letter-spacing: .05em;
}
.admin-game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  gap: .5rem;
  flex-wrap: wrap;
}
.admin-game-row:last-child { border-bottom: none; }
.admin-game-teams { font-size: .88rem; font-weight: 600; flex: 1; }
.admin-game-round { font-size: .72rem; color: var(--text-muted); }
.admin-score-inputs { display: flex; align-items: center; gap: .3rem; }
.admin-score-input {
  width: 44px;
  height: 36px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--blue);
}
.admin-score-sep { font-weight: 700; color: var(--text-muted); }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }

.add-game-form { display: flex; flex-direction: column; gap: .75rem; margin-top: .5rem; }

/* ==================== EMPTY STATES ==================== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; line-height: 1.5; }

/* ==================== LOADING ==================== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-muted);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== TOAST ==================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: #333;
  color: white;
  padding: .65rem 1.25rem;
  border-radius: 30px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease, toastOut .3s ease 2.7s forwards;
  white-space: nowrap;
}
.toast.success { background: var(--green-dark); }
.toast.error { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 400px) {
  .lb-header, .lb-row { grid-template-columns: 32px 1fr 44px 44px 44px 44px; font-size: .7rem; padding: .5rem; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
