/* 格子谜题 - shared styles (light, minimal) */
:root {
  --bg: #f6f6f4;
  --bg-2: #eeeeeb;
  --card: #ffffff;
  --card-2: #f3f3f0;
  --line: #e2e2dd;
  --text: #1b1b1f;
  --muted: #72727c;
  --red: #d64550;
  --red-2: #e25563;
  --accent: #3557d6;
  --accent-2: #5b7ae6;
  --green: #2f9e63;
  --radius: 12px;
  --shadow: none;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", Consolas, "Cascadia Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.topbar .back { color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; background: var(--card); }
.topbar .back:hover { color: var(--text); border-color: var(--muted); }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: .3px; font-weight: 700; }
.topbar h1 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
.badge { display: inline-block; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent-2); border-radius: 4px; padding: 1px 6px; }

/* hub */
.hero { text-align: center; padding: 44px 12px 24px; }
.hero h1 { font-size: 34px; margin: 10px 0 8px; letter-spacing: 1px; font-weight: 700; }
.hero h1 small { display: block; color: var(--muted); font-size: 14px; font-weight: 400; letter-spacing: 2px; margin-top: 6px; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 620px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 26px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s ease; }
.card:hover { border-color: var(--muted); }
.card h2 { margin: 0; font-size: 22px; font-weight: 700; }
.card h2 small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .preview { background: var(--bg-2); border-radius: 10px; padding: 14px; display: flex; justify-content: center; align-items: center; min-height: 150px; }
.card .cta { margin-top: auto; }
.rules { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin-top: 26px; color: var(--muted); font-size: 14px; }
.rules h3 { margin: 0 0 8px; color: var(--text); font-size: 16px; }
.rules ul { margin: 6px 0 0; padding-left: 20px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 40px; }

/* buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; padding: 10px 16px; font-size: 15px; cursor: pointer; transition: transform .08s ease, background .15s ease, border-color .15s ease; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--text); border-color: var(--text); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #333339; border-color: #333339; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.accent:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

/* segmented controls */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; margin-bottom: 16px; }
.controls .label { color: var(--muted); font-size: 13px; margin-right: 6px; }

/* game layout */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 820px) { .game { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.board { position: relative; min-height: 360px; display: flex; align-items: center; justify-content: center; padding: 22px; overflow: hidden; background: var(--bg-2); }
.board .cover { position: absolute; inset: 0; background: rgba(246, 246, 244, .94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 20px; z-index: 5; }
.board .cover h2 { margin: 0; font-size: 22px; }
.board .cover p { margin: 0; color: var(--muted); font-size: 14px; max-width: 420px; }
.board .cover .count { font-size: 72px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.side { padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stat-row .k { color: var(--muted); font-size: 13px; }
.stat-row .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.target { text-align: center; padding: 12px; border-radius: 12px; background: var(--bg-2); }
.target .k { color: var(--muted); font-size: 13px; letter-spacing: 1px; }
.target .v { font-size: 44px; font-weight: 800; color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums; }
.timer { font-family: var(--mono); font-size: 30px; font-weight: 700; text-align: center; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.timer.warn { color: var(--red-2); }
.answer { display: flex; gap: 8px; }
.answer input { flex: 1 1 0%; width: 0; min-width: 0; font-size: 26px; font-weight: 700; text-align: center; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-variant-numeric: tabular-nums; }
.answer input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.keypad button { font-size: 20px; padding: 12px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.keypad button:active { background: var(--bg-2); }
.keypad button.wide { grid-column: span 2; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* result */
.result { padding: 16px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 8px; }
.result.ok { border-color: rgba(47, 158, 99, .6); }
.result.bad { border-color: rgba(214, 69, 80, .6); }
.result .headline { font-size: 22px; font-weight: 800; }
.result.ok .headline { color: var(--green); }
.result.bad .headline { color: var(--red-2); }
.result .detail { color: var(--muted); font-size: 14px; }
.result .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* rectangle grid */
.rgrid { position: relative; display: grid; gap: var(--gap, 6px); }
.rgrid .cell { width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--card); color: var(--text); font-weight: 700; font-size: calc(var(--cell) * .42); font-variant-numeric: tabular-nums; user-select: none; transition: background .2s ease, transform .2s ease; }
.rgrid .cell.dim { background: #e4e4df; color: #a3a3aa; }
.rgrid .cell.hl { background: var(--accent); color: #fff; transform: scale(1.04); }
.rgrid svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.explain { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.explain .formula { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.explain .formula span { color: var(--accent); }
.explain .nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.explain .nav .idx { color: var(--muted); font-size: 13px; min-width: 60px; text-align: center; }

/* cube canvas */
canvas.cubes { display: block; max-width: 100%; }
.view-tools { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 3; }
canvas.cubes { touch-action: none; user-select: none; -webkit-user-select: none; }
canvas.cubes.grab { cursor: grab; }
canvas.cubes.grabbing { cursor: grabbing; }
.drag-hint { position: absolute; left: 12px; bottom: 14px; z-index: 3; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .85); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; pointer-events: none; }

/* summary table */
table.summary { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.summary th, table.summary td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.summary th { color: var(--muted); font-weight: 500; font-size: 12px; }
.ok-text { color: var(--green); } .bad-text { color: var(--red-2); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); opacity: 0; transition: opacity .25s ease; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }

/* slitherlink board */
svg.lsvg { display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; max-width: 100%; }
.lsvg .ldot { fill: #5f5f6a; pointer-events: none; transition: fill .15s ease; }
.lsvg .ldot.bad { fill: var(--red-2); r: 6; }
.lsvg .ledge .guide { stroke: rgba(0, 0, 0, .08); stroke-width: 1; }
.lsvg .ledge .seg { stroke: var(--text); stroke-width: 5; stroke-linecap: round; opacity: 0; transition: opacity .1s ease, stroke .2s ease; }
.lsvg .ledge.s1 .seg { opacity: 1; }
.lsvg .ledge .x { stroke: #b3b3ba; stroke-width: 2.4; stroke-linecap: round; fill: none; opacity: 0; transition: opacity .1s ease; }
.lsvg .ledge.s2 .x { opacity: 1; }
.lsvg .ledge.wrong .seg, .lsvg .ledge.wrong .x { stroke: var(--red-2); opacity: 1; }
.lsvg .ledge.hinted .seg { stroke: var(--green); }
.lsvg .lclue { fill: var(--text); font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-variant-numeric: tabular-nums; transition: fill .15s ease; }
.lsvg .lclue.ok { fill: #b0b0b8; }
.lsvg .lclue.over { fill: var(--red-2); }
.lsvg.done .ledge.s1 .seg { stroke: var(--green); }
.lsvg.done .ledge .x, .lsvg.revealed .ledge .x { opacity: 0; }
.lsvg.revealed .ledge.s1 .seg { stroke: var(--accent-2); }
.ltools { display: flex; flex-direction: column; gap: 8px; }
.lbtns { display: flex; flex-wrap: wrap; gap: 6px; }

/* symmetry puzzle board */
svg.ssvg { display: block; touch-action: none; user-select: none; -webkit-user-select: none; max-width: 100%; }
.ssvg .board-bg { fill: #ffffff; stroke: var(--line); }
.ssvg .staging-bg { fill: rgba(0, 0, 0, .025); }
.ssvg .grid { stroke: rgba(0, 0, 0, .06); stroke-width: 1; }
.ssvg .staging-label { fill: #9a9aa2; font-size: 11px; letter-spacing: 1px; }
.ssvg .silhouette .sil-fill { fill: rgba(0, 0, 0, .09); }
.ssvg .silhouette .sil-rim { fill: none; stroke: rgba(0, 0, 0, .35); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ssvg .piece { cursor: grab; }
.ssvg .piece .body { stroke: none; transition: filter .15s ease; }
.ssvg .piece .rim { fill: none; stroke: rgba(0, 0, 0, .28); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ssvg .piece.sel .rim { stroke: var(--text); stroke-width: 2.5; }
.ssvg .piece.drag { cursor: grabbing; opacity: .9; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); }
.ssvg .piece.rotating { filter: drop-shadow(0 0 10px rgba(53, 87, 214, .45)); }
.ssvg .piece.bad .body { fill: var(--red-2) !important; }
.ssvg .handle { cursor: grab; }
.ssvg .handle-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .55; animation: handlePulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.ssvg .handle-bg { fill: var(--accent); stroke: #ffffff; stroke-width: 2; }
.ssvg .handle-glyph { fill: #ffffff; font-size: 24px; font-weight: 800; pointer-events: none; }
.ssvg .handle-label { fill: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 1px; pointer-events: none; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 4px; }
.ssvg .rotate-guide { fill: none; stroke: rgba(0, 0, 0, .3); stroke-width: 1.5; stroke-dasharray: 6 5; pointer-events: none; }
@keyframes handlePulse { 0%, 100% { transform: scale(1); opacity: .55; } 50% { transform: scale(1.18); opacity: .15; } }
.ssvg .axis { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 8 6; opacity: .9; }
.ssvg .axis.good { stroke: var(--green); stroke-dasharray: none; stroke-width: 3; }
.ssvg .asym { fill: none; stroke: var(--red-2); stroke-width: 2.5; pointer-events: none; }
.ssvg.done .piece .rim, .ssvg.revealed .piece .rim { stroke: rgba(0, 0, 0, .35); }

/* author display rules above must not defeat the hidden attribute */
[hidden] { display: none !important; }

/* wall go */
.wg-wrap { width: 100%; max-width: 480px; }
.wg-wrap svg { display: block; width: 100%; height: auto; user-select: none; -webkit-tap-highlight-color: transparent; }
.wg-turn { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); }
.wg-turn .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.wg-turn .dot.red { background: var(--red-2); }
.wg-turn .dot.blue { background: var(--accent); }
.wg-turn .dot.yellow { background: #e0a020; }
.wg-clock { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; margin: -4px 0 2px; }
.wg-clock[hidden] { display: none; }
.wg-clock-bar { height: 100%; width: 100%; background: var(--accent); border-radius: 3px; transition: width .2s linear, background .2s; }
.wg-clock-bar.warn { background: var(--red-2); }
#clockLabel.warn { color: var(--red-2); }
.wg-score { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wg-score.three { grid-template-columns: repeat(3, 1fr); }
.wg-score.three .wg-sc { padding: 8px 9px; }
.wg-score.three .wg-sc .v { font-size: 24px; }
.wg-sc .brk { color: var(--muted); font-size: 11px; margin-top: 2px; }
.wg-sc .brk:empty { display: none; }
.wg-sc { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--line); }
.wg-sc .k { color: var(--muted); font-size: 12px; }
.wg-sc .v { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.wg-sc.red { border-top-color: var(--red-2); }
.wg-sc.blue { border-top-color: var(--accent); }
.wg-sc.red .v { color: var(--red-2); }
.wg-sc.blue .v { color: var(--accent); }
.wg-sc.yellow { border-top-color: #e0a020; }
.wg-sc.yellow .v { color: #b8820f; }
svg.wallgo .wg-cell { fill: var(--card); stroke: var(--line); stroke-width: 1; }
svg.wallgo .wg-cell.own1 { fill: rgba(226, 85, 99, .17); }
svg.wallgo .wg-cell.own2 { fill: rgba(53, 87, 214, .17); }
svg.wallgo .wg-cell.own3 { fill: rgba(224, 160, 32, .2); }
svg.wallgo .wg-cell.own0 { fill: #e4e4df; }
svg.wallgo .wg-cell.clickable { cursor: pointer; }
svg.wallgo .wg-cell.clickable:hover { stroke: var(--muted); }
svg.wallgo .wg-stone.mine { cursor: pointer; }
svg.wallgo .wg-dest { cursor: pointer; opacity: .55; }
svg.wallgo .wg-dest:hover { opacity: 1; }
svg.wallgo .wg-dest.stay { opacity: 1; }
svg.wallgo .wg-dest.brk { opacity: .85; }
svg.wallgo .wg-bwall, svg.wallgo .wg-break-x { cursor: pointer; }
svg.wallgo .wg-bwall:hover rect { fill: rgba(27, 27, 31, .22); }
svg.wallgo .wg-slot { cursor: pointer; fill: rgba(27, 27, 31, .2); stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 3; }
svg.wallgo .wg-slot:hover { fill: rgba(27, 27, 31, .5); }

/* kongming lock */
.lk-wrap { width: 100%; max-width: 560px; display: flex; justify-content: center; }
canvas.lock { display: block; max-width: 100%; cursor: pointer; -webkit-tap-highlight-color: transparent; }
canvas.lock { touch-action: none; user-select: none; -webkit-user-select: none; }
canvas.lock.grabbing { cursor: grabbing; }
.lk-chips { display: inline-flex; align-items: center; gap: 5px; font-size: 16px; }
.lk-chips .n { margin-right: 4px; }
.lk-chips .chip { width: 14px; height: 14px; border-radius: 4px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
