/* MiniGames Park: a printed puzzle-book look on graph paper, shared by every game page.
   Layout: one centered reading column, the puzzle board as the hero object. */
:root {
  --paper: #f3f6f8;      /* cool graph-paper ground */
  --sheet: #ffffff;      /* the puzzle sheet */
  --ink: #15233f;        /* navy pencil-on-paper ink */
  --ink-soft: #4a5872;
  --rule: #c9d4de;       /* faint graph lines */
  --rule-strong: #6f8199;
  --accent: #2550c4;     /* cobalt pencil */
  --accent-soft: #e3eafb;
  --fill: #15233f;
  --mark: #c2410c;
  --ok: #1f7a4d;
  --ok-soft: #e1f2e9;
  --danger: #b42318;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1524; --sheet: #141d30; --ink: #e6ecf5; --ink-soft: #a5b2c7;
    --rule: #2a3750; --rule-strong: #6a7c99; --accent: #8aa8ff; --accent-soft: #1d2b4d;
    --fill: #dbe5f5; --mark: #fb923c; --ok: #4ade80; --ok-soft: #12301f; --danger: #f87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1524; --sheet: #141d30; --ink: #e6ecf5; --ink-soft: #a5b2c7;
  --rule: #2a3750; --rule-strong: #6a7c99; --accent: #8aa8ff; --accent-soft: #1d2b4d;
  --fill: #dbe5f5; --mark: #fb923c; --ok: #4ade80; --ok-soft: #12301f; --danger: #f87171;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
  color: var(--ink);
  font: 17px/1.6 var(--font-body);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { background-image: linear-gradient(color-mix(in srgb, var(--rule) 55%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--rule) 55%, transparent) 1px, transparent 1px); } }
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.site-head { background: var(--sheet); border-bottom: 2px solid var(--ink); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 1.25rem/1 var(--font-display); letter-spacing: -0.01em; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 8px); gap: 2px; }
.brand-mark i { width: 8px; height: 8px; background: var(--ink); border-radius: 1px; }
.brand-mark i.o { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule-strong); }
.nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.95rem; }
.nav a { color: var(--ink-soft); text-decoration: none; font-weight: 600; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* Sheets: the paper the content sits on */
.sheet {
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--ink);
  padding: clamp(18px, 3.5vw, 32px);
}
.game-sheet { padding: clamp(10px, 2.6vw, 28px); }
main { padding-block: 28px 56px; display: grid; gap: 28px; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0; }
.eyebrow { font: 600 0.78rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 60ch; }

/* Article text */
.prose { display: grid; gap: 16px; max-width: 68ch; }
.prose h2 { margin-top: 18px; }
.prose h3 { margin-top: 8px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.table-scroll { overflow-x: auto; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 8px 8px 0; }
kbd { font: 0.85em var(--font-mono); border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }

/* Home */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 40px); align-items: center; }
.hero-copy { display: grid; gap: 16px; }
.hero-copy .cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.hero-board { min-width: 0; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 8px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); font: 700 1rem/1 var(--font-body); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--ink); color: var(--sheet); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.puzzles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.pz { display: grid; gap: 10px; align-content: start; color: var(--ink); text-decoration: none; }
.pz:hover h3 { text-decoration: underline; text-decoration-color: var(--accent); }
.pz .meta { font: 0.8rem/1.4 var(--font-mono); color: var(--ink-soft); }
.pz-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; max-width: 132px; }
.pz-grid i { aspect-ratio: 1; border: 1px solid var(--rule); border-radius: 2px; }
.pz-grid i.f { background: var(--fill); border-color: var(--fill); }
.soon { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font: 600 0.8rem/1 var(--font-mono); padding: 6px 10px; border: 1px dashed var(--rule-strong); border-radius: 999px; color: var(--ink-soft); }

.section-head { display: grid; gap: 8px; margin-bottom: 18px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.two-col > * { min-width: 0; display: grid; gap: 8px; align-content: start; }

/* Game page */
.game-layout { display: grid; gap: 22px; }
.game-head { display: grid; gap: 8px; }
.game-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
.game-head .lede { font-size: 1rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--ink); text-decoration: none; color: var(--ink); font-weight: 700; font-size: 0.95rem; background: var(--sheet); }
.tab[aria-current="page"] { background: var(--ink); color: var(--sheet); }

/* Ad slots stay hidden until AdSense is approved. */
.ad-slot { min-height: 100px; display: grid; place-items: center; }
.ad-slot[hidden] { display: none !important; }

/* Footer */
.site-foot { border-top: 2px solid var(--ink); background: var(--sheet); }
.site-foot .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 20px; font-size: 0.9rem; color: var(--ink-soft); }
.site-foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-foot a { color: var(--ink-soft); }

/* ---------- Nonogram board ---------- */
.ng { display: grid; gap: 14px; justify-items: center; width: 100%; min-width: 0; }
.ng-bar { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ng-title { font: 700 1.05rem/1.2 var(--font-display); display: flex; gap: 8px; align-items: baseline; }
.ng-kicker { font: 600 0.75rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.ng-time { font: 600 1.05rem/1 var(--font-mono); font-variant-numeric: tabular-nums; padding: 6px 10px; border: 1.5px solid var(--ink); border-radius: 6px; min-width: 70px; text-align: center; }
.ng-sizes { display: flex; gap: 6px; width: 100%; }
.ng-chip { padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--rule-strong); background: var(--sheet); color: var(--ink); font: 600 0.88rem/1 var(--font-mono); cursor: pointer; }
.ng-chip.on { background: var(--ink); color: var(--sheet); border-color: var(--ink); }

.ng-board-wrap { width: 100%; display: flex; justify-content: center; overflow-x: auto; }
.ng-board {
  display: grid;
  grid-template-columns: var(--rcw) repeat(var(--n), var(--cell));
  grid-template-rows: var(--cch) repeat(var(--n), var(--cell));
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  outline-offset: 6px;
  border-radius: 4px;
}
.ng-corner { border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.ng-cclue, .ng-rclue {
  display: flex; font: 600 var(--cfont)/1.12 var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--accent-soft);
}
.ng-cclue { flex-direction: column; justify-content: flex-end; align-items: center; gap: 0; padding-bottom: 5px; border-right: 1px solid var(--rule); border-bottom: 2px solid var(--ink); }
.ng-rclue { justify-content: flex-end; align-items: center; gap: 0.62em; padding-right: 7px; border-bottom: 1px solid var(--rule); border-right: 2px solid var(--ink); }
.ng-cclue.ng-b5 { border-left: 2px solid var(--ink); }
.ng-rclue.ng-b5 { border-top: 2px solid var(--ink); }
.ng-cclue.ng-edge { border-right: 2px solid var(--ink); }
.ng-cclue.ok, .ng-rclue.ok { color: var(--ink-soft); background: var(--ok-soft); }
.ng-cclue.ok span, .ng-rclue.ok span { text-decoration: line-through; text-decoration-color: var(--ok); opacity: 0.7; }

.ng-cell {
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  background: var(--sheet); cursor: pointer; position: relative;
}
.ng-cell.ng-r5 { border-right: 2px solid var(--ink); }
.ng-cell.ng-d5 { border-bottom: 2px solid var(--ink); }
.ng-cell.ng-edge-r { border-right: 2px solid var(--ink); }
.ng-cell.ng-edge-b { border-bottom: 2px solid var(--ink); }
.ng-rclue.ng-edge-b { border-bottom: 2px solid var(--ink); }
@media (hover: hover) { .ng-cell:hover { background: var(--accent-soft); } }
.ng-cell.is-fill { background: var(--fill); }
@media (hover: hover) { .ng-cell.is-fill:hover { background: var(--accent); } }
.ng-cell.is-mark::before, .ng-cell.is-mark::after {
  content: ""; position: absolute; left: 22%; right: 22%; top: 50%; height: 2px; background: var(--mark); border-radius: 2px;
}
.ng-cell.is-mark::before { transform: rotate(45deg); }
.ng-cell.is-mark::after { transform: rotate(-45deg); }
.ng-cell.ng-cur { box-shadow: inset 0 0 0 3px var(--accent); }
.ng-done .ng-cell { cursor: default; }
.ng-done .ng-cell.is-fill { background: var(--ink); animation: ng-pop 420ms ease-out both; }
@keyframes ng-pop { from { transform: scale(0.6); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .ng-done .ng-cell.is-fill { animation: none; } }

.ng-tools { width: 100%; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ng-modes { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.ng-mode { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 0; background: var(--sheet); color: var(--ink); font: 700 0.95rem/1 var(--font-body); cursor: pointer; }
.ng-mode + .ng-mode { border-left: 1.5px solid var(--ink); }
.ng-mode.on { background: var(--ink); color: var(--sheet); }
.ng-swatch { width: 14px; height: 14px; border-radius: 2px; display: inline-block; position: relative; }
.ng-swatch-fill { background: currentColor; }
.ng-swatch-mark { box-shadow: inset 0 0 0 1.5px currentColor; }
.ng-swatch-mark::before, .ng-swatch-mark::after { content: ""; position: absolute; left: 2px; right: 2px; top: 6px; height: 2px; background: var(--mark); }
.ng-swatch-mark::before { transform: rotate(45deg); }
.ng-swatch-mark::after { transform: rotate(-45deg); }
.ng-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ng-btn { display: inline-flex; align-items: center; padding: 9px 14px; border-radius: 8px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); font: 700 0.95rem/1 var(--font-body); cursor: pointer; text-decoration: none; }
.ng-btn:hover { background: var(--accent-soft); }
.ng-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ng-btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.ng-btn-danger { border-color: var(--danger); color: var(--danger); }
.ng-confirm { width: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1.5px dashed var(--danger); border-radius: 8px; }
.ng-confirm span { font-weight: 700; margin-right: auto; }
.ng-result { width: 100%; display: grid; gap: 10px; padding: 16px; border: 2px solid var(--ok); background: var(--ok-soft); border-radius: var(--radius); }
.ng-res-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ng-res-head strong { font: 800 1.4rem/1 var(--font-display); color: var(--ok); }
.ng-res-time { font: 700 1.4rem/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.ng-res-line, .ng-res-next { color: var(--ink-soft); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.ng-res-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ng-share-text { width: 100%; font: 0.9rem/1.4 var(--font-mono); padding: 8px; border-radius: 6px; border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--ink); resize: none; }
.ng-help { font-size: 0.88rem; color: var(--ink-soft); text-align: center; max-width: 52ch; }

/* Worked-example mini grids in the guide */
.demo { display: inline-grid; gap: 0; border: 2px solid var(--ink); margin-block: 4px; }
.demo-row { display: flex; }
.demo-row b { width: 26px; height: 26px; border-right: 1px solid var(--rule); background: var(--sheet); display: grid; place-items: center; font: 600 0.75rem var(--font-mono); }
.demo-row b:last-child { border-right: 0; }
.demo-row b.f { background: var(--fill); }
.demo-row b.x { color: var(--mark); }
.demo-row b.k { background: var(--accent-soft); color: var(--ink); width: auto; padding: 0 8px; border-right: 2px solid var(--ink); }
.demo-cap { font: 0.8rem/1.4 var(--font-mono); color: var(--ink-soft); }

/* ---------- Arcade game shell ---------- */
.mgp-stage { display: grid; gap: 10px; width: 100%; min-width: 0; justify-items: center; }
.mgp-bar { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.mgp-hud { display: flex; gap: 8px; flex-wrap: wrap; }
.mgp-stat { display: grid; padding: 4px 10px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--sheet); min-width: 58px; }
.mgp-stat small { font: 600 0.62rem/1.2 var(--font-mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-soft); }
.mgp-stat b { font: 700 1rem/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }
.mgp-tools { display: flex; gap: 6px; }
.mgp-btn { padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); font: 700 0.9rem/1 var(--font-body); cursor: pointer; }
.mgp-btn:hover { background: var(--accent-soft); }
.mgp-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.mgp-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mgp-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.mgp-frame {
  position: relative;
  width: min(100%, calc((100vh - 120px) * var(--arw)), calc((100svh - 120px) * var(--arw)));
  aspect-ratio: var(--ar);
  border: 2px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: var(--sheet);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.mgp-frame canvas { display: block; width: 100%; height: 100%; outline: none; }
.mgp-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  overflow-y: auto;
}
.mgp-card {
  width: min(100%, 360px); display: grid; gap: 12px; justify-items: center; text-align: center;
  background: var(--sheet); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink); padding: 20px 18px;
}
.mgp-card h2 { font: 800 1.6rem/1.1 var(--font-display); margin: 0; }
.mgp-card p { font-size: 0.95rem; color: var(--ink-soft); }
.mgp-kicker { font: 600 0.72rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.mgp-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mgp-stats > div { display: grid; padding: 6px 12px; border: 1.5px solid var(--rule-strong); border-radius: 8px; min-width: 76px; }
.mgp-stats small { font: 600 0.65rem/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.mgp-stats b { font: 700 1.2rem/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }
.mgp-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mgp-shop { display: grid; gap: 8px; width: 100%; }
.mgp-shop button { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; }
.mgp-shop button span { font: 600 0.8rem/1.2 var(--font-mono); }
.mgp-stage:fullscreen { background: var(--paper); padding: 12px; align-content: center; }
.mgp-stage:fullscreen .mgp-frame { width: min(100%, calc((100vh - 90px) * var(--arw))); }
@media (max-width: 520px) { .mgp-fs { display: none; } }

/* Game cards on the homepage */
.pz-art { width: 100%; max-width: 132px; aspect-ratio: 4 / 3; border: 1.5px solid var(--ink); border-radius: 8px; display: block; }
