@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap");

:root {
  --primary-color: #a876aa;
  --gradient-start: #cbd5ff;
  --gradient-end: #902680;
  --correct: #6aaa64;
  --present: #c9b458;
  --absent: #787c7e;
  --empty: #ffffff;
  --border: #d3d6da;
}

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

body {
  font-family: "Montserrat", sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 30px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.5s ease;
}

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

/* Header */
.header {
  text-align: center;
  margin-bottom: 25px;
  position: relative;
}

.back-btn {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.2s ease;
}

.back-btn:hover {
  transform: translateX(-3px);
}

.header h1 {
  font-size: 32px;
  color: var(--primary-color);
  margin-bottom: 5px;
}

.subtitle {
  color: #666;
  font-size: 14px;
}

/* Tablero */
.board {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 25px;
}

.row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.tile {
  width: 60px;
  height: 60px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--empty);
  transition: all 0.3s ease;
}

/* Ajustes dinámicos según el número de letras */
.row[data-length="6"] .tile {
  width: 52px;
  height: 52px;
  font-size: 28px;
}

.row[data-length="7"] .tile {
  width: 46px;
  height: 46px;
  font-size: 24px;
}

.row[data-length="8"] .tile {
  width: 42px;
  height: 42px;
  font-size: 22px;
}

.row[data-length="9"] .tile {
  width: 38px;
  height: 38px;
  font-size: 20px;
}

.row[data-length="10"] .tile {
  width: 35px;
  height: 35px;
  font-size: 18px;
}

.tile.filled {
  border-color: #999;
  animation: pop 0.1s ease;
}

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

.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: white;
  animation: flip 0.5s ease;
}

.tile.present {
  background: var(--present);
  border-color: var(--present);
  color: white;
  animation: flip 0.5s ease;
}

.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: white;
  animation: flip 0.5s ease;
}

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

.tile.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Teclado */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  min-width: 40px;
  height: 50px;
  border: none;
  border-radius: 4px;
  background: #d3d6da;
  color: #000;
  font-size: 14px;
  font-weight: 700;
  font-family: "Montserrat", sans-serif;
  cursor: pointer;
  transition: all 0.1s ease;
  padding: 0 10px;
}

.key:hover {
  background: #b3b6b9;
}

.key:active {
  transform: scale(0.95);
}

.key.wide {
  min-width: 60px;
  font-size: 12px;
}

.key.correct {
  background: var(--correct);
  color: white;
}

.key.present {
  background: var(--present);
  color: white;
}

.key.absent {
  background: var(--absent);
  color: white;
}

/* Mensaje */
.message {
  text-align: center;
  padding: 15px;
  margin-top: 20px;
  border-radius: 10px;
  font-weight: 600;
  animation: slideDown 0.3s ease;
}

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

.message.error {
  background: #ffebee;
  color: #c62828;
}

.message.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.message.hidden {
  display: none;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

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

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

.modal-content h2 {
  color: var(--primary-color);
  margin-bottom: 15px;
  font-size: 28px;
}

.modal-content p {
  color: #666;
  margin-bottom: 25px;
  font-size: 16px;
  line-height: 1.6;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Montserrat", sans-serif;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 20px;
  }

  .header h1 {
    font-size: 28px;
  }

  .tile {
    width: 50px;
    height: 50px;
    font-size: 26px;
  }
  
  .row[data-length="6"] .tile {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
  
  .row[data-length="7"] .tile {
    width: 39px;
    height: 39px;
    font-size: 20px;
  }
  
  .row[data-length="8"] .tile {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }
  
  .row[data-length="9"] .tile {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  .row[data-length="10"] .tile {
    width: 29px;
    height: 29px;
    font-size: 15px;
  }

  .key {
    min-width: 25px;
    height: 45px;
    font-size: 12px;
    padding: 0 8px;
  }

  .key.wide {
    min-width: 50px;
    font-size: 11px;
  }
}