/* ---------- Wordish ---------- */

:root {
  --w-absent:  #3a4150;
  --w-present: #c9a227;
  --w-correct: #4e9c62;
}

.stage { justify-content: center; gap: 0; padding: 6px 8px; }

.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, var(--tile, 56px));
  grid-auto-rows: var(--tile, 56px);
  gap: var(--tile-gap, 5px);
}

.tile {
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 4px;
  font-size: calc(var(--tile, 56px) * .52);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  /* the flip is done on the tile itself, so give it a 3D context */
  transition: border-color .1s;
}

.tile.is-filled { border-color: var(--surface-3); animation: pop .1s var(--ease); }

.tile.is-revealing { animation: flip .5s ease forwards; }

.tile.st-absent  { background: var(--w-absent);  border-color: var(--w-absent);  color: #fff; }
.tile.st-present { background: var(--w-present); border-color: var(--w-present); color: #14100a; }
.tile.st-correct { background: var(--w-correct); border-color: var(--w-correct); color: #06210e; }

.row-shake { animation: shake .5s; }
.row-bounce .tile { animation: bounce .6s var(--ease); }

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

/* Half-turn hides the face, the class swap happens at the midpoint. */
@keyframes flip {
  0%   { transform: rotateX(0deg); }
  49%  { transform: rotateX(90deg); }
  51%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  35%      { transform: translateY(-22px); }
  55%      { transform: translateY(4px); }
  75%      { transform: translateY(-6px); }
}

/* ---------- keyboard ---------- */

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

.kb__row {
  display: flex;
  gap: 5px;
  justify-content: center;
  touch-action: manipulation;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  text-transform: uppercase;
  transition: background .12s, transform .06s;
}
.key:active { transform: translateY(1px); background: #414a5a; }
.key--wide { flex: 1.5 1 0; }
.key svg { width: 22px; height: 22px; }

/* Half-width gap that gives rows 2 and 3 the offset of a real keyboard. */
.key--spacer { flex: .5 1 0; background: none; pointer-events: none; }

.key.st-absent  { background: var(--w-absent);  color: #8e96a6; }
.key.st-present { background: var(--w-present); color: #14100a; }
.key.st-correct { background: var(--w-correct); color: #06210e; }

/* Keyboard needs to survive very short screens (landscape, small phones). */
@media (max-height: 620px) {
  .key { height: 42px; font-size: 13px; }
  .kb { gap: 5px; }
}

/* ---------- result sheet ---------- */

.result__word {
  display: block;
  margin: 2px 0 14px;
  font-size: 15px;
  color: var(--text-2);
}
.result__word b {
  font-size: 24px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  display: block;
  margin-top: 2px;
}

.dist { display: grid; gap: 5px; margin: 10px 0 2px; }
.dist__row {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.dist__bar {
  background: var(--surface-3);
  border-radius: 3px;
  padding: 2px 7px;
  min-width: 22px;
  text-align: right;
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  transition: width .4s var(--ease);
}
.dist__bar.is-current { background: var(--w-correct); color: #06210e; }
