* { box-sizing: border-box; }
:root { color-scheme: light; --ink: #30291f; --muted: #887b68; --orange: #ff8a3d; --paper: #f5eee2; --line: #dacbb4; --cell: min(18.2vw, 74px); }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif; overscroll-behavior: none; }
body { min-height: 100svh; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.game { width: min(100%, 480px); min-height: 100svh; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
.scoreline { width: min(100%, 390px); display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 12px; min-height: 70px; }
.scoreline > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { color: var(--muted); font-size: 12px; }
.scoreline strong { font-size: 19px; }
.steps { text-align: center; white-space: nowrap; }
.steps > strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.steps span { color: var(--muted); font-size: 13px; }
.steps b { color: var(--ink); font-weight: 600; }
.stars { color: var(--orange); font-size: 21px; letter-spacing: 2px; white-space: nowrap; }
.board-wrap { position: relative; width: calc(var(--cell) * 4 + 20px); margin: 18px auto 34px; padding: 10px; border: 3px solid #705840; border-radius: 12px; background: #b99a70; box-shadow: 0 7px 0 #8f704d, 0 12px 24px #563b2020; touch-action: none; }
.board { position: relative; width: calc(var(--cell) * 4); height: calc(var(--cell) * 5); overflow: hidden; border-radius: 5px; background-color: #dfcba9; background-image: linear-gradient(#b69a73 1px, transparent 1px), linear-gradient(90deg, #b69a73 1px, transparent 1px); background-size: var(--cell) var(--cell); }
.block { position: absolute; display: flex; align-items: center; justify-content: center; padding: 3px; border: 2px solid #fff8e9; border-radius: 8px; background: #6a9b92; box-shadow: inset 0 -4px 0 #00000019, 0 2px 3px #49331738; color: #fffdf5; font-size: 15px; font-weight: 700; text-align: center; line-height: 1.2; user-select: none; touch-action: none; transition: left .14s ease, top .14s ease, transform .12s ease; }
.block:active { transform: scale(.96); }
.block.selected { outline: 3px solid #ffcc61; outline-offset: -4px; }
.block.cao { background: #e88942; border-color: #ffe5bd; font-size: 18px; }
.block.guan { background: #bf6350; }
.block.general { background: #637ea0; }
.block.soldier { background: #70a77a; font-size: 13px; }
.exit-label { position: absolute; left: 50%; bottom: -29px; transform: translateX(-50%); color: #945b2f; font-size: 13px; font-weight: 700; letter-spacing: 3px; }
.controls { width: min(100%, 390px); display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.action { min-height: 54px; border: 1px solid var(--line); border-radius: 9px; background: #fffaf2; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 650; }
.action .mp-icon { font-size: 19px; }
.action.primary { color: #fff; border-color: #e97932; background: var(--orange); }
.action:disabled { opacity: .42; }
.message { min-height: 24px; margin: 17px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 22px; background: #28211988; }
.overlay.hidden { display: none; }
.dialog { width: min(100%, 340px); padding: 26px 22px 22px; border-radius: 12px; background: #fffaf2; text-align: center; box-shadow: 0 16px 50px #1b130d44; }
.result-mark { color: var(--orange); font-size: 34px; }
.dialog h1 { margin: 7px 0; font-size: 24px; }
.dialog p { margin: 8px 0; color: var(--muted); }
.result-stars { min-height: 34px; color: #f1a42f; font-size: 28px; letter-spacing: 4px; }
.dialog-actions { display: grid; gap: 9px; margin-top: 16px; }
.dialog-actions button { min-height: 48px; border: 0; border-radius: 8px; background: var(--orange); color: white; font-weight: 700; }
.dialog-actions button.secondary { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.toast { position: fixed; z-index: 8; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px); max-width: calc(100vw - 36px); padding: 11px 16px; border-radius: 8px; background: #34291e; color: white; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s; text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (max-height: 720px) { :root { --cell: min(16.5vw, 60px); } .game { padding-top: max(14px, env(safe-area-inset-top)); } .board-wrap { margin-top: 10px; margin-bottom: 31px; } }

/* 游戏操作与结算补全：竖屏单页，不添加导航。 */
.game { padding-top: max(8px, env(safe-area-inset-top)); }
.scoreline { grid-template-columns: 1fr auto; gap: 6px 12px; }
.scoreline .stars { grid-column: 2; text-align: right; font-size: 18px; }
.scoreline > div:first-child { grid-row: 1 / 3; }
.remaining { width: min(100%, 390px); color: #945b2f; font-size: 13px; text-align: right; margin-top: 4px; font-variant-numeric: tabular-nums; }
.board-wrap { border-color: #9b572a; background: #e0a367; }
.block { cursor: pointer; appearance: none; }
.block.cao { background: #ff8a3d; box-shadow: inset 0 3px 0 #ffcc8e, inset 0 -5px 0 #c45b24, 0 2px 3px #49331738; }
.block:disabled { opacity: 1; }
.direction { position: absolute; z-index: 3; width: 44px; height: 44px; border: 2px solid #fff6db; border-radius: 50%; background: #ff8a3d; color: #fff; font-size: 25px; box-shadow: 0 2px 5px #5b32194d; cursor: pointer; touch-action: manipulation; }
.action { position: relative; min-height: 66px; padding-top: 14px; }
.action small { position: absolute; top: 5px; right: 7px; font-size: 9px; font-weight: 500; opacity: .8; }
.action:disabled { cursor: default; }
.dialog button { cursor: pointer; }
.dialog button:disabled { opacity: .45; cursor: wait; }
.ad-preview { z-index: 10; }
.ad-preview .dialog { display: grid; gap: 12px; }
.ad-preview h2 { margin: 0; font-size: 21px; }
.ad-preview button { min-height: 48px; border: 0; border-radius: 8px; background: var(--orange); color: #fff; }
.ad-preview button:last-child { background: #ede2d0; color: var(--ink); }
.block.shake { animation: blocked .2s linear; }
.block.escaped { transform: translateY(70%); opacity: 0; transition: transform .4s ease-in, opacity .4s; }
@keyframes blocked { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (max-width: 340px) { .game { padding-left: 10px; padding-right: 10px; } .scoreline strong { font-size: 16px; } .steps span { font-size: 11px; } }
@media (prefers-reduced-motion: reduce) { .block { transition: none; animation: none; } }

/* 待实现功能的增量样式，保留原棋盘与广告界面。 */
.race-clock { width: min(100%,390px); margin-top: 5px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.board-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: #f5e4ca; padding: 24px; text-align: center; }
.board-state strong { font-size: 21px; }
.board-state span { color: #766449; font-size: 13px; }
.board-state progress { width: 75%; accent-color: var(--orange); }
.board-state button,.feature-controls button { min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: #fffaf2; padding: 10px 15px; cursor: pointer; }
.board-state button { background: var(--orange); color: white; min-width: 120px; border: 0; }
.feature-controls { width: min(100%,390px); display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 10px; }
.feature-controls button { font-size: 13px; padding: 9px 5px; }
.feature-dialog { width: min(100%,440px); max-height: 88svh; overflow: auto; text-align: left; position: relative; padding-top: 20px; }
.feature-dialog h2 { margin: 0 65px 18px 0; font-size: 21px; }
.feature-dialog p { font-size: 13px; line-height: 1.6; }
.feature-dialog button { min-height: 44px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff4e3; margin: 4px 3px; }
.feature-dialog .panel-close { position: absolute; right: 14px; top: 10px; }
.feature-dialog label { display: block; margin: 12px 0; font-size: 13px; }
.feature-dialog input,.feature-dialog textarea { display: block; width: 100%; padding: 12px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 16px; background: white; color: #30291f; }
.feature-dialog textarea { min-height: 130px; overflow-wrap: anywhere; resize: vertical; }
.feature-dialog .record { border-bottom: 1px solid var(--line); padding: 12px 0; }
.level-row { display: flex; gap: 5px; align-items: center; }
.level-row button:first-child { flex: 1; text-align: left; overflow-wrap: anywhere; }
.editor-tools { display: flex; flex-wrap: wrap; margin-bottom: 12px; }
.feature-dialog button.chosen { background: var(--orange); color: #fff; }
.editor-grid { display: grid; gap: 3px; padding: 5px; background: #cdb38d; border-radius: 8px; }
.editor-grid button { margin: 0; padding: 0; min-height: 40px; font-size: 12px; border-radius: 5px; }
.editor-grid .editor-piece { background: #637ea0; color: white; }
.editor-grid .editor-cao { background: var(--orange); color: white; }
body[data-palette="jade"] { --paper: #e9f1e7; --ink: #293f39; --muted: #64786b; --line: #bdcfc0; }
body[data-palette="jade"] .block.general { background: #497b72; }
body[data-palette="jade"] .block.guan { background: #92704d; }
body[data-palette="jade"] .block.soldier { background: #89a370; }
body[data-palette="night"] { --paper: #292c35; --ink: #f5e6cf; --muted: #c0b5a8; --line: #77716a; }
body[data-palette="night"] .dialog,body[data-palette="night"] .feature-controls button { background: #383b44; }
body[data-palette="night"] .feature-dialog button { background: #57504a; }
body[data-palette="night"] .remaining { color: #ffb57b; }
body[data-palette="night"] .board-state { color: #30291f; }
body[data-skin="flat"] .block { box-shadow: none; border-width: 1px; }
body[data-skin="round"] .block { border-radius: 22px; border-width: 3px; }
