:root {
  --bg: #121213;
  --panel: #1b1b1d;
  --text: #f8f8f8;
  --muted: #9fa0a4;
  --tile-border: #3a3a3c;
  --tile-filled: #565758;
  --absent: #4b5563;
  --present: #ea580c;
  --correct: #2563eb;
  --key: #818384;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  touch-action: manipulation;
}

.topbar {
  text-align: center;
  padding: 1.1rem 1rem 0.4rem;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: 0.05em;
}

.puzzle-meta {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.app {
  width: 100%;
  max-width: 38rem;
  padding: 0 0.8rem 1rem;
  display: grid;
  justify-items: center;
  gap: 0.9rem;
}

.status-wrap {
  min-height: 1.5rem;
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.board {
  width: min(22rem, 92vw);
  display: grid;
  gap: 0.35rem;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--tile-border);
  display: grid;
  place-items: center;
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
}

.tile.filled {
  border-color: var(--tile-filled);
}

.tile.revealed {
  color: #fff;
  border-color: transparent;
}

.tile.correct {
  background: var(--correct);
}

.tile.present {
  background: var(--present);
}

.tile.absent {
  background: var(--absent);
}

.keyboard {
  width: min(34rem, 97vw);
  display: grid;
  gap: 0.45rem;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}

.key {
  flex: 1;
  min-height: 3.25rem;
  max-width: 2.6rem;
  border: 0;
  border-radius: 0.35rem;
  background: var(--key);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
}

.key:hover {
  filter: brightness(1.07);
}

.key:active {
  transform: translateY(1px);
}

.key.wide {
  max-width: 4.8rem;
  font-size: 0.74rem;
}

.key.state-correct {
  background: var(--correct);
}

.key.state-present {
  background: var(--present);
}

.key.state-absent {
  background: var(--absent);
}

.actions {
  display: flex;
  gap: 0.55rem;
  justify-content: center;
  flex-wrap: wrap;
}

.secondary {
  border: 1px solid #4e4f54;
  background: #202124;
  color: #e8e8ea;
  border-radius: 0.4rem;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 420px) {
  .key {
    min-height: 3rem;
    max-width: 2.2rem;
    font-size: 0.86rem;
  }

  .key.wide {
    max-width: 4.3rem;
    font-size: 0.7rem;
  }
}
