:root {
  color-scheme: light;
  --ink: #2C2340;
  --muted: #6B6380;
  --paper: #F8F7FC;
  --panel: #ffffff;
  --line: #D9D3E8;
  --focus: #7C5CFF;
  --selected: #6748E8;
  --valid: #36C9A7;
  --valid-deep: #176E60;
  --valid-soft: #E8FAF5;
  --path: #56C7B5;
  --path-new: #2FBFA8;
  --path-label: #DDF7F2;
  --path-label-line: #A9E7DB;
  --path-label-ink: #1F7F72;
  --hint: #F1ECFF;
  --hint-line: #CFC2FF;
  --keyword: #5A3FD6;
  --keyword-soft: #EDE7FF;
  --keyword-line: #C7B8FF;
  --reminder: #F4B544;
  --error: #E08A2E;
  --dim: rgba(44, 35, 64, 0.12);
  --green: var(--valid-deep);
  --green-soft: var(--valid-soft);
  --blue: var(--selected);
  --blue-soft: var(--hint);
  --orange: var(--reminder);
  --shadow: 0 18px 50px rgba(44, 35, 64, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button { font: inherit; }

.app-shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 18px 0 30px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 12px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.eyebrow { margin: 0 0 7px; color: var(--selected); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.level-title { margin: 8px 0 0; color: var(--muted); }

.workspace { display: flex; justify-content: center; align-items: start; gap: 18px; }
.workspace.design-open { display: grid; grid-template-columns: minmax(620px, 1fr) 320px; }
.game-area, .debug-panel { background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.game-area { position: relative; width: min(100%, 760px); padding: 12px 20px 16px; }
.workspace.design-open .game-area { width: 100%; }
.debug-panel { padding: 22px; position: sticky; top: 24px; }

.mode-panel { display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 44px; margin-top: 12px; }
.mode-label { font-size: 13px; color: var(--muted); font-weight: 700; }
.segmented { display: inline-flex; padding: 4px; background: #F0EDF8; border-radius: 12px; }
.mode-button { border: 0; border-radius: 9px; padding: 9px 16px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s; }
.mode-button:not(:disabled):hover { background: #fff; color: var(--ink); box-shadow: 0 0 0 1px var(--hint-line); }
.mode-button.active { background: white; color: var(--selected); box-shadow: inset 0 0 0 2px var(--selected), 0 2px 8px rgba(44,35,64,.1); }
.mode-button.active::before { content: "✓ "; }
.mode-button.tutorial-action-focus { border: 2px solid var(--focus); background: var(--hint); color: var(--ink); box-shadow: 0 0 0 3px rgba(124,92,255,.12); animation: focusBreath 1.35s ease-in-out infinite; }
.tutorial-mode .mode-button.tutorial-action-dimmed { opacity: .3; cursor: default; box-shadow: none; }
.tutorial-mode .mode-button.tutorial-action-dimmed:hover { background: transparent; color: var(--muted); box-shadow: none; }
.tutorial-mode .mode-button.active { opacity: 1; }
.path-hint-button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: #FCFBFF; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; }
.path-hint-button[aria-pressed="true"] { border: 2px solid var(--valid); background: var(--valid-soft); color: var(--valid-deep); }
.path-hint-button:hover { background: var(--hint); border-color: var(--hint-line); }
.tutorial-mode .path-hint-button, .tutorial-mode .undo-button { opacity: .3; cursor: default; }
.tutorial-mode .path-hint-button:hover, .tutorial-mode .undo-button:hover { background: #FCFBFF; border-color: var(--line); box-shadow: none; }
.mode-button:disabled { color: #A9A1BA; cursor: not-allowed; opacity: .6; }
.mode-button.mode-nudge { color: var(--selected); background: #fff; box-shadow: 0 0 0 3px rgba(124,92,255,.22), 0 2px 8px rgba(44,35,64,.08); }
.mode-help { max-width: 620px; min-height: 46px; margin: 0 auto; padding: 9px 12px; border: 1px solid var(--hint-line); border-radius: 10px; background: #F7F4FF; color: var(--ink); font-size: 15px; font-weight: 600; text-align: center; line-height: 1.55; }
.tutorial-mode .mode-help { border-color: #E1D8FF; background: #F7F4FF; }
.keyword-chip { display: inline-block; margin: 0 2px; padding: 1px 6px; border: 1px solid var(--keyword-line); border-radius: 6px; background: var(--keyword-soft); color: var(--keyword); font-weight: 900; white-space: nowrap; }
.tutorial-visual { display: flex; justify-content: center; align-items: center; min-height: 38px; margin: 5px auto 0; color: var(--ink); }
.tutorial-formula { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; }
.target-symbol { color: var(--valid-deep); font-size: 24px; }
.tutorial-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 5px; }
.tutorial-controls .button { padding: 7px 13px; }
.tutorial-controls .text-button { opacity: .65; }

.feedback { min-height: 24px; margin: 2px 0 4px; opacity: 0; text-align: center; font-weight: 800; line-height: 1.45; white-space: pre-line; transition: opacity .2s; }
.feedback.visible { opacity: 1; }
.feedback.success { color: var(--valid-deep); }
.feedback.error { max-width: 620px; margin-left: auto; margin-right: auto; padding: 4px 10px; border: 1px solid rgba(224,138,46,.35); border-left: 3px solid var(--error); border-radius: 8px; background: #FFF5E9; color: #965319; }
.feedback.muted { color: var(--selected); }

.board-wrap { width: min(560px, calc(100vh - 360px), 100%); aspect-ratio: 1; margin: 0 auto; position: relative; }
.tutorial-mode .board-wrap { width: min(540px, calc(100vh - 395px), 100%); }
.board { --rows: 4; --cols: 4; display: grid; grid-template: repeat(var(--rows), 1fr) / repeat(var(--cols), 1fr); gap: 12px; width: 100%; height: 100%; position: relative; z-index: 1; }
.cell { position: relative; border: 2px solid var(--line); border-radius: 18px; background: #FFFFFF; color: var(--ink); cursor: default; transition: transform .16s, border-color .16s, box-shadow .16s, background .16s, opacity .18s; overflow: visible; }
.cell.interactive { cursor: pointer; }
.cell.interactive:hover { transform: translateY(-2px); border-color: var(--valid); box-shadow: 0 0 0 5px rgba(54,201,167,.16); }
.tutorial-mode .cell.tutorial-dimmed { opacity: .4; background-color: var(--dim); filter: grayscale(.35); cursor: default; }
.tutorial-mode .cell.tutorial-focus { opacity: 1; filter: none; }
.cell.has-tile { background: #FFFFFF; border-color: var(--line); box-shadow: 0 7px 17px rgba(44,35,64,.06); }
.cell.empty { background: repeating-linear-gradient(135deg, #FCFBFF, #FCFBFF 8px, #F6F3FC 8px, #F6F3FC 16px); border-style: dashed; }
.cell.disabled { background: #EDEAF4; border-color: transparent; opacity: .55; cursor: default; }
.cell.selected { border-color: var(--selected); background: var(--hint); box-shadow: 0 0 0 3px rgba(103,72,232,.12); }
.cell.selected::after { content: "已选"; position: absolute; z-index: 8; left: 7px; bottom: 7px; padding: 2px 5px; border-radius: 5px; background: var(--selected); color: white; font: 800 10px/1.3 "Microsoft YaHei", sans-serif; }
.cell.actionable-tile { border-color: var(--valid); box-shadow: 0 0 0 4px rgba(54,201,167,.12); }
.cell.locked-tile { background: #F3F0F9; border-color: #B9B0C9; }
.cell.locked-tile .tile-glyph { color: var(--muted); }
.lock-badge { position: absolute; z-index: 7; left: 8px; bottom: 8px; padding: 4px 7px; border-radius: 7px; background: var(--muted); color: white; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.cell.legal-move { background: var(--valid-soft); border-color: var(--valid); border-style: dashed; box-shadow: 0 0 0 5px rgba(54,201,167,.14); animation: softPulse 1.7s infinite; }
.cell.legal-move::after { content: "可走"; position: absolute; z-index: 8; right: 7px; bottom: 7px; padding: 2px 5px; border-radius: 5px; background: var(--valid-deep); color: #fff; font: 800 10px/1.3 "Microsoft YaHei", sans-serif; }
.cell.legal-tile-target { background: var(--valid-soft); border-color: var(--valid); border-style: dashed; box-shadow: 0 0 0 5px rgba(54,201,167,.14); animation: softPulse 1.7s infinite; }
.cell.empty.legal-tile-target::before { content: "◎"; position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--valid-deep); font-size: 30px; font-weight: 800; }
.cell.legal-tile-target::after { content: "目标"; position: absolute; z-index: 8; right: 7px; bottom: 7px; padding: 2px 5px; border-radius: 5px; background: var(--valid-deep); color: #fff; font: 800 10px/1.3 "Microsoft YaHei", sans-serif; }
.cell.tutorial-focus { outline: 2px solid var(--focus); outline-offset: 3px; animation: focusBreath 1.35s ease-in-out infinite; }
.cell.tutorial-focus.selected { animation: none; outline: none; }
.cell.tutorial-valid { border-width: 2px; }
.tutorial-mode[data-tutorial-phase="goal"] .cell.tutorial-start,
.tutorial-mode[data-tutorial-phase="moveTarget"] .cell.tutorial-focus:has(.player-marker),
.tutorial-mode[data-tutorial-phase="endTarget"] .cell.tutorial-focus:has(.player-marker) { outline: none; animation: none; box-shadow: 0 0 0 2px rgba(103,72,232,.12); }
.tutorial-mode[data-tutorial-phase="relation"] .cell.tutorial-focus { outline: none; animation: none; border-color: var(--path-label-line); box-shadow: 0 0 0 2px rgba(86,199,181,.11); }
.cell.tutorial-nudge, .mode-button.tutorial-nudge, .button.tutorial-nudge { animation: targetNudge .65s ease-out 1 !important; }
@keyframes focusBreath { 50% { outline-color: #A995FF; box-shadow: 0 0 0 4px rgba(124,92,255,.10); } }
@keyframes targetNudge { 35% { transform: scale(1.055); box-shadow: 0 0 0 10px rgba(244,181,68,.25); } }
.cell.swap-flash { animation: swapConfirm .55s ease-out; }
@keyframes swapConfirm { 45% { transform: scale(.94); box-shadow: 0 0 0 6px rgba(124,92,255,.22); } }
@keyframes softPulse { 50% { box-shadow: 0 0 0 9px rgba(54,201,167,.08); } }
.tile-glyph { position: absolute; inset: 0; display: grid; place-items: center; font-family: "STSong", "SimSun", serif; font-size: clamp(32px, 4vw, 54px); font-weight: 700; }
.coordinate { position: absolute; left: 9px; top: 8px; color: #9B93AE; font: 700 10px/1 system-ui, sans-serif; }
.empty-label { color: #A79DBB; font-size: 14px; letter-spacing: .15em; }
.endpoint { position: absolute; top: 7px; right: 7px; z-index: 4; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; color: #fff; font: 900 13px/1 system-ui, sans-serif; }
.endpoint.start { background: var(--valid); color: var(--ink); }
.endpoint.end { background: var(--reminder); color: var(--ink); }
.player-marker { position: absolute; z-index: 6; left: 50%; bottom: 7px; width: 34px; height: 20px; transform: translateX(-50%); border: 3px solid white; border-radius: 12px 12px 8px 8px; background: var(--ink); box-shadow: 0 3px 9px rgba(44,35,64,.26); }
.player-marker::before { content: ""; position: absolute; left: 50%; top: -15px; width: 14px; height: 14px; transform: translateX(-50%); border: 3px solid white; border-radius: 50%; background: var(--ink); box-shadow: 0 1px 3px rgba(44,35,64,.2); }
.player-marker::after { content: "玩家"; position: absolute; left: 50%; top: 1px; transform: translateX(-50%); color: white; font: 800 9px/1.2 "Microsoft YaHei", sans-serif; white-space: nowrap; }
.path-layer { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.path-line { stroke: var(--path); stroke-width: 4.5; stroke-linecap: round; opacity: .62; }
.path-label rect { fill: var(--path-label); stroke: var(--path-label-line); stroke-width: 2; }
.path-label text { fill: var(--path-label-ink); font: 800 17px "Microsoft YaHei", sans-serif; text-anchor: middle; }
.path-emphasis .path-line { stroke: var(--path-new); animation: pathDraw 1.2s ease-out; }
.path-emphasis .path-label { animation: pathAppear 1.4s ease-out; }
.tutorial-mode .path-layer { opacity: .38; }
.tutorial-mode[data-tutorial-phase="relation"] .path-layer { opacity: .85; }
.tutorial-mode[data-tutorial-phase="relation"] .path-line { stroke-width: 5; opacity: .75; }
@keyframes pathDraw { from { stroke-dasharray: 220; stroke-dashoffset: 220; opacity: .15; } to { stroke-dasharray: 220; stroke-dashoffset: 0; opacity: .75; } }
@keyframes pathAppear { from { opacity: .1; } to { opacity: .9; } }

.legend { display: flex; justify-content: center; gap: 18px; margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.tutorial-mode .legend { opacity: .3; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-radius: 5px; background: white; }
.empty-swatch { border-style: dashed; background: #F6F3FC; }
.disabled-swatch { border-color: #E2DDEE; background: #EDEAF4; }
.legend-player { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--line); }

.relations-panel { border-top: 1px solid var(--line); padding-top: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-heading h2 { margin: 0; font-size: 18px; }
.count-pill, .status-badge { padding: 6px 10px; border-radius: 99px; background: var(--hint); color: var(--muted); font-size: 11px; font-weight: 800; }
.status-badge.complete { color: var(--green); background: var(--green-soft); }
.relation-list { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.relation-chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 11px; border: 1px solid var(--hint-line); border-radius: 11px; background: #FAF8FF; font-size: 13px; }
.relation-chip b { color: var(--green); font-size: 17px; }
.relation-chip small { color: var(--muted); }
.empty-state { color: var(--muted); font-size: 13px; }

.button { border: 0; border-radius: 11px; padding: 11px 17px; cursor: pointer; font-weight: 800; }
.button:not(:disabled):hover { filter: brightness(.96); box-shadow: 0 0 0 2px rgba(124,92,255,.2); }
.button.primary { color: white; background: var(--selected); }
.button.secondary { color: var(--ink); background: white; border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(44,35,64,.06); }
.button.subtle { color: var(--muted); background: transparent; border: 1px solid transparent; }
.button:focus-visible, .mode-button:focus-visible, .cell:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.shell-screen { min-height: calc(100vh - 50px); display: grid; place-items: center; }
.shell-card { width: min(650px, 100%); padding: clamp(26px, 5vw, 60px); border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.93); box-shadow: var(--shadow); }
.shell-card h1 { font-size: clamp(42px, 6vw, 72px); }
.shell-card h2 { margin: 0 0 18px; font-size: clamp(26px, 3vw, 38px); }
.shell-card p { line-height: 1.85; color: var(--muted); }
.shell-card .shell-lead { color: var(--ink); font-size: clamp(18px, 2vw, 24px); font-weight: 700; }
.shell-wordmark { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 28px 0; }
.shell-wordmark span { display: grid; place-items: center; width: clamp(49px, 10vw, 76px); aspect-ratio: 1; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: 700 clamp(30px, 5vw, 48px) "STSong", "SimSun", serif; }
.shell-wordmark i { position: relative; min-width: 30px; padding: 4px 5px; border-bottom: 2px solid var(--valid); color: var(--valid-deep); font-size: 12px; font-style: normal; font-weight: 800; text-align: center; }
.shell-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.level-group { padding: 13px 0; border-top: 1px solid var(--line); }
.level-group h3 { margin: 0 0 10px; font-size: 16px; }
.level-options { display: flex; flex-wrap: wrap; gap: 9px; }
.select-card { width: min(800px, 100%); }
.complete-overlay { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; padding: 20px; border-radius: 22px; background: rgba(248,247,252,.88); }
.complete-card { max-width: 460px; padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.complete-card h2 { margin: 0; font-size: 30px; }
.complete-card .shell-actions { justify-content: center; }
.button.full { width: 100%; margin-top: 18px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 23px; }
.stats div { padding: 12px; border-radius: 12px; background: #F6F3FC; }
.stats dt { color: var(--muted); font-size: 11px; }
.stats dd { margin: 5px 0 0; font-size: 17px; font-weight: 800; }
.level-select-stat { grid-column: 1 / -1; }
.level-select-stat select { width: 100%; margin-top: 2px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font: 800 13px "Microsoft YaHei", sans-serif; cursor: pointer; }
.history-heading { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 19px; }
.history-heading h3 { margin: 0; font-size: 14px; }
.text-button { border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 11px; }
.text-button:hover { text-decoration: underline; color: var(--keyword); }
.history-list { height: 268px; margin: 12px 0 0; padding: 0; list-style: none; overflow-y: auto; }
.history-list li { position: relative; margin-left: 8px; padding: 8px 7px 8px 17px; border-left: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.45; }
.history-list li::before { content: ""; position: absolute; left: -4px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: #A79DBB; }
.event-number { display: inline-block; min-width: 25px; margin-right: 5px; color: #9B93AE; font: 700 10px/1 system-ui, sans-serif; }
.validator-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.validator-panel h3 { margin: 0 0 10px; font-size: 14px; }
.validator-panel pre { max-height: 360px; margin: 0; padding: 12px; overflow: auto; border-radius: 10px; background: #202723; color: #dce8e1; font: 11px/1.55 Consolas, monospace; white-space: pre-wrap; }
.character-data-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.character-data-panel summary { cursor: pointer; font-size: 14px; font-weight: 800; }
.character-data-tabs { display: flex; gap: 5px; margin: 12px 0 8px; }
.character-data-tab { flex: 1; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: #F6F3FC; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 800; }
.character-data-tab.active { border-color: var(--focus); background: var(--hint); color: var(--selected); }
.character-table-scroll, #character-pair-view { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.character-table { width: 100%; border-collapse: collapse; background: white; font-size: 10px; }
.character-table th { position: sticky; top: 0; z-index: 1; padding: 7px 5px; background: var(--hint); color: var(--muted); text-align: left; white-space: nowrap; }
.character-table td { padding: 6px 5px; border-top: 1px solid var(--line); white-space: nowrap; }
.character-filter-table { min-width: 980px; }
.character-filter-table .detail-cell { max-width: 260px; white-space: normal; overflow-wrap: anywhere; }
.character-glyph { font-family: "STSong", "SimSun", serif; font-size: 16px; font-weight: 700; }
.status-chip { display: inline-block; padding: 3px 6px; border-radius: 99px; font: 800 9px/1.2 system-ui, sans-serif; }
.status-playable { color: #176245; background: #dff3e9; }
.status-review { color: #8a5a14; background: #fff0d5; }
.status-excluded { color: #7a4742; background: #f4e6e4; }
.pair-group { padding: 10px 11px; border-bottom: 1px solid var(--line); background: white; }
.pair-group:last-child { border-bottom: 0; }
.pair-group h4 { margin: 0 0 6px; color: var(--green); font-size: 13px; }
.pair-group p { margin: 4px 0; font-size: 11px; }
.pair-group p span, .pair-group p small { color: var(--muted); }

@media (max-width: 1050px) {
  .app-shell { width: calc(100% - 32px); }
  .workspace.design-open { display: flex; flex-direction: column; align-items: stretch; }
  .workspace.design-open .game-area { max-width: 760px; align-self: center; }
  .debug-panel { position: static; }
  .history-list { height: 180px; }
}
@media (max-width: 650px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .game-area { padding: 12px; }
  .board { gap: 6px; }
  .mode-panel { flex-wrap: wrap; gap: 6px; }
  .legend { flex-wrap: wrap; }
  .coordinate { font-size: 8px; left: 5px; top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .cell, .mode-button, .path-line, .path-label { animation: none !important; transition: none !important; }
}

/* Game Feel Pass v1 — presentation only; rules and board data remain unchanged. */
.game-eyebrow, .coordinate, .legend { display: none; }
.topbar:has(+ .workspace.design-open) .game-eyebrow, .workspace.design-open .coordinate { display: block; }
.workspace.design-open .legend { display: flex; }
.game-area { background: transparent; border-color: transparent; box-shadow: none; }
.board-wrap { padding: 9px; border-radius: 24px; background: #EEEAF6; box-shadow: inset 0 2px 5px rgba(44,35,64,.08), 0 13px 28px rgba(44,35,64,.09); }
.path-layer { inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px); }
.board { gap: 10px; }
.cell.has-tile { border-color: #DDD7EA; box-shadow: 0 3px 0 #D5CEDE, 0 8px 13px rgba(44,35,64,.09); }
.cell.interactive:hover { box-shadow: 0 3px 0 #C9C1D8, 0 9px 17px rgba(44,35,64,.13); }
.cell.actionable-tile { border-color: var(--valid); box-shadow: 0 3px 0 #C7DCD6, 0 0 0 2px rgba(54,201,167,.1); }
.cell.selected { transform: translateY(-3px) scale(1.015); border-color: var(--selected); box-shadow: 0 5px 0 #B7ABE7, 0 12px 18px rgba(77,54,150,.18); }
.cell.selected::after, .cell.legal-move::after, .cell.legal-tile-target::after { content: none; }
.cell.legal-move, .cell.legal-tile-target { background: #EDFAF6; border: 2px dashed var(--valid); box-shadow: inset 0 0 0 3px rgba(54,201,167,.09), 0 3px 0 #C6E9DF; }
.cell.legal-move:hover, .cell.legal-tile-target:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 3px rgba(54,201,167,.15), 0 5px 0 #AADFD0, 0 10px 17px rgba(30,127,114,.13); }
.game-area.swap-active .cell.legal-tile-target:hover::before { content: "↔"; position: absolute; z-index: 8; left: 7px; bottom: 6px; color: var(--selected); font: 800 18px/1 system-ui, sans-serif; }
.game-area.move-active:not(.tutorial-mode) .cell:not(.legal-move):not(:has(.player-marker)):not(.disabled) { opacity: .68; }
.cell.valid-pulse { animation: validOnce .36s ease-out 1; }
@keyframes validOnce { 50% { box-shadow: 0 0 0 7px rgba(54,201,167,.2); } }
.endpoint { width: 22px; height: 22px; border-radius: 50%; font-size: 10px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(44,35,64,.12); }
.endpoint.start { background: #C8F0E6; color: #207F70; border-color: #79D9C2; }
.endpoint.end { background: #FFE9AA; color: #7F5814; border-color: #E8B852; border-radius: 3px 9px 3px 3px; transform: rotate(-9deg); }
.player-marker { bottom: -4px; width: 30px; height: 13px; border: 2px solid #fff; border-radius: 50%; background: var(--selected); box-shadow: 0 3px 0 #3B298D, 0 5px 9px rgba(44,35,64,.22); }
.player-marker::before { top: -17px; width: 19px; height: 19px; border: 2px solid #fff; background: #8E73F7; box-shadow: inset 0 -4px 0 rgba(46,28,118,.18); }
.player-marker::after { content: none; }
.motion-layer { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: visible; }
.motion-token, .motion-tile { position: absolute; display: grid; place-items: center; pointer-events: none; }
.motion-token { width: 30px; height: 13px; border: 2px solid #fff; border-radius: 50%; background: var(--selected); box-shadow: 0 3px 0 #3B298D, 0 5px 9px rgba(44,35,64,.22); }
.motion-token::before { content: ""; position: absolute; top: -17px; width: 19px; height: 19px; border: 2px solid #fff; border-radius: 50%; background: #8E73F7; }
.motion-tile { border: 2px solid #D2C9E4; border-radius: 18px; background: white; box-shadow: 0 5px 0 #C9C0DA, 0 11px 19px rgba(44,35,64,.17); color: var(--ink); font: 700 clamp(32px, 4vw, 54px) "STSong", "SimSun", serif; }
.cell.motion-arriving .tile-glyph, .cell.motion-arriving .player-marker { visibility: hidden; }
.path-line.path-enter { animation: gamePathDraw .3s ease-out both; }
.path-label.path-enter { animation: gamePathAppear .3s ease-out both; }
.path-exit { animation: gamePathFade .22s ease-in both; }
@keyframes gamePathDraw { from { opacity: 0; stroke-dasharray: 160; stroke-dashoffset: 160; } to { opacity: .62; stroke-dasharray: 160; stroke-dashoffset: 0; } }
@keyframes gamePathAppear { from { opacity: 0; transform: scale(.88); transform-origin: center; } to { opacity: 1; transform: scale(1); transform-origin: center; } }
@keyframes gamePathFade { to { opacity: 0; } }
.mode-panel { gap: 13px; }
.segmented { gap: 7px; padding: 6px; border: 1px solid #DED7ED; background: #EDE9F5; box-shadow: inset 0 2px 3px rgba(44,35,64,.06); }
.mode-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; border: 1px solid #DDD6EB; background: #fff; color: var(--ink); box-shadow: 0 3px 0 #D0C8DF; }
.mode-button.active { background: var(--hint); box-shadow: inset 0 0 0 1px var(--selected), 0 2px 0 #B7ABE7; }
.mode-button.active::before { content: none; }
.hud-icon { font: 800 21px/1 system-ui, sans-serif; }
.undo-button { width: 44px; padding: 8px; }
.resource-dots { display: inline-flex; gap: 3px; margin-left: 3px; }
.resource-dot { width: 8px; height: 8px; border: 1.5px solid var(--selected); border-radius: 2px; transform: rotate(45deg); background: var(--selected); }
.resource-dot.spent { background: transparent; opacity: .5; }
.path-hint-button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); box-shadow: none; }
.path-hint-button[aria-pressed="true"] { border: 0; background: transparent; color: var(--path-label-ink); }
.hint-switch { position: relative; width: 27px; height: 16px; border-radius: 10px; background: #C9C3D4; transition: background .16s; }
.hint-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: white; transition: transform .16s; }
.path-hint-button[aria-pressed="true"] .hint-switch { background: var(--path); }
.path-hint-button[aria-pressed="true"] .hint-switch::after { transform: translateX(11px); }
.mode-help { max-width: 560px; min-height: 35px; border: 0; border-left: 3px solid var(--hint-line); border-radius: 3px; background: transparent; font-size: 14px; }
.tutorial-mode .mode-help { border-color: var(--focus); background: transparent; }
.feedback.success { color: var(--path-label-ink); }
.feedback.relation-pop { animation: relationPop 1.55s ease-out both; }
@keyframes relationPop { 0% { opacity: 0; transform: translateY(6px); } 15%, 76% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-5px); } }
.game-area.complete-celebrating .endpoint.end { animation: endBounce .5s ease-out 1; }
.game-area.complete-celebrating .path-layer { animation: completePathGlow .65s ease-out 1; }
.game-area.complete-celebrating .board, .game-area.complete-celebrating .action-bar { pointer-events: none; }
@keyframes endBounce { 50% { transform: rotate(-9deg) scale(1.3); } }
@keyframes completePathGlow { 50% { filter: drop-shadow(0 0 5px var(--path-new)); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .motion-layer { display: none; }
  .path-line.path-enter, .path-label.path-enter, .path-exit, .feedback.relation-pop, .game-area.complete-celebrating .endpoint.end, .game-area.complete-celebrating .path-layer, .cell.valid-pulse { animation: none !important; }
}

/* Stable board layout: every message and HUD state occupies a reserved slot. */
.game-eyebrow { display: block; visibility: hidden; }
.topbar:has(+ .workspace.design-open) .game-eyebrow { visibility: visible; }
.game-area { display: flex; flex-direction: column; align-items: stretch; }
.top-info-slot { flex: 0 0 94px; height: 94px; display: grid; grid-template-rows: 26px 34px 34px; align-items: center; overflow: hidden; }
.goal-line { grid-row: 1; justify-self: center; display: inline-flex; align-items: center; gap: 7px; min-height: 24px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.goal-label { color: var(--path-label-ink); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.goal-mark { width: 10px; height: 10px; border: 2px solid var(--path); border-radius: 50%; box-shadow: inset 0 0 0 1px #fff; }
.tutorial-visual { grid-row: 2; min-height: 0; margin: 0; }
.tutorial-controls { grid-row: 3; margin: 0; }
.tutorial-controls .button { padding: 5px 11px; font-size: 12px; }
.board-wrap, .tutorial-mode .board-wrap { flex: none; width: min(540px, max(280px, calc(100vh - 330px)), 100%); margin: 0 auto; }
.context-slot { position: relative; flex: 0 0 48px; height: 48px; display: grid; place-items: center; overflow: hidden; }
.mode-help, .tutorial-mode .mode-help { display: flex; align-items: center; justify-content: center; width: min(100%, 560px); height: 48px; min-height: 0; max-height: 48px; margin: 0; padding: 0 8px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.35; text-align: center; overflow: hidden; }
.tutorial-mode .mode-help { color: var(--ink); }
.context-slot:has(.feedback.visible) .mode-help { opacity: 0; }
.feedback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; width: 100%; height: 48px; min-height: 0; margin: 0; padding: 0 10px; font-size: 13px; font-weight: 700; line-height: 1.35; overflow: hidden; }
.feedback.error { max-width: none; margin: 0; padding: 0 10px; border: 0; border-radius: 0; background: transparent; color: #AC691B; }
.feedback.visible.error { animation: contextAppear .2s ease-out both; }
@keyframes contextAppear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.action-bar { flex: 0 0 60px; height: 60px; min-height: 60px; margin: 0; flex-wrap: nowrap; }
.action-button[data-action="move"] { width: 98px; }
.action-button[data-action="tile"] { width: 160px; }
.undo-button { width: 94px; }
.path-hint-button { flex: 0 0 100px; width: 100px; justify-content: center; white-space: nowrap; }
.mode-button.context-nudge { animation: validOnce .4s ease-out 1; }
@media (max-width: 650px) {
  .action-bar { flex-basis: 94px; height: 94px; min-height: 94px; flex-wrap: wrap; align-content: center; }
  .path-hint-button { height: 28px; }
}
@media (max-width: 420px) {
  .action-button[data-action="move"] { width: 78px; }
  .action-button[data-action="tile"] { width: 132px; }
  .undo-button { width: 78px; }
  .mode-button { padding: 7px 5px; gap: 3px; font-size: 13px; }
  .hud-icon { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .feedback.visible.error, .mode-button.context-nudge { animation: none !important; }
}

/* Game Feel v1 layout refinement: one centered action cluster, quieter auxiliary HUD. */
.top-info-slot { position: relative; }
.goal-line { gap: 9px; font-size: 19px; font-weight: 600; color: var(--ink); }
.goal-label { font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.goal-mark { width: 12px; height: 12px; }
.top-info-slot .path-hint-button { position: absolute; top: 0; right: 2px; width: 100px; height: 27px; padding: 3px 5px; font-size: 12px; }
.mode-help, .tutorial-mode .mode-help { font-size: 21px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.tutorial-mode .mode-help { font-weight: 700; }
.action-bar { justify-content: center; width: 100%; gap: 0; }
.segmented { display: flex; justify-content: center; align-items: center; gap: 9px; width: auto; padding: 6px; border-radius: 15px; }
.segmented .mode-button { flex: none; width: 128px; height: 48px; min-height: 48px; padding: 8px 10px; border-radius: 10px; }
.segmented .hud-icon { width: 22px; text-align: center; }
.resource-dots { flex: none; }
.path-label { transform-box: fill-box; transform-origin: center; transform: scale(.87); }
.path-label rect { fill: #E6F8F4; stroke: #B9E8DF; stroke-width: 1.5; }
.path-label text { fill: var(--path-label-ink); font-size: 16px; font-weight: 700; }
@keyframes gamePathAppear { from { opacity: 0; transform: scale(.74); } to { opacity: 1; transform: scale(.87); } }
.endpoint.end { top: 5px; right: 5px; width: 19px; height: 19px; border-width: 1.5px; font-size: 9px; box-shadow: 0 1px 2px rgba(44,35,64,.08); }
@media (max-width: 650px) {
  .top-info-slot { flex-basis: 124px; height: 124px; grid-template-rows: 26px 34px 34px 30px; }
  .top-info-slot .path-hint-button { top: 96px; right: calc(50% - 50px); }
  .goal-line { font-size: 18px; }
  .mode-help, .tutorial-mode .mode-help { font-size: clamp(16px, 3.4vw, 21px); }
  .action-bar { flex-basis: 60px; height: 60px; min-height: 60px; flex-wrap: nowrap; }
  .segmented .mode-button { width: min(116px, calc((100vw - 66px) / 3)); }
}
@media (max-width: 380px) {
  .goal-line { font-size: 16px; }
  .goal-label { font-size: 13px; }
  .segmented { gap: 4px; padding: 4px; }
  .segmented .mode-button { padding: 6px 4px; gap: 3px; font-size: 13px; }
  .segmented .hud-icon { width: 17px; font-size: 17px; }
  .resource-dots { gap: 2px; margin-left: 0; }
  .resource-dot { width: 6px; height: 6px; }
}

/* Character-relation results have their own reserved space above the board. */
.top-info-slot { flex-basis: 136px; height: 136px; grid-template-rows: 26px 48px 30px 32px; }
.relation-feedback { grid-row: 2; align-self: stretch; justify-self: center; display: flex; align-items: center; justify-content: center; width: min(100%, 640px); padding: 0 12px; color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1.3; text-align: center; white-space: pre-line; overflow: hidden; opacity: 0; transition: opacity .18s ease-out; }
.relation-feedback.visible { opacity: 1; }
.relation-feedback.success { color: var(--path-label-ink); }
.tutorial-visual { grid-row: 3; }
.tutorial-controls { grid-row: 4; }
.board-wrap, .tutorial-mode .board-wrap { width: min(540px, max(280px, calc(100vh - 365px)), 100%); }
@media (max-width: 650px) {
  .top-info-slot { flex-basis: 166px; height: 166px; grid-template-rows: 26px 48px 30px 32px 30px; }
  .top-info-slot .path-hint-button { top: 138px; }
  .board-wrap, .tutorial-mode .board-wrap { width: min(540px, max(280px, calc(100vh - 395px)), 100%); }
  .relation-feedback { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .relation-feedback { transition: none; }
}

/* A1 opening frame: goal → board → tutorial sentence → start/skip. */
.game-area[data-tutorial-phase="goal"] { display: grid; grid-template-columns: 1fr; grid-template-rows: 136px auto 48px 60px; }
.game-area[data-tutorial-phase="goal"] .top-info-slot { display: contents; }
.game-area[data-tutorial-phase="goal"] .goal-line { grid-row: 1; align-self: end; margin-bottom: 8px; }
.game-area[data-tutorial-phase="goal"] .relation-feedback,
.game-area[data-tutorial-phase="goal"] .path-hint-button,
.game-area[data-tutorial-phase="goal"] .action-bar { display: none; }
.game-area[data-tutorial-phase="goal"] .board-wrap { grid-row: 2; }
.game-area[data-tutorial-phase="goal"] .context-slot { grid-row: 3; }
.game-area[data-tutorial-phase="goal"] .tutorial-controls { grid-row: 4; align-self: center; min-height: 52px; margin: 0; }
.game-area[data-tutorial-phase="goal"] #tutorial-acknowledge { min-width: 116px; min-height: 42px; padding: 9px 16px; border-color: var(--selected); background: var(--selected); color: #fff; font-size: 15px; box-shadow: 0 3px 0 #4D34BA; }
.game-area[data-tutorial-phase="goal"] #tutorial-skip { min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font-size: 14px; font-weight: 700; opacity: 1; text-decoration: none; }
@media (max-width: 650px) {
  .game-area[data-tutorial-phase="goal"] { grid-template-rows: 166px auto 48px 60px; }
}

/* The tutorial controls are real siblings of the action bar below the board. */
.game-area[data-tutorial-phase="goal"] { display: flex; }
.game-area[data-tutorial-phase="goal"] .top-info-slot { display: grid; }
.game-area[data-tutorial-phase="goal"] .goal-line { align-self: center; margin-bottom: 0; }
.game-area[data-tutorial-phase="goal"] .relation-feedback { display: flex; }
.top-info-slot { flex: 0 0 70px; height: 70px; grid-template-rows: 26px 44px; }
.relation-feedback { font-size: 13px; line-height: 1.12; }
.tutorial-visual { position: absolute; top: 26px; left: 0; right: 0; height: 44px; }
.top-info-slot:has(.relation-feedback.visible) .tutorial-visual { visibility: hidden; }
.bottom-hud-slot { position: relative; flex: 0 0 60px; height: 60px; display: flex; align-items: center; justify-content: center; }
.bottom-hud-slot .tutorial-controls { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; min-height: 0; margin: 0; z-index: 1; }
.bottom-hud-slot .tutorial-controls[hidden] { display: none !important; }
.bottom-hud-slot:has(.tutorial-controls:not([hidden])) .action-bar { visibility: hidden; }
.bottom-hud-slot .action-bar { margin: 0; }
.game-area[data-tutorial-phase="goal"] .tutorial-controls { grid-row: auto; min-height: 0; }
.game-area[data-tutorial-phase="goal"] #tutorial-acknowledge { min-width: 132px; min-height: 46px; font-size: 16px; }
.game-area[data-tutorial-phase="goal"] #tutorial-skip { min-height: 46px; padding: 10px 15px; font-size: 15px; }
.board-wrap, .tutorial-mode .board-wrap { width: min(540px, max(280px, calc(100vh - 310px)), 100%); }
@media (max-width: 650px) {
  .top-info-slot { flex-basis: 100px; height: 100px; grid-template-rows: 26px 44px 30px; }
  .top-info-slot .path-hint-button { top: 72px; }
  .board-wrap, .tutorial-mode .board-wrap { width: min(540px, max(280px, calc(100vh - 340px)), 100%); }
}

/* Once Start is pressed, the action bar remains visible; Skip becomes a small line below it. */
.bottom-hud-slot:has(.tutorial-controls:not([hidden])) .action-bar { visibility: visible; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot { flex-basis: 86px; height: 86px; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot .action-bar { align-self: flex-start; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot .tutorial-controls { inset: auto 0 0; height: 26px; min-height: 26px; gap: 10px; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot #tutorial-skip { padding: 3px 7px; font-size: 11px; font-weight: 600; opacity: .7; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot #tutorial-acknowledge { min-height: 24px; padding: 2px 10px; font-size: 11px; }
.game-area[data-tutorial-phase="goal"] .bottom-hud-slot { flex-basis: 60px; height: 60px; }
.game-area[data-tutorial-phase="goal"] .bottom-hud-slot .tutorial-controls { inset: 0; height: 60px; }
/* Pixel art preview: original 16px glyph courier, crisp integer geometry. */
:root {
 --ink:#573128; --muted:#866259; --paper:#fffbf7; --panel:#ffffff; --line:#eed9c7;
 --focus:#d64824; --selected:#d74b28; --valid:#ee7152; --valid-deep:#a53e24;
 --valid-soft:#ffefe1; --path:#ef8469; --path-new:#d85636; --path-label:#fff3e9;
 --path-label-line:#efc29a; --path-label-ink:#a53e24; --hint:#fff2e6; --hint-line:#e9c29f;
 --keyword:#aa4228; --keyword-soft:#fff2e6; --keyword-line:#efc49f; --reminder:#ffc84d;
 --error:#ae542d; --dim:rgba(48,58,53,.12); --shadow:none;
 --courier:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 18' shape-rendering='crispEdges'%3E%3Cpath fill='%23303a35' d='M3 1h10v2h2v11h-2v3h-3v-3H6v3H3v-3H1V3h2z'/%3E%3Cpath fill='%23efba52' d='M3 3h10v10H3z'/%3E%3Cpath fill='%23ffda78' d='M3 3h10v3H3z'/%3E%3Cpath fill='%23303a35' d='M5 7h2v3H5zm5 0h2v3h-2z'/%3E%3Cpath fill='%23d48939' d='M3 11h2v2H3zm8 0h2v2h-2z'/%3E%3C/svg%3E");
}
body { background:var(--paper); }
::selection { background:#efd16f; color:var(--ink); }
* { scrollbar-color:#ecbf98 var(--paper); scrollbar-width:thin; }
button:focus-visible,select:focus-visible { outline:3px dashed var(--focus); outline-offset:5px; }
.app-shell { max-width:1160px; }
.shell-screen { min-height:calc(100svh - 48px); }
.shell-card { position:relative; width:min(780px,100%); border:0; border-radius:0; background:none; box-shadow:none; padding:40px 32px; }
.start-card { text-align:center; }
.eyebrow { display:none; }
.start-card h1 { font-family:'SimSun',serif; font-weight:900; font-size:clamp(46px,8vw,80px); letter-spacing:.08em; text-shadow:3px 3px 0 var(--stage-depth); }
.start-card h1::after { content:'GLYPH TRAIL'; display:block; font:700 14px/1.5 'Courier New',monospace; letter-spacing:.36em; margin-top:12px; color:var(--muted); text-shadow:none; }
.shell-card .shell-lead { font-size:20px; margin:24px 0; }
.start-card > p:not(.shell-lead) { max-width:440px; margin:24px auto; font-size:14px; }
.shell-wordmark { gap:0; margin:66px auto 32px; padding-bottom:18px; border-bottom:4px solid var(--stage-line); width:fit-content; position:relative; }
.shell-wordmark::after { content:''; position:absolute; left:0; right:0; bottom:-12px; height:4px; background:#fae8d9; }
.shell-wordmark span { position:relative; border:3px solid var(--ink); border-radius:0; width:80px; background:#ffdb64; box-shadow:inset 0 -7px 0 #eebd42; font-family:'SimSun',serif; }
.shell-wordmark span:nth-of-type(2) { background:#ffbd83; box-shadow:inset 0 -7px 0 #e4775c; }
.shell-wordmark span:nth-of-type(3) { background:#ffa394; box-shadow:inset 0 -7px 0 #ec7d70; }
.shell-wordmark span:nth-of-type(4) { background:#ffd3ad; box-shadow:inset 0 -7px 0 #de9b8a; }
.shell-wordmark span:first-child::before { content:''; position:absolute; bottom:calc(100% + 3px); width:40px; height:45px; background:var(--courier) center/contain no-repeat; image-rendering:pixelated; animation:courierHello 1.8s steps(2,end) infinite; }
.shell-wordmark i { min-width:38px; padding:3px 0; border-bottom:4px solid #d58d7b; background:#fff5ed; }
.shell-actions { justify-content:center; gap:16px; }
.button,.mode-button,.path-hint-button,.text-button,select { border-radius:0; }
.button { min-height:44px; border:2px solid var(--ink); font-size:14px; font-weight:800; box-shadow:0 4px 0 #e4c5a9; transition:transform .1s steps(2),background .1s; }
.button.primary { background:var(--selected); border-color:#b04024; color:#ffffff; box-shadow:0 4px 0 #99371e; }
.button.secondary { background:#ffffff; color:var(--ink); border-color:#d59f91; }
.button.subtle { border-color:transparent; background:none; box-shadow:none; color:var(--muted); }
.button:hover { transform:translateY(-2px); background:#fff5ed; color:var(--ink); }
.button.primary:hover { background:#ed5a35; color:white; }
.button:active { transform:translateY(3px); box-shadow:none; }
.level-group { border-top:2px solid var(--line); padding:14px 0; }
.level-group h3 { color:var(--selected); }
.level-options { gap:14px; }
.stage-card { text-align:center; }
.stage-card::before,.ending-card::before { content:''; display:block; width:64px; height:72px; margin:0 auto 28px; background:var(--courier) center/contain no-repeat; image-rendering:pixelated; }
.topbar { border-bottom:2px solid var(--line); padding-bottom:14px; }
.topbar h1 { font-family:'SimSun',serif; letter-spacing:.08em; }
.topbar .button { font-size:12px; min-height:36px; padding:6px 10px; }
.game-area,.debug-panel { border-radius:0; box-shadow:none; background:transparent; }
.game-area { border:0; }
.board { gap:12px; }
.cell,.cell.has-tile { border:3px solid #d6a092; border-radius:0; background:#fff2bf; box-shadow:inset 0 -6px 0 #ebd78c; transition:background .1s,transform .1s steps(2); }
.cell.empty { border:2px dashed #e5c3a6; background:#fff5ed; box-shadow:inset 0 4px 0 #faecdf; }
.cell.disabled { background:#fbe8d8; border:0; box-shadow:none; opacity:.45; }
.cell.selected { border-color:#d35131; background:#ffebd9; box-shadow:inset 0 -6px 0 #f7d5b8; }
.cell.interactive:hover { transform:translateY(-2px); border-color:var(--selected); box-shadow:inset 0 -6px 0 #f7d5b8; }
.cell.legal-move,.cell.legal-tile-target { border:3px dashed #d55839; background:#ffedde; box-shadow:inset 0 -6px 0 #f5d3b5; animation:none; }
.cell.locked-tile { background:#f3eae2; border-color:#c4a69f; }
.cell.selected::after,.cell.legal-move::after,.cell.legal-tile-target::after,.lock-badge,.keyword-chip { border-radius:0; }
.tile-glyph { font-family:'SimSun',serif; color:#573128; }
.player-marker { bottom:-4px; width:32px; height:36px; border:0; border-radius:0; background:var(--courier) center/contain no-repeat; box-shadow:none; image-rendering:pixelated; }
.player-marker::before,.player-marker::after { content:none; }
.endpoint,.endpoint.start,.endpoint.end { border-radius:0; transform:none; box-shadow:none; border:2px solid #837449; background:#efd278; color:#4e472f; }
.endpoint.start { background:#ffdaba; border-color:#d67056; color:#8a3824; }
.goal-mark,.hint-switch,.hint-switch::after,.resource-dot,.status-badge,.count-pill { border-radius:0; }
.path-line { stroke-linecap:square; }
.path-label rect { fill:#fff3e9; stroke:#e8a493; rx:0; ry:0; }
.mode-help,.tutorial-mode .mode-help { border-radius:0; color:var(--ink); background:none; }
.segmented { border-radius:0; background:#fcf0e5; border:2px solid #e9c8ab; gap:8px; }
.segmented .mode-button { border-radius:0; background:#fffbf7; box-shadow:0 3px 0 #e6cab1; color:var(--ink); }
.segmented .mode-button.active { background:#d74b28; color:#fff; box-shadow:0 3px 0 #9c3920; }
.path-hint-button,.path-hint-button[aria-pressed="true"] { border-radius:0; background:#fff1e5; color:#a53e24; border:2px solid #e8a392; }
.complete-overlay { background:rgba(255,249,245,.94); backdrop-filter:none; }
.complete-card { border:3px solid #dc8c78; border-radius:0; background:#ffffff; box-shadow:8px 8px 0 #f4d9c1; }
.feedback.error { border-radius:0; background:#fff0d7; }
.game-area[data-tutorial-phase="goal"] #tutorial-acknowledge { border-color:#b04024; background:var(--selected); box-shadow:0 4px 0 #99371e; }
.game-area[data-tutorial-phase="goal"] #tutorial-skip { border-radius:0; background:#ffffff; border:2px solid #dbbea5; }
@keyframes courierHello { 0%,80%,100% { transform:translateY(0); } 40% { transform:translateY(-8px); } }
@media(max-width:650px) {
 .shell-card { padding:28px 8px; }
 .shell-wordmark span { width:clamp(45px,13vw,70px); }
 .shell-wordmark i { min-width:26px; }
 .shell-wordmark { margin-top:60px; }
 .shell-actions { gap:12px; }
 .topbar { align-items:flex-start; gap:10px; }
 .topbar h1 { font-size:24px; }
 .top-actions { gap:6px; }
 .topbar .button { font-size:11px; padding:5px 6px; }
 .cell,.cell.has-tile { border-width:2px; }
 .player-marker { width:24px; height:27px; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; } }
/* Board tray and in-flight pieces share the same pixel materials. */
.board-wrap { border-radius:0; background:#fff1e5; box-shadow:0 6px 0 #edd4be; border:0; }
.motion-token { width:32px; height:36px; border:0; border-radius:0; background:var(--courier) center/contain no-repeat; box-shadow:none; image-rendering:pixelated; }
.motion-token::before { content:none; }
.motion-tile { border:3px solid #d6a092; border-radius:0; background:#fff2bf; box-shadow:inset 0 -6px 0 #ebd78c; }
.cell.legal-move:hover,.cell.legal-tile-target:hover { box-shadow:inset 0 -6px 0 #fad4b2; }
.cell.actionable-tile { border-color:#e17d64; box-shadow:inset 0 -6px 0 #f6dcc6; }
.mode-button { border-color:#e2c3a7; }
.hint-switch { background:#ddc8b6; }
.resource-dot { transform:none; }
.cell.tutorial-focus { animation:none; outline:3px dashed #d15739; }
.tutorial-mode .cell.tutorial-dimmed { background-color:#fff1e5; }
@media(max-width:650px) { .motion-token { width:24px; height:27px; } }
/* Soft pixel pieces, warm coral actions, and pre-level rule cards. */
:root { --selected:#bd4932; --focus:#963823; --ink:#49352f; --muted:#796057; --paper:#fffcfa; --stage-dark:#963b2c; --stage-soft:#fff5f1; --stage-line:#e8b9ac; --stage-tile:#fffdfb; --stage-depth:#f4dcd3; --valid-deep:#9c482b; --path-label-ink:#9c482b; --keyword:#963823; }
.cell,.cell.has-tile,.motion-tile { border-radius:7px; border-width:2px; box-shadow:inset 0 -4px 0 #ead09c; }
.cell.empty { border-radius:7px; }
.board-wrap { border-radius:10px; box-shadow:0 4px 0 #e9d4c6; }
.cell.selected,.cell.interactive:hover,.cell.actionable-tile,.cell.legal-move,.cell.legal-tile-target { box-shadow:inset 0 -4px 0 #edc2a3; }
.shell-wordmark span { border-radius:6px; border-width:2px; }
.button,.segmented,.segmented .mode-button { border-radius:5px; }
.button.primary,.segmented .mode-button.active { background:var(--selected); color:#fff; border-color:#973b28; box-shadow:0 3px 0 #873823; }
.button.primary:hover { background:#a93d29; }
#select-back { display:flex; align-items:center; gap:9px; margin-top:28px; background:#49352f; color:white; border-color:#49352f; box-shadow:0 3px 0 #2b211d; padding:11px 20px; }
#select-back::before { content:''; width:9px; height:9px; border-left:2px solid currentColor; border-bottom:2px solid currentColor; transform:rotate(45deg); }
#select-back:hover { background:#65493f; }
.level-options .button { background:#fffdf9; border-color:#e2cbbb; box-shadow:0 2px 0 #ecdcd0; }
.rule-brief { max-width:750px; padding:32px; border:2px solid #e6cabc; border-radius:14px; background:#fffdf9; margin:20px 0; }
.rule-brief h2 { font-size:clamp(25px,4vw,34px); margin-bottom:8px; }
.rule-brief .brief-subtitle { margin:0 0 24px; font-size:14px; color:var(--selected); font-weight:700; }
.rule-brief p,.rule-brief li { line-height:1.8; font-size:15px; }
.rule-brief strong { color:var(--ink); }
.rule-brief ul { padding-left:22px; color:var(--muted); }
.rule-brief .brief-tip { background:#fff0d6; color:#765037; padding:12px 16px; border-radius:7px; margin:22px 0; }
.budget-demo { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:16px; background:#fff1de; padding:28px 12px; margin-bottom:24px; border-radius:9px; font-size:14px; }
.budget-pips { display:flex; gap:6px; }
.budget-pips i { width:21px; height:21px; background:#edaa42; border:2px solid #b87723; border-radius:4px; box-shadow:inset 0 -3px 0 #da902f; }
.budget-pips i.spent { background:transparent; border-style:dashed; box-shadow:none; opacity:.5; }
.structure-examples { display:grid; grid-template-columns:1fr 1fr; gap:24px; margin-top:24px; }
.structure-examples section + section { border-left:1px solid #ead4c5; padding-left:24px; }
.structure-examples h3 { font-size:16px; margin:0 0 14px; }
.glyph-example { display:flex; align-items:center; justify-content:center; gap:8px; min-height:106px; background:#fff3dc; border-radius:8px; padding:10px; }
.glyph-example span { display:grid; place-items:center; width:43px; height:43px; border:2px solid #dfba83; background:#ffe3a0; border-radius:5px; font:700 27px SimSun,serif; }
.glyph-example b { font-size:22px; margin-left:8px; }
.vertical-pair { display:grid; gap:4px; }
.structure-examples p { margin:12px 0 8px; font-size:14px; }
.wrong-example { font-size:13px; line-height:1.7; color:#9f4433; }
@media(max-width:550px) { .rule-brief { padding:22px 18px; } .structure-examples { grid-template-columns:1fr; gap:20px; } .structure-examples section + section { border-left:0; border-top:1px solid #ead4c5; padding:20px 0 0; } .budget-demo { gap:10px; } .budget-pips i { width:17px; height:17px; } }
/* Shared coral palette across every stage and introduction. */
[data-stage] { --focus:var(--selected); --path:var(--selected); --path-label-ink:var(--stage-dark); --valid-deep:var(--stage-dark); --keyword:var(--stage-dark); }
[data-stage] .button.primary,[data-stage] .segmented .mode-button.active { background:var(--selected); border-color:var(--stage-dark); box-shadow:0 3px 0 var(--stage-dark); }
[data-stage] .button.primary:hover { background:var(--stage-dark); }
#game-screen .topbar { border-color:var(--stage-line); }
#game-screen .board-wrap,#game-screen .segmented { background:var(--stage-soft); box-shadow:0 4px 0 var(--stage-depth); border-color:var(--stage-line); }
#game-screen .cell.has-tile,#game-screen .motion-tile { background:var(--stage-tile); border-color:var(--stage-line); box-shadow:inset 0 -4px 0 var(--stage-depth); }
#game-screen .cell.disabled,#game-screen .cell.empty { background:var(--stage-soft); border-color:var(--stage-line); }
#game-screen .cell.selected,#game-screen .cell.legal-move,#game-screen .cell.legal-tile-target { background:var(--stage-depth); border-color:var(--selected); }
#game-screen .path-label rect { fill:var(--stage-soft); stroke:var(--stage-line); }
#game-screen .mode-help,#game-screen .goal-label { color:var(--stage-dark); }
#game-screen .top-actions { display:flex; align-items:center; flex-wrap:nowrap; gap:8px; }
#game-screen .top-actions .path-hint-button { position:static; flex:0 0 auto; width:auto; min-height:36px; padding:6px 10px; background:var(--stage-soft); border:1px solid var(--stage-line); border-radius:5px; color:var(--stage-dark); font-size:12px; }
#game-screen .hint-switch { background:#d1cdd8; }
#game-screen .path-hint-button[aria-pressed="true"] .hint-switch { background:var(--selected); }
#game-screen .top-info-slot { flex-basis:70px; height:70px; grid-template-rows:26px 44px; }
.rule-brief { max-width:650px; padding:28px 32px; border-color:var(--stage-line); }
.rule-brief h2 { text-align:center; margin-bottom:4px; }
.rule-brief .brief-subtitle { text-align:center; margin-bottom:20px; }
.rule-brief .brief-summary { text-align:center; font-size:15px; line-height:1.8; color:var(--ink); margin:20px 0 0; }
.rule-brief .shell-actions { margin-top:24px; }
.budget-demo { background:var(--stage-soft); padding:20px 10px; gap:22px; margin:0; }
.swap-demo { position:relative; display:flex; align-items:center; gap:6px; padding-bottom:25px; }
.swap-demo > span { display:grid; place-items:center; width:36px; height:36px; background:#ffe5a1; border:2px solid #dcb969; border-radius:5px; font:700 24px SimSun,serif; animation:swapWiggle 2.4s steps(3,end) infinite; }
.swap-demo > span:nth-of-type(2) { animation-direction:reverse; }
.swap-demo small { position:absolute; bottom:0; width:100%; text-align:center; color:var(--stage-dark); font-size:12px; }
.structure-examples { gap:20px; margin-top:10px; }
.structure-examples section + section { padding-left:20px; border-color:var(--stage-line); }
.structure-examples h3,.structure-examples p { text-align:center; }
.glyph-example { position:relative; padding-bottom:25px; background:var(--stage-soft); min-height:124px; }
.example-courier { position:absolute; bottom:0; right:16px; width:24px; height:27px; background:var(--courier) center/contain no-repeat; image-rendering:pixelated; animation:courierHello 2s steps(2,end) infinite; }
@keyframes swapWiggle { 0%,75%,100% { transform:translateY(0) rotate(0); } 35% { transform:translateY(-4px) rotate(-6deg); } }
@media(max-width:650px) { #game-screen .topbar { flex-direction:column; } #game-screen .top-actions { width:100%; justify-content:flex-end; } #game-screen .top-actions .button { white-space:nowrap; } }
@media(max-width:550px) { .rule-brief { padding:22px 16px; } .structure-examples { grid-template-columns:1fr 1fr; gap:10px; } .structure-examples section + section { border-top:0; border-left:1px solid var(--stage-line); padding:0 0 0 10px; } .glyph-example { gap:4px; padding:8px 4px 25px; } .glyph-example span { width:30px; height:32px; font-size:22px; } .glyph-example b { font-size:17px; margin-left:0; } .structure-examples h3 { font-size:14px; } .structure-examples p { font-size:13px; } .budget-demo { gap:12px; } .budget-pips { gap:3px; } .budget-pips i { width:14px; height:16px; } .swap-demo > span { width:30px; height:32px; } }
@media(prefers-reduced-motion:reduce) { .swap-demo > span,.example-courier { animation:none; } }
/* Consistent stage controls and a pictorial destination. */
#game-screen .topbar { flex-direction:column; align-items:stretch; gap:16px; }
#game-screen .top-actions { width:100%; justify-content:flex-start; }
#game-screen .top-actions .button,#game-screen .top-actions .path-hint-button { min-height:36px; padding:6px 10px; font-size:12px; font-weight:700; background:#fff; color:var(--stage-dark); border:1px solid var(--stage-line); border-radius:5px; box-shadow:0 3px 0 var(--stage-depth); }
#game-screen .top-actions .path-hint-button { margin-left:auto; }
#game-screen .top-actions .button:hover,#game-screen .top-actions .path-hint-button:hover { background:var(--stage-soft); }
[data-stage] .button.secondary,[data-stage] .segmented .mode-button { background:#fff; color:var(--stage-dark); border-color:var(--stage-line); box-shadow:0 3px 0 var(--stage-depth); }
[data-stage] .segmented .mode-button.active { background:var(--selected); color:white; border-color:var(--stage-dark); box-shadow:0 3px 0 var(--stage-dark); }
[data-stage] .button.secondary:hover,[data-stage] .segmented .mode-button:not(.active):not(:disabled):hover { background:var(--stage-soft); }
[data-stage] .button.subtle { color:var(--stage-dark); }
[data-stage] .complete-card { background:var(--stage-tile); border-color:var(--stage-line); box-shadow:6px 6px 0 var(--stage-depth); }
.level-group[data-stage] .button { color:var(--stage-dark); border-color:var(--stage-line); background:var(--stage-tile); box-shadow:0 3px 0 var(--stage-depth); }
#game-screen .endpoint.end { width:24px; height:28px; top:5px; right:5px; border:0; border-radius:0; background:none; box-shadow:none; transform:none; }
.endpoint.end::before { content:''; position:absolute; left:4px; top:2px; width:3px; height:24px; background:var(--stage-dark); }
.endpoint.end::after { content:''; position:absolute; left:7px; top:2px; width:15px; height:13px; background:var(--selected); clip-path:polygon(0 0,33.333% 0,33.333% 20%,66.667% 20%,66.667% 40%,100% 40%,100% 60%,66.667% 60%,66.667% 80%,33.333% 80%,33.333% 100%,0 100%); }
#game-screen .goal-line { color:var(--ink); }
#game-screen .game-area[data-tutorial-phase="goal"] #tutorial-acknowledge { background:var(--selected); border-color:var(--stage-dark); box-shadow:0 3px 0 var(--stage-dark); }
#game-screen #tutorial-skip { background:#fff; border-color:var(--stage-line); color:var(--stage-dark); }
#game-screen .keyword-chip { background:var(--stage-soft); border-color:var(--stage-line); color:var(--stage-dark); }
#game-screen .mode-button.tutorial-action-focus { background:var(--stage-soft); border-color:var(--selected); color:var(--stage-dark); }
#game-screen .endpoint.end { width:18px; height:22px; top:3px; right:3px; }
#game-screen .endpoint.end::before { left:2px; height:19px; width:2px; }
#game-screen .endpoint.end::after { left:4px; width:12px; height:10px; }

/* Small pixel corners and crisp depth keep the softer palette game-like. */
.cell,.cell.has-tile,.cell.empty,.motion-tile,.shell-wordmark span { border-radius:3px; }
.board-wrap,.rule-brief,.budget-demo,.glyph-example { border-radius:3px; }
.button,.segmented,.segmented .mode-button,
#game-screen .top-actions .button,#game-screen .top-actions .path-hint-button { border-radius:2px; }
.hint-switch,.hint-switch::after,.budget-pips i,.swap-demo > span,.glyph-example span { border-radius:0; }
.rule-brief { background:#fffefd; }
::selection { background:#f4dcd3; color:#49352f; }
/* Shared violet pixel palette. Corner markers leave glyphs unobstructed. */
:root { --selected:#8050c5; --focus:#64359e; --ink:#40334f; --muted:#786888; --paper:#fdfbff; --stage-dark:#64359e; --stage-soft:#f7f2fc; --stage-line:#ceb9e5; --stage-tile:#fefcff; --stage-depth:#e9ddf5; --valid-deep:#64359e; --path-label-ink:#64359e; --keyword:#64359e; }
.shell-wordmark span { background:#e5d3ff; border-color:#68517e; box-shadow:inset 0 -7px 0 #c8aceb; }
.shell-wordmark span:nth-of-type(2) { background:#d7bbf5; box-shadow:inset 0 -7px 0 #b395d9; }
.shell-wordmark span:nth-of-type(3) { background:#c4a0ed; box-shadow:inset 0 -7px 0 #a47bce; }
.shell-wordmark span:nth-of-type(4) { background:#eadcff; box-shadow:inset 0 -7px 0 #ceb5eb; }
.shell-wordmark::after { background:var(--stage-depth); }
.shell-wordmark i { background:var(--stage-soft); border-color:var(--stage-line); }
.start-card .button.secondary { border-color:var(--stage-line); box-shadow:0 3px 0 var(--stage-depth); }
.start-card .button:not(.primary):hover { background:var(--stage-soft); }
.button.primary,.segmented .mode-button.active { border-color:var(--stage-dark); box-shadow:0 3px 0 var(--stage-dark); }
.button.primary:hover { background:var(--stage-dark); }
#select-back { background:#514060; border-color:#514060; box-shadow:0 3px 0 #382c43; }
#select-back:hover { background:#675278; }
.rule-brief { background:var(--stage-tile); }
.cell.tutorial-focus { outline-color:var(--selected); }
.tutorial-mode .cell.tutorial-dimmed { background-color:var(--stage-soft); }
#game-screen .endpoint.end { top:-7px; right:-7px; pointer-events:none; }
#game-screen .player-marker { left:clamp(12.5px,66.6667%,calc(100% - 12.5px)); right:auto; bottom:5px; width:25px; height:28.125px; transform:translateX(-50%); pointer-events:none; }
.motion-token { width:25px; height:28.125px; }
.hint-switch { flex-shrink:0; transition:background-color 160ms ease-out; }
.hint-switch::after { transform:translateX(0); transition:transform 160ms ease-out; }
#game-screen .path-hint-button:hover { transform:none; }
::selection { background:var(--stage-depth); color:var(--ink); }

/* Spacious tutorial footer, raised movable tiles, and stable path visibility. */
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot { flex-basis:126px; height:126px; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot .tutorial-controls { height:46px; min-height:46px; gap:16px; }
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot #tutorial-acknowledge,
.tutorial-mode:not([data-tutorial-phase="goal"]) .bottom-hud-slot #tutorial-skip { min-height:40px; padding:9px 18px; font-size:14px; opacity:1; }
#game-screen .cell.has-tile { box-shadow:inset 0 -5px 0 var(--stage-depth),0 3px 0 var(--stage-line); }
#game-screen .cell.has-tile.selected,#game-screen .cell.has-tile.actionable-tile,
#game-screen .cell.has-tile.legal-tile-target { box-shadow:inset 0 -5px 0 #ceb6e7,0 3px 0 #b99bd6; }
#game-screen .path-layer { transition:opacity 160ms ease-out; }
.path-hint-intro { color:var(--stage-dark); line-height:1.7; }

/* A target has one dashed boundary; neutral violet replaces warm remnants. */
#game-screen .cell.tutorial-focus.legal-tile-target,
#game-screen .cell.tutorial-focus.legal-move { outline:none; }
#game-screen .cell.empty { box-shadow:inset 0 4px 0 #e7e1ee; }
#game-screen .cell.empty.legal-tile-target,
#game-screen .cell.empty.legal-tile-target:hover { box-shadow:inset 0 -4px 0 #d7cede; }
* { scrollbar-color:#b9afc5 var(--paper); }
/* Keep the target border as its single focus cue, including keyboard focus. */
#game-screen .cell.empty.legal-tile-target:focus-visible { outline:none; border-color:var(--focus); }
#game-screen .board-wrap { box-shadow:0 4px 0 #d7cede; }
::-webkit-scrollbar { width:10px; height:10px; }
::-webkit-scrollbar-track { background:var(--paper); }
::-webkit-scrollbar-thumb { background:#b9afc5; border:2px solid var(--paper); }
