/* 所有小遊戲共用的樣式：跟網站同一套宣紙／墨色／朱紅配色 */
:root {
  --bg: #f5efe3; --board: #ebe2d0; --surface: #fbf7ef; --text: #2b2520; --muted: #776b5d; --line: #d9ccb5;
  --accent: #b23a26; --accent2: #3f6b5c; --gold: #c08a1e; --blue: #3a6ea5; --purple: #7a4f9a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1815; --board: #24201c; --surface: #2c2722; --text: #ece3d4; --muted: #a69888; --line: #3f372f;
    --accent: #e0775f; --accent2: #8cc0aa; --gold: #e2b44f; --blue: #7fa9d6; --purple: #b592d1; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { display: grid; place-items: center; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, "Noto Sans TC", sans-serif; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.wrap { width: min(100%, 560px); padding: 10px; text-align: center; }
.bar { display: flex; justify-content: space-between; gap: 12px; margin: 0 auto 8px; max-width: 480px; color: var(--muted); font-size: 15px; }
.bar b { color: var(--text); font-variant-numeric: tabular-nums; }
.stage { position: relative; display: flex; justify-content: center; }
canvas { display: block; max-width: 100%; max-height: calc(100vh - 130px); background: var(--board); border-radius: 12px; touch-action: none; }
.help { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
button, .btn { font: inherit; cursor: pointer; border: 0; border-radius: 999px; padding: 8px 22px; background: var(--accent); color: var(--bg); }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.ov { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.ov[hidden] { display: none; }
.ov .card { pointer-events: auto; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px 26px; max-width: 86%; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.ov h2 { margin: 0 0 6px; font: 900 26px "Noto Serif TC", serif; }
.ov p { margin: 0 0 14px; color: var(--muted); font-size: 15px; white-space: pre-line; }
.pad { display: none; justify-content: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
@media (pointer: coarse) { .pad { display: flex; } }
.pad button { width: 64px; height: 56px; padding: 0; border-radius: 14px; font-size: 22px; background: var(--surface); color: var(--text); border: 1px solid var(--line); touch-action: none; }
.pad button:active, .pad button.on { background: var(--accent); color: var(--bg); }
/* 格子類遊戲 */
.board { display: grid; gap: 6px; margin: 0 auto; width: min(100%, 440px, calc(100vh - 140px)); }
.cell { aspect-ratio: 1; border-radius: 8px; background: var(--board); display: grid; place-items: center; font-weight: 700; cursor: pointer; transition: background .15s, transform .1s; }
.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.controls button { padding: 6px 16px; font-size: 14px; }
