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

:root {
  --primary: #4a90d9;
  --primary-dark: #357abd;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --light: #f8f9fa;
  --dark: #343a40;
  --team1: #e74c3c;
  --team2: #3498db;
  --bg: #1a1a2e;
  --bg-light: #16213e;
  --text: #eee;
  --text-muted: #aaa;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  padding: 20px;
}

.screen.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* Typography */
.title {
  font-size: 3.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #8e44ad 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1.2rem;
}

h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

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

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input[type="text"],
select {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid #333;
  border-radius: 8px;
  background: var(--bg-light);
  color: var(--text);
  transition: border-color 0.2s;
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

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

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

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

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

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

.btn-secondary:hover:not(:disabled) {
  background: #5a6268;
}

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

.btn-success:hover:not(:disabled) {
  background: #218838;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.2rem;
  width: 100%;
  margin-top: 1rem;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.button-group .btn {
  flex: 1;
}

/* Home Screen */
#join-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #333;
}

/* Lobby Screen */
.session-info {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--bg-light);
  border-radius: 12px;
}

.session-code {
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: var(--primary);
  font-family: monospace;
}

.session-url {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.teams-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.team {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 1rem;
}

#team1-container {
  border-top: 3px solid var(--team1);
}

#team2-container {
  border-top: 3px solid var(--team2);
}

.team h3 {
  text-align: center;
}

.player-list {
  list-style: none;
  min-height: 100px;
  margin-bottom: 1rem;
}

.player-list li {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-list li.host::after {
  content: '(Host)';
  font-size: 0.75rem;
  color: var(--warning);
  margin-left: auto;
}

.player-list li.you {
  background: rgba(74, 144, 217, 0.2);
  border: 1px solid var(--primary);
}

.player-list li.disconnected {
  opacity: 0.5;
}

.join-team-btn {
  width: 100%;
}

/* Settings */
.settings {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row select {
  width: auto;
  min-width: 100px;
}

/* Word Submission */
.instruction {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

#submission-screen .form-group {
  display: flex;
  gap: 0.5rem;
}

#submission-screen .form-group input {
  flex: 1;
}

#submission-screen .form-group .btn {
  white-space: nowrap;
}

.submitted-words {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

#word-list {
  list-style: none;
}

#word-list li {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  margin-bottom: 6px;
}

.player-progress {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 1rem;
}

#progress-list {
  list-style: none;
}

#progress-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#progress-list li:last-child {
  border-bottom: none;
}

#progress-list li.ready {
  color: var(--success);
}

/* Game Screen */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.round-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.round-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  font-weight: bold;
}

.round-name {
  color: var(--text-muted);
}

.timer {
  font-size: 2.5rem;
  font-weight: bold;
  font-family: monospace;
  color: var(--text);
}

.timer.warning {
  color: var(--warning);
  animation: pulse 0.5s infinite;
}

.timer.danger {
  color: var(--danger);
  animation: pulse 0.3s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.scoreboard {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg-light);
  border-radius: 12px;
}

.team-score {
  text-align: center;
}

.team-score .team-name {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.team-score .score {
  font-size: 2.5rem;
  font-weight: bold;
}

.team-score:first-child .score {
  color: var(--team1);
}

.team-score:last-child .score {
  color: var(--team2);
}

.words-remaining {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.game-view {
  text-align: center;
}

.word-card {
  background: linear-gradient(135deg, var(--primary) 0%, #8e44ad 100%);
  border-radius: 16px;
  padding: 3rem 2rem;
  margin-bottom: 2rem;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#current-word {
  font-size: 2.5rem;
  font-weight: bold;
  word-break: break-word;
}

.action-buttons {
  display: flex;
  gap: 1rem;
}

.action-buttons .btn {
  flex: 1;
  padding: 1.5rem;
  font-size: 1.2rem;
}

.big-message {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

.sub-message {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

/* Round End / Game Over */
.round-scores,
.final-scores {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin: 2rem 0;
}

.round-team-score,
.final-team-score {
  text-align: center;
  padding: 1.5rem 2rem;
  background: var(--bg-light);
  border-radius: 12px;
}

.big-score {
  display: block;
  font-size: 3rem;
  font-weight: bold;
}

.round-team-score:first-child .big-score,
.final-team-score:first-child .big-score {
  color: var(--team1);
}

.round-team-score:last-child .big-score,
.final-team-score:last-child .big-score {
  color: var(--team2);
}

.next-round-info {
  text-align: center;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--bg-light);
  border-radius: 12px;
}

.next-round-info h3 {
  margin-bottom: 0.5rem;
}

.next-round-info p {
  color: var(--text-muted);
}

#winner-announcement {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.word-recap {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 1rem;
  margin: 2rem 0;
  max-height: 200px;
  overflow-y: auto;
}

.word-recap h3 {
  text-align: center;
}

#all-words-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

#all-words-list li {
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

/* Utilities */
.hidden {
  display: none !important;
}

.waiting-message {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

/* Connection Status */
.connection-status {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--warning);
  color: var(--dark);
  z-index: 1000;
}

.connection-status.connected {
  background: var(--success);
  color: white;
}

.connection-status.disconnected {
  background: var(--danger);
  color: white;
}

/* Responsive */
@media (max-width: 480px) {
  .title {
    font-size: 2.5rem;
  }

  .session-code {
    font-size: 2rem;
  }

  .teams-container {
    grid-template-columns: 1fr;
  }

  .round-scores,
  .final-scores {
    flex-direction: column;
    gap: 1rem;
  }

  .scoreboard {
    gap: 1.5rem;
  }

  #current-word {
    font-size: 1.8rem;
  }

  .action-buttons {
    flex-direction: column;
  }
}
