:root {
  color-scheme: light;
  --ink: #17263a;
  --muted: #64748b;
  --blue: #1769c2;
  --blue-dark: #123f78;
  --cyan: #64d8ef;
  --line: #dce6f1;
  --panel: #fff;
  --soft: #f2f7fc;
  --green: #16a673;
  --gold: #f3b63f;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f3f7fb; color: var(--ink); }
button { font: inherit; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px clamp(18px,4vw,54px); color:#fff; background:linear-gradient(110deg,#113d72,#176dc3); box-shadow:0 8px 24px #183b641c; }
.topbar a { color:#fff; text-decoration:none; font-weight:700; }
.brand { display:flex; align-items:center; gap:12px; }
.brand-mark { display:grid; place-items:center; width:40px; height:40px; border-radius:12px; background:#ffffff20; color:var(--cyan); font-size:22px; }
.topbar .back { padding:9px 14px; border:1px solid #ffffff55; border-radius:999px; font-size:13px; }
.page { width:min(1200px,calc(100% - 32px)); margin:0 auto; padding:34px 0 64px; }
.intro { display:flex; align-items:end; justify-content:space-between; gap:26px; margin-bottom:22px; }
.eyebrow { margin:0 0 8px; color:var(--blue); font-size:12px; font-weight:800; letter-spacing:.16em; }
h1 { margin:0; font-size:clamp(28px,4vw,42px); letter-spacing:-.04em; }
.intro p:last-child { max-width:580px; margin:10px 0 0; color:var(--muted); line-height:1.7; }
.pill-row { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:18px; }
.pill { padding:8px 12px; border:1px solid #d5e2ef; border-radius:999px; background:#fff; color:#49617b; font-size:12px; }
.mode-tabs { display:flex; gap:9px; overflow:auto; padding:3px 1px 14px; }
.mode-tab { flex:none; min-height:46px; padding:10px 17px; border:1px solid var(--line); border-radius:13px; background:#fff; color:#456079; font-weight:750; cursor:pointer; transition:.18s ease; }
.mode-tab:hover { border-color:#8bb8e8; color:var(--blue); }
.mode-tab[aria-selected="true"] { border-color:var(--blue); background:var(--blue); color:#fff; box-shadow:0 6px 16px #1769c233; }
.game-layout { display:grid; grid-template-columns:minmax(0,1.45fr) minmax(290px,.75fr); gap:18px; align-items:start; }
.board-card,.control-card,.lesson-card { border:1px solid var(--line); border-radius:20px; background:var(--panel); box-shadow:0 10px 30px #294c700b; }
.board-card { overflow:hidden; }
.board-head { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:17px 20px; border-bottom:1px solid #edf1f5; }
.board-head h2 { margin:0; font-size:18px; }
.level { padding:6px 10px; border-radius:999px; background:#e7f3ff; color:#1769c2; font-size:11px; font-weight:800; }
.board-wrap { padding:clamp(14px,3vw,24px); background:linear-gradient(180deg,#f8fbff,#f1f7fd); }
.board { display:grid; width:min(100%,600px); aspect-ratio:1; margin:auto; gap:4px; }
.board[data-mode="key"] { gap:0; overflow:hidden; border:7px solid #cbd8e5; border-radius:18px; background:#cbd8e5; box-shadow:0 12px 28px #2546661c,inset 0 0 0 1px #ffffff; }
.board[data-mode="key"] .cell { border:0; border-radius:0; background:#f6f9fc; box-shadow:none; }
.board[data-mode="key"] .cell.wall { background:#2d5274; box-shadow:none; }
.board[data-mode="key"] .cell.agent { border:2px solid #fff; border-radius:50%; background:#d9edff; box-shadow:0 2px 12px #1769c266; }
.board[data-mode="key"] .cell.goal,.board[data-mode="key"] .cell.key { background:#e7f5ed; }
.board[data-mode="key"] .cell.key { background:#fff2c6; }
.board[data-mode="key"] .cell.trail::after { width:24%; background:#4f9de855; }
[hidden] { display:none !important; }
.board[data-mode="key"][data-size="5"] { width:min(100%,360px); }
.board[data-mode="key"][data-size="5"] .symbol { font-size:clamp(20px,5vw,32px); }
.key-map-picker { display:flex; flex-wrap:wrap; gap:8px; padding:12px 20px; }
.key-map-picker [aria-pressed="true"], #slow-button[aria-pressed="true"] { border-color:#79b2ec; background:#e6f2ff; color:#104f8c; }
.key-play { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:0 20px 18px; }
.key-live { min-width:0; padding:12px; border-radius:12px; background:#edf6ff; flex:1; }
.key-live strong { display:block; margin-top:6px; color:#1e4f81; font-size:14px; }
.key-board-actions { display:flex; gap:6px; flex-wrap:wrap; margin-top:9px; }
.key-board-actions button { min-height:36px; padding:5px 10px; font-size:12px; }
#key-dpad-slot .dpad { margin:0 !important; }
#key-dpad-slot .btn { padding:0; font-size:20px; }
.key-route-compare { padding:14px 20px 20px; border-top:1px solid var(--line); }
.key-route-compare h3 { margin:0 0 5px; font-size:16px; }
.key-route-cards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:10px; }
.key-route-card { min-width:0; border:1px solid var(--line); padding:10px; border-radius:14px; }
.key-route-card h4 { margin:0 0 4px; font-size:13px; }
.key-route-card p { margin:0 0 5px; font-size:11px; color:#49617b; line-height:1.5; }
.key-mini-map { display:grid; width:min(100%,170px); aspect-ratio:1; margin:7px auto 0; overflow:hidden; border:2px solid #cbd8e5; border-radius:8px; background:#f6f9fc; }
.key-mini-map span { position:relative; min-width:0; }
.key-mini-map .mini-wall { background:#2d5274; }
.key-mini-map .mini-key { background:#ffe184; }
.key-mini-map .mini-door { background:#bfa283; }
.key-mini-map .mini-goal { background:#a4e6c2; }
.key-mini-map .mini-trail::after { position:absolute; inset:32%; border-radius:50%; background:#1769c2; content:""; }
.key-transfer-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
#key-transfer-results:not(:empty) { margin-top:12px; padding:10px; background:#edf6ff; border-radius:10px; color:#1e4f81; font-size:13px; }
#key-transfer-results ul { padding-left:1.2em; margin:6px 0 0; line-height:1.7; }
.prediction { display:grid; gap:5px; margin:12px 0 0; color:#405c77; font-size:13px; font-weight:700; }
.prediction select { padding:7px; border:1px solid var(--line); border-radius:8px; background:white; color:var(--ink); font:inherit; }
body[data-mode="key"] #train-button,
body[data-mode="key"] #step-counter,
body[data-mode="key"] .pill-row,
body[data-mode="key"] .side > .lesson-card:last-child,
body[data-mode="key"] .legend .hazard-swatch { display:none; }
body[data-mode="key"] .legend span:has(.hazard-swatch) { display:none; }
body[data-mode="key"] #training-details { margin-top:12px; }
#training-details summary { display:none; }
body[data-mode="key"] #training-details summary { display:list-item; color:#405c77; cursor:pointer; font-size:13px; }
body[data-mode="key"] #more-rewards[aria-expanded="false"] + .reward-rules .reward-rule { grid-template-columns:minmax(0,1fr) auto 64px; }
body[data-mode="key"] #more-rewards[aria-expanded="false"] + .reward-rules :is(input[type="checkbox"], .remove-rule) { display:none; }
body[data-mode="key"] .reward-rule label { font-size:13px; }
body[data-mode="key"] .speed { justify-content:flex-start; }
body[data-mode="key"] .speed > :not(#slow-button) { display:none; }
.cell { position:relative; display:grid; place-items:center; min-width:0; border:1px solid #e0e9f2; border-radius:9px; background:#fff; color:#7890a8; font-size:clamp(11px,2vw,22px); transition:background .14s, transform .14s; }
.cell.wall { border-color:#264a70; background:linear-gradient(145deg,#345c83,#23476c); box-shadow:inset 0 -3px 0 #18395a; }
.cell.gate { background:#e9eff7; color:#9aaabd; }
.cell.gate.open { border-color:#8ed5bc; background:#dff7ed; color:#168459; }
.cell.start { background:#e8f4ff; }
.cell.goal { border-color:#93d9bd; background:#e1f8ee; }
.cell.key { background:#fff6d9; }
.cell.agent { z-index:1; border-color:#57a4ed; background:#d9edff; box-shadow:0 3px 10px #1769c24d; }
.cell.guard { background:#ffebeb; }
.cell.trail::after { position:absolute; width:20%; aspect-ratio:1; border-radius:50%; background:#76b4ef66; content:""; }
.cell .symbol { position:relative; z-index:2; }
.legend { display:flex; flex-wrap:wrap; justify-content:center; gap:8px 16px; margin:14px 0 0; color:#6b7e92; font-size:11px; }
.legend span { display:inline-flex; align-items:center; gap:6px; }
.legend i { width:11px; height:11px; border:1px solid #d5e1ed; border-radius:3px; background:#fff; }
.legend .wall-swatch { border-color:#345c83; background:#345c83; }
.legend .agent-swatch { border-color:#57a4ed; background:#d9edff; }
.legend .goal-swatch { border-color:#93d9bd; background:#e1f8ee; }
.legend .hazard-swatch { border-color:#f2a8a8; background:#ffebeb; }
.board-foot { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; padding:14px 20px 18px; }
.status { margin:0; color:#47617b; font-size:13px; line-height:1.5; }
.side { display:grid; gap:14px; }
.control-card,.lesson-card { padding:18px; }
.reward-card { padding:18px; border:1px solid var(--line); border-radius:20px; background:var(--panel); box-shadow:0 10px 30px #294c700b; }
.control-card h3,.lesson-card h3 { margin:0 0 13px; font-size:15px; }
.reward-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.reward-head h3 { margin:0; font-size:16px; }
.reward-sub { margin:6px 0 12px; color:var(--muted); font-size:12px; line-height:1.6; }
.reward-presets { display:flex; align-items:center; gap:5px; flex:none; }
.reward-presets select { max-width:124px; min-height:36px; font:inherit; font-size:11px; }
.btn.compact { min-height:36px; padding:6px 9px; font-size:11px; }
.reward-palette { display:flex; flex-wrap:wrap; gap:6px; padding:10px; border:1px solid #e5edf6; border-radius:12px; background:#f6f9fd; }
.reward-palette .btn { min-height:34px; padding:6px 8px; font-size:11px; }
.reward-rules { display:grid; gap:7px; margin-top:10px; }
.reward-rule { display:grid; grid-template-columns:16px minmax(0,1fr) auto 62px 26px; align-items:center; gap:7px; padding:8px; border:1px solid #c9d8ed; border-left:4px solid #638bc3; border-radius:10px; background:#edf3ff; font-size:12px; }
.reward-rule[data-event="bump"],.reward-rule[data-event="caught"] { border-color:#eacac7; border-left-color:#cf7f78; background:#fff0ef; }
.reward-rule[data-event="goal"],.reward-rule[data-event="key"],.reward-rule[data-event="survive"] { border-color:#c9e4d6; border-left-color:#58a77f; background:#effaf4; }
.reward-rule.off { opacity:.55; }
.reward-rule input[type="checkbox"] { accent-color:var(--blue); }
.reward-rule label { font-weight:700; }
.reward-rule input[type="number"] { width:62px; min-height:32px; padding:4px; border:1px solid #c4d2e3; border-radius:7px; background:white; color:var(--ink); font:inherit; text-align:right; }
.reward-rule .remove-rule { min-width:26px; min-height:28px; padding:2px; border:1px solid #d8e1ef; border-radius:6px; background:#ffffffb5; color:#60758c; cursor:pointer; }
.reward-empty { padding:14px 10px; border:1px dashed #bfd1eb; border-radius:10px; color:var(--muted); font-size:12px; text-align:center; }
.reward-preview { display:grid; grid-template-columns:auto minmax(110px,1fr) auto; align-items:center; gap:8px; margin-top:10px; color:#49617b; font-size:11px; }
.reward-preview select { min-width:0; min-height:34px; font:inherit; }
.reward-preview output { color:#184f88; font-size:14px; font-weight:800; white-space:nowrap; }
.reward-apply { display:grid; gap:7px; margin-top:10px; }
.reward-apply .btn { min-height:40px; }
.reward-apply .learn { font-size:11px; }
.actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.btn { min-height:42px; padding:9px 12px; border:1px solid var(--line); border-radius:11px; background:#fff; color:#405c77; font-weight:700; cursor:pointer; transition:.16s ease; }
.btn:hover:not(:disabled) { transform:translateY(-1px); border-color:#9dc3eb; }
.btn:disabled { cursor:not-allowed; opacity:.48; }
.btn.primary { border-color:var(--blue); background:var(--blue); color:#fff; }
.btn.primary:hover:not(:disabled) { background:#0f57a6; }
.btn.stop { border-color:#f0c2bd; color:#a94438; }
.speed { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:14px; color:#6b7e92; font-size:12px; }
.speed input { width:54%; accent-color:var(--blue); }
.metrics { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:14px; }
.metric { padding:10px; border-radius:12px; background:var(--soft); }
.metric small { display:block; margin-bottom:4px; color:#78899b; font-size:11px; }
.metric strong { color:#1e4f81; font-size:19px; }
.learn { margin:0; color:#5f7185; font-size:12px; line-height:1.7; }
.learn strong { color:#284b70; }
.callout { margin-top:12px; padding:10px 12px; border-radius:12px; background:#fff8e8; color:#89641c; font-size:11px; line-height:1.6; }
.kbd { display:inline-grid; place-items:center; min-width:22px; height:22px; margin:0 2px; border:1px solid #d8e3ef; border-radius:6px; background:#fff; color:#48627c; font-size:11px; }
.policy { display:flex; flex-wrap:wrap; gap:5px; margin-top:12px; }
.policy span { padding:4px 7px; border-radius:7px; background:#eef5fc; color:#50708e; font-size:10px; }
.toast { position:fixed; inset:auto 16px 16px; z-index:5; width:fit-content; max-width:calc(100% - 32px); margin:auto; padding:10px 16px; border-radius:999px; background:#173f68; color:#fff; box-shadow:0 8px 25px #173f6840; font-size:13px; opacity:0; transform:translateY(8px); pointer-events:none; transition:.2s ease; }
.toast.show { opacity:1; transform:translateY(0); }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@media(max-width:850px) { .game-layout { grid-template-columns:1fr; } .side { grid-template-columns:1fr 1fr; align-items:start; } .reward-card { grid-column:1/-1; grid-row:1; } .intro { display:block; } }
@media(max-width:560px) { .page { width:min(100% - 20px,1200px); padding-top:24px; } .topbar { padding:12px 14px; } .topbar .back { font-size:11px; } .side { grid-template-columns:1fr; } .reward-card { grid-column:auto; } .reward-head { display:block; } .reward-presets { margin-bottom:9px; } .reward-palette { gap:5px; padding:8px; } .reward-palette .btn { flex:1 1 calc(50% - 5px); } .reward-rule { grid-template-columns:16px minmax(0,1fr) auto 58px 25px; gap:5px; font-size:11px; } .reward-rule input[type="number"] { width:58px; } .reward-preview { grid-template-columns:1fr auto; } .reward-preview label { grid-column:1/-1; } .board { gap:3px; } .cell { border-radius:6px; } .board-head { padding:14px; } .board-foot { padding:12px 14px 15px; } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important; transition:none!important; } }
