/* Importar fuentes de Google */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Variables CSS para colores y estilos - Modo Nocturno */
:root {
  --primary-color: #10b981;
  --secondary-color: #f59e0b;
  --background-color: #0f172a;
  --surface-color: #1e293b;
  --card-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --border-color: #475569;
  --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 8px 24px rgba(0, 0, 0, 0.4);
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Colores de estado */
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --info-color: #3b82f6;
}

/* Reset y estilos base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-primary);
  position: relative;
  overflow-x: hidden;
}

/* Efecto de estrellas en el fondo */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 20px 30px, #eee, transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 90px 40px, #fff, transparent),
    radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
    radial-gradient(2px 2px at 160px 30px, #ddd, transparent);
  background-repeat: repeat;
  background-size: 200px 100px;
  animation: twinkle 4s ease-in-out infinite;
  opacity: 0.3;
  z-index: -1;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* Contenedor principal */
.main-container {
  background: linear-gradient(145deg, var(--surface-color), var(--card-color));
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  padding: 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.main-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--info-color));
  animation: rainbow 3s ease-in-out infinite;
}

@keyframes rainbow {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(180deg); }
}

/* Título */
h1 {
  font-size: 2.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
  text-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* Subtítulo */
.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-weight: 400;
  opacity: 0.9;
}

/* Información del juego */
.game-info {
  margin-bottom: 25px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  padding: 20px;
  background: linear-gradient(145deg, var(--card-color), var(--surface-color));
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-light);
  min-height: 80px;
  align-items: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 80px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  white-space: nowrap;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--info-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-width: 30px;
  text-align: center;
  line-height: 1;
}

/* Tablero de juego */
.game-board {
  margin-bottom: 20px;
}

/* Filas de inputs */
.row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  justify-content: center;
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cuadrados de input */
.square {
  width: 60px;
  height: 60px;
  border: 2px solid var(--border-color);
  background: linear-gradient(145deg, var(--surface-color), var(--card-color));
  outline: none;
  font-size: 1.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-primary);
  text-align: center;
  border-radius: 12px;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  box-shadow: var(--shadow-light);
}

.square:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
  transform: scale(1.05);
  background: linear-gradient(145deg, var(--card-color), var(--surface-color));
}

.square:not(:placeholder-shown) {
  border-color: var(--text-secondary);
}

/* Estados de los cuadrados */
.square.green {
  background: linear-gradient(145deg, var(--success-color), #059669);
  border-color: var(--success-color);
  color: white;
  animation: flipIn 0.6s ease-out;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.square.gold {
  background: linear-gradient(145deg, var(--warning-color), #d97706);
  border-color: var(--warning-color);
  color: white;
  animation: flipIn 0.6s ease-out;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

@keyframes flipIn {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

/* Contenedor de resultados */
.result {
  margin-top: 30px;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-content {
  padding: 30px;
  border-radius: var(--border-radius);
  border: 2px solid;
  text-align: center;
  animation: bounceIn 0.6s ease-out;
  position: relative;
  overflow: hidden;
}

.result-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.8s;
}

.result-content:hover::before {
  left: 100%;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-content.victory {
  background: linear-gradient(145deg, #065f46, #047857);
  border-color: var(--success-color);
  color: #ecfdf5;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

.result-content.defeat {
  background: linear-gradient(145deg, #7f1d1d, #991b1b);
  border-color: var(--error-color);
  color: #fef2f2;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.result-content p {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 25px;
  position: relative;
  z-index: 1;
}

.result-content.victory p {
  color: #d1fae5;
  font-size: 1.6rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.result-content.defeat p {
  color: #fecaca;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Botón de reinicio */
.button {
  background: linear-gradient(135deg, var(--primary-color), var(--info-color));
  color: white;
  border: none;
  padding: 14px 28px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  box-shadow: var(--shadow-light);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.button:hover::before {
  left: 100%;
}

.button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.button:active {
  transform: translateY(-1px);
}

/* Responsive design */
@media (max-width: 600px) {
  .main-container {
    padding: 30px 20px;
    margin: 10px;
  }
  
  h1 {
    font-size: 2.2rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .stats {
    gap: 20px;
    padding: 15px;
    min-height: 70px;
  }
  
  .stat-item {
    min-width: 60px;
  }
  
  .stat-label {
    font-size: 0.75rem;
  }
  
  .stat-value {
    font-size: 1.4rem;
    min-width: 25px;
  }
  
  .square {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .row {
    gap: 6px;
  }
  
  .result-content {
    padding: 25px;
  }
  
  .result-content p {
    font-size: 1.2rem;
  }
}

@media (max-width: 400px) {
  .square {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }
  
  .row {
    gap: 4px;
  }
}

/* Animaciones adicionales */
.square.focus {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
}

/* Loading state */
.loading {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 500;
  animation: loadingPulse 1.5s ease-in-out infinite;
}

.stat-value.loading {
  animation: loadingPulse 1.5s ease-in-out infinite;
  opacity: 0.7;
}

@keyframes loadingPulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Efectos adicionales */
.square:invalid {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Hover effects */
.square:hover:not(:focus) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

/* Loading animation */
.loading-dots {
  display: inline-block;
}

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Success celebration */
.celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.celebration::before,
.celebration::after {
  content: '🎉';
  position: absolute;
  font-size: 2rem;
  animation: celebration 3s ease-out forwards;
}

.celebration::before {
  left: 20%;
  animation-delay: 0s;
}

.celebration::after {
  right: 20%;
  animation-delay: 0.5s;
}

@keyframes celebration {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) scale(1.5);
    opacity: 0;
  }
}
  
  