/* 东方筑境 - 营造互动体验 - 核心样式表 */
:root {
  --canvas: #11100d;
  --surface: #191815;
  --surface2: #24221d;
  --paper: #f5efe2;
  --ink: #f5efe2;
  --muted: #a8a296;
  --line: rgba(214, 173, 95, 0.16);
  --red: #b33a31;
  --red2: #c9463b;
  --gold: #d6ad5f;
  --danger: #9b3028;
  --panel: rgba(24, 23, 20, 0.96);
  --radius: 8px;
  --nav-h: 76px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

button, a, input {
  font: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  background: var(--canvas);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 16, 13, 0.96);
  backdrop-filter: blur(16px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--paper);
  text-decoration: none;
}

.seal {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--red);
  font: bold 25px STKaiti, KaiTi, serif;
  color: var(--paper);
  box-shadow: 4px 4px 0 rgba(179, 58, 49, 0.22);
}

.brand b {
  display: block;
  font: 500 22px STSong, SimSun, serif;
  letter-spacing: .12em;
  color: var(--paper);
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: .12em;
}

.top-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(179, 58, 49, 0.12);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--muted);
  text-decoration: none;
  font-size: 22px;
  border-radius: 8px;
  background: none;
  border: 0;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface2);
  color: var(--gold);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  background: var(--canvas);
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0d0c0a;
}

.stage:after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
}

.stage-meta {
  position: absolute;
  left: 20px;
  top: 76px;
  z-index: 7;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(17, 16, 13, 0.85);
  color: var(--paper);
  backdrop-filter: blur(10px);
  font-size: 11px;
}

.stage-meta span:first-child {
  color: var(--gold);
  font-family: ui-monospace, monospace;
}

.viewport {
  display: none;
  position: absolute;
  inset: 0;
}

.viewport.active {
  display: block;
}

#three-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#runner-canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.floating-help {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 8;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(17, 16, 13, 0.85);
  color: var(--paper);
  font-weight: 700;
  cursor: pointer;
}

.floating-help:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.toast {
  position: absolute;
  left: 50%;
  top: 18px;
  z-index: 30;
  max-width: calc(100% - 32px);
  transform: translate(-50%, -12px);
  opacity: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(17, 16, 13, 0.95);
  color: var(--paper);
  font-size: 12px;
  transition: .2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.control-panel {
  min-height: 0;
  overflow: auto;
  padding: 36px 28px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.sheet-handle {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.panel-heading>div {
  min-width: 0;
  flex: 1;
}

.eyebrow {
  display: block;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.panel-heading h1 {
  margin: 9px 0 0;
  font: 500 28px/1.28 STSong, SimSun, serif;
  letter-spacing: .02em;
  color: var(--paper);
}

.text-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--gold);
}

.tool-panel {
  display: none;
  padding-top: 20px;
}

.tool-panel.active {
  display: block;
  animation: panel-in .22s ease;
}

.lead {
  margin: 0 0 20px;
  color: var(--paper-muted);
  font-size: 14px;
  line-height: 1.75;
}

.segmented, .mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}

.segmented button, .mode-switch button {
  min-height: 42px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--paper-muted);
  font-size: 13px;
  cursor: pointer;
}

.segmented button.active, .mode-switch button.active {
  background: var(--surface2);
  color: var(--gold);
  box-shadow: none;
}

.range-label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
}

.range-label output {
  color: var(--paper);
  font: 600 13px ui-monospace, monospace;
}

.range-label input {
  grid-column: 1/-1;
  width: 100%;
  height: 28px;
  accent-color: var(--red);
}

.insight {
  margin-top: 18px;
  padding: 14px;
  border-left: 2px solid var(--red);
  background: var(--surface);
}

.insight span {
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

.insight p {
  margin: 7px 0 0;
  color: var(--paper-muted);
  font-size: 12px;
  line-height: 1.65;
}

.piece-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.piece-grid button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--paper);
  text-align: left;
  cursor: pointer;
}

.piece-grid button:hover, .piece-grid button:focus-visible {
  border-color: var(--gold);
  background: var(--surface2);
}

.piece-grid button.active-brush {
  border-color: var(--gold) !important;
  background: var(--surface2) !important;
  box-shadow: 0 0 12px rgba(214, 173, 95, 0.35) !important;
}

/* 2026-07 mobile-first immersive polish: ink black + cinnabar + warm gold */
:root{--canvas:#09090b;--surface:#111114;--surface2:#19191e;--paper:#f3eee4;--paper-muted:#a7a19a;--muted:#77736e;--line:rgba(236,201,135,.14);--red:#c43d32;--red2:#e25548;--gold:#e1bb72;--panel:rgba(13,13,16,.92)}
html,body{background:#09090b;color:var(--paper);font-family:"Noto Sans SC","Microsoft YaHei","PingFang SC",system-ui,sans-serif}
.app-shell{background:radial-gradient(circle at 70% 12%,rgba(196,61,50,.08),transparent 32%),#09090b}
.topbar{background:rgba(9,9,11,.88);border-color:var(--line)}
.seal{display:none}.brand{gap:0}.brand b{font-family:"Noto Serif SC",STSong,SimSun,serif;font-size:21px;letter-spacing:.12em}.brand small{color:var(--gold)}
.stage{background:#09090b}.stage:after{border-color:rgba(255,255,255,.05)}
.control-panel{background:rgba(13,13,16,.94);border-left:1px solid var(--line)}
.primary-button,.template-row button.active,.segmented button.active{background:var(--red);color:#fff;border-color:var(--red)}
button{transition:transform .14s ease,border-color .14s ease,background .14s ease}button:active{transform:scale(.97)}
.tool-panel h3,.eyebrow{color:var(--gold);letter-spacing:.11em}.panel-heading h1,.map-copy h2{font-family:"Noto Serif SC",STSong,SimSun,serif;font-weight:500}
.map-view{padding:clamp(72px,9vh,110px) clamp(22px,5vw,76px) 90px;background:radial-gradient(circle at 48% 48%,rgba(196,61,50,.08),transparent 36%),#0b0b0d}
.map-board>img{filter:grayscale(1) invert(.86) contrast(1.2);opacity:.72}.map-point.done i{background:var(--red);box-shadow:0 0 0 1px var(--red),0 0 24px rgba(196,61,50,.65)}
.map-story-link{position:absolute;left:clamp(22px,5vw,76px);right:clamp(22px,5vw,76px);bottom:24px;z-index:8;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:15px 18px;border:1px solid var(--line);border-radius:10px;background:rgba(17,17,20,.9);backdrop-filter:blur(18px);color:var(--paper);text-decoration:none}.map-story-link span{color:var(--gold);font-size:12px}.map-story-link.locked{opacity:.62}.map-challenge button.correct{border-color:#70c486;color:#9ee4ae}.map-challenge button.wrong{border-color:var(--red);color:#ff8d83}
.build-mobile-dock{pointer-events:none}.build-mobile-dock button,.build-mobile-dock .joystick{pointer-events:auto}
.landscape-gate{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at 70% 20%,rgba(196,61,50,.22),transparent 35%),rgba(5,5,7,.97);text-align:center}.landscape-gate[hidden]{display:none}.landscape-gate>div{max-width:420px}.landscape-gate span{color:var(--gold);font:600 11px ui-monospace,monospace;letter-spacing:.16em}.landscape-gate h2{margin:12px 0 8px;font:500 clamp(30px,8vw,46px)/1.12 "Noto Serif SC",STSong,serif}.landscape-gate p{color:var(--paper-muted);line-height:1.7}.landscape-gate button{min-width:220px;min-height:50px;margin:18px 0 12px;border:0;border-radius:9px;background:var(--red);color:#fff;font-weight:700}.landscape-gate small{display:block;color:var(--muted);line-height:1.5}

@media(max-width:900px){
  .app-shell{grid-template-rows:50px minmax(0,1fr) 64px}.topbar{height:50px;padding:0 14px}.brand b{font-size:17px}.brand small{display:none}
  .control-panel{left:10px;right:10px;bottom:8px;max-height:min(46vh,390px);border:1px solid var(--line);border-radius:14px;padding:6px 14px 14px;background:rgba(14,14,17,.93);box-shadow:0 -20px 60px rgba(0,0,0,.38)}
  .control-panel.collapsed{transform:translateY(calc(100% - 56px))!important}.panel-heading h1{font-size:22px}.lead{font-size:12px}
  .bottom-nav{height:64px;background:rgba(9,9,11,.96);border-top:1px solid var(--line);backdrop-filter:blur(18px)}.bottom-nav button{min-width:0}.bottom-nav button.active{background:var(--surface2);color:var(--gold)}
  .map-view{padding:76px 18px 82px}.map-copy h2{font-size:30px}.map-copy p{font-size:12px}.map-board{margin-top:8px}.map-board>img{max-height:44vh}.map-point span{font-size:9px}.map-story-link{left:12px;right:12px;bottom:8px;padding:12px 14px}.map-story-link b{font-size:13px}
}

@media(max-width:900px) and (orientation:landscape){
  .app-shell{grid-template-rows:44px minmax(0,1fr)}.topbar{height:44px}.bottom-nav{display:none!important}.workspace{height:calc(100vh - 44px)}
  .control-panel{display:none!important}.stage{height:100%}.stage-meta{display:flex!important;top:12px;left:50%;transform:translateX(-50%)}
  .build-mobile-dock:not([hidden]){display:block!important;position:absolute;inset:0;z-index:20;pointer-events:none}
  .joystick{position:absolute;left:max(22px,env(safe-area-inset-left));bottom:24px;width:112px;height:112px;border:1px solid rgba(255,255,255,.18);border-radius:50%;background:rgba(10,10,12,.5);backdrop-filter:blur(8px);box-shadow:inset 0 0 28px rgba(255,255,255,.03)}.joystick:before{content:"移动";position:absolute;inset:0;display:grid;place-items:center;color:rgba(255,255,255,.28);font-size:11px}.joystick i{position:absolute;left:36px;top:36px;width:40px;height:40px;border-radius:50%;background:rgba(243,238,228,.9);box-shadow:0 4px 20px rgba(0,0,0,.45)}
  .build-hotbar{position:absolute;left:50%;bottom:18px;transform:translateX(-50%);display:flex;gap:7px;padding:7px;border:1px solid var(--line);border-radius:12px;background:rgba(10,10,12,.7);backdrop-filter:blur(12px)}.build-hotbar button{display:grid;place-items:center;width:58px;height:56px;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#17171b;color:var(--paper)}.build-hotbar button.active-brush{border-color:var(--gold);box-shadow:0 0 18px rgba(225,187,114,.18)}.build-hotbar i{color:var(--gold);font-style:normal}.build-hotbar span{font-size:10px}
  .build-actions{position:absolute;right:max(20px,env(safe-area-inset-right));bottom:18px;display:flex;gap:8px}.build-actions button{display:grid;place-items:center;width:58px;height:58px;border:1px solid rgba(255,255,255,.12);border-radius:50%;background:rgba(17,17,20,.82);color:var(--paper);font-size:22px;backdrop-filter:blur(12px)}.build-actions button:first-child{width:70px;height:70px;background:var(--red);border-color:var(--red)}.build-actions span{font-size:9px}
  .joint-quick{bottom:18px;left:50%;transform:translateX(-50%);width:min(58vw,480px)}
  .runner-controls{bottom:20px}.runner-controls button{min-width:120px}
  .map-view{padding:54px 28px 24px}.map-copy{position:absolute;left:28px;top:54px;z-index:3;max-width:310px}.map-copy h2{font-size:28px}.map-board{width:min(64vw,700px);margin:0 7% 0 auto}.map-board>img{max-height:calc(100vh - 90px)}.map-story-link{left:auto;right:22px;bottom:18px;width:min(42vw,430px)}
}

@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation-duration:.01ms!important;transition-duration:.01ms!important}}

/* Mobile-first creation refinements */
.topbar .seal{display:none}.brand{gap:0}.template-row{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin:0 0 14px}.template-row button{min-height:44px;padding:6px;border:1px solid var(--line);background:transparent;color:var(--ink);font-size:11px}.template-row button:active{background:var(--red);color:#fff}.legacy-note{margin-top:18px;padding:14px 0;border-top:1px solid var(--line)}.legacy-note b{font:500 17px STSong,SimSun,serif}.legacy-note p{margin:7px 0 0;color:var(--muted);font-size:11px;line-height:1.65}.build-mobile-dock{display:none}
@media(max-width:820px){.build-mobile-dock{position:fixed;z-index:24;left:12px;right:12px;bottom:82px;display:flex;align-items:flex-end;justify-content:space-between;pointer-events:none}.joystick{position:relative;width:92px;height:92px;border:1px solid var(--line);border-radius:50%;background:rgba(243,237,223,.88);pointer-events:auto;touch-action:none}.joystick i{position:absolute;left:27px;top:27px;width:38px;height:38px;border-radius:50%;background:#2d2b29}.quick-pieces{display:grid;grid-template-columns:repeat(2,52px);gap:6px;pointer-events:auto}.quick-pieces button{height:46px;border:1px solid var(--line);background:rgba(243,237,223,.96);color:#2b251f;font-size:11px}}
.build-mobile-dock[hidden]{display:none!important}
.joint-quick{display:none}@media(max-width:820px){.joint-quick{position:absolute;z-index:10;left:16px;right:16px;bottom:88px;display:grid;grid-template-columns:1fr;gap:8px;padding:12px 14px;background:rgba(18,17,15,.9);color:#fff;border:1px solid rgba(214,173,95,.35)}.joint-quick span{display:flex;justify-content:space-between;font-size:12px}.joint-quick input{width:100%;accent-color:#c53e34}.joint-quick[hidden]{display:none!important}}
@media(max-width:820px) and (orientation:portrait){.build-mobile-dock:not([hidden])::before{content:"横置手机，进入完整营造视野";position:absolute;left:0;bottom:104px;padding:7px 10px;background:#a63e31;color:#fff;font-size:11px}}
@media(max-width:920px) and (orientation:landscape){.app-shell{grid-template-rows:48px minmax(0,1fr) 58px}.topbar{height:48px}.control-panel{transform:translateY(calc(100% - 58px))!important}.build-mobile-dock:not([hidden]){display:flex;bottom:64px;left:18px;right:18px}.joystick{width:86px;height:86px}.joystick i{left:24px;top:24px}.quick-pieces{grid-template-columns:repeat(5,58px)}.quick-pieces button{height:48px}.bottom-nav button{min-height:46px}.stage{height:100%}.joint-quick:not([hidden]){display:grid;left:18%;right:18%;bottom:66px}}
.map-legacy-float{position:sticky;left:16px;right:16px;bottom:82px;z-index:8;margin:12px auto 0;width:min(620px,calc(100% - 24px));padding:12px 14px;background:rgba(18,17,15,.92);color:#fff;border-left:3px solid #a63e31}.map-legacy-float b,.map-legacy-float span{display:block}.map-legacy-float b{font:500 16px STSong,SimSun,serif}.map-legacy-float span{margin-top:4px;color:#d7d2ca;font-size:11px;line-height:1.55}

.piece-grid i {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: rgba(179, 58, 49, 0.12);
  color: var(--gold);
  font-style: normal;
  font-family: serif;
}

.piece-grid span {
  font-size: 13px;
}

.piece-grid small {
  display: block;
  margin-top: 3px;
  color: var(--paper-muted);
  font-size: 10px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.action-row button, .save-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--paper);
  font-size: 11px;
  cursor: pointer;
}

.action-row button:hover, .save-row button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.action-row .danger {
  color: var(--red);
}

.action-row .danger:hover {
  border-color: var(--red);
  color: var(--red2);
}

.save-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.save-row span {
  margin-right: auto;
  color: var(--paper-muted);
  font-size: 11px;
}

.save-row span b {
  color: var(--paper);
  font-size: 16px;
}

.save-row button {
  padding: 0 11px;
}

.primary-button, .secondary-button {
  min-height: 46px;
  border-radius: 4px;
  padding: 0 17px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
}

.primary-button:hover {
  background: var(--red2);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--paper);
}

.secondary-button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.full {
  width: 100%;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.metric-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--paper);
}

.metric-grid span, .metric-grid b {
  display: block;
}

.metric-grid span {
  color: var(--paper-muted);
  font-size: 10px;
}

.metric-grid b {
  margin-top: 5px;
  font-size: 14px;
}

.map-progress {
  padding: 12px 0;
  margin-bottom: 16px;
  border-width: 1px 0;
  border-style: solid;
  border-color: var(--line);
  background: transparent;
}

.map-progress>div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.map-progress span {
  font-size: 24px;
  font-family: STSong, SimSun, serif;
}

.map-progress small {
  color: var(--paper-muted);
}

progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 12px;
  border: 0;
  accent-color: var(--red);
}

.bottom-nav {
  display: none;
}

.runner-hud {
  position: absolute;
  z-index: 4;
  left: 18px;
  right: 18px;
  top: 18px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.runner-hud span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(17, 16, 13, 0.85);
  font-size: 11px;
  color: var(--muted);
}

.runner-hud b {
  margin-left: 5px;
  color: var(--gold);
  font-family: ui-monospace, monospace;
}

.loading-card, .game-dialog {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 16, 13, 0.96);
  text-align: center;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.loading-card[hidden] {
  display: none;
}

.loading-card small, .game-dialog p {
  color: var(--paper-muted);
  font-size: 12px;
}

.game-dialog h2 {
  margin: 10px 0 8px;
  font-size: 25px;
  letter-spacing: -.04em;
  font-family: STSong, SimSun, serif;
  color: var(--gold);
}

.game-dialog p {
  line-height: 1.7;
  color: var(--paper-muted);
}

.runner-controls {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 20px;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.runner-controls button {
  min-width: 126px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(17, 16, 13, 0.85);
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.runner-controls button:active, .runner-controls button.active {
  background: var(--red);
  border-color: var(--red2);
}

.runner-controls small {
  margin-left: 8px;
  color: var(--muted);
}

.map-view {
  overflow: auto;
  padding: 58px 5vw 40px;
  background: var(--canvas);
  color: var(--paper);
}

.map-copy {
  max-width: 660px;
}

.map-copy h2 {
  margin: 10px 0;
  font-family: STSong, SimSun, serif;
  font-size: clamp(32px, 4.2vw, 58px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: .01em;
  color: var(--paper);
}

.map-copy p {
  max-width: 560px;
  color: var(--paper-muted);
  line-height: 1.7;
}

.map-board {
  position: relative;
  width: min(820px, 100%);
  margin: 24px auto 0;
}

.map-board>img {
  display: block;
  width: 100%;
  max-height: 54vh;
  object-fit: contain;
  opacity: 0.65;
  filter: invert(0.9) grayscale(1) contrast(1.25);
}

.map-point {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--paper);
  text-align: left;
  transform: translate(-8px, -8px);
  cursor: pointer;
}

.map-point i {
  flex: none;
  width: 16px;
  height: 16px;
  border: 4px solid var(--canvas);
  border-radius: 50%;
  background: #3a3730;
  box-shadow: 0 0 0 1px #8d8981;
}

.map-point span {
  opacity: 0;
  transform: translateX(-5px);
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 10px;
  transition: .18s;
  white-space: nowrap;
  pointer-events: none;
  color: var(--paper);
}

.map-point:hover span, .map-point:focus-visible span, .map-point.done span {
  opacity: 1;
  transform: none;
}

.map-point span b {
  font-size: 11px;
}

.map-point.done i {
  background: var(--red);
  box-shadow: 0 0 0 1px var(--red), 0 0 0 7px rgba(179, 58, 49, 0.16);
}

dialog {
  width: min(440px, calc(100% - 28px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--paper);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(3px);
}

dialog h2 {
  margin: 10px 0 18px;
  font-size: 24px;
  color: var(--gold);
}

dialog ol {
  padding-left: 22px;
  color: var(--paper-muted);
  font-size: 13px;
  line-height: 1.8;
}

dialog li+li {
  margin-top: 8px;
}

.dialog-close {
  float: right;
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--surface2);
  color: var(--paper);
  border-radius: 8px;
  font-size: 22px;
  cursor: pointer;
}

.build-guide {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.build-guide summary {
  padding: 15px 0;
  color: var(--gold);
  font-weight: 600;
  cursor: pointer;
}

.guide-steps {
  display: grid;
  gap: 0;
}

.guide-steps p {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  margin: 0;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.guide-steps b {
  font: 500 14px STSong, SimSun, serif;
  color: var(--paper);
}

.guide-steps span {
  color: var(--paper-muted);
  font-size: 11px;
  line-height: 1.65;
}

.map-challenge {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.map-challenge>b {
  font: 500 17px STSong, SimSun, serif;
  color: var(--gold);
}

.map-challenge p {
  margin: 8px 0 12px;
  color: var(--paper-muted);
  font-size: 12px;
}

.map-challenge>div {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.map-challenge button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--paper);
  border-radius: 4px;
  cursor: pointer;
}

.map-challenge button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.map-challenge button:active {
  background: var(--red);
  color: #fff;
}

.map-challenge small {
  display: block;
  margin-top: 9px;
  color: var(--paper-muted);
  font-size: 10px;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------
   PC VIEW STYLING FOR BOTTOM NAV
   ------------------------------------------------------------- */
@media(min-width: 821px) {
  .bottom-nav {
    position: fixed;
    z-index: 30;
    left: 20px;
    top: 76px;
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(17, 16, 13, 0.94);
    backdrop-filter: blur(14px);
  }
  .bottom-nav button {
    min-height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--paper-muted);
    cursor: pointer;
  }
  .bottom-nav button span {
    margin-right: 6px;
    color: var(--muted);
    font: 9px ui-monospace, monospace;
  }
  .bottom-nav button b {
    font-size: 11px;
  }
  .bottom-nav button.active {
    background: var(--surface2);
    color: var(--gold);
  }
  .bottom-nav button.active span {
    color: var(--red);
  }
  .stage-meta {
    top: 76px;
  }
}

/* -------------------------------------------------------------
   MOBILE VIEW STYLING (MAX-WIDTH: 820PX)
   ------------------------------------------------------------- */
@media(max-width: 820px) {
  :root {
    --nav-h: 74px;
  }
  
  .app-shell {
    grid-template-rows: 54px minmax(0, 1fr) var(--nav-h);
  }
  
  .topbar {
    height: 54px;
    padding: 0 12px;
  }
  
  .seal {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }
  
  .brand b {
    font-size: 17px;
  }
  
  .brand small, .top-status {
    display: none !important;
  }
  
  .workspace {
    display: block;
    position: relative;
  }
  
  .stage {
    height: 100%;
  }
  
  /* Hide redundant elements on mobile screen */
  .stage-meta {
    display: none !important;
  }
  .floating-help {
    display: none !important;
  }
  
  /* Collapsible mobile bottom drawer sheet */
  .control-panel {
    position: absolute;
    z-index: 12;
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-height: min(60vh, 480px); /* Raised height to prevent contents cutoff */
    padding: 6px 14px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(25, 24, 21, 0.96);
    backdrop-filter: blur(18px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .control-panel.collapsed {
    transform: translateY(calc(100% - 62px)) !important;
  }
  
  .sheet-handle {
    display: block;
    width: 38px;
    height: 4px;
    margin: 2px auto 8px;
    border-radius: 2px;
    background: var(--line);
  }
  
  .panel-heading {
    align-items: center;
    padding-bottom: 8px;
    margin-bottom: 4px;
  }
  
  .panel-heading h1 {
    margin-top: 2px;
    font-size: 18px;
  }
  
  .panel-heading .eyebrow {
    font-size: 8px;
  }
  
  .tool-panel {
    padding-top: 8px;
  }
  
  .lead {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.45;
  }
  
  .range-label {
    margin-top: 10px !important;
    gap: 6px !important;
  }
  
  .insight {
    margin-top: 10px !important;
    padding: 10px !important;
  }
  
  .insight p {
    font-size: 11px !important;
    line-height: 1.45 !important;
  }
  
  .piece-grid {
    grid-template-columns: repeat(3, 1fr);
    margin: 10px 0;
    gap: 6px;
  }
  
  .piece-grid button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 60px;
    padding: 6px;
    text-align: center;
  }
  
  .piece-grid i {
    margin: 0 0 4px;
    width: 28px;
    height: 25px;
    font-size: 11px;
  }
  
  .piece-grid span {
    font-size: 11px;
  }
  
  .piece-grid small {
    display: none !important;
  }
  
  .action-row {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }
  
  .action-row button {
    min-height: 38px;
    font-size: 10px;
    padding: 0;
  }
  
  /* RESTORE MOBILE BOTTOM NAVIGATION BAR DISPLAY */
  .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid var(--line) !important;
    background: rgba(17, 16, 13, 0.98) !important;
    z-index: 100 !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4) !important;
  }
  
  .bottom-nav button {
    min-width: 0 !important;
    min-height: 54px !important;
    border: 0 !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: var(--paper-muted) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
  }
  
  .bottom-nav button span {
    display: block !important;
    font: 9px ui-monospace, monospace !important;
    color: var(--muted) !important;
    margin: 0 0 2px 0 !important;
  }
  
  .bottom-nav button b {
    display: block !important;
    font-size: 11px !important;
    margin: 0 !important;
  }
  
  .bottom-nav button.active {
    background: var(--surface2) !important;
    color: var(--gold) !important;
  }
  
  .bottom-nav button.active span {
    color: var(--red) !important;
  }
  
  /* Console-style layout for mobile runner controls */
  .runner-hud {
    position: absolute;
    z-index: 10;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    display: flex;
    gap: 8px;
    justify-content: center;
    pointer-events: none;
  }
  
  .runner-hud span {
    padding: 6px 10px;
    font-size: 10px;
    background: rgba(17, 16, 13, 0.9);
  }
  
  .runner-controls {
    position: absolute;
    z-index: 11;
    bottom: 90px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    width: auto;
    transform: none;
    pointer-events: none;
  }
  
  .runner-controls button {
    pointer-events: auto;
    width: 68px;
    height: 68px;
    border-radius: 50% !important;
    border: 1px solid var(--gold);
    background: rgba(25, 24, 21, 0.88);
    color: var(--paper);
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 0 12px rgba(214, 173, 95, 0.25);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
  }
  
  .runner-controls button:active, .runner-controls button.active {
    background: var(--red);
    border-color: var(--red2);
    box-shadow: 0 0 12px rgba(179, 58, 49, 0.45);
  }
  
  .runner-controls small {
    display: none !important;
  }
  
  .map-view {
    padding: 54px 18px 180px;
  }
  
  .map-copy h2 {
    font-size: 29px;
  }
  
  .map-copy p {
    font-size: 12px;
  }
  
  .map-point span {
    display: none;
  }
  
  .map-point.done span {
    display: block;
    font-size: 9px;
  }
  
  .game-dialog {
    top: 42%;
  }
}

/* Selected active brush highlighting style */
.piece-grid button.active-brush {
  border-color: var(--gold) !important;
  background: var(--surface2) !important;
  box-shadow: 0 0 12px rgba(214, 173, 95, 0.35) !important;
}
