/* Paidia: playful arcade, readable docs. All colours are tokens; dark theme follows the OS. */

:root {
  color-scheme: light dark;

  --bg: #fff6e5;
  --bg-dots: #f3dfbb;
  --surface: #ffffff;
  --surface-2: #fdeccd;
  --ink: #1c1633;
  --ink-soft: #4a4363;
  --line: #1c1633;
  --line-soft: #e6d3b0;
  --shadow: #1c1633;

  --brand: #ff5a36;
  --on-brand: #1c1633;
  --sun: #ffc83d;
  --mint: #3fd0b2;
  --pink: #ff8fc0;
  --sky: #7cc4ff;
  --link: #b42d0c;
  --link-hover: #7f1d05;
  --focus: #0050c8;

  --ok: #0b7a52;
  --ok-bg: #d4f5e6;
  --warn-bg: #fff0b8;
  --todo: #a3123a;
  --todo-bg: #ffe1ea;
  --highlight: #ffc83d;
  --stripe: rgba(255, 255, 255, 0.18);

  --code-bg: #1c1633;
  --code-fg: #fff3dc;
  --code-muted: #b9b0d6;
  --code-accent: #ffc83d;

  --radius: 14px;
  --radius-sm: 8px;
  --border: 3px solid var(--line);
  --lift: 5px 5px 0 var(--shadow);

  --font-display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  /* System monospace stacks include the block characters (░) the Maze Runner map uses. */
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15122a;
    --bg-dots: #221d40;
    --surface: #211c3d;
    --surface-2: #2b2550;
    --ink: #fff3dc;
    --ink-soft: #cfc6e6;
    --line: #6a5fa8;
    --line-soft: #3a3366;
    --shadow: #07060f;

    --brand: #ff6f4f;
    --on-brand: #15122a;
    --sun: #ffd25e;
    --mint: #4fdcbf;
    --pink: #ff9cc8;
    --sky: #8ccbff;
    --link: #ffab8f;
    --link-hover: #ffd2c2;
    --focus: #ffd25e;

    --ok: #6fe3b2;
    --ok-bg: #123d30;
    --warn-bg: #3d3210;
    --todo: #ffb3c7;
    --todo-bg: #4a1428;
    --highlight: #7a3418;
    --stripe: rgba(255, 255, 255, 0.05);

    --code-bg: #0c0a1a;
    --code-fg: #fff3dc;
    --code-muted: #a79fc6;
    --code-accent: #ffd25e;
  }
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 1.0625rem/1.6 var(--font-body);
  overflow-wrap: break-word;
}

main { flex: 1; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.1rem, 6vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.05rem; margin: 1.4em 0 0.4em; }

p, ul, ol, dl { margin: 0 0 1em; }

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 0.08em; }
a:hover { color: var(--link-hover); text-decoration-thickness: 0.14em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

code, pre, kbd, samp { font-family: var(--font-mono); }

:not(pre) > code {
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 1.25em;
  padding: 16px 18px;
  background: var(--code-bg);
  color: var(--code-fg);
  border: var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
  max-width: 100%;
}
pre .c { color: var(--code-muted); }
pre .k { color: var(--code-accent); }

hr { border: 0; border-top: 2px dashed var(--line-soft); margin: 2.5rem 0; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: 16px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--sun);
  color: var(--on-brand);
  border: var(--border);
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.skip-link:focus { top: 12px; }

.muted { color: var(--ink-soft); }
.lead { font-size: 1.2rem; color: var(--ink-soft); max-width: 60ch; }

/* ---------- Header / footer shell ---------- */

.site-header {
  background: var(--surface);
  border-bottom: var(--border);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-mark .die { fill: var(--brand); stroke: var(--line); stroke-width: 3; }
.brand-mark .pip { fill: var(--on-brand); }
.brand-name { font-family: var(--font-display); font-size: 1.85rem; line-height: 1; letter-spacing: 0.02em; }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  display: inline-block;
  padding: 8px 12px;
  border: 2px solid transparent;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.site-nav a:hover { border-color: var(--line); }
@media (max-width: 420px) {
  .site-nav ul { gap: 4px 2px; }
  .site-nav a { padding: 6px 8px; font-size: 0.95rem; }
}
.site-nav a[aria-current="page"] {
  background: var(--sun);
  color: var(--on-brand);
  border-color: var(--line);
}

.site-footer {
  margin-top: 64px;
  background: var(--surface);
  border-top: var(--border);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 20px;
}
.footer-inner p { margin: 0; }
.footer-brand .brand-name { font-size: 1.3rem; margin-right: 8px; }
.site-footer ul { display: flex; gap: 18px; margin: 0; padding: 0; list-style: none; }
.site-footer a { color: var(--ink); font-weight: 700; }

/* ---------- Buttons, pills, chips ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border: var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  font: 700 1.05rem/1.2 var(--font-body);
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.btn:hover { color: var(--ink); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.btn-primary, .btn-primary:hover { background: var(--sun); color: var(--on-brand); }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--on-brand);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chip[data-kind="puzzle"] { background: var(--mint); }
.chip[data-kind="social"] { background: var(--pink); }
.chip[data-kind="luck"] { background: var(--sun); }
.chip.soon { background: var(--surface-2); color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border: 2px solid var(--line-soft);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill.active { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.pill.active::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.4s steps(2, start) infinite;
}
.pill.finished { color: var(--ink-soft); }

@keyframes blink { to { visibility: hidden; } }

/* ---------- Sections ---------- */

.section { margin-top: 64px; }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 20px;
}
.section-head h2 { margin: 0; }
.section-head h2::before {
  content: "";
  display: inline-block;
  width: 0.55em; height: 0.55em;
  margin-right: 0.35em;
  background: var(--brand);
  border: 3px solid var(--line);
  vertical-align: 0.05em;
}
.section-head p { margin: 0; }

.panel {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  padding: 20px;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  gap: 32px;
  align-items: center;
  padding-top: 48px;
}
@media (min-width: 880px) {
  .hero { grid-template-columns: 1.1fr 1fr; padding-top: 64px; }
}
.hero h1 { margin-bottom: 16px; }
.hero h1 .hl {
  background: linear-gradient(transparent 58%, var(--highlight) 58%, var(--highlight) 92%, transparent 92%);
  padding-inline: 0.05em;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 24px; }

.screen {
  margin: 0;
  background: var(--surface);
  border: var(--border);
  border-radius: 18px;
  box-shadow: 8px 8px 0 var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.screen-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: var(--border);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 700;
  font-size: 0.9rem;
}
.screen-bar .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--sun);
}
.screen-bar .dot + .dot { background: var(--mint); }
.screen-bar .label { margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  font-size: 0.9rem;
}
.screen figcaption { padding: 10px 14px; font-size: 0.9rem; color: var(--ink-soft); border-top: var(--border); }
.cursor {
  display: inline-block;
  width: 0.6em;
  background: var(--code-accent);
  color: var(--code-bg);
  animation: blink 1s steps(2, start) infinite;
}

/* ---------- Game cards ---------- */

.cards {
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
a.card:hover { color: var(--ink); transform: translate(-3px, -3px); box-shadow: 8px 8px 0 var(--shadow); }
a.card:focus-visible { outline-offset: 4px; border-radius: var(--radius); }
.card-art {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 92px;
  padding: 14px 16px;
  border-bottom: var(--border);
  background: var(--surface-2);
  background-image: repeating-linear-gradient(45deg, transparent 0 12px, var(--stripe) 12px 24px);
}
.card[data-kind="puzzle"] .card-art { background-color: var(--mint); }
.card[data-kind="social"] .card-art { background-color: var(--pink); }
.card[data-kind="luck"] .card-art { background-color: var(--sun); }
.card-glyph {
  font-family: var(--font-display);
  font-size: 2.6rem;
  line-height: 1;
  color: var(--on-brand);
}
.card-body { display: flex; flex-direction: column; flex: 1; padding: 16px; }
.card-body h3 { margin-bottom: 6px; }
.card-body p { margin: 0 0 12px; color: var(--ink-soft); }
.card-meta {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}
.card-cta { color: var(--link); }
.card.soon { border-style: dashed; box-shadow: none; }
.card.soon .card-art { background-color: var(--surface-2); filter: saturate(0.5); }
.card.soon .card-glyph { color: var(--ink-soft); }
.card.note .card-body { justify-content: center; }

/* ---------- Session list ---------- */

.session-list { margin: 0; padding: 0; list-style: none; }
.session-list li {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr) auto auto;
  align-items: center;
  gap: 6px 16px;
  padding: 12px 4px;
  border-bottom: 2px dashed var(--line-soft);
}
.session-list li:last-child { border-bottom: 0; }
.session-list .s-game { font-weight: 700; }
.session-list .s-players { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.session-list time { color: var(--ink-soft); font-size: 0.9rem; white-space: nowrap; }
.session-list .empty { display: block; color: var(--ink-soft); }
@media (max-width: 620px) {
  .session-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .session-list .s-players { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Steps (quick start) ---------- */

.steps { counter-reset: step; display: grid; gap: 22px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 980px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.steps > li {
  counter-increment: step;
  min-width: 0;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  padding: 18px;
}
.steps > li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  margin-bottom: 10px;
  border: var(--border);
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  font: 1.5rem/1 var(--font-display);
}
.steps h3 { font-size: 1.25rem; }
.steps pre { margin-bottom: 0; font-size: 0.8rem; }

/* ---------- Prose pages (mission, docs, legal) ---------- */

.page-head { padding-top: 48px; margin-bottom: 32px; }
.page-head .lead { margin-bottom: 0; }

.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.6em; }
.prose li + li { margin-top: 0.3em; }
.prose > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

.callout {
  margin: 1.5em 0;
  padding: 16px 18px;
  border: var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.callout > :last-child { margin-bottom: 0; }

.kinds { display: grid; gap: 16px; margin: 1.5em 0; padding: 0; list-style: none; }
@media (min-width: 720px) { .kinds { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kinds li { margin: 0; padding: 16px; border: var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.kinds li + li { margin-top: 0; }
.kinds .chip { margin-bottom: 8px; }
.kinds p { margin: 0; }

.draft-banner {
  margin: 32px 0 0;
  padding: 14px 18px;
  border: var(--border);
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  background-image: repeating-linear-gradient(-45deg, transparent 0 14px, rgba(255, 200, 61, 0.25) 14px 28px);
  font-weight: 700;
}
.draft-banner p { margin: 0; }

.todo {
  display: inline;
  padding: 0.05em 0.4em;
  border: 2px dashed var(--todo);
  border-radius: 5px;
  background: var(--todo-bg);
  color: var(--todo);
  font: 700 0.88em/1.5 var(--font-mono);
}

/* ---------- Docs ---------- */

.docs { display: grid; gap: 32px; }
@media (min-width: 980px) {
  .docs { grid-template-columns: 230px minmax(0, 1fr); align-items: start; }
  .toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
.toc {
  padding: 16px 18px;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
}
.toc h2 { font-size: 1.2rem; margin-bottom: 8px; }
.toc ul { margin: 0; padding: 0; list-style: none; font-size: 0.95rem; }
.toc ul ul { padding-left: 14px; }
.toc li { margin: 4px 0; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }
.docs-body { min-width: 0; }
.docs-body > section { scroll-margin-top: 16px; }
.docs-body h2 { margin-top: 2em; }
.docs-body > section:first-child h2 { margin-top: 0; }
.docs-body p, .docs-body ul, .docs-body ol { max-width: 75ch; }

.endpoint {
  margin: 28px 0;
  padding: 18px;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 16px;
}
.endpoint h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.endpoint pre { font-size: 0.82rem; }
.method {
  display: inline-block;
  padding: 3px 10px;
  border: 2px solid var(--line);
  border-radius: 6px;
  color: var(--on-brand);
  font: 700 0.85rem/1.3 var(--font-mono);
}
.method.get { background: var(--mint); }
.method.post { background: var(--brand); }
.auth-tag { font: 700 0.8rem/1.3 var(--font-body); color: var(--ink-soft); }

.table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 1.25em; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 2px solid var(--line-soft); }
th { font-weight: 700; background: var(--surface-2); }
td code { white-space: nowrap; }

/* ---------- Game & session pages ---------- */

.crumbs { margin: 32px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.95rem; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--ink-soft); }

.game-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 16px 0 8px; }
.game-head h1 { margin: 0; }

.two-col { display: grid; gap: 28px; margin-top: 28px; }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.two-col > * { min-width: 0; }

.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--ink-soft); }

.spectator pre { font-size: 0.95rem; line-height: 1.35; }
.spectator .screen-bar .label { flex: 1; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 118px), 1fr));
  gap: 12px;
  margin: 0;
}
.result-grid div { padding: 10px 12px; border: 2px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface); }
.result-grid dt { font-size: 0.85rem; color: var(--ink-soft); }
.result-grid dd { margin: 0; font: 1.4rem/1.2 var(--font-display); }
.score-big { font: 3rem/1 var(--font-display); color: var(--brand); }

.messages { margin: 0; padding: 0; list-style: none; }
.messages li { padding: 8px 0; border-bottom: 2px dashed var(--line-soft); }
.messages .from { font-weight: 700; margin-right: 8px; }

.notice { padding: 14px 16px; border: 2px dashed var(--line-soft); border-radius: var(--radius-sm); color: var(--ink-soft); }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .btn:hover, a.card:hover { transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- Research ---------- */

.article-list { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.article-card h2 { margin-bottom: 0.2em; }
.article-card h2 a { color: var(--ink); text-decoration: none; }
.article-card h2 a:hover { text-decoration: underline; }
.article-card p:last-child { margin-bottom: 0; }
.article-meta { color: var(--ink-soft); font-size: 0.95rem; }
[data-stat] { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Admin ---------- */

.admin-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.admin-filters label, #login-form label { display: grid; gap: 4px; font-weight: 700; }
.admin-filters input, .admin-filters select, #login-form input {
  font: inherit; padding: 8px 10px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
#login-form { display: grid; gap: 12px; max-width: 360px; }
.cost-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.cost-facts dt { font-weight: 700; }
.cost-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
