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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
header {
  background: linear-gradient(135deg, #1a3a2a, #0d2818);
  border-bottom: 3px solid #ffd700;
  padding: 16px 0;
  margin-bottom: 24px;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

h1 {
  color: #ffd700;
  font-size: 1.5rem;
}

h1 small {
  font-size: 0.7rem;
  color: #aaa;
  display: block;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

nav a, nav button {
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

nav a:hover, nav button:hover {
  background: rgba(255,255,255,0.2);
}

nav a.active {
  background: #ffd700;
  color: #000;
}

/* Cards */
.card {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid #2a2a4a;
}

.card h2 {
  color: #ffd700;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.card h3 {
  color: #90ee90;
  margin-bottom: 10px;
  font-size: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #aaa;
  font-size: 0.85rem;
}

input[type="text"],
input[type="number"],
input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0d0d1a;
  color: #fff;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #ffd700;
}

input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: #ffd700;
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: #ffed4a;
  transform: translateY(-1px);
}

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #e74c5e;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-success {
  background: #28a745;
  color: #fff;
}

/* Match cards */
.match-card {
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.match-card.locked {
  opacity: 0.75;
  border-color: #555;
}

.match-card .date-badge {
  background: #1a3a2a;
  color: #90ee90;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.match-card .round-badge {
  background: #2a1a3a;
  color: #c090ff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}

.match-card .teams {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-card .team {
  font-weight: 600;
  font-size: 0.95rem;
}

.match-card .team.guest {
  color: #888;
}

.match-card .vs {
  color: #666;
}

.match-card .score-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.match-card .score-inputs input {
  width: 44px;
  text-align: center;
  padding: 5px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #0d0d1a;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 0.2s, background 0.2s;
}

.match-card .score-inputs input:focus {
  border-color: #ffd700;
  background: #1a1a2e;
}

.match-card .score-inputs input.saved {
  border-color: #28a745;
}

.match-card .score-inputs input.dirty {
  border-color: #ffd700;
  background: #2a2a1a;
}

.match-card .result-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.1rem;
  font-weight: 700;
}

.match-card .result-display .score {
  color: #ffd700;
}

.match-card .guess-display {
  font-size: 0.85rem;
  color: #aaa;
}

.match-card .guess-display .guess-score {
  color: #90ee90;
  font-weight: 700;
}

.match-card .status-icon {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.match-card .lock-icon {
  color: #666;
  font-size: 0.8rem;
}

/* Group tabs */
.group-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.group-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #333;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.group-tab.active {
  background: #ffd700;
  color: #000;
  border-color: #ffd700;
}

.group-tab:hover:not(.active) {
  border-color: #ffd700;
  color: #ffd700;
}

/* Ranking */
.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table th,
.ranking-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #2a2a4a;
}

.ranking-table th {
  color: #ffd700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ranking-table .pos {
  color: #ffd700;
  font-weight: 700;
  font-size: 1.1rem;
  width: 40px;
}

.ranking-table .name {
  font-weight: 600;
}

.ranking-table .points {
  color: #ffd700;
  font-weight: 700;
  font-size: 1.2rem;
}

.ranking-table .pos-1 { color: #ffd700; }
.ranking-table .pos-2 { color: #c0c0c0; }
.ranking-table .pos-3 { color: #cd7f32; }

/* Login */
.login-box {
  max-width: 420px;
  margin: 60px auto;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 8px;
}

.login-box p {
  color: #888;
  margin-bottom: 24px;
}

/* Match group headers */
.match-group {
  margin-bottom: 8px;
}

.match-group h3 {
  color: #ffd700;
  margin-bottom: 8px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Status colors */
.correct-exact { color: #00ff88; }
.correct-winner { color: #ffd700; }
.correct-none { color: #ff4444; }

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 20px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.success { background: #28a745; }
.toast.error { background: #dc3545; }
.toast.info { background: #1a6bc4; }
.toast.warning { background: #e67e22; }

.toast.fade-out {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Progress bar */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: #2a2a4a;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ffed4a);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  color: #aaa;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Loading spinner */
.loading {
  text-align: center;
  padding: 40px;
  color: #888;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  border: 2px solid #ffd700;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Others' guesses table */
.guess-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.guess-table th,
.guess-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid #1a1a2e;
}

.guess-table th {
  color: #aaa;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: sticky;
  top: 0;
  background: #1a1a2e;
}

.guess-table td:first-child {
  text-align: left;
  font-weight: 600;
}

.guess-table .match-header {
  background: #0d0d1a;
  color: #ffd700;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Saving spinner */
.saving-badge {
  display: none;
  color: #90ee90;
  font-size: 0.8rem;
  align-items: center;
  gap: 4px;
}

.saving-badge.visible {
  display: inline-flex;
}

.saving-badge .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #90ee90;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Responsive */
@media (max-width: 640px) {
  header .container {
    flex-direction: column;
    text-align: center;
  }

  .match-card {
    padding: 10px;
  }

  .match-card .teams {
    width: 100%;
    order: -1;
  }

  .match-card .score-inputs input {
    width: 38px;
    font-size: 0.9rem;
  }

  .ranking-table {
    font-size: 0.85rem;
  }

  .ranking-table th,
  .ranking-table td {
    padding: 8px 4px;
  }

  #toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}
