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

body {
  background: #202124;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8eaed;
  overflow: hidden;
}

#back-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  z-index: 20;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #5f6368;
  transition: background 0.2s;
  line-height: 1;
}

#back-btn:hover {
  background: #80868b;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 16px;
  width: 100%;
  height: 100vh;
  max-width: 600px;
}

#header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
  font-size: 18px;
  font-weight: 500;
}

#stats-display {
  color: #9aa0a6;
}

#board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 420px;
  align-content: center;
}

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

.tile {
  width: 100%;
  aspect-ratio: 1;
  max-width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid #3a3a3c;
  border-radius: 4px;
  background: transparent;
  color: #e8eaed;
  transition: transform 0.1s;
}

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

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

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

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

.tile.reveal {
  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%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

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

#message {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 8px;
  background: #e8eaed;
  color: #202124;
  transition: opacity 0.3s;
}

#message.hidden {
  opacity: 0;
  pointer-events: none;
}

#keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
  max-width: 560px;
  padding-bottom: 4px;
}

.kb-row {
  display: flex;
  gap: 5px;
  width: 100%;
  justify-content: center;
}

.key {
  height: 58px;
  min-width: 36px;
  padding: 0 8px;
  border-radius: 6px;
  border: none;
  background: #818384;
  color: #e8eaed;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  transition: background 0.15s, transform 0.1s;
  flex: 1;
  max-width: 50px;
  user-select: none;
  -webkit-user-select: none;
}

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

.key.wide {
  min-width: 64px;
  max-width: 76px;
  font-size: 13px;
}

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

.key.present {
  background: #b59f3b;
}

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

@media (max-width: 420px) {
  .tile {
    font-size: 26px;
  }

  .key {
    height: 50px;
    font-size: 13px;
  }

  #header {
    font-size: 16px;
  }

  #game-container {
    padding: 12px 8px;
  }
}
