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

:root {
  --green-dark: #0d2818;
  --green-main: #1a5c2a;
  --green-light: #2d8a4e;
  --green-pitch: #3a9d5e;
  --gold: #d4a843;
  --gold-light: #f0d68a;
  --white: #ffffff;
  --cream: #f8f4e8;
  --gray-100: #f0f0f0;
  --gray-200: #e0e0e0;
  --gray-400: #999;
  --gray-600: #666;
  --gray-800: #333;
  --gray-900: #1a1a1a;
  --red: #d32f2f;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  color: var(--gray-900);
  min-height: 100vh;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--green-dark), var(--green-main));
  color: var(--white);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo .trophy {
  font-size: 28px;
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.9;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--white);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.25);
}

/* Screens */
.screen { display: block; }
.screen.hidden { display: none; }

.hidden { display: none !important; }

/* Login */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-main) 50%, var(--green-light) 100%);
}

#login-screen.hidden {
  display: none;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 30px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
}

.login-badge {
  font-size: 60px;
  margin-bottom: 16px;
}

.login-card h2 {
  font-size: 24px;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--gray-600);
  font-size: 15px;
  margin-bottom: 24px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#login-form input {
  padding: 14px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 16px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: var(--green-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-main), var(--green-light));
  color: var(--white);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-800);
}

.btn-secondary:hover {
  background: var(--gray-400);
  color: var(--white);
}

.error-msg {
  color: var(--red);
  font-size: 14px;
  margin-top: 8px;
}

.error-card {
  background: #fff0f0;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin: 20px;
}

.error-card p {
  font-size: 16px;
  margin-bottom: 12px;
}

/* Main layout */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* Deadline banner */
.deadline-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--gray-900);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Section title */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 14px;
}

/* Games */
.games-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.game-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 4px solid var(--green-main);
}

.game-card.played {
  border-left-color: var(--gold);
  opacity: 0.85;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--gray-100);
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 600;
}

.game-stage {
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

.game-body {
  padding: 16px 14px;
}

.teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.team-flag {
  font-size: 36px;
  line-height: 1;
}

.team-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  text-align: center;
}

.vs-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Score display */
.score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}

.score-display .score {
  font-size: 28px;
  font-weight: 800;
  color: var(--green-dark);
}

.score-display .score-divider {
  font-size: 18px;
  color: var(--gray-400);
  font-weight: 700;
}

.match-result {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--green-main);
  padding: 4px 12px;
  background: #e8f5e9;
  border-radius: 20px;
  display: inline-block;
  margin: 0 auto 4px;
}

/* Prediction form */
.prediction-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pred-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pred-inputs input {
  width: 64px;
  height: 48px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.pred-inputs input::-webkit-outer-spin-button,
.pred-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pred-inputs input:focus {
  border-color: var(--green-main);
}

.pred-inputs .pred-vs {
  font-weight: 700;
  color: var(--gray-400);
  font-size: 14px;
}

.prediction-form .btn {
  width: 100%;
  max-width: 200px;
  padding: 10px;
  font-size: 14px;
}

.prediction-status {
  text-align: center;
  font-size: 13px;
  padding: 4px 0;
}

.prediction-status.saved {
  color: var(--green-main);
}

.prediction-status.closed {
  color: var(--gray-400);
}

.prediction-status .pred-score {
  font-weight: 700;
  font-size: 16px;
}

/* Loading & Empty */
.loading, .empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-600);
  font-size: 15px;
}

/* Admin */
.add-game-form {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-row input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.form-row input:focus {
  border-color: var(--green-main);
}

.form-row .vs {
  font-weight: 700;
  color: var(--gray-400);
  font-size: 13px;
  flex-shrink: 0;
}

.add-game-form .btn {
  align-self: flex-start;
}

/* Results game list */
.result-game-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.result-game-card .teams-small {
  font-weight: 700;
  font-size: 14px;
  min-width: 100px;
}

.result-game-card .result-vs {
  font-weight: 700;
  color: var(--gray-400);
  font-size: 13px;
}

.result-game-card select {
  width: 60px;
  height: 40px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  border: 2px solid var(--gray-200);
  border-radius: 6px;
  outline: none;
  background: var(--white);
  color: var(--gray-900);
  cursor: pointer;
  padding: 0 4px;
}

.result-game-card select:focus {
  border-color: var(--green-main);
}

.result-game-card .btn {
  font-size: 13px;
  padding: 8px 16px;
}

/* Standings table */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.standings-table th {
  background: var(--green-dark);
  color: var(--white);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 8px;
  text-align: left;
}

.standings-table td {
  padding: 10px 8px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
}

.standings-table tr:last-child td {
  border-bottom: none;
}

.standings-table .rank {
  width: 32px;
  text-align: center;
  font-weight: 700;
  color: var(--gray-400);
}

.standings-table .rank.gold { color: var(--gold); }
.standings-table .rank.silver { color: var(--gray-400); }
.standings-table .rank.bronze { color: #cd7f32; }

.standings-table .score-col {
  font-weight: 700;
  color: var(--green-main);
  text-align: center;
}

/* Predictions detail table */
.predictions-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.predictions-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.predictions-table th {
  background: var(--green-dark);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 8px 6px;
  text-align: center;
  white-space: nowrap;
}

.predictions-table th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--green-dark);
}

.predictions-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

.predictions-table td:first-child {
  font-weight: 600;
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--white);
}

.predictions-table tr:nth-child(even) td:first-child {
  background: var(--gray-100);
}

.predictions-table tr:nth-child(even) td {
  background: var(--gray-100);
}

.predictions-table .game-header-cell {
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.predictions-table .pred-correct {
  color: var(--green-main);
  font-weight: 700;
}

.predictions-table .pred-wrong {
  color: var(--gray-400);
}

.predictions-table .result-badge {
  display: inline-block;
  background: var(--gold);
  color: var(--gray-900);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  display: flex;
  border-top: 1px solid var(--gray-200);
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  text-decoration: none;
  color: var(--gray-400);
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--green-main);
}

.nav-icon {
  font-size: 22px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* Responsive */
@media (min-width: 600px) {
  .game-body {
    padding: 20px;
  }

  .team-flag {
    font-size: 48px;
  }

  .team-name {
    font-size: 18px;
  }

  .standings-table th,
  .standings-table td {
    padding: 12px 16px;
  }
}

/* Timer countdown */
.countdown {
  font-size: 12px;
  color: var(--red);
  font-weight: 600;
}
