:root {
  color-scheme: light;
  --bg: #f4efe5;
  --ink: #17201c;
  --muted: #65706a;
  --line: #d8ccbb;
  --panel: #fffaf0;
  --correct: #2f9d63;
  --present: #d8a437;
  --absent: #8a918c;
  --accent: #245e57;
  --shadow: 0 24px 70px rgba(32, 30, 23, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(47, 157, 99, 0.13), transparent 42%),
    radial-gradient(circle at 88% 12%, rgba(216, 164, 55, 0.22), transparent 26%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.game-shell {
  width: min(760px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  align-items: center;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar a {
  color: var(--accent);
  font-weight: 900;
}

.topbar button,
.guess-form button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 900;
}

.topbar button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 1.35rem;
}

.hero {
  margin: 30px 0 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--present);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(3rem, 10vw, 6.4rem);
  line-height: 0.9;
}

.hero p:last-child {
  max-width: 650px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.7;
}

.board {
  display: grid;
  gap: 8px;
  justify-content: start;
}

.word-row {
  display: grid;
  grid-template-columns: repeat(5, clamp(48px, 11vw, 72px));
  gap: 8px;
}

.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid #cfc4b2;
  border-radius: 8px;
  background: #eadfce;
  color: var(--ink);
  font-size: clamp(1.6rem, 6vw, 3rem);
  font-weight: 1000;
  line-height: 1;
}

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

.tile.correct { background: var(--correct); }
.tile.present { background: var(--present); }
.tile.absent { background: var(--absent); }

.guess-form {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.guess-form label {
  color: var(--muted);
  font-weight: 900;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-row input {
  width: min(100%, 280px);
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.input-row button {
  min-width: 118px;
  min-height: 52px;
  padding: 0 18px;
}

.input-row button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.status {
  min-height: 28px;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 900;
}

.legend {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.legend div {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.swatch {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 4px;
}

.swatch.correct { background: var(--correct); }
.swatch.present { background: var(--present); }
.swatch.absent { background: var(--absent); }

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(23, 32, 28, 0.34);
}

.result-modal[hidden] {
  display: none;
}

.result-dialog {
  width: min(420px, 100%);
  padding: 22px;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.result-dialog p {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.55;
}

.result-dialog button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

@media (max-width: 560px) {
  .panel {
    padding: 16px;
  }

  .board {
    justify-content: stretch;
  }

  .word-row {
    grid-template-columns: repeat(5, 1fr);
  }

  .input-row {
    display: grid;
  }

  .input-row input,
  .input-row button {
    width: 100%;
  }
}
