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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f0e6;
  color: #2c3e50;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: fixed;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hidden { display: none !important; }

/* MENU */
#menu { background: linear-gradient(135deg, #f5f0e6 0%, #e8e0d0 100%); }

.menu-content {
  background: #fff;
  padding: 25px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  max-width: 90%;
  width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}

.title { font-size: 2em; color: #27ae60; text-align: center; margin-bottom: 5px; }
.subtitle { text-align: center; color: #7f8c8d; margin-bottom: 20px; font-size: 0.9em; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.85em; color: #34495e; }
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1em;
}
.form-group input:focus { outline: none; border-color: #27ae60; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s;
}
.color-btn:hover { transform: scale(1.1); }
.color-btn.selected { border-color: #2c3e50; transform: scale(1.15); }

.pattern-picker { display: flex; gap: 6px; }
.pattern-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  color: #2c3e50;
  font-size: 0.85em;
  cursor: pointer;
}
.pattern-btn:hover { border-color: #27ae60; }
.pattern-btn.selected { background: #27ae60; border-color: #27ae60; color: #fff; }

.play-button {
  width: 100%;
  padding: 14px;
  font-size: 1.1em;
  font-weight: 700;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
}
.play-button:hover { background: #2ecc71; }

.instructions {
  margin-top: 15px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 0.8em;
}
.instructions h3 { font-size: 0.85em; color: #7f8c8d; margin-bottom: 6px; margin-top: 8px; }
.instructions h3:first-child { margin-top: 0; }
.instructions ul { list-style: none; color: #555; }
.instructions li { padding: 3px 0; }

/* JUEGO */
#gameCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* Joystick */
.joystick {
  position: absolute;
  bottom: 25px; left: 25px;
  width: 90px; height: 90px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
}
.joystick-knob {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.8);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Zoom */
.zoom-controls {
  position: absolute;
  bottom: 25px;
  left: 130px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 2px solid #ddd;
  font-size: 1.4em;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}
.zoom-btn:active { background: #eee; transform: scale(0.95); }

/* Voz */
.voice-container {
  position: absolute;
  bottom: 25px; right: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.voice-button {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 15px rgba(155, 89, 182, 0.4);
}
.voice-button:active, .voice-button.recording {
  transform: scale(1.1);
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}
.voice-icon { font-size: 1.6em; }
.voice-hint {
  font-size: 0.65em;
  color: #fff;
  background: rgba(0,0,0,0.5);
  padding: 3px 8px;
  border-radius: 8px;
}

/* Indicador grabación */
.recording-indicator {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(231, 76, 60, 0.95);
  padding: 20px 30px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 50;
}
.recording-animation { display: flex; gap: 5px; }
.recording-dot {
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: bounce 0.5s infinite alternate;
}
.recording-dot:nth-child(2) { animation-delay: 0.15s; }
.recording-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-8px); } }
.recording-text { color: #fff; font-weight: 600; font-size: 0.9em; }
.recording-timer { font-size: 1.3em; font-weight: 700; color: #fff; }

/* Indicador reproducción */
.playing-indicator {
  position: absolute;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  background: rgba(155, 89, 182, 0.95);
  padding: 10px 20px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 500;
  animation: pulse 1s infinite;
  z-index: 40;
}
.playing-icon { font-size: 1.2em; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Ayuda de voz */
.voice-help {
  position: absolute;
  bottom: 100px; right: 15px;
  background: rgba(155, 89, 182, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.7em;
  max-width: 140px;
  text-align: center;
}

/* Leaderboard */
.leaderboard {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 10px;
  min-width: 150px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  overflow: hidden;
  font-size: 0.85em;
}
.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #27ae60;
  color: #fff;
  font-weight: 600;
}
.toggle-btn { background: none; border: none; color: #fff; font-size: 1.1em; cursor: pointer; }
.leaderboard-content { padding: 6px; max-height: 200px; overflow-y: auto; }
.leaderboard-content.collapsed { display: none; }
.leaderboard-entry {
  display: flex;
  align-items: center;
  padding: 4px;
  border-bottom: 1px solid #f0f0f0;
}
.leaderboard-entry:last-child { border-bottom: none; }
.leaderboard-rank { width: 22px; font-weight: 600; }
.leaderboard-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-score { color: #e67e22; font-weight: 700; margin-left: 6px; }

/* Puntuación */
.score-display {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(255,255,255,0.95);
  padding: 8px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 6px;
}
.score-label { font-size: 0.8em; color: #7f8c8d; }
#currentScore { font-size: 1.2em; font-weight: 700; color: #e67e22; }

/* Muerte */
.death-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}
.death-content {
  background: #fff;
  padding: 25px 35px;
  border-radius: 16px;
  text-align: center;
}
.death-content h2 { font-size: 1.6em; color: #e74c3c; margin-bottom: 15px; }
.death-stats { display: flex; justify-content: center; gap: 25px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.8em; font-weight: 700; color: #2c3e50; }
.stat-label { font-size: 0.8em; color: #7f8c8d; }
.respawn-button {
  padding: 12px 30px;
  font-size: 1em;
  font-weight: 600;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Notificación */
.voice-notification {
  position: absolute;
  bottom: 130px; left: 50%;
  transform: translateX(-50%);
  background: rgba(39, 174, 96, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 500;
  animation: fadeInOut 3s forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(15px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Desktop */
@media (min-width: 768px) and (pointer: fine) {
  .joystick { display: none; }
  .zoom-controls { left: 25px; }
  .voice-hint { display: none; }
  .voice-help { display: none; }
}

/* Móvil pequeño */
@media (max-width: 400px) {
  .menu-content { padding: 18px; }
  .title { font-size: 1.6em; }
  .joystick { width: 75px; height: 75px; bottom: 18px; left: 18px; }
  .joystick-knob { width: 32px; height: 32px; }
  .zoom-controls { left: 105px; bottom: 18px; }
  .zoom-btn { width: 32px; height: 32px; font-size: 1.1em; }
  .voice-button { width: 50px; height: 50px; }
  .voice-icon { font-size: 1.3em; }
  .voice-help { font-size: 0.6em; max-width: 110px; bottom: 85px; }
}
