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

body {
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  background: linear-gradient(135deg, #e8d5ff 0%, #f0e6ff 50%, #ffeaa7 100%);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.floating-decoration {
  position: absolute;
  font-size: 24px;
  animation: float 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

.floating-decoration:nth-child(2n) {
  animation-delay: -2s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

.container {
  /* max-width is set via inline style in index.html for game vs stats */
  margin: 0 auto;
  padding: 15px;
  position: relative;
  z-index: 10;
}

/* Shared Header Style */
.header {
  text-align: center;
  background: linear-gradient(45deg, #e91e63, #c2185b);
  color: white;
  padding: 15px 20px; /* From new compact design */
  border-radius: 20px; /* From new compact design */
  margin-bottom: 20px; /* From new compact design, can be overridden for stats header if needed */
  box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4); /* From new compact design */
  border: 3px solid #c2185b; /* From new compact design */
  position: relative;
  overflow: hidden;
}

.header h1 {
  font-size: 28px; /* From new compact design */
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3); /* From new compact design */
  margin: 0; /* From new compact design */
}

/* Game View Specific Header Decorations */
#game-view .header::before {
  content: '✨';
  position: absolute;
  top: 8px; /* From new compact design */
  right: 15px; /* From new compact design */
  font-size: 18px; /* From new compact design */
  animation: twinkle 2s infinite;
}

#game-view .header::after {
  content: '🌟';
  position: absolute;
  bottom: 8px; /* From new compact design */
  left: 15px; /* From new compact design */
  font-size: 18px; /* From new compact design */
  animation: twinkle 2s infinite 1s;
}

/* Stats view header has emojis in H1, so no specific pseudo-elements needed here by default */
#stats-view .header {
    margin-bottom: 30px; /* Specific margin for stats header */
}


@keyframes twinkle {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

.corner-decoration {
  position: fixed;
  font-size: 35px;
  animation: bounce 3s infinite;
  z-index: 100;
}
.corner-decoration.top-left { top: 15px; left: 15px; }
.corner-decoration.top-right { top: 15px; right: 15px; }

@keyframes bounce {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-10px) scale(1.1); }
}

.game-section { /* Specific to game view */
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid #e91e63;
  border-radius: 25px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  position: relative;
}

.mode-selector {
  display: flex;
  gap: 8px; /* From new compact design */
  justify-content: center;
  margin-bottom: 20px; /* From new compact design */
  flex-wrap: wrap;
}

.mode-btn {
  padding: 10px 16px; /* From new compact design */
  border: 3px solid transparent;
  border-radius: 18px; /* From new compact design */
  font-size: 14px; /* From new compact design */
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
  color: white;
}

.mode-btn.facil { background: linear-gradient(45deg, #4caf50, #2e7d32); }
.mode-btn.medio { background: linear-gradient(45deg, #ff9800, #f57c00); }
.mode-btn.dificil { background: linear-gradient(45deg, #f44336, #d32f2f); }

.mode-btn:hover {
  transform: translateY(-2px); /* From new compact design */
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.mode-btn.active {
  border-color: white;
  transform: scale(1.05); /* From new compact design */
  box-shadow: 0 0 20px rgba(255,255,255,0.8);
}

.score-display {
  text-align: center;
  font-size: 22px; /* From new compact design */
  font-weight: bold;
  color: #e91e63;
  margin-bottom: 20px; /* From new compact design */
  padding: 12px; /* From new compact design */
  background: linear-gradient(45deg, #fce4ec, #f8bbd9);
  border-radius: 18px; /* From new compact design */
  border: 3px solid #e91e63;
  box-shadow: 0 4px 15px rgba(233, 30, 99, 0.2);
}

.word-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px; /* From new compact design */
  margin-bottom: 20px; /* From new compact design */
  min-height: 70px; /* From new compact design */
  flex-wrap: wrap;
}

.letter-slot {
  width: 45px; /* From new compact design */
  height: 55px; /* From new compact design */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px; /* From new compact design */
  font-weight: bold;
  border: 3px solid #e91e63;
  border-radius: 12px; /* From new compact design */
  background: white;
  transition: all 0.3s;
  position: relative;
}
.letter-slot.filled {
  background: linear-gradient(45deg, #e1bee7, #ce93d8);
  color: #4a148c;
  transform: scale(1.05);
  border-color: #9c27b0;
  box-shadow: 0 4px 15px rgba(156, 39, 176, 0.3);
}
.letter-slot.empty { background: #f5f5f5; border-style: dashed; }
.letter-slot.correct { background: linear-gradient(45deg, #4caf50, #2e7d32); color: white; animation: correctPulse 0.6s; }
.letter-slot.wrong { background: linear-gradient(45deg, #f44336, #d32f2f); color: white; animation: wrongShake 0.6s; }

@keyframes correctPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
@keyframes wrongShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.speaker-section { text-align: center; margin-bottom: 20px; } /* From new compact design */
.speaker-btn {
  background: linear-gradient(45deg, #ff69b4, #ff1493);
  border: 4px solid #e91e63; border-radius: 50%;
  width: 70px; height: 70px; /* From new compact design */
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; cursor: pointer; transition: all 0.3s;
  box-shadow: 0 6px 20px rgba(255, 105, 180, 0.4); position: relative;
}
.speaker-btn:hover { transform: scale(1.1); box-shadow: 0 8px 25px rgba(255, 105, 180, 0.6); }
.speaker-btn:active { transform: scale(0.95); }
.speaker-btn.playing { animation: pulse 1s infinite; }
.speaker-icon { font-size: 28px; color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); } /* From new compact design */

.keyboard-container { margin-bottom: 15px; max-width: 100%; overflow: hidden; } /* From new compact design */
.keyboard-row { display: flex; justify-content: center; gap: 3px; margin-bottom: 6px; flex-wrap: nowrap; padding: 0 5px; } /* From new compact design */

.key {
  min-width: 26px; width: 26px; height: 42px; /* From new compact design */
  background: linear-gradient(45deg, #ff69b4, #ff1493);
  border: 2px solid #e91e63; border-radius: 8px; /* From new compact design */
  font-size: 13px; font-weight: bold; color: white; /* From new compact design */
  cursor: pointer; transition: all 0.3s;
  box-shadow: 0 3px 12px rgba(255, 105, 180, 0.3);
  display: flex; align-items: center; justify-content: center;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  position: relative; flex-shrink: 0;
}
.key:hover { background: linear-gradient(45deg, #e91e63, #c2185b); transform: translateY(-2px); box-shadow: 0 5px 18px rgba(255, 105, 180, 0.4); }
.key:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(255, 105, 180, 0.3); }
.key.special {
  background: linear-gradient(45deg, #ffd93d, #ffca28);
  border-color: #ffb300; color: #8d6e00;
  min-width: 36px; width: 36px; font-size: 14px; /* From new compact design */
}
.key.special:hover { background: linear-gradient(45deg, #ffcc00, #ffb300); }
.key.enter {
  background: linear-gradient(45deg, #4caf50, #2e7d32);
  border-color: #1b5e20; min-width: 46px; width: 46px; /* From new compact design */
  font-size: 10px; font-weight: bold; /* From new compact design */
}
.key.enter:hover { background: linear-gradient(45deg, #388e3c, #1b5e20); }

/* New Utility Controls Area from user's HTML */
.utility-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px; /* From new compact design */
  margin-top: 10px; /* Added some top margin */
  flex-wrap: wrap;
}
.utility-btn {
  background: linear-gradient(45deg, #6c757d, #495057);
  border: 2px solid #495057; border-radius: 15px;
  padding: 8px 12px; font-size: 12px; font-weight: bold; /* From new compact design */
  color: white; cursor: pointer; transition: all 0.3s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 4px;
}
.utility-btn:hover {
  background: linear-gradient(45deg, #5a6268, #3d4448);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.message-area { text-align: center; min-height: 50px; display: flex; align-items: center; justify-content: center; margin-bottom: 15px; } /* From new compact design */
.message {
  font-size: 18px; font-weight: bold; padding: 12px 20px; /* From new compact design */
  border-radius: 18px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); transition: all 0.3s;
}
.message.success { background: linear-gradient(45deg, #4caf50, #2e7d32); color: white; border: 3px solid #1b5e20; }
.message.error { background: linear-gradient(45deg, #f44336, #d32f2f); color: white; border: 3px solid #b71c1c; }
.message.info { background: linear-gradient(45deg, #2196f3, #1976d2); color: white; border: 3px solid #0d47a1; }

.next-btn { /* Game specific next button */
  background: linear-gradient(45deg, #ffd93d, #ffca28);
  border: 3px solid #ffb300; border-radius: 22px; /* From new compact design */
  padding: 12px 25px; font-size: 16px; font-weight: bold; /* From new compact design */
  color: #8d6e00; cursor: pointer; transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  width: 100%; text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}
.next-btn:hover { background: linear-gradient(45deg, #ffcc00, #ffb300); transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }

/* Sparkle animations */
.sparkle { position: fixed; pointer-events: none; font-size: 20px; animation: sparkleFloat 3s ease-out forwards; z-index: 1000; }
@keyframes sparkleFloat { 0% { opacity: 0; transform: scale(0) rotate(0deg) translateY(0px); } 20% { opacity: 1; transform: scale(1.2) rotate(90deg) translateY(-20px); } 50% { opacity: 1; transform: scale(1) rotate(180deg) translateY(-40px); } 100% { opacity: 0; transform: scale(0) rotate(360deg) translateY(-80px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* === Styles for Statistics View (Merged & Refined) === */
.stat-card {
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid #e91e63;
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  transition: transform 0.3s;
}
.stat-card:hover { transform: translateY(-5px); }

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

.stat-number { font-size: 48px; font-weight: bold; color: #e91e63; text-shadow: 2px 2px 4px rgba(0,0,0,0.1); }
.stat-label { font-size: 18px; color: #666; margin-top: 5px; }

.difficulty-badge {
  display: inline-block; padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: bold; color: white; margin-right: 8px; vertical-align: middle;
}
.difficulty-easy { background: linear-gradient(45deg, #4caf50, #2e7d32); }
.difficulty-medium { background: linear-gradient(45deg, #ff9800, #f57c00); }
.difficulty-hard { background: linear-gradient(45deg, #f44336, #d32f2f); }

.progress-bar { width: 100%; height: 20px; background: #f0f0f0; border-radius: 10px; overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; background: linear-gradient(45deg, #4caf50, #2e7d32); border-radius: 10px; transition: width 0.5s ease; position: relative; }
.progress-fill::after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.word-list { max-height: 300px; overflow-y: auto; background: #f9f9f9; border-radius: 10px; padding: 15px; border: 1px solid #eee; }
.word-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee; }
.word-item:last-child { border-bottom: none; }

.accuracy-indicator { width: 18px; height: 18px; border-radius: 50%; display: inline-block; margin-left: 10px; vertical-align: middle; }
.accuracy-high { background: #4caf50; }
.accuracy-medium { background: #ff9800; }
.accuracy-low { background: #f44336; }

.back-btn { /* Shared style for "Volver al Juego" and "Empezar a Jugar" in stats */
  background: linear-gradient(45deg, #ffd93d, #ffca28); border: 3px solid #ffb300;
  border-radius: 25px; padding: 15px 30px; font-size: 18px; font-weight: bold;
  color: #8d6e00 !important; cursor: pointer; transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2); text-decoration: none;
  display: inline-block; margin-bottom: 20px;
}
.back-btn:hover { background: linear-gradient(45deg, #ffcc00, #ffb300); transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }

.chart-container { position: relative; height: 300px; width: 100%; margin: 20px 0; background: rgba(255,255,255,0.7); border-radius: 10px; padding:10px; }
@media (min-width: 768px) { .chart-container { height: 350px; } }

.no-data { text-align: center; color: #666; font-size: 18px; padding: 50px; background: rgba(255, 255, 255, 0.8); border-radius: 20px; border: 2px dashed #ddd;}

.trophy { font-size: 24px; margin-right: 10px; }
.achievement {
  background: linear-gradient(45deg, #ffd93d, #ffca28); border: 3px solid #ffb300;
  border-radius: 15px; padding: 15px; margin: 5px; display: flex; align-items: center;
  color: #8d6e00; font-weight: bold; flex-basis: calc(50% - 10px); box-sizing: border-box;
}
@media (max-width: 768px) { .achievement { flex-basis: 100%; } }

.mistake-item { background: #fff0f0; border: 1px solid #ffcdd2; border-radius: 10px; padding: 10px; margin: 8px 0; }
.correct-word { color: #388e3c; font-weight: bold; }
.incorrect-word { color: #d32f2f; font-weight: bold; }

/* Mobile responsiveness from original game CSS (with new compact values) */
@media (max-width: 480px) {
  .container { /* General container padding for mobile */
    padding: 10px;
  }
  #game-view .header h1 { font-size: 24px; } /* Compact game header H1 */
  #stats-view .header h1 { font-size: 26px; } /* Stats header H1 on mobile */
  
  .letter-slot { width: 38px; height: 48px; font-size: 22px; } /* Compact letter slot */
  .key { min-width: 28px; width: 28px; height: 38px; font-size: 12px; } /* Compact key */
  .key.special { min-width: 32px; width: 32px; } /* Compact special key */
  .key.enter { min-width: 42px; width: 42px; } /* Compact enter key */
  .keyboard-row { gap: 2px; padding: 0 2px; } /* Compact keyboard row */
  
  .utility-controls { gap: 6px; }
  .utility-btn { padding: 6px 10px; font-size: 11px; }

  .stat-grid { grid-template-columns: 1fr; }
  .stat-number { font-size: 36px; }
  .stat-label { font-size: 16px; }
  .chart-container { height: 250px; }
}

/* Rainbow sparkle and unicorn trail animations - kept from previous full style.css */
.rainbow-sparkle { animation: rainbowSparkle 4s ease-out forwards; }
.unicorn-trail { animation: unicornFly 2s ease-out forwards; }
@keyframes rainbowSparkle { 0% { opacity: 0; transform: scale(0) rotate(0deg) translateY(0px); } 15% { opacity: 1; transform: scale(1.5) rotate(60deg) translateY(-15px); } 50% { opacity: 1; transform: scale(1.2) rotate(180deg) translateY(-50px); } 80% { opacity: 0.8; transform: scale(0.8) rotate(300deg) translateY(-80px); } 100% { opacity: 0; transform: scale(0) rotate(360deg) translateY(-100px); } }
.letter-sparkle { animation: letterSparkle 1.5s ease-out forwards; }
@keyframes letterSparkle { 0% { opacity: 1; transform: scale(0.5) translateY(0px); } 30% { opacity: 1; transform: scale(1.2) translateY(-15px); } 70% { opacity: 0.7; transform: scale(1) translateY(-30px); } 100% { opacity: 0; transform: scale(0.3) translateY(-50px); } }
.fallback-confetti { animation: fallbackConfetti 3s ease-out forwards; }
@keyframes fallbackConfetti { 0% { opacity: 1; transform: translateY(0px) rotate(0deg) scale(0.5); } 25% { opacity: 1; transform: translateY(25vh) rotate(90deg) scale(1); } 50% { opacity: 1; transform: translateY(50vh) rotate(180deg) scale(1.2); } 75% { opacity: 0.8; transform: translateY(75vh) rotate(270deg) scale(1); } 100% { opacity: 0; transform: translateY(100vh) rotate(360deg) scale(0.3); } }
@keyframes cheerBounce { 0% { opacity: 0; transform: translateX(-50%) scale(0.3) translateY(50px); } 20% { opacity: 1; transform: translateX(-50%) scale(1.3) translateY(-10px); } 40% { transform: translateX(-50%) scale(1.1) translateY(5px); } 60% { transform: translateX(-50%) scale(1.2) translateY(-5px); } 80% { transform: translateX(-50%) scale(1) translateY(0px); } 100% { opacity: 0; transform: translateX(-50%) scale(0.8) translateY(-20px); } }
@keyframes unicornFly { 0% { opacity: 0; transform: translateX(-50px) translateY(0px) scale(0.5); } 20% { opacity: 1; transform: translateX(0px) translateY(-20px) scale(1); } 80% { opacity: 1; transform: translateX(80vw) translateY(-40px) scale(1.2); } 100% { opacity: 0; transform: translateX(100vw) translateY(-60px) scale(0.8); } }