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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.screen { min-height: 100vh; }

/* Auth */
.auth-card {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  position: relative;
  top: 15vh;
}

.auth-card h1 { font-size: 2rem; margin-bottom: 0.3rem; }
.subtitle { color: #888; margin-bottom: 2rem; font-size: 0.9rem; }
.auth-card h2 { font-size: 1.1rem; margin-bottom: 1rem; color: #555; }

input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
input:focus { border-color: #667eea; }

button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
button:hover { opacity: 0.9; }
button:active { transform: scale(0.98); }

.error { color: #e74c3c; margin-top: 8px; font-size: 0.9rem; min-height: 1.2em; }

.tabs { display: flex; gap: 8px; margin-bottom: 1rem; }
.tab {
  flex: 1;
  padding: 8px;
  background: #f0f0f0;
  color: #666;
  border-radius: 8px;
  font-size: 0.9rem;
}
.tab.active { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }

/* Main layout */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  color: white;
}
header h1 { font-size: 1.3rem; }
.header-right { display: flex; align-items: center; gap: 10px; }
#user-name { font-weight: 600; color: rgba(255,255,255,0.9); }
.btn-small {
  width: auto;
  padding: 6px 14px;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
}

nav {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
}
.nav-btn {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.nav-btn.active { background: white; color: #667eea; }

main { padding: 0 16px 24px; }

.card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  margin-bottom: 16px;
}
.card h2 { margin-bottom: 16px; font-size: 1.2rem; }

/* Round tabs */
.round-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.round-tab {
  width: auto;
  padding: 6px 14px;
  font-size: 0.8rem;
  background: #f0f0f0;
  color: #666;
  border-radius: 8px;
  white-space: nowrap;
}
.round-tab.active { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }

/* Match cards */
.match-item {
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  transition: background 0.2s;
}
.match-item.locked { opacity: 0.7; }
.match-meta {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.match-teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}
.match-teams .team { flex: 1; text-align: center; min-width: 0; }
.match-teams .team:first-child { text-align: right; }
.match-teams .team:last-child { text-align: left; }

.team-link {
  color: #333;
  text-decoration: none;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.team-link:hover {
  color: #667eea;
  text-decoration: underline;
}

.flag {
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  vertical-align: middle;
  flex-shrink: 0;
}

.flag-icon {
  font-size: 1.1rem;
  vertical-align: middle;
}

.team-placeholder {
  font-style: italic;
  color: #999;
}

.score-input {
  width: 48px;
  text-align: center;
  padding: 8px 4px;
  font-size: 1.1rem;
  font-weight: 700;
  border: 2px solid #ddd;
  border-radius: 8px;
  margin: 0 2px;
  -moz-appearance: textfield;
}
.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.score-input:focus { border-color: #667eea; }
.score-input:disabled { background: #f8f8f8; color: #999; }

.vs { color: #ccc; font-weight: 400; }

.match-result {
  text-align: center;
  margin-top: 6px;
  font-size: 0.8rem;
}
.result-exact { color: #27ae60; font-weight: 600; }
.result-winner { color: #f39c12; font-weight: 600; }
.result-wrong { color: #e74c3c; }
.result-score { 
  font-size: 1.2rem; 
  font-weight: 700; 
  color: #333; 
  background: #f0f0f0;
  padding: 4px 12px;
  border-radius: 8px;
  display: inline-block;
}

/* Standings */
.standing-row {
  display: flex;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  gap: 12px;
}
.standing-row:last-child { border-bottom: none; }
.standing-rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.rank-1 { background: #ffd700; color: #333; }
.rank-2 { background: #c0c0c0; color: #333; }
.rank-3 { background: #cd7f32; color: white; }
.rank-other { background: #f0f0f0; color: #666; }
.standing-name { flex: 1; font-weight: 600; }
.standing-points { font-size: 1.3rem; font-weight: 700; color: #667eea; }
.standing-detail { font-size: 0.75rem; color: #999; text-align: right; }

/* Save button */
.btn-save {
  position: sticky;
  bottom: 16px;
  margin-top: 16px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Group header */
.group-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: #667eea;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #667eea;
}
.group-header:first-child { margin-top: 0; }

/* Deadline notice */
.deadline-notice {
  background: #fff3cd;
  color: #856404;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  text-align: center;
}
.deadline-passed {
  background: #f8d7da;
  color: #721c24;
}

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

@media (max-width: 600px) {
  .auth-card { top: 8vh; margin: 0 16px; }
  .match-teams { font-size: 0.85rem; }
  .score-input { width: 42px; font-size: 1rem; }
}
