/* KiWE 大家來找碴: game page in the KiWEDOGO paper-and-ink look. No flashing: finds draw an ink circle, misses a small ✕. */
@font-face { font-family: "Gochi Hand"; font-display: swap; src: url("/assets/brand-20261013/gochi-hand.woff") format("woff"); }
:root {
  --ink: #1c1c1c; --paper: #fffdf7; --bg: #f3eedf; --dots: #e2dac4; --kiwi: #b9dc63; --citrus: #f7e27a; --coral: #ff8a95; --seed: #8dbb3f; --muted: #6b675e;
  --sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --wobble: 22px 12px 20px 14px / 14px 20px 12px 22px; --wobble-sm: 14px 6px 12px 7px / 7px 12px 6px 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font-family: var(--sans);
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body { background: var(--bg) radial-gradient(var(--dots) 1.4px, transparent 1.6px) 0 0 / 22px 22px; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font: 400 28px "Gochi Hand", var(--sans); }
button { font-family: var(--sans); color: var(--ink); }

/* play: HUD on top, the two pictures, tools underneath */
.play { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left)); }
.hud { width: 100%; max-width: 960px; padding: 8px 4px 2px; }
.hud-row { display: flex; align-items: center; gap: 12px; }
.stat { display: grid; margin: 0; line-height: 1.05; min-width: 3.2em; }
.stat small { font: 400 15px "Gochi Hand", var(--sans); color: var(--muted); }
.stat b { font-size: 21px; font-variant-numeric: tabular-nums; }
.clock { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.clock b { font-size: 24px; min-width: 1.8em; text-align: right; font-variant-numeric: tabular-nums; }
.clock .bar { flex: 1; height: 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.clock .bar i { display: block; height: 100%; width: 100%; background: var(--kiwi); transition: width 0.2s linear; }
.clock.low b { color: #c42a43; }
.clock.low .bar i { background: var(--coral); }
.round { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--paper); font: 800 14px var(--sans); cursor: pointer; }
.round.off { opacity: 0.5; }
.dots { display: flex; gap: 7px; justify-content: center; list-style: none; margin: 6px 0 0; padding: 0; min-height: 15px; }
.dots li { width: 15px; height: 15px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; transition: background 0.2s; }
.dots li.on { background: var(--kiwi); }

.stage { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 0; width: 100%; }
.stage.stack { flex-direction: column; }
.pic { position: relative; flex: none; border: 3px solid var(--ink); border-radius: var(--wobble-sm); overflow: hidden; background: #fff;
  touch-action: none; box-shadow: 0 5px 0 rgba(28, 28, 28, 0.2); cursor: crosshair; }
.pic canvas { display: block; width: 100%; height: 100%; }
.pic.shake { animation: shake 0.3s ease; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.stage.covered .pic canvas { visibility: hidden; }

.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px 0 10px; }
.tool { min-width: 48px; height: 44px; padding: 0 14px; border: 2.5px solid var(--ink); border-radius: var(--wobble-sm); background: #fff; font: 800 17px var(--sans); cursor: pointer; }
.tool.hint { background: var(--citrus); }
.tool:disabled { opacity: 0.45; cursor: default; }
.tool:active, .round:active, .btn:active { transform: translateY(2px); }
.tool:focus-visible, .round:focus-visible, .btn:focus-visible, .fmt-btn:focus-visible, .share-to:focus-visible { outline: 3px solid var(--seed); outline-offset: 3px; }
.keys { width: 100%; margin: 0; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }

/* +3s / −5s next to the clock; level banners: soft fade, no flashing */
.float { position: fixed; top: calc(env(safe-area-inset-top) + 46px); left: 50%; margin: 0; font: 900 22px var(--sans); pointer-events: none; opacity: 0; }
.float.plus { color: #4d7a1f; }
.float.minus { color: #c42a43; }
.float.on { animation: floatUp 0.9s ease-out; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-22px); } }
.banner { position: fixed; left: 0; right: 0; top: 42%; translate: 0 -50%; width: fit-content; margin: 0 auto; padding: 10px 24px; max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
  font: 400 clamp(26px, 6.4vw, 40px)/1.15 "Gochi Hand", var(--sans); background: var(--paper); border: 3px solid var(--ink); border-radius: var(--wobble); box-shadow: 0 5px 0 rgba(28, 28, 28, 0.25); }
.banner.on { animation: banner 1.7s ease both; }
@keyframes banner { 0% { opacity: 0; transform: scale(0.92); } 15% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

/* screens and cards */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; touch-action: pan-y; background: rgba(243, 238, 223, 0.6); }
.card { width: min(100%, 460px); background: var(--paper); border: 3px solid var(--ink); border-radius: var(--wobble); padding: 18px 20px 18px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2); }
.card.center { text-align: center; }
.card h1 { display: flex; align-items: center; gap: 10px; margin: 8px 0 8px; font: 400 32px/1.1 "Gochi Hand", var(--sans); }
.card h2 { margin: 4px 0 10px; font: 400 32px/1.1 "Gochi Hand", var(--sans); }
.back { display: inline-block; color: var(--ink); font-weight: 800; font-size: 14px; text-decoration: none; margin-top: 4px; }
.card.center .back { margin-top: 14px; }
.title-art { display: block; width: 100%; aspect-ratio: 10 / 7; border: 2.5px solid var(--ink); border-radius: var(--wobble-sm); background: #fff; }
.sub { margin: 12px 0 6px; font-weight: 700; line-height: 1.5; }
.how { margin: 0; padding-left: 1.3em; font-size: 14px; line-height: 1.6; color: #3d3b36; }
.best { margin: 8px 0 0; font-weight: 800; color: #4d7a1f; }
.best:empty { display: none; }
.field { display: grid; gap: 6px; margin: 12px 0 0; font-weight: 800; font-size: 14px; }
.field input { font: 600 16px var(--sans); padding: 10px 12px; border: 2.5px solid var(--ink); border-radius: var(--wobble-sm); background: #fff; color: var(--ink); user-select: text; }
.acct-line { margin: 12px 0 0; font-weight: 800; }
.link { border: 0; background: none; padding: 0 4px; font: 700 14px var(--sans); text-decoration: underline; cursor: pointer; }
.hint { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: #4d4b46; }
.hint:empty { display: none; }
.hint.warn { color: #c42a43; font-weight: 700; }
.hint a { color: var(--ink); }
.gsi { display: flex; justify-content: center; margin-top: 10px; min-height: 44px; }
.btn { display: block; width: 100%; margin: 10px 0 0; padding: 12px 16px; font: 800 17px var(--sans); background: #fff; border: 2.5px solid var(--ink); border-radius: var(--wobble-sm); cursor: pointer; }
.btn.hot { background: var(--citrus); }
.btn.wide { margin-top: 14px; }
.btn.small { padding: 9px 14px; font-size: 15px; }
.label { margin: 6px 0 0; font: 400 18px "Gochi Hand", var(--sans); color: var(--muted); }
.big { margin: 0; font-size: 54px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.lvl { margin: 4px 0 0; font-weight: 800; }
.note { margin: 6px 0 0; font-weight: 900; color: #c2410c; }
.note:empty, .post-msg:empty { display: none; }
.post-msg { margin: 6px 0 0; font-size: 14px; font-weight: 700; color: #4d4b46; }

/* score wall */
.wall { margin-top: 14px; border-top: 2px dashed #d9d3c3; padding-top: 10px; text-align: left; }
.wall-h { margin: 0 0 4px; font: 400 20px "Gochi Hand", var(--sans); }
.fine { margin: 4px 0; font-size: 13px; color: var(--muted); }
.wall-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 2px; }
.wall-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px dashed #e4dece; font-size: 14px; }
.wall-list li:last-child { border-bottom: 0; }
.wall-list li.me { background: #fff6c9; border-radius: 8px; }
.wall-list .rk { text-align: center; font-variant-numeric: tabular-nums; font-weight: 800; }
.wall-list li:nth-child(-n+3) .rk { color: #c2410c; }
.wall-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.wall-list .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.wall-list .lv { color: var(--muted); font-size: 12px; }

/* share sheet */
.share-screen { z-index: 8; background: rgba(28, 28, 28, 0.45); }
.share-screen .card { position: relative; }
.share-x { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; }
.share-screen h2 { margin: 2px 44px 10px; }
.fmt-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.fmt-btn { padding: 7px 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; font: 800 14px var(--sans); cursor: pointer; }
.fmt-btn.on { background: var(--kiwi); }
.share-preview { display: grid; place-items: center; min-height: 160px; }
.share-loading { margin: 0; font-weight: 800; color: #4d4b46; }
.share-img { display: block; max-width: 100%; max-height: 46vh; border: 2.5px solid var(--ink); border-radius: 12px; }
.share-img.story { max-height: 52vh; }
.share-main { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin-top: 10px; }
.share-main .btn { margin: 0; }
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 0; }
.share-to { display: grid; justify-items: center; gap: 4px; padding: 8px 2px 6px; font: 700 12px var(--sans); color: var(--ink); text-decoration: none; border: 2px solid var(--ink); border-radius: var(--wobble-sm); background: #fff; }
.share-to i { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); font: 900 14px/1 var(--sans); font-style: normal; color: #fff; }
.share-to.threads i, .share-to.x i { background: #111; }
.share-to.line i { background: #06c755; }
.share-to.fb i { background: #1877f2; }
.share-note { text-align: left; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); translate: -50% 0; z-index: 9; margin: 0; padding: 10px 18px; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; border-radius: 999px; font-weight: 700; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .pic.shake, .float.on, .banner.on { animation-duration: 0.01s; }
  .banner.on { animation: none; opacity: 1; }
}
