:root {
  /* Theme (overridable by JS) */
  --theme-dark: #0f172a;
  --theme-light: #f8fafc;
  --theme-highlight: #facc15;

  /* Back-compat aliases used in your styles */
  --blue: var(--theme-dark);
  --light: var(--theme-light);
  --gold: var(--theme-highlight);

  /* Modern mobile-app variables */
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-variant: #f8fafc;
  --outline: #e2e8f0;
  --outline-variant: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 0.75rem;
  --spacing-lg: 1rem;
  --spacing-xl: 1.5rem;
  --spacing-2xl: 2rem;
  --spacing-3xl: 3rem;
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--theme-light) 0%, #f1f5f9 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container with mobile-first responsive design */
.container {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 768px) {
  .container {
    max-width: 480px;
    padding: var(--spacing-2xl);
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 520px;
  }
}

/* Logo styling */
.logo {
  width: 80px;
  height: 80px;
  display: block;
  margin: 0 auto var(--spacing-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  object-fit: contain;
}

@media (min-width: 768px) {
  .logo {
    width: 100px;
    height: 100px;
  }
}

/* Typography */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--spacing-xl);
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

@media (min-width: 768px) {
  h1 {
    font-size: 2rem;
  }
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
}

/* Form elements with mobile-app styling */
label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
}

input, select, textarea {
  font: inherit;
  padding: var(--spacing-md) var(--spacing-lg);
  border: 2px solid var(--outline);
  border-radius: var(--radius-lg);
  width: 100%;
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--theme-highlight);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.1);
  transform: translateY(-1px);
}

input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}

select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Button styling with mobile-app aesthetics */
button {
  font: inherit;
  padding: var(--spacing-md) var(--spacing-xl);
  border: none;
  border-radius: var(--radius-lg);
  width: 100%;
  background: linear-gradient(135deg, var(--theme-dark) 0%, #1e293b 100%);
  color: var(--theme-text, white);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 1rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

button:hover::before {
  left: 100%;
}

button:hover {
  background: linear-gradient(135deg, var(--theme-highlight) 0%, var(--theme-highlight) 100%);
  color: var(--theme-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Ghost button variant */
button.ghost {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--outline);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--surface-variant);
  border-color: var(--theme-highlight);
  color: var(--theme-dark);
}

/* Action button styling */
.action-btn {
  background: linear-gradient(135deg, var(--theme-dark) 0%, #1e293b 100%);
  color: var(--theme-text, white);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--spacing-md) var(--spacing-xl);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  min-width: 120px;
}

.action-btn:hover {
  background: linear-gradient(135deg, var(--theme-highlight) 0%, var(--theme-highlight) 100%);
  color: var(--theme-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.action-btn.ghost {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--outline);
  box-shadow: none;
}

.action-btn.ghost:hover {
  background: var(--surface-variant);
  border-color: var(--theme-highlight);
  color: var(--theme-dark);
}

/* Message styling */
.msg {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
}

.msg.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.msg.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.msg.info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* Muted text */
.muted {
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

/* Voting system styles */
.voting-rules {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-sm);
}

.voting-rules h3 {
  margin: 0 0 var(--spacing-md) 0;
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 600;
}

.voting-rules p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.voting-rules ul {
  margin: var(--spacing-md) 0 0 var(--spacing-lg);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.voting-rules li {
  margin: var(--spacing-xs) 0;
  line-height: 1.5;
}

/* Responsive utilities */
@media (max-width: 767px) {
  .container {
    padding: var(--spacing-md);
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .logo {
    width: 70px;
    height: 70px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for better accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--theme-highlight);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --outline: #000000;
    --text-primary: #000000;
    --text-secondary: #000000;
  }
}

/* Team selection specific styles */
.selection-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-md);
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group:last-of-type {
  margin-bottom: var(--spacing-xl);
}

.selection-info {
  background: var(--surface-variant);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-top: var(--spacing-lg);
}

.info-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.info-content {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.signout-section {
  margin-top: var(--spacing-2xl);
  text-align: center;
}

/* Button with icon styling */
button svg {
  margin-left: var(--spacing-sm);
  transition: transform 0.2s ease;
}

button:hover svg {
  transform: translateX(2px);
}

/* Responsive button layout */
@media (max-width: 767px) {
  .selection-card {
    padding: var(--spacing-lg);
  }
  
  button {
    padding: var(--spacing-lg) var(--spacing-xl);
    font-size: 1rem;
  }
}

/* Voting page specific styles */
.vote-info-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.info-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
}

.info-item svg {
  color: var(--theme-highlight);
  flex-shrink: 0;
}

.info-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-xs);
}

.info-value {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.voting-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-md);
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-2xl);
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--outline);
  border-top: 3px solid var(--theme-highlight);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.submit-btn {
  background: linear-gradient(135deg, var(--theme-dark) 0%, #1e293b 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg) var(--spacing-xl);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  margin-top: var(--spacing-lg);
}

.submit-btn:hover {
  background: linear-gradient(135deg, var(--theme-highlight) 0%, #fbbf24 100%);
  color: var(--theme-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
}

@media (min-width: 768px) {
  .action-buttons {
    flex-direction: row;
    justify-content: center;
  }
  
  .action-buttons .action-btn {
    flex: 0 0 auto;
    min-width: 200px;
  }
}

/* Player list styling */
.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-sm);
  background: var(--surface);
  transition: all 0.2s ease;
}

.player-item:hover {
  border-color: var(--theme-highlight);
  box-shadow: var(--shadow-sm);
}

.player-name {
  font-weight: 500;
  color: var(--text-primary);
}

.vote-select {
  min-width: 80px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.vote-select:focus {
  border-color: var(--theme-highlight);
  outline: none;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.1);
}

/* Login page specific styles */
.login-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--spacing-xl);
}

.login-btn {
  background: linear-gradient(135deg, var(--theme-dark) 0%, #1e293b 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg) var(--spacing-xl);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  margin-top: var(--spacing-lg);
}

.login-btn:hover {
  background: linear-gradient(135deg, var(--theme-highlight) 0%, #fbbf24 100%);
  color: var(--theme-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Code styling for examples */
code {
  background: var(--surface-variant);
  color: var(--theme-highlight);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.875rem;
  font-weight: 600;
}