:root {
  --bg: #0c0b0a;
  --bg-elev: #161412;
  --ink: #e8e2d6;
  --ink-dim: #9a9284;
  --line: #3a342c;
  --gold: #c4a574;
  --gold-deep: #8d7348;
  --correct: #3d6b4f;
  --correct-ink: #e7f3ea;
  --present: #a68b3a;
  --present-ink: #1c1608;
  --absent: #2a2824;
  --absent-ink: #7a7368;
  --tile: clamp(2.55rem, 12.4vw, 3.55rem);
  --gap: clamp(0.28rem, 1.4vw, 0.42rem);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "Iowan Old Style", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(196, 165, 116, 0.09), transparent 55%),
    radial-gradient(800px 500px at 80% 110%, rgba(61, 107, 79, 0.08), transparent 50%),
    var(--bg);
}

.vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(12, 11, 10, 0.15), transparent 18%),
    linear-gradient(0deg, rgba(12, 11, 10, 0.55), transparent 22%);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.45);
}

.app {
  position: relative;
  z-index: 1;
  width: min(42rem, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.35rem 0 calc(1.2rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
}

.mast {
  text-align: center;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

.mast h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.1rem, 8vw, 2.85rem);
  letter-spacing: 0.06em;
}

.mast h1 span {
  color: var(--gold);
}

.tag {
  margin: 0.45rem 0 0;
  color: var(--ink-dim);
  font-size: 0.92rem;
}

.boot {
  margin: 2.5rem 0;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

.boot.is-error {
  color: #d2b08a;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: rgba(22, 20, 18, 0.85);
  min-width: 6.4rem;
}

.chip-label {
  color: var(--ink-dim);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hint-btn,
.new-game {
  appearance: none;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #2a241c, #1a1612);
  color: var(--gold);
  font: inherit;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  padding: 0.48rem 0.9rem;
  cursor: pointer;
}

.hint-btn:hover,
.new-game:hover {
  border-color: var(--gold);
  color: var(--ink);
}

.hint-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint-text {
  margin: 0 0 0.85rem;
  max-width: 34rem;
  text-align: center;
  color: #d8c7a4;
  font-family: var(--serif);
  font-style: italic;
  line-height: 1.45;
}

.board {
  display: grid;
  gap: var(--gap);
  margin: 0.15rem 0 1rem;
}

.row {
  display: grid;
  grid-template-columns: repeat(6, var(--tile));
  gap: var(--gap);
}

.tile {
  width: var(--tile);
  height: var(--tile);
  border: 1px solid #4a4338;
  background: #141210;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: calc(var(--tile) * 0.48);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tile.is-filled {
  border-color: #8a7b64;
  background: #1c1915;
}

.tile.is-correct {
  background: var(--correct);
  border-color: #6d9a7a;
  color: var(--correct-ink);
}

.tile.is-present {
  background: var(--present);
  border-color: #d4b65a;
  color: var(--present-ink);
}

.tile.is-absent {
  background: var(--absent);
  border-color: #3d3a35;
  color: var(--absent-ink);
}

.tile.is-reveal {
  animation: flip 0.42s ease both;
  animation-delay: var(--delay, 0ms);
}

.row.is-shake {
  animation: shake 0.42s ease;
}

.result {
  width: min(28rem, 100%);
  margin: 0 0 1rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  background: rgba(22, 20, 18, 0.92);
  text-align: center;
}

.result[data-status="won"] {
  border-color: #4d7a5c;
}

.result[data-status="lost"] {
  border-color: #6f5a3a;
}

.result-line {
  margin: 0 0 0.8rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.4;
}

.keyboard {
  width: min(40rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.4rem;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 0.28rem;
}

.key {
  appearance: none;
  border: 1px solid #3f392f;
  background: #221f1b;
  color: var(--ink);
  min-width: clamp(1.45rem, 8vw, 2.35rem);
  height: 2.7rem;
  padding: 0 0.15rem;
  font: 600 0.82rem var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.key.wide {
  min-width: clamp(3.1rem, 14vw, 4.4rem);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.key:hover {
  border-color: var(--gold-deep);
}

.key.is-correct {
  background: var(--correct);
  border-color: #6d9a7a;
  color: var(--correct-ink);
}

.key.is-present {
  background: var(--present);
  border-color: #d4b65a;
  color: var(--present-ink);
}

.key.is-absent {
  background: #1a1917;
  border-color: #2e2b27;
  color: #5e5850;
}

.foot {
  margin-top: 1.15rem;
  color: var(--ink-dim);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.foot a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.foot a:hover {
  color: var(--gold);
  border-color: var(--gold-deep);
}

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 5;
  max-width: min(28rem, calc(100% - 2rem));
  padding: 0.65rem 0.9rem;
  background: #2a241c;
  border: 1px solid var(--gold-deep);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes flip {
  0% {
    transform: rotateX(0);
  }
  45% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@media (max-width: 420px) {
  .app {
    width: min(42rem, calc(100% - 0.8rem));
    padding-top: 0.9rem;
  }

  .key {
    height: 2.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile.is-reveal,
  .row.is-shake,
  .toast {
    animation: none;
    transition: none;
  }
}
