:root {
  --max: 60rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 2rem;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --border: #d9e2ec;
  --correct: #2f855a;
  --present: #b7791f;
  --absent: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --error: #b91c1c;
  --shadow: 0 1px 8px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.4rem;
}

a {
  color: inherit;
}

a:hover {
  text-decoration: none;
}

button {
  font: inherit;
}

.site-header,
.site-footer {
  padding: var(--space-2) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-footer {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--space-2);
}

.stack > * + * {
  margin-top: var(--space-2);
}

.muted {
  color: var(--muted);
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0;
  margin: var(--space-1) 0 0;
  list-style: none;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(28rem, 34rem);
  gap: var(--space-2);
  align-items: start;
  padding-top: var(--space-3);
}

.game-panel,
.keyboard-panel {
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
  justify-content: space-between;
}

#restart-button {
  padding: 0.6rem 0.9rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

#restart-button:hover {
  background: var(--accent-dark);
}

.message {
  min-height: 1.6rem;
  font-weight: 700;
  color: var(--muted);
}

.message.success {
  color: var(--correct);
}

.message.error {
  color: var(--error);
}

.guess-grid {
  display: grid;
  grid-template-columns: repeat(5, 3.5rem);
  gap: 0.45rem;
  justify-content: center;
}

.tile {
  display: grid;
  width: 3.5rem;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 0.35rem;
  background: #ffffff;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.tile.filled {
  border-color: #94a3b8;
}

.tile.correct,
.tile.present,
.tile.absent {
  border-color: transparent;
  color: #ffffff;
}

.correct {
  background: var(--correct);
}

.present {
  background: var(--present);
}

.absent {
  background: var(--absent);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
  color: var(--muted);
  font-size: 0.95rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-box {
  width: 1rem;
  aspect-ratio: 1;
  border-radius: 0.2rem;
}

.keyboard {
  display: grid;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  gap: 0.45rem;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
}

.key {
  flex: 1 1 0;
  max-width: 2.25rem;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 0.35rem;
  border: 1px solid #94a3b8;
  border-radius: 0.35rem;
  background: #cbd5e1;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
}

.key:hover:not(:disabled):not(.key-correct):not(.key-present):not(.key-absent) {
  background: #b6c3d1;
}

.key.wide {
  flex-grow: 2.1;
  max-width: 5rem;
  font-size: 0.85rem;
}

.key.key-correct,
.key.key-present,
.key.key-absent {
  border-color: transparent;
  color: #ffffff;
}

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

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

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

.key:disabled {
  cursor: not-allowed;
}

@media (max-width: 48rem) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-panel,
  .keyboard-panel {
    padding: var(--space-2);
  }
}

@media (max-width: 24rem) {
  .guess-grid {
    grid-template-columns: repeat(5, 2.8rem);
  }

  .tile {
    width: 2.8rem;
    font-size: 1.3rem;
  }

  .key {
    min-height: 2.4rem;
    padding: 0 0.35rem;
  }

  .key.wide {
    font-size: 0.75rem;
  }
}
