:root {
  --bg: #0b1220;
  --panel: #0f1724;
  --muted: #9aa6b2;
  --tile: #1a2230;
  --text: #e7eef6;
  --absent: #3a3a3c;
  --present: #b59f3b;
  --correct: #538d4e;
  --accent: #2b6fda;
  --glass: rgba(255, 255, 255, 0.03);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial;
  background: linear-gradient(180deg, var(--bg), #071019);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* Oculta cualquier desbordamiento/scroll */
}

.app {
  max-width: 760px;
  margin: 0;
  padding: 18px;
  border-radius: 14px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  box-shadow: 0 8px 30px rgba(2, 6, 23, 0.6);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  justify-content: space-between;
}
.controls button {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.controls button:hover {
  transform: translateY(-1px);
}
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  display: none;
}
.toggle-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  display: inline-block;
}
.toggle-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  display: block;
  position: absolute;
  left: 3px;
  top: 3px;
  transition: transform 0.18s ease;
}
.toggle input:checked + .toggle-track {
  background: rgba(255, 255, 255, 0.12);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}
.toggle-label {
  font-size: 0.86rem;
  color: var(--muted);
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px;
}

.grid {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}
.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(4px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-8px);
  }
  40%,
  60% {
    transform: translateX(8px);
  }
}
.row.shake {
  animation: shake 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.tile {
  width: 62px;
  height: 62px;
  background: var(--tile);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 26px;
  text-transform: uppercase;
  user-select: none;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.tile.selected {
  outline: 3px solid rgba(43, 111, 218, 0.22);
  box-shadow: 0 6px 18px rgba(43, 111, 218, 0.06);
  transform: translateY(-2px);
}
.tile.filled {
  border: 2px solid rgba(255, 255, 255, 0.04);
}
.tile.absent {
  background: var(--absent);
  color: #fff;
}
.tile.present {
  background: var(--present);
  color: #fff;
}
.tile.correct {
  background: var(--correct);
  color: #fff;
}

/* Keyboard */
.keyboard {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.key-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.key {
  padding: 16px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  flex-grow: 1;
  max-width: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.key.wide {
  padding: 16px 22px;
  flex-grow: 2;
  max-width: 80px;
}
.key.absent {
  background: var(--absent);
}
.key.present {
  background: var(--present);
}
.key.correct {
  background: var(--correct);
}

/* message */
.message {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--panel);
  color: var(--text);
  padding: 14px 28px;
  border-radius: var(--radius);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  font-weight: 700;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease, top 0.4s ease;
}

.message.show {
  top: 10%;
  opacity: 1;
  visibility: visible;
}

/* flip animation (usada por .tile.flipping) */
@keyframes flip {
  0% {
    transform: rotateX(0);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

.tile.flipping {
  animation-name: flip;
  animation-duration: 0.6s;
  animation-timing-function: ease-in-out;
}

/* responsive grid */
@media (min-width: 700px) {
  .grid {
    grid-auto-rows: repeat(6, 1fr);
  }
  .row .tile {
    width: 70px;
    height: 70px;
    font-size: 30px;
  }
}

@media (max-width: 520px) {
  .tile {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
  .key {
    padding: 14px 8px;
    font-size: 0.8rem;
  }
  .key.wide {
    padding: 14px 10px;
  }
}
