:root {
  --bg: #fbf7ec;
  --fg: #2a2312;
  --muted: #6b5f45;
  --card: #fffdf6;
  --line: #e7dcc0;
  --accent: #b8860b;
  --accent-ink: #fff;
  --link: #8a5a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130a;
    --fg: #f1e8d2;
    --muted: #b5a684;
    --card: #211b0f;
    --line: #3a301b;
    --accent: #e0b23c;
    --accent-ink: #1b1508;
    --link: #f0c75e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* header / footer */
.site-h { border-bottom: 1px solid var(--line); }
.site-h .wrap { display: flex; align-items: center; gap: 16px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 800; text-decoration: none; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; }
.site-h nav { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; margin-left: auto; }
.site-h nav a { text-decoration: none; color: var(--muted); }
.site-h nav a[aria-current] { color: var(--fg); font-weight: 600; }
.site-f { border-top: 1px solid var(--line); margin-top: 56px; padding: 24px 0 40px; color: var(--muted); font-size: 14px; }
.site-f nav { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }

/* game */
.game {
  position: relative; height: min(72vh, 640px); min-height: 380px;
  margin: 12px auto 0; max-width: 1100px; border-radius: 14px; overflow: hidden;
  background: #1b1508; user-select: none; -webkit-user-select: none;
}
.game:fullscreen { height: 100vh; max-width: none; border-radius: 0; }
.game canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
.game canvas:active { cursor: grabbing; }
.hud {
  position: absolute; inset: 10px 10px auto 10px; display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.chip {
  background: rgba(20,15,5,.78); color: #f6ecd0; border-radius: 999px; padding: 5px 12px;
  font: 600 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; backdrop-filter: blur(4px);
}
.tools { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font: 700 15px/1.2 system-ui, sans-serif;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: rgba(20,15,5,.78); color: #f6ecd0; }
.tools .btn { width: 46px; height: 46px; padding: 0; font-size: 20px; }
.hud .btn { padding: 6px 12px; font-size: 14px; }
.toast {
  position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 20px); opacity: 0;
  background: rgba(20,15,5,.85); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 15px;
  transition: .2s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(20,15,5,.55); backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.panel {
  background: var(--card); color: var(--fg); border-radius: 16px; padding: 22px; width: min(420px, 100%);
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.panel h2 { margin: 0 0 4px; font-size: 24px; line-height: 1.2; }
.panel p { margin: 6px 0 14px; color: var(--muted); font-size: 15px; }
.panel .row { display: grid; gap: 8px; }
.panel .row .btn { width: 100%; }
.panel small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.levels .btn { background: transparent; color: var(--fg); border: 2px solid var(--line); }
.levels .btn:hover { border-color: var(--accent); }

/* content */
.content h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; margin: 28px 0 8px; }
.content h2 { font-size: 24px; margin: 36px 0 8px; line-height: 1.25; }
.content h3 { font-size: 19px; margin: 24px 0 4px; }
.content .lead { font-size: 19px; color: var(--muted); margin-top: 0; }
.content table { border-collapse: collapse; width: 100%; font-size: 15px; }
.content th, .content td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
.cta { display: inline-block; text-decoration: none; margin: 8px 0; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 650; }
.crumbs { font-size: 14px; color: var(--muted); margin-top: 16px; }
.crumbs a { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.cards a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--fg); background: var(--card); }
.cards a strong { display: block; }
.cards a span { color: var(--muted); font-size: 14px; }
