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

:root {
  --color-correct: #4caf50;
  --color-present: #ff9800;
  --color-absent: #9e9e9e;
  --color-empty: #ffffff;
  --color-border: #ccc;
  --color-header: #5c35a0;
  --tile-size: 62px;   /* overridden by game.js based on word length */
  --tile-font: 1.9rem; /* overridden by game.js based on word length */
  --tile-gap: 6px;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #e8f4fd 0%, #fce4ec 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  user-select: none;
}

header {
  width: 100%;
  max-width: 500px;
  text-align: center;
  padding: 16px 0 8px;
  border-bottom: 2px solid var(--color-header);
  margin-bottom: 16px;
}

header h1 {
  color: var(--color-header);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
}

header .subtitle {
  color: #666;
  font-size: 0.85rem;
  margin-top: 2px;
}

#message-area {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

#message {
  background: #333;
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
}

#message.show {
  opacity: 1;
}

/* Grid */
#board {
  display: grid;
  grid-template-rows: repeat(6, var(--tile-size));
  gap: var(--tile-gap);
  margin-bottom: 20px;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  gap: var(--tile-gap);
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--tile-font);
  font-weight: 900;
  color: #222;
  background: var(--color-empty);
  text-transform: uppercase;
  transition: transform 0.1s;
}

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

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

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

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

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

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

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

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

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

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

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

.key {
  height: 54px;
  min-width: 38px;
  padding: 0 6px;
  border: none;
  border-radius: 8px;
  background: #d3d6da;
  color: #222;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.key.wide {
  min-width: 58px;
  font-size: 0.8rem;
}

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

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

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

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

/* Win animation */
.row.win .tile {
  animation: bounce 0.5s ease forwards;
}
.row.win .tile:nth-child(2) { animation-delay: 0.1s; }
.row.win .tile:nth-child(3) { animation-delay: 0.2s; }
.row.win .tile:nth-child(4) { animation-delay: 0.3s; }
.row.win .tile:nth-child(5) { animation-delay: 0.4s; }

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

#new-game-btn {
  margin-top: 20px;
  padding: 12px 28px;
  background: var(--color-header);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: none;
}

#new-game-btn:hover {
  background: #7c4dbc;
}

@media (max-width: 400px) {
  .key { min-width: 30px; height: 44px; font-size: 0.75rem; }
  .key.wide { min-width: 46px; }
}
