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

:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --accent: #f59e0b;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --success: #10b981;
  --error: #ef4444;
  --spacing: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f3f4f6;
    --text-light: #9ca3af;
    --bg: #111827;
    --surface: #1f2937;
    --border: #374151;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing);
}

.screen {
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.screen.hidden {
  display: none;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  color: var(--primary);
}

h2 {
  font-size: 1.875rem;
  margin-bottom: 1.5rem;
}

h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
}

.buttons {
  display: flex;
  gap: var(--spacing);
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  min-width: 120px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--text-light);
  color: white;
}

.btn-secondary:hover {
  background: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  color: var(--text);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

#qr-code {
  background: white;
  padding: 1rem;
  border-radius: 0.5rem;
  display: inline-block;
  margin: 1rem 0;
}

#qr-code canvas {
  display: block;
  max-width: 200px;
  height: auto;
}

#session-info, #player-count {
  font-size: 0.95rem;
  color: var(--text-light);
  margin: 0.5rem 0;
}

code {
  background: var(--bg);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.9rem;
}

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}

.player-tag {
  background: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-tag.ready::after {
  content: "✓";
  color: var(--success);
  font-weight: bold;
}

.clues {
  text-align: left;
  margin: 1.5rem 0;
}

.clue {
  background: var(--bg);
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  border-left: 4px solid var(--primary);
}

.clue-author {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}

.clue-text {
  margin-top: 0.25rem;
  font-style: italic;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.vote-btn {
  padding: 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.vote-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.vote-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.timer {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  animation: countdown 30s linear;
}

@keyframes countdown {
  from { width: 100%; }
  to { width: 0%; }
}

.scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  text-align: left;
}

.score-item {
  background: var(--bg);
  padding: 1rem;
  border-radius: 0.5rem;
  border-top: 3px solid var(--primary);
}

.score-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.score-points {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent);
  margin-top: 0.5rem;
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.leaderboard thead {
  background: var(--primary);
  color: white;
}

.leaderboard th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
}

.leaderboard td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.leaderboard tr:hover {
  background: var(--bg);
}

.mini-lb {
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: right;
}

.status-msg {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 1rem;
  font-weight: 500;
}

.results-card {
  border-top: 4px solid var(--success);
}

.results-card.lose {
  border-top-color: var(--error);
}

#result-text {
  font-size: 1.1rem;
  margin: 1rem 0 1.5rem;
}

@media (max-width: 640px) {
  .screen {
    max-width: 100%;
    padding: 0;
  }

  h1 {
    font-size: 2rem;
  }

  .card {
    padding: 1.5rem;
  }

  .buttons {
    gap: 0.5rem;
  }

  .btn {
    font-size: 0.95rem;
    padding: 0.6rem 1rem;
  }

  .vote-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .leaderboard {
    font-size: 0.9rem;
  }

  .leaderboard th, .leaderboard td {
    padding: 0.75rem 0.5rem;
  }
}
