/* Shared structure for the kit games. Each game's theme.css sets the
   variables and adds its own look; this file only lays things out. */
@font-face { font-family: "Young Serif"; font-display: swap; src: url(../fonts/young-serif-latin-400-normal.woff2) format("woff2"); }

:root {
  --bg: #F4F4F4; --card: #FFFFFF; --ink: #1A1A1A; --mute: #6B6B6B; --line: #DDDDDD;
  --taro: #444; --taro-d: #222; --taro-l: #EEE; --on-taro: #FFFFFF;
  --good: #2E8B57; --bad: #C8372D; --warn: #B7791F; --sky: #3F8FD6;
  --r: 12px; --btn-r: 12px;
  --ground: #C9C9C9; --water: #CFE3F5; --trail: rgba(0,0,0,.2);
  --display: "Young Serif", Georgia, serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden], .hide { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--page-ink, var(--ink)); font-family: var(--font); font-size: 16px; line-height: 1.4; min-height: 100vh; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--taro); outline-offset: 2px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 14px; }
#app { padding-bottom: 6px; }

/* site chrome */
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 0; }
.back { text-decoration: none; color: var(--page-mute, var(--mute)); font-size: 0.95rem; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--page-ink, var(--ink)); cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; padding: 0; }
.icon-btn:hover { background: var(--taro-l); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.title-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: 10px; row-gap: 0; padding: 4px 0 6px; }
h1 { font-family: var(--display); font-weight: 400; font-size: 2.2rem; margin: 0; line-height: 1; }
.sub { margin: 0; color: var(--page-mute, var(--mute)); font-size: 0.95rem; white-space: nowrap; }
.rule { margin: 0 0 14px; color: var(--page-mute, var(--mute)); font-size: 0.95rem; }
.rule b { color: var(--page-ink, var(--ink)); }

/* game building blocks */
.card { color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 0 0 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.sp { justify-content: space-between; }
.row.c { justify-content: center; }
.wrap.row, .row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
button, .btn { font-weight: 700; border: 0; border-radius: var(--btn-r); padding: 12px 16px; background: var(--taro); color: var(--on-taro); cursor: pointer; touch-action: manipulation; user-select: none; }
button:active { transform: translateY(1px); }
button.ghost { background: var(--taro-l); color: var(--taro-d); }
button.plain { background: transparent; color: var(--taro-d); padding: 8px 10px; }
button.sm { padding: 8px 12px; font-size: 14px; border-radius: calc(var(--btn-r) - 2px); }
button:disabled { opacity: .4; cursor: default; transform: none; }
button.on { outline: 3px solid var(--ink); outline-offset: -1px; }
.big { font-family: var(--display); font-weight: 400; font-size: 44px; letter-spacing: -.01em; line-height: 1; }
.mid { font-size: 22px; font-weight: 800; }
.mono { font-family: var(--mono); }
.mute { color: var(--mute); }
.sm { font-size: 13px; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); } .tc { color: var(--taro); }
.center { text-align: center; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--taro-l); color: var(--taro-d); font-size: 12px; font-weight: 700; }
.pill.bad { background: color-mix(in srgb, var(--bad) 16%, var(--card)); color: var(--bad); }
.pill.good { background: color-mix(in srgb, var(--good) 16%, var(--card)); color: var(--good); }
canvas { display: block; width: 100%; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); touch-action: none; }
.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--taro); border-radius: 99px; transition: width .4s; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.shake { animation: shake .3s; }
table.lb { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
table.lb td { padding: 5px 4px; border-top: 1px solid var(--line); }
table.lb tr.me td { font-weight: 800; color: var(--taro-d); background: var(--taro-l); }
table.lb td:last-child { text-align: right; font-family: var(--mono); }
table.lb td:first-child { width: 26px; color: var(--mute); font-family: var(--mono); }
input[type=text], input[type=number] { font-weight: 700; padding: 12px; border-radius: var(--btn-r); border: 2px solid var(--line); background: var(--card); color: var(--ink); width: 100%; outline: none; }
input[type=text]:focus { border-color: var(--taro); }
input[type=range] { width: 100%; accent-color: var(--taro); }

/* result card */
.result { animation: pop .3s ease-out; padding: 18px; }
.result .kicker { margin: 0; color: var(--mute); font-weight: 600; font-size: .9rem; }
.result .title { margin: 4px 0 6px; font-weight: 800; color: var(--taro-d); font-size: 1.05rem; }
.res-big { margin: 4px 0 6px; }
.res-sub { margin: 0 0 4px; color: var(--mute); }
.res-lines p { margin: 6px 0; font-size: .95rem; }
.res-board { margin-top: 10px; }
.res-actions { display: grid; gap: 8px; margin-top: 14px; }
.go { width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 800; }
.fine { color: var(--mute); font-size: 0.85rem; text-align: center; margin: 10px 0 0; }

/* ads, footer, toast, dialogs: same as the rest of the site */
.ad-inline { margin-top: 26px; }
.ad-slot { display: block; margin: 0 auto; overflow: hidden; }
.ad-banner { width: 100%; max-width: 728px; min-height: 100px; }
.ad-slot.placeholder { border: 1.5px dashed var(--page-line, var(--line)); border-radius: 12px; display: grid; place-items: center; color: var(--page-mute, var(--mute)); font-size: 0.85rem; }
.ad-slot.placeholder::before { content: "Ad space " attr(data-size); }
.ad-slot.collapsed { min-height: 0; }
.ad-slot ins[data-ad-status="unfilled"] { display: none !important; }
.ad-label { font-size: 11px; color: var(--mute); text-align: center; margin: 0 0 4px; }
.foot { display: flex; justify-content: center; gap: 22px; padding: 26px 0 40px; color: var(--page-mute, var(--mute)); font-size: 0.9rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; font-weight: 600; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dlg { border: 0; border-radius: var(--r); padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.dlg::backdrop { background: rgba(10, 10, 20, .5); }
.dlg h2 { font-family: var(--display); font-weight: 400; margin: 0 0 10px; font-size: 1.6rem; }
.dlg p, .dlg li { color: var(--mute); }
.dlg b { color: var(--ink); }
.dlg ul { padding-left: 18px; margin: 0 0 12px; }
.dlg .x { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--mute); width: 40px; height: 40px; padding: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; background: var(--taro-l); border-radius: 10px; padding: 10px; }
.stats dt { color: var(--mute); font-size: 0.85rem; }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .toast, .bar > i { transition: none; } .result, .shake { animation: none; } }
