/* Poople Unlimited — word ladder to POOP.
 * Theme tokens on :root; light/dark via [data-theme]. Board tiles use the
 * "hit" colour that matches the 🟫 share emoji so results look the same
 * on the page and in a chat.
 */
:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-dim: #efe8da;
  --ink: #2b1d12;
  --ink-soft: #6f5a48;
  --accent: #8b5a2b;        /* chocolate — the "hit" tile */
  --accent-ink: #fff8ec;
  --accent-2: #2f8f6b;      /* fresh green — primary buttons, done marks */
  --accent-2-ink: #ffffff;
  --line: #d9cdb9;
  --line-soft: #e8dfcf;
  --error: #c4432f;
  --focus: #2f8f6b;
  --tile-bg: #ffffff;
  --key-bg: #e9e1d2;
  --shadow: 0 1px 2px rgba(43, 29, 18, 0.06), 0 8px 28px rgba(43, 29, 18, 0.08);
  --radius: 14px;
  --radius-tile: 10px;
  --display: 'Bricolage Grotesque', 'Avenir Next', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', 'Helvetica Neue', system-ui, sans-serif;
}
[data-theme='dark'] {
  --bg: #17120e;
  --surface: #221a14;
  --surface-dim: #2b2119;
  --ink: #f3ebdd;
  --ink-soft: #b9a68f;
  --accent: #b8834a;
  --accent-ink: #1b120a;
  --accent-2: #4fbf93;
  --accent-2-ink: #0f1f18;
  --line: #4a3b2d;
  --line-soft: #33281f;
  --error: #ff7b66;
  --focus: #4fbf93;
  --tile-bg: #2b2119;
  --key-bg: #3a2e24;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 28px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.6; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0.2em 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(26px, 4.2vw, 38px); font-weight: 800; }
h2 { font-size: clamp(20px, 3vw, 26px); font-weight: 700; margin-top: 1.4em; }
h3 { font-size: 18px; font-weight: 700; margin-top: 1.2em; }
p { margin: 0.5em 0 0.9em; }
.muted { color: var(--ink-soft); font-size: 14px; }
.note { color: var(--ink-soft); font-size: 14px; }
.date { color: var(--ink-soft); font-weight: 600; font-size: 0.7em; white-space: nowrap; }
.wrap { max-width: 1020px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line-soft); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 40; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 24px; height: 24px; flex: none; }
.brand-mark .m1 { fill: var(--accent); }
.brand-mark .m2 { fill: var(--accent-2); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 19px; letter-spacing: 0.04em; white-space: nowrap; }
.site-nav { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 14px; padding: 8px 9px; border-radius: 8px; white-space: nowrap; }
.site-nav a:hover { color: var(--ink); background: var(--surface-dim); }
.site-nav a[aria-current='page'] { color: var(--ink); background: var(--surface-dim); }
.theme-toggle { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; padding: 0; font-size: 16px; flex: none; margin-left: 4px; }
.theme-toggle:hover { border-color: var(--ink-soft); }

/* ---------- Page scaffolding ---------- */
main { padding: 24px 0 64px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 6px; }
.lede { color: var(--ink-soft); font-size: 18px; max-width: 62ch; }
.game-head { max-width: 720px; margin: 0 auto 14px; text-align: center; }
.game-head h1 { margin-bottom: 4px; }
.game-meta { color: var(--ink-soft); font-size: 15px; max-width: 56ch; margin: 0 auto; }
.prose { max-width: 720px; margin: 48px auto 0; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin: 0.35em 0; }
.prose.reveal { margin-top: 24px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px 18px; }
.prose.reveal summary { cursor: pointer; font-weight: 700; font-family: var(--display); }

/* ---------- Game ---------- */
.game { max-width: 520px; margin: 0 auto; position: relative; }
.toast { position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%); background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; padding: 8px 14px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.2s; margin: 0; white-space: nowrap; z-index: 5; }
.toast.show { opacity: 1; }
.board { display: grid; gap: 8px; justify-content: center; padding: 18px 12px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow-y: auto; }
.ladder { display: grid; gap: 6px; justify-content: center; margin: 12px 0; padding: 0; list-style: none; }
.ladder-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: min(100%, 248px); margin: 0 auto; }
.tile { aspect-ratio: 1; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 26px; text-transform: uppercase; background: var(--tile-bg); border: 2px solid var(--line); border-radius: var(--radius-tile); color: var(--ink); transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.tile.filled { border-color: var(--ink-soft); }
.tile.hit { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ladder-row.start .tile { background: var(--surface-dim); }
.ladder-row.typing .tile { border-style: dashed; }
.ladder-row.typing .tile.filled { border-style: solid; }
.ladder-row.goal .tile { animation: jump 0.5s ease; }
.ladder-row.wiggle { animation: wiggle 0.35s ease; }
@keyframes wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes jump { 0% { transform: translateY(0); } 40% { transform: translateY(-10px); } 100% { transform: translateY(0); } }
.controls { display: flex; gap: 8px; justify-content: center; margin: 12px 0 4px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 15px; padding: 9px 16px; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--ink-soft); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent-2); color: var(--accent-2-ink); border-color: var(--accent-2); }
.btn-primary:hover { opacity: 0.92; }
.hint-note { text-align: center; min-height: 1.4em; margin: 6px 0; font-size: 15px; color: var(--ink-soft); }
.keyboard { display: grid; gap: 6px; margin: 10px auto 0; max-width: 520px; user-select: none; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key { flex: 1 1 0; max-width: 46px; height: 52px; border: 0; border-radius: 8px; background: var(--key-bg); color: var(--ink); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; padding: 0; touch-action: manipulation; }
.key.wide { flex: 1.6 1 0; max-width: 72px; font-size: 13px; }
.key:hover { filter: brightness(0.95); }
.key:active { transform: scale(0.95); }
.difficulty { display: flex; gap: 8px; justify-content: center; margin: 0 0 14px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 14px; padding: 7px 14px; border-radius: 999px; cursor: pointer; display: grid; text-align: center; line-height: 1.2; }
.chip small { font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip[aria-pressed='true'] small { color: inherit; opacity: 0.8; }

/* ---------- Win panel & stats ---------- */
.win-panel { margin-top: 16px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; text-align: center; animation: rise 0.4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.win-panel h2 { margin: 0 0 6px; }
.win-line { margin: 0 0 12px; }
.win-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.best-path { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.stats { max-width: 520px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 8px 16px; }
.stats summary { cursor: pointer; font-weight: 700; font-family: var(--display); padding: 6px 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 12px; text-align: center; }
.stats-grid div { display: grid; gap: 2px; }
.stats-grid .num { font-family: var(--display); font-weight: 800; font-size: 26px; }
.stats-grid .lbl { font-size: 12px; color: var(--ink-soft); }
.dist { display: grid; gap: 4px; padding-bottom: 8px; }
.bar-row { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: center; font-size: 13px; }
.bar { display: block; background: var(--line); color: var(--ink); border-radius: 4px; padding: 2px 8px; min-width: 24px; font-weight: 700; }
.bar-row.cur .bar { background: var(--accent); color: var(--accent-ink); }

/* ---------- Archive ---------- */
.archive-strip { margin-top: 28px; }
.archive-strip .row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.archive-chip { display: inline-block; text-decoration: none; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); font-weight: 700; font-size: 14px; background: var(--surface); }
.archive-chip:hover { border-color: var(--ink-soft); color: var(--ink); }
.month-grid { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-grid a, .month-grid span { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 700; background: var(--surface); }
.month-grid span { opacity: 0.3; border-style: dashed; }
.month-grid a:hover { border-color: var(--ink-soft); }
.month-grid a.done { background: color-mix(in srgb, var(--accent-2) 22%, var(--surface)); border-color: var(--accent-2); }
.answer-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.answer-list li { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 14px; }
.answer-list a { text-decoration: none; color: var(--ink); }
.answer-list a:hover { color: var(--accent); }
.answer-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 16px 0; }
.steps { list-style: none; padding: 0; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 18px 14px 56px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 16px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-family: var(--display); }
.steps h2 { margin: 0 0 4px; font-size: 19px; }
.steps p { margin: 0; }

/* ---------- Solver ---------- */
.solver { display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.solver label { display: grid; gap: 4px; font-weight: 700; font-size: 14px; }
.solver label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.solver input[type='text'], .solver input:not([type]) { font: inherit; font-family: var(--display); font-weight: 800; font-size: 24px; text-transform: uppercase; letter-spacing: 0.2em; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--tile-bg); color: var(--ink); width: 100%; max-width: 220px; }
.solver-out .err { color: var(--error); font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line-soft); margin-top: 24px; padding: 24px 0 40px; color: var(--ink-soft); font-size: 14px; }
.site-footer .wrap { display: grid; gap: 8px; }
.site-footer a { color: var(--ink-soft); }
.site-footer .disclaimer { max-width: 72ch; }
.more-games { max-width: 72ch; }
.more-games strong { color: var(--ink); font-weight: 600; }

/* ---------- Responsive & a11y ---------- */
@media (max-width: 560px) {
  .brand-name { font-size: 16px; }
  .site-nav a { font-size: 13px; padding: 8px 7px; }
  .stats-grid .num { font-size: 22px; }
  .tile { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
