/*
 * [INPUT]: index.html 的游戏工作台结构与 board-view.js 的格尺寸/视图/可用高度变量。
 * [OUTPUT]: 游戏页全部样式：难度页签/工作台/HUD/棋盘/聚焦算式栏/聚合托盘/操作栏/通关卡/指南与双栏响应式。
 * [POS]: game 的视觉层；与全站纸色/墨绿体系同构，零外部字体或图片。
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */
:root {
  --ink: #143d32; --muted: #4c645b; --green: #146b51; --olive: #577500; --lime: #d5ed79;
  --paper: #f5f4ed; --card: #fffef8; --line: #d2d8cd; --red: #9e2430;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
a { color: var(--green); text-underline-offset: 3px; touch-action: manipulation; }
button, select { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; min-height: 44px; padding: 8px 12px; border: 1px solid #cbd4c7; border-radius: 8px; background: var(--card); font-weight: 650; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: 0.48; cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible, .board-scroll:focus-visible { outline: 3px solid var(--olive); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fffef8; padding: 10px 16px; z-index: 30; }
.skip-link:focus { left: 0; }

header { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 1064px; margin: auto; padding: 10px 12px; }
.brand { display: inline-flex; align-items: center; min-height: 44px; font-size: 18px; font-weight: 800; letter-spacing: -0.6px; color: var(--ink); text-decoration: none; }
.brand-dot { color: var(--green); }
.preview { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 3px 9px; background: #eef1e8; }
main { max-width: 1040px; margin: auto; padding: 0 12px 32px; }
.intro { margin-block: 4px 10px; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 1.8px; color: var(--green); margin: 0 0 4px; }
h1 { font-size: clamp(26px, 4vw, 34px); letter-spacing: -1.2px; line-height: 1.12; margin: 0; }
.intro p:last-child { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
footer { max-width: 1040px; margin: auto; padding: 14px 12px 28px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; }

.analytics-settings { background: #edf1e7; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-block: 10px 14px; font-size: 13px; }
.analytics-settings h2 { font-size: 14px; margin: 0 0 4px; }
.analytics-settings p { margin: 4px 0 8px; color: var(--muted); }
.analytics-settings button { font-size: 12.5px; margin-right: 6px; }
#analytics-status { font-size: 12px; margin-bottom: 0; }

.diff-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.diff-btn { flex: 1; min-width: 72px; min-height: 44px; padding: 6px 10px; font-size: 12.5px; border-radius: 9px; background: #ecefe6; border-color: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25; }
.diff-btn small { font-size: 10px; font-weight: 500; color: var(--muted); }
.diff-btn[aria-pressed="true"] { background: var(--ink); color: #fffef8; box-shadow: 0 3px 10px rgba(20, 61, 50, 0.16); }
.diff-btn[aria-pressed="true"] small { color: var(--lime); }
.diff-btn .solved-mark { color: var(--lime); font-weight: 800; }
.diff-btn[aria-pressed="false"] .solved-mark { color: var(--green); }

.game-workbench { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 10px; box-shadow: 0 10px 32px rgba(20, 61, 50, 0.05); }
.hud-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid #e5e9df; margin-bottom: 8px; }
.level-picker { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.level-picker select { min-height: 40px; max-width: 100%; padding: 4px 8px; border-radius: 7px; border: 1px solid #c3cec0; background: white; font-weight: 700; font-size: 13px; }
.hud-badges { display: flex; align-items: center; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.badge { background: #edf1e7; border: 1px solid #d6dfd0; padding: 4px 8px; border-radius: 6px; font-weight: 650; }
.badge.rule-badge { background: #eef4dc; border-color: #c5d982; color: #2c4c00; }

.status-banner { padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 8px; background: #eef2e8; border-left: 4px solid var(--green); }
.status-banner.valid { background: #e9f3c5; border-left-color: #4f8116; color: #244705; }
.status-banner.conflict { background: #fff0e8; border-left-color: #b64533; color: #7d2519; }
.status-banner.info { background: #edf2e9; border-left-color: var(--ink); }

.confirm-box { padding: 12px; border-radius: 10px; background: #fff4df; border: 1px solid #d8ae68; color: #6e4212; margin-bottom: 10px; font-size: 12.5px; }
.confirm-box strong { display: block; margin-bottom: 4px; font-size: 13.5px; }
.confirm-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.confirm-actions .danger { color: #823426; border-color: #b99b6e; }

.victory-card { padding: 16px; border-radius: 14px; background: linear-gradient(135deg, #143d32 0%, #1b5243 100%); color: #fffef8; margin-bottom: 12px; box-shadow: 0 10px 26px rgba(20, 61, 50, 0.18); }
.victory-card .v-tag { display: inline-block; background: var(--lime); color: var(--ink); font-size: 10px; font-weight: 800; letter-spacing: 1px; padding: 3px 8px; border-radius: 20px; margin-bottom: 6px; }
.victory-card h2 { margin: 0 0 6px; font-size: 20px; color: #fffef8; }
.victory-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: #cfe0d9; margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
.victory-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.victory-actions .btn-lime { background: var(--lime); border-color: var(--lime); color: var(--ink); font-weight: 800; }
.victory-actions .btn-ghost { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); color: #fffef8; }

.board-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.board-help { font-size: 12px; color: var(--muted); margin-block: 6px; }
.board-controls { display: flex; gap: 6px; }
.board-controls button { font-size: 12px; min-height: 36px; padding: 4px 9px; }
.board-scroll { width: 100%; max-height: var(--board-height); overflow: auto; padding: 4px; border-radius: 10px; background: #eff2ea; border: 1px solid #dce2d5; overflow-anchor: none; }
.board-scroll[data-view="zoom"] { height: var(--board-height); }
#board { --edit-font: 18px; width: max-content; min-width: 100%; display: flex; flex-direction: column; gap: 3px; }
#board [role="row"] { display: grid; grid-template-columns: repeat(var(--columns), var(--cell-size, 44px)); gap: 3px; justify-content: center; }
#board button { padding: 0; min-width: 0; min-height: 0; height: var(--cell-size, 44px); border-radius: 7px; font-size: var(--cell-font, 18px); font-weight: 750; font-variant-numeric: tabular-nums; position: relative; overflow: hidden; display: grid; place-items: center; user-select: none; }
#board button[data-kind="void"] { background: transparent; border-color: transparent; pointer-events: none; }
#board button[data-kind="void"]::before { content: '·'; color: #81917a; font-size: 11px; }
#board button[data-kind="given"] { background: #e5ebe0; border: 1px solid #cad4c3; color: var(--ink); cursor: default; }
#board button[data-kind="given"].in-active-eq { background: #dce6d2; }
#board button[data-kind="operator"], #board button[data-kind="equals"] { background: #e8ede2; border-color: transparent; color: #465e55; font-weight: 600; cursor: default; }
#board button[data-kind="equals"].eq-balanced { background: #e4f2b8; border-color: #7ea340; color: #244d00; font-weight: 800; }
#board button[data-kind="equals"].eq-balanced::after { content: '✓'; position: absolute; bottom: 0; right: 2px; font-size: min(9px, calc(var(--cell-font, 18px) * 0.5)); }
#board button[data-kind="equals"].eq-conflict { background: #ffe6dc; border-color: #c44735; color: #8f2116; font-weight: 800; }
#board button[data-kind="slot"] { background: #ffffff; border: 1.5px dashed #93a694; box-shadow: inset 0 2px 3px rgba(20, 61, 50, 0.05); color: #7c9084; }
#board button[data-kind="slot"].in-active-eq { border-color: #5b7867; background: #fbfdf7; }
#board button[data-kind="slot"].filled { background: #fffef6; border: 1.5px solid var(--green); box-shadow: 0 2px 0 #b7c8b6; color: #0d4a37; }
#board button[data-kind="slot"].hinted { background: #edf8c7; border: 1.5px solid #6b9430; box-shadow: none; color: #264d00; }
#board button[data-kind="slot"].hinted::after { content: '★'; position: absolute; top: 1px; right: 2px; font-size: min(9px, calc(var(--cell-font, 18px) * 0.5)); color: #4e7314; }
#board button[data-kind="slot"].eq-line-balanced { border-color: #5b8c22; background: #f6fce2; }
#board button[data-kind="slot"].eq-line-conflict { border: 2px solid #c44735; background: #fff5f2; color: var(--red); }
#board button[data-kind="slot"].flagged { border: 2px solid #c44735; background: #fff0ed; color: var(--red); }
#board button[data-kind="slot"].flagged::before { content: '!'; position: absolute; top: 0; left: 3px; font-size: 10px; font-weight: 900; color: #b6291c; }
#board button[data-kind="slot"][aria-selected="true"] { border: 2px solid var(--ink); box-shadow: inset 0 0 0 2.5px var(--lime); background: #f9fde8; z-index: 2; }
#board button[data-kind="slot"].armed-target:not(.hinted) { border-color: var(--green); background: #f5fbe0; }

.control-dock { margin-top: 10px; background: #f7f8f2; border: 1px solid #dce2d5; border-radius: 14px; padding: 10px; }
.active-eq-hud { background: #eef2e7; border: 1px solid #ced8c7; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.eq-hud-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.4px; flex-wrap: wrap; }
.eq-hud-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--card); border: 1px solid #d8e0d2; border-radius: 8px; padding: 5px 8px; font-variant-numeric: tabular-nums; }
.eq-dir { font-size: 11px; font-weight: 800; color: var(--green); min-width: 54px; }
.eq-tokens { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; font-size: 14px; font-weight: 700; }
.eq-slot-pill { min-height: 28px; min-width: 32px; padding: 2px 7px; border-radius: 6px; border: 1.5px dashed #8ca18e; background: #ffffff; font-size: 13.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.eq-slot-pill.filled { border-style: solid; border-color: var(--green); background: #f5faeb; }
.eq-slot-pill.active { border: 2px solid var(--ink); background: var(--lime); box-shadow: 0 1px 4px rgba(20, 61, 50, 0.15); }
.eq-state-tag { font-size: 11px; font-weight: 750; padding: 2px 6px; border-radius: 5px; background: #edf1e8; color: var(--muted); }
.eq-state-tag.balanced { background: #e4f2b8; color: #244d00; }
.eq-state-tag.conflict { background: #ffe6dc; color: #8f2116; }

.tray-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.tray-header strong { font-size: 12.5px; }
.tray-header span { color: var(--muted); font-size: 11.5px; }
.tile-tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 6px; margin-bottom: 10px; }
.tray-tile { min-height: 46px; padding: 4px; border-radius: 9px; background: #ffffff; border: 1.5px solid #b5c4b4; box-shadow: 0 3px 0 #cbd6c8; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; display: grid; place-items: center; position: relative; }
.tray-tile:hover:not(:disabled) { border-color: var(--green); background: #fbfef2; }
.tray-tile[aria-pressed="true"] { background: var(--lime); border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--ink); transform: translateY(-3px); }
.tray-tile .count-badge { position: absolute; top: 2px; right: 3px; font-size: 9.5px; font-weight: 800; background: #e5ece0; color: var(--green); padding: 0 4px; border-radius: 6px; line-height: 1.3; }
.tray-tile[aria-pressed="true"] .count-badge { background: var(--ink); color: var(--lime); }
.tray-tile.used { background: #ebeee6; border: 1px dashed #c4cdc0; box-shadow: none; color: #8c9c92; font-weight: 600; }
.tray-tile.used .count-badge { background: transparent; color: #8c9c92; }

.action-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.action-bar button { min-height: 44px; padding: 6px 4px; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 8px; }
.action-bar button .ico { font-size: 14px; line-height: 1; }
.action-bar .btn-hint { background: #eef6d4; border-color: #b7cf72; color: #274a00; }
.action-bar .btn-reset { color: var(--red); }

.solver-callout { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #edf2e7; border: 1px solid #ced8c7; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.solver-callout a { font-weight: 750; display: inline-flex; align-items: center; min-height: 44px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }

.guide { margin-top: 24px; max-width: 760px; }
.guide-nav { display: flex; gap: 16px; flex-wrap: wrap; padding-block: 10px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 650; }
.guide section { padding-block: 16px; border-top: 1px solid var(--line); }
.guide h2 { font-size: 19px; margin: 0 0 8px; }
.guide p, .guide li { font-size: 13.5px; color: var(--muted); }
.guide code { font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: #e9eee3; padding: 1px 5px; border-radius: 4px; color: #0f382d; }
.guide details { border-top: 1px solid #e1e6dc; padding-block: 4px; }
.guide summary { min-height: 44px; display: flex; align-items: center; font-weight: 650; cursor: pointer; font-size: 14px; color: var(--ink); }
.rule-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-block: 8px; }
.rule-table caption { text-align: left; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.rule-table th, .rule-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rule-table thead th { background: #edf1e8; }

@media (min-width: 760px) {
  .game-workbench { padding: 20px; }
  .work-split { display: grid; grid-template-columns: minmax(340px, 1.3fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
  .control-dock { margin-top: 0; position: sticky; top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
