/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --green-light: #E1F5EE;
  --green-mid: #9FE1CB;
  --white: #ffffff;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F4;
  --gray-200: #E8EAED;
  --gray-400: #BDC1C6;
  --gray-600: #80868B;
  --gray-900: #202124;
  --blue: #1A73E8;
  --blue-light: #E8F0FE;
  --red: #D93025;
  --red-light: #FCE8E6;
  --amber: #F9AB00;
  --amber-light: #FEF7E0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p  { font-size: 0.95rem; }

/* ===== LAYOUT ===== */
.container { max-width: 480px; margin: 0 auto; padding: 0 1rem; }
.page { padding-bottom: 5rem; }

/* ===== HEADER ===== */
.app-header {
  background: var(--green);
  color: var(--white);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.app-header .container {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .logo {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.app-header h1 { font-size: 1.1rem; color: var(--white); }
.app-header p  { font-size: 0.75rem; color: rgba(255,255,255,0.8); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px;
  color: var(--gray-600);
  font-size: 0.65rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  transition: color 0.15s;
  min-height: 56px;
}
.nav-item .icon { font-size: 1.3rem; }
.nav-item.active { color: var(--green); }

/* ===== SECTIONS ===== */
.section { display: none; padding-top: 1rem; }
.section.active { display: block; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-600);
  margin-bottom: 0.75rem;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.4rem; color: var(--gray-900); }
.form-input, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  min-height: 48px;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--green);
}
.form-hint { font-size: 0.78rem; color: var(--gray-600); margin-top: 0.3rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  min-height: 48px;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-900); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-whatsapp { background: #25D366; color: var(--white); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.8rem; min-height: 36px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-green  { background: var(--green-light); color: var(--green-dark); }
.badge-blue   { background: var(--blue-light);  color: var(--blue); }
.badge-amber  { background: var(--amber-light); color: #8C5A00; }
.badge-red    { background: var(--red-light);   color: var(--red); }
.badge-gray   { background: var(--gray-100);    color: var(--gray-600); }

/* ===== MATCH CARD ===== */
.match-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}
.match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.75rem;
}
.match-player {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
}
.match-vs {
  font-size: 0.75rem;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.match-score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green-dark);
}
.match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--gray-600);
  margin-top: 0.5rem;
}
.match-code {
  font-family: monospace;
  background: var(--gray-100);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--gray-900);
}

/* ===== STANDINGS TABLE ===== */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.standings-table th {
  text-align: center;
  padding: 6px 4px;
  color: var(--gray-600);
  font-weight: 500;
  border-bottom: 1px solid var(--gray-200);
}
.standings-table th:first-child { text-align: left; }
.standings-table td {
  text-align: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--gray-100);
}
.standings-table td:first-child { text-align: left; font-weight: 500; }
.standings-table tr.qualify td:first-child {
  border-left: 3px solid var(--green);
  padding-left: 6px;
}
.standings-table tr:last-child td { border-bottom: none; }

/* ===== PLAYER ITEM ===== */
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}
.player-avatar {
  width: 36px; height: 36px;
  background: var(--green-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--green-dark);
  flex-shrink: 0;
}
.player-name { font-weight: 600; font-size: 0.9rem; }
.player-sub  { font-size: 0.75rem; color: var(--gray-600); }

/* ===== WINNER BANNER ===== */
.winner-banner {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: var(--white);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}
.winner-banner .trophy { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.winner-banner h2 { font-size: 1.4rem; color: var(--white); }
.winner-banner p  { opacity: 0.85; font-size: 0.9rem; margin-top: 0.25rem; }

/* ===== BRACKET ===== */
.bracket-round { margin-bottom: 1.5rem; }
.bracket-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  margin-bottom: 0.5rem;
}
.bracket-match {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}
.bracket-team {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}
.bracket-team.winner { color: var(--green); font-weight: 700; }

/* ===== JOIN CODE INPUT ===== */
.join-code-input {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-600);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--gray-900);
  color: var(--white);
  padding: 0.6rem 1.2rem;
  border-radius: 99px;
  font-size: 0.85rem;
  z-index: 999;
  opacity: 0;
  transition: all 0.25s;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== LOADING ===== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 1rem 0;
}

/* ===== STATUS PILL ===== */
.status-scheduled { background: var(--blue-light);  color: var(--blue); }
.status-live      { background: var(--green-light); color: var(--green-dark); }
.status-completed { background: var(--gray-100);    color: var(--gray-600); }

/* ===== OFFLINE BANNER ===== */
.offline-banner {
  background: var(--amber);
  color: var(--white);
  text-align: center;
  padding: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  display: none;
}
.offline-banner.show { display: block; }

/* ===== SPLASH ===== */
#splash {
  position: fixed;
  inset: 0;
  background: var(--green);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s;
}
#splash .splash-icon { font-size: 4rem; margin-bottom: 1rem; }
#splash h1 { color: var(--white); font-size: 1.6rem; }
#splash p  { color: rgba(255,255,255,0.75); font-size: 0.9rem; margin-top: 0.25rem; }
#splash.hidden { opacity: 0; pointer-events: none; }
