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

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: #121213;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header {
  border-bottom: 1px solid #3a3a3c;
  width: 100%;
  text-align: center;
  padding: 14px 0;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#message {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 4px;
}

#message.show {
  background: #fff;
  color: #121213;
  padding: 8px 16px;
  border-radius: 4px;
}

/* Board */
#board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  margin-bottom: 20px;
}

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

.tile {
  width: 62px;
  height: 62px;
  border: 2px solid #3a3a3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: transform 0.1s;
}

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

.tile.correct {
  background: #538d4e;
  border-color: #538d4e;
}

.tile.present {
  background: #b59f3b;
  border-color: #b59f3b;
}

.tile.absent {
  background: #3a3a3c;
  border-color: #3a3a3c;
}

.tile.flip {
  animation: flip 0.5s ease forwards;
}

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

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

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

.row.shake {
  animation: shake 0.4s ease;
}

/* Keyboard */
#keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.kb-row {
  display: flex;
  gap: 6px;
}

.key {
  height: 58px;
  min-width: 43px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  background: #818384;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  user-select: none;
}

.key.wide {
  min-width: 65px;
  font-size: 0.75rem;
}

.key.correct {
  background: #538d4e;
}

.key.present {
  background: #b59f3b;
}

.key.absent {
  background: #3a3a3c;
}

/* Stats bar */
#stats {
  display: flex;
  gap: 20px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #818384;
}

#stats span {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#stats .stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

/* Game over overlay */
#game-over {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 18, 19, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 10;
}

#game-over.hidden {
  display: none;
}

#game-over-text {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.6;
}

#play-again {
  padding: 14px 32px;
  border: none;
  border-radius: 4px;
  background: #538d4e;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#play-again:hover {
  background: #6aaf59;
}

@media (max-width: 500px) {
  .tile {
    width: 52px;
    height: 52px;
    font-size: 1.6rem;
  }

  .key {
    height: 50px;
    min-width: 32px;
    font-size: 0.75rem;
  }

  .key.wide {
    min-width: 52px;
  }
}
