:root {
  --bg: #e7efe6;
  --ink: #17211b;
  --muted: #5d6b63;
  --card: #fffdf8;
  --line: #d7e0d6;
  --accent: #e24a1b;
  --good: #1d7a45;
  --key: #f3f6f2;
  --shadow: 0 16px 40px rgba(23, 33, 27, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 10% -10%, #fff7e8 0%, transparent 55%),
    linear-gradient(180deg, #f4f7f1 0%, var(--bg) 40%, #e4ebe2 100%);
}

main {
  width: min(440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.top { margin-bottom: 18px; }

.brand {
  color: inherit;
  text-decoration: none;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.tag, .lede, .note, footer {
  color: var(--muted);
  line-height: 1.45;
}

.tag { margin: 4px 0 0; }

h1, h2 {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.55rem; }

.lede { margin: 0 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px 20px 18px;
  margin-bottom: 14px;
}

.demo {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 6px;
}

.demo li, .tiles, .path .tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.demo span, .tile, .key {
  display: grid;
  place-items: center;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 700;
}

.demo span {
  height: 36px;
  background: #f6f3ea;
  border: 1px solid var(--line);
}

.demo span.hot, .tile.match {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.note { margin: 8px 0 0; font-size: 0.92rem; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 12px;
  font: 700 1.15rem/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

input:focus, button:focus-visible, a.button:focus-visible {
  outline: 3px solid #f3c7b6;
  outline-offset: 2px;
}

#find { margin-top: 0; }

button, a.button {
  font: 650 0.95rem/1 ui-sans-serif, system-ui, sans-serif;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--key);
  color: var(--ink);
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
}

button.primary, a.primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

button:disabled { opacity: 0.45; cursor: default; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.msg {
  min-height: 1.3em;
  margin: 10px 0 0;
  color: var(--accent);
  font-weight: 650;
}

.kicker, .score, .editor-label {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  font-weight: 750;
  color: var(--muted);
}

.score { color: var(--ink); font-size: 0.95rem; letter-spacing: 0.02em; }

.path {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.tiles { margin: 8px 0 4px; }

.tile {
  aspect-ratio: 1;
  background: white;
  border: 2px solid var(--ink);
  font-size: clamp(1.2rem, 6vw, 1.7rem);
  cursor: pointer;
}

.tile.current { box-shadow: inset 0 0 0 3px #f3c7b6; }
.tile.blank { color: transparent; }

.tiles.shake { animation: shake 0.35s linear; }

@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.keys { display: grid; gap: 6px; margin-top: 12px; }

.keyrow { display: flex; gap: 4px; justify-content: center; }

.key {
  flex: 1;
  height: 46px;
  border-radius: 8px;
  border: 0;
  background: #e7eee6;
  padding: 0;
  font-size: 0.95rem;
}

.key.wide { flex: 1.5; font-size: 0.75rem; letter-spacing: 0.04em; }

button.tile {
  width: 100%;
  padding: 0;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: white;
}

button.key {
  border-radius: 8px;
  padding: 0;
  border: 0;
}

span.tile { cursor: default; }

.path .tile {
  aspect-ratio: auto;
  height: 42px;
  font-size: 1rem;
  border-width: 1.5px;
}

#win { margin-top: 8px; }
#win h2.match { color: var(--good); }

footer { font-size: 0.82rem; padding: 0 6px; }

footer a, .legal a {
  color: var(--ink);
}

main.legal {
  width: min(640px, calc(100% - 28px));
}

.legal h1 { font-size: 2.2rem; }

.legal h2 {
  font-size: 1.25rem;
  margin-top: 22px;
}

.legal p, .legal li { line-height: 1.5; }

.legal ul { padding-left: 1.2rem; }

.poop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  width: 56px;
  height: 56px;
  margin: 0;
  font-size: 52px;
  line-height: 56px;
  text-align: center;
  user-select: none;
  touch-action: none;
  cursor: grab;
  filter: drop-shadow(0 8px 0 rgba(23, 33, 27, 0.12));
}

.poop.held { cursor: grabbing; }

@media (prefers-reduced-motion: reduce) {
  .tiles.shake { animation: none; }
}
