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

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

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Botones */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn.primary {
  background: #2ecc71;
  color: white;
}

.btn.secondary {
  background: #3498db;
  color: white;
}

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

/* Pantalla de inicio */
#home-screen {
  text-align: center;
  padding-top: 50px;
}

#home-screen h1 {
  color: white;
  font-size: 48px;
  margin-bottom: 40px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.home-options {
  background: white;
  padding: 40px;
  border-radius: 16px;
  max-width: 400px;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.home-options input[type="text"],
.home-options select {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
}

.home-options input[type="text"]:focus,
.home-options select:focus {
  border-color: #667eea;
  outline: none;
}

.option-group {
  margin: 20px 0;
}

.option-group h3 {
  margin-bottom: 15px;
  color: #555;
}

.option-group label {
  display: block;
  margin-bottom: 8px;
  color: #666;
}

.divider {
  color: #999;
  margin: 20px 0;
  position: relative;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #ddd;
}

.divider::before {
  left: 0;
}

.divider::after {
  right: 0;
}

/* Lobby */
#lobby-screen {
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #eee;
}

.lobby-header h2 {
  color: #333;
}

#room-code-display {
  font-family: monospace;
  font-size: 28px;
  color: #667eea;
  letter-spacing: 3px;
}

.teams-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.team-card {
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s;
}

.team-card:hover {
  transform: scale(1.02);
}

.team-card h3 {
  color: white;
  margin-bottom: 15px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.team-card .players-list {
  background: rgba(255,255,255,0.9);
  border-radius: 8px;
  padding: 10px;
  min-height: 60px;
  margin-bottom: 15px;
}

.team-card .player-item {
  padding: 5px;
  margin: 3px 0;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
}

.team-card .player-item.is-me {
  font-weight: bold;
  background: rgba(0,0,0,0.1);
}

.team-card .join-team-btn {
  background: rgba(255,255,255,0.9);
  color: #333;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.team-card .join-team-btn:hover {
  background: white;
}

.team-card .join-team-btn.joined {
  background: #2ecc71;
  color: white;
}

.lobby-footer {
  text-align: center;
  padding-top: 20px;
  border-top: 2px solid #eee;
}

#waiting-text {
  color: #666;
  margin-bottom: 15px;
}

/* Pantalla de juego */
#game-screen {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
  margin-bottom: 20px;
}

.scores {
  display: flex;
  gap: 20px;
}

.score-item {
  padding: 8px 16px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
}

.round-info {
  font-size: 18px;
  color: #666;
  display: flex;
  gap: 20px;
}

.turn-info {
  color: #999;
}

.timer-container {
  background: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 24px;
  font-weight: bold;
  font-family: monospace;
  min-width: 80px;
  text-align: center;
}

#timer-display {
  transition: color 0.3s;
}

#timer-display.warning {
  color: #e74c3c;
  animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.5;
  }
}

.game-main {
  display: flex;
  gap: 20px;
}

.drawing-area,
.guessing-area {
  flex: 1;
}

.word-display {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 20px;
  text-align: center;
}

.word-display span {
  color: #e74c3c;
  font-weight: bold;
  font-size: 24px;
}

canvas {
  border: 3px solid #333;
  border-radius: 8px;
  background: white;
  cursor: crosshair;
  display: block;
  max-width: 100%;
}

.drawing-tools {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
}

#color-picker {
  width: 50px;
  height: 40px;
  border: none;
  cursor: pointer;
}

#brush-size {
  flex: 1;
  max-width: 150px;
}

.guess-input-container {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.guess-input-container input {
  flex: 1;
  padding: 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
}

.guess-input-container input:focus {
  border-color: #667eea;
  outline: none;
}

.game-sidebar {
  width: 280px;
  margin-left: 20px;
}

.chat-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 15px;
  height: 480px;
  display: flex;
  flex-direction: column;
}

.chat-container h3 {
  margin-bottom: 10px;
  color: #555;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 10px;
  background: white;
  border-radius: 8px;
}

.chat-message {
  margin-bottom: 8px;
  padding: 8px;
  background: #f0f0f0;
  border-radius: 6px;
}

.chat-message .player-name {
  font-weight: bold;
  color: #333;
}

.chat-message.guess-attempt {
  background: #fff3cd;
  border-left: 3px solid #ffc107;
}

.chat-message.system {
  background: #d4edda;
  border-left: 3px solid #28a745;
  font-style: italic;
}

.chat-input-container {
  display: flex;
  gap: 8px;
}

.chat-input-container input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  animation: modalPop 0.3s ease;
}

@keyframes modalPop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-content p {
  font-size: 20px;
  color: #333;
}

/* Modal de preparación */
.preparation-content {
  max-width: 450px;
}

.preparation-content h2 {
  color: #667eea;
  margin-bottom: 10px;
  font-size: 28px;
}

.round-indicator {
  color: #666;
  font-size: 16px;
  margin-bottom: 25px;
}

.drawers-list {
  margin-bottom: 25px;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  margin-bottom: 10px;
  background: #f8f9fa;
  border-radius: 10px;
  border-left: 4px solid;
}

.team-badge {
  color: white;
  padding: 4px 12px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: 600;
}

.drawer-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.drawer-name.is-me {
  color: #667eea;
}

.drawer-role {
  color: #999;
  font-style: italic;
}

.countdown-container {
  margin-top: 20px;
}

#prep-countdown {
  display: inline-block;
  width: 60px;
  height: 60px;
  line-height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 32px;
  font-weight: bold;
  border-radius: 50%;
  animation: countdownPulse 1s infinite;
}

@keyframes countdownPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Pantalla de fin de juego */
#end-screen {
  text-align: center;
  padding-top: 50px;
}

.end-container {
  background: white;
  padding: 40px;
  border-radius: 16px;
  max-width: 500px;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.end-container h1 {
  color: #333;
  margin-bottom: 30px;
  font-size: 36px;
}

.end-container h2 {
  margin-top: 20px;
  margin-bottom: 30px;
}

#final-scores {
  margin-bottom: 20px;
}

.final-score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  margin-bottom: 10px;
  border-radius: 10px;
  color: white;
  font-size: 18px;
}

.final-score-item .position {
  font-size: 24px;
  font-weight: bold;
  width: 40px;
}

.final-score-item .team-name {
  flex: 1;
  text-align: left;
}

.final-score-item .team-score {
  font-weight: bold;
  font-size: 22px;
}

.waiting-host {
  color: #666;
  font-style: italic;
  margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
  .game-main {
    flex-direction: column;
  }

  .game-sidebar {
    width: 100%;
    margin-left: 0;
    margin-top: 20px;
  }

  canvas {
    width: 100%;
    height: auto;
  }

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