* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: #0C0D14;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  font-family: 'Courier New', monospace;
  color: #fff;
  overflow: auto;
}

#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  padding: 12px;
  gap: 12px;
}

#hud {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  padding: 8px 16px;
  background: #13141D;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.hud-group { display: flex; flex-direction: column; align-items: center; }
.hud-label { font-size: 10px; font-weight: 700; letter-spacing: 3px; color: #888; }
.hud-value { font-size: 22px; font-weight: 700; color: #00ff88; }

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

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

.tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: transparent;
  transition: transform 0.1s;
}

.tile.filled {
  border-color: rgba(255, 255, 255, 0.4);
  animation: pop 0.1s ease;
}

.tile.correct {
  background: #00ff88;
  color: #0C0D14;
  border-color: #00ff88;
}

.tile.present {
  background: #ffcc00;
  color: #0C0D14;
  border-color: #ffcc00;
}

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

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

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

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

.row.bounce .tile:nth-child(2) { animation-delay: 0.1s; }
.row.bounce .tile:nth-child(3) { animation-delay: 0.2s; }
.row.bounce .tile:nth-child(4) { animation-delay: 0.3s; }
.row.bounce .tile:nth-child(5) { animation-delay: 0.4s; }

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

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

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 420px;
}

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

.key {
  min-width: 32px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 8px;
  transition: background 0.15s;
}

.key:hover { background: #2a2a3e; }
.key.wide { min-width: 56px; font-size: 11px; }
.key.correct { background: #00ff88; color: #0C0D14; }
.key.present { background: #ffcc00; color: #0C0D14; }
.key.absent { background: #3a3a4a; color: #666; }

#overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#overlay.hidden { display: none; }

#overlay-box {
  background: #13141D;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
}

#overlay-box h1 {
  font-size: 36px;
  margin-bottom: 12px;
  letter-spacing: 4px;
  color: #00ff88;
}

.subtitle { color: #aaa; font-size: 14px; margin-bottom: 8px; }
.controls-hint { color: #666; font-size: 12px; margin-bottom: 24px; }

.game-btn {
  background: #00ff88;
  color: #0C0D14;
  border: none;
  padding: 14px 28px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.game-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.hidden { display: none !important; }
