
:root{
  --tile-size: 56px;
  --gap: 8px;

  --bg: #121213;
  --fg: #d7dadc;
  --muted: #8a8f98;

  --absent: #3a3a3c;
  --present: #b59f3b;
  --correct: #538d4e;

  --key-bg: #818384;
  --key-fg: #ffffff;

  --accent: #6ca0ff;
}

*{ box-sizing: border-box; }
html,body{
  height:100%;
  margin:0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.game{
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 12px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.title{
  font-size: 24px;
  margin: 0;
  letter-spacing: 2px;
  font-weight: 700;
  padding-right: 64px
}

.controls{
  display:flex; gap:8px;
}

.btn{
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover{ border-color: var(--fg); }
.btn:disabled{
  opacity: .5;
  cursor: not-allowed;
}

.board{
  display: grid;
  grid-template-rows: repeat(6, var(--tile-size));
  grid-auto-rows: var(--tile-size);
  gap: var(--gap);
  width: calc((5 * var(--tile-size)) + (4 * var(--gap)));
  margin: 12px auto 16px;
}

.row{
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  gap: var(--gap);
}

.tile{
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid #3a3a3c;
  display:grid;
  place-items: center;
  font-weight: 700;
  font-size: 28px;
  text-transform: uppercase;
  user-select: none;
  background: #121213;
}
.tile.filled{ border-color: #565758; }

.tile.reveal{ animation: flip 520ms ease forwards; }

.tile.absent{ background: var(--absent); border-color: var(--absent); color: #fff; }
.tile.present{ background: var(--present); border-color: var(--present); color: #fff; }
.tile.correct{ background: var(--correct); border-color: var(--correct); color: #fff; }

@keyframes flip{
  0%{ transform: rotateX(0); }
  49%{ transform: rotateX(90deg); }
  50%{ transform: rotateX(90deg); }
  100%{ transform: rotateX(0deg); }
}

.shake{ animation: shake 250ms ease-in-out; }
@keyframes shake{
  0%,100%{ transform: translateX(0); }
  20%,60%{ transform: translateX(-8px); }
  40%,80%{ transform: translateX(8px); }
}

.pop{ animation: pop 100ms ease-in-out; }
@keyframes pop{
  0%{ transform: scale(1); }
  50%{ transform: scale(1.08); }
  100%{ transform: scale(1); }
}

.status{
  text-align: center;
  min-height: 22px;
  color: var(--muted);
  margin: 4px 0 10px;
}

.keyboard{
  display:flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  margin-left: auto;
  margin-right: auto;
}

.kb-row{
  display:flex;
  gap: 6px;
  justify-content: center;
}

.key{
  background: var(--key-bg);
  color: var(--key-fg);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  height: 46px;
  min-width: 34px;
  padding: 0 8px;
  cursor: pointer;
  user-select: none;
}
.key.wide{ min-width: 62px; }
.key.absent{ background: var(--absent); }
.key.present{ background: var(--present); }
.key.correct{ background: var(--correct); }

@media (max-width: 420px){
  :root{ --tile-size: 48px; --gap: 6px; }
  .title{ font-size: 20px; }
}