/* 스팀펑크 기관실: 위아래는 리벳 박은 철판과 구리 파이프, 가운데는 판화 도면.
   도면 = 밝은 테마는 베이지 종이에 잉크 판화, 어두운 테마는 청회색 도면에 크림색 선.
   철판 테두리와 호박색 램프 빛은 두 테마에서 같다. */
:root {
  /* 도면(캔버스·위에 뜨는 카드) */
  --paper: #e9e1cd;
  --panel: #f2ecdc;
  --ink: #1d1914;
  --ink-soft: #5b5144;
  --line: #a99c82;
  --grid: rgba(29, 25, 20, 0.07);
  --grid-major: rgba(29, 25, 20, 0.22);
  --ground: #d9cfb6;
  --ground-hatch: rgba(29, 25, 20, 0.55);
  --accent: #8a3b1c;
  --tension: #23466e;
  --compression: #9c3b20;
  --ok: #3f6b2a;
  --warn: #8a5a10;
  --zone: rgba(35, 70, 110, 0.65);
  --target: rgba(138, 59, 28, 0.95);
  /* 철판·구리(테마 공통) */
  --iron: #2a2724;
  --iron-hi: #3d3933;
  --iron-lo: #161412;
  --iron-ink: #eadfc6;
  --iron-soft: #b3a68d;
  --copper: #b2643a;
  --copper-hi: #e3a06e;
  --copper-lo: #6b3519;
  --amber: #ffb547;
  --scope-bg: #0f1a17;
  --scope-trace: #ffc46b;
  --shadow: 0 8px 26px rgba(20, 14, 8, 0.35);
  --font-plate: "IM Fell English", "Nanum Myeongjo", "Batang", serif;
  --font-display: "IM Fell English SC", "Nanum Myeongjo", "Batang", serif;
  --font-ui: "Gowun Batang", "Nanum Myeongjo", "Batang", serif;
  --font-num: "Courier Prime", "Courier New", ui-monospace, monospace;
  --radius: 4px;
  --rivet: radial-gradient(circle, #8f8679 0 1.3px, #3a352f 1.9px, rgba(0, 0, 0, 0.5) 2.5px, transparent 3px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #26323a;
    --panel: #2e3b44;
    --ink: #e8dec6;
    --ink-soft: #a9b0aa;
    --line: #52646d;
    --grid: rgba(232, 222, 198, 0.06);
    --grid-major: rgba(232, 222, 198, 0.17);
    --ground: #2f3d46;
    --ground-hatch: rgba(232, 222, 198, 0.45);
    --accent: #f0a868;
    --tension: #8cc4e8;
    --compression: #f08a62;
    --ok: #a6d184;
    --warn: #f0c46a;
    --zone: rgba(140, 196, 232, 0.65);
    --target: rgba(240, 168, 104, 0.95);
    --shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #26323a;
  --panel: #2e3b44;
  --ink: #e8dec6;
  --ink-soft: #a9b0aa;
  --line: #52646d;
  --grid: rgba(232, 222, 198, 0.06);
  --grid-major: rgba(232, 222, 198, 0.17);
  --ground: #2f3d46;
  --ground-hatch: rgba(232, 222, 198, 0.45);
  --accent: #f0a868;
  --tension: #8cc4e8;
  --compression: #f08a62;
  --ok: #a6d184;
  --warn: #f0c46a;
  --zone: rgba(140, 196, 232, 0.65);
  --target: rgba(240, 168, 104, 0.95);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--iron-lo);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* 철판 바탕: 은은한 결 + 녹 얼룩. 안에서는 글자색을 크림색으로 바꾼다. */
.iron {
  --panel: #33302b;
  --ink: var(--iron-ink);
  --ink-soft: var(--iron-soft);
  --line: #4d473f;
  --accent: var(--amber);
  --compression: #f08a62;
  --ok: #a6d184;
  color: var(--iron-ink);
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 181, 71, 0.14), transparent 55%),
    radial-gradient(ellipse at 85% 120%, rgba(178, 100, 58, 0.16), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, var(--iron-hi), var(--iron) 45%, var(--iron-lo));
}

/* 구리 파이프 띠 */
.pipe {
  height: 9px;
  background:
    linear-gradient(90deg, transparent 0 calc(100% - 1px), rgba(0, 0, 0, 0.45) calc(100% - 1px)) 0 0 / 120px 100%,
    linear-gradient(180deg, var(--copper-lo), var(--copper-hi) 30%, var(--copper) 55%, var(--copper-lo));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6), 0 -1px 0 rgba(0, 0, 0, 0.6);
}

.app {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  min-height: 560px;
}

/* 윗판 */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 9px;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
.topbar::before, .topbar::after, .dock::before, .dock::after {
  content: "";
  position: absolute;
  width: 6px;
  height: calc(100% - 12px);
  top: 6px;
  background: var(--rivet) 0 0 / 6px 18px repeat-y;
  pointer-events: none;
}
.topbar::before, .dock::before { left: 5px; }
.topbar::after, .dock::after { right: 5px; }
.title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.title > div { min-width: 0; }
.title h1 > span:first-child { white-space: nowrap; }
.gear { width: 32px; height: 32px; flex-shrink: 0; color: var(--copper); filter: drop-shadow(0 0 6px rgba(255, 181, 71, 0.35)); }
.app[data-mode="sim"] .gear { animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  row-gap: 0;
  line-height: 1.25;
  color: #f3e3bd;
  text-shadow: 0 0 12px rgba(255, 181, 71, 0.35), 0 1px 0 #000;
}
.chip-draft {
  font-family: var(--font-plate);
  font-style: italic;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--copper-hi);
  white-space: nowrap;
  text-shadow: none;
}
.mission-line {
  margin: 0;
  font-family: var(--font-plate);
  font-style: italic;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--amber);
  opacity: 0.9;
}
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 버튼: 검은 철 + 구리 테 */
.btn {
  appearance: none;
  border: 1px solid var(--copper-lo);
  background: linear-gradient(180deg, #4a443c, #2c2823 60%, #1d1a17);
  color: var(--iron-ink);
  border-radius: var(--radius);
  padding: 6px 12px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  text-shadow: 0 1px 0 #000;
  box-shadow:
    inset 0 0 0 1px rgba(227, 160, 110, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.6);
}
.btn:hover { border-color: var(--copper); box-shadow: inset 0 0 0 1px rgba(227, 160, 110, 0.6), 0 0 8px rgba(255, 181, 71, 0.25); }
.btn:active { box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.7); transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--copper-hi), var(--copper) 55%, var(--copper-lo));
  border-color: #3f1d0b;
  color: #fff4e0;
  text-shadow: 0 -1px 0 rgba(50, 18, 0, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 230, 200, 0.5), 0 0 10px rgba(255, 181, 71, 0.25), 0 1px 2px rgba(0, 0, 0, 0.6);
}
.btn.ghost { background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.15)); }
.btn[aria-pressed="true"] {
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 181, 71, 0.35), rgba(0, 0, 0, 0.4)), #1a1714;
  color: var(--amber);
  border-color: var(--copper);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.7), 0 0 8px rgba(255, 181, 71, 0.35);
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.lang { font-family: var(--font-num); min-width: 44px; }

/* 도면 */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
}
#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
  cursor: crosshair;
}
/* 종이 가장자리 그을음 + 철 틀 안쪽 그림자 */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(40, 28, 14, 0.25);
}

/* 판화 해설 카드: 이중 잉크 테두리 */
.callout {
  background: var(--panel);
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -4px;
  border-radius: 0;
  box-shadow: var(--shadow);
}
.goal {
  position: absolute;
  top: 10px;
  left: max(10px, env(safe-area-inset-left, 0px));
  max-width: min(370px, calc(100% - 20px));
  font-size: 13px;
  z-index: 2;
  padding: 3px;
}
.goal-toggle {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 9px 2px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--accent);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.goal-toggle::after { content: " ▾"; }
.goal-toggle[aria-expanded="false"]::after { content: " ▸"; }
.goal-body { padding: 0 9px 7px; }
.goal-body p { margin: 0 0 4px; text-wrap: pretty; }
.goal-body ul { margin: 0; padding-left: 16px; color: var(--ink-soft); font-size: 12px; }

/* 표제란 = 리벳 박은 철 명판 + 구리 테 */
.titleblock {
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: 10px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  min-width: 210px;
  border-radius: 3px;
  padding: 7px 12px;
  z-index: 1;
  border: 2px solid var(--copper);
  box-shadow: inset 0 0 0 1px var(--copper-lo), var(--shadow), 0 0 14px rgba(255, 181, 71, 0.15);
}
.plate {
  --ink: var(--iron-ink);
  color: var(--iron-ink);
  background:
    var(--rivet) 3px 3px / 6px 6px no-repeat,
    var(--rivet) calc(100% - 3px) 3px / 6px 6px no-repeat,
    var(--rivet) 3px calc(100% - 3px) / 6px 6px no-repeat,
    var(--rivet) calc(100% - 3px) calc(100% - 3px) / 6px 6px no-repeat,
    radial-gradient(ellipse at 30% 0%, rgba(255, 181, 71, 0.12), transparent 70%),
    linear-gradient(180deg, #3a362f, #24211d);
}
.titleblock th, .titleblock td {
  border-bottom: 1px solid rgba(227, 160, 110, 0.25);
  padding: 2px 6px;
  text-align: left;
  white-space: nowrap;
}
.titleblock tr:last-child th, .titleblock tr:last-child td { border-bottom: 0; }
.titleblock th { font-family: var(--font-plate); font-style: italic; font-weight: 400; font-size: 11px; color: var(--copper-hi); }
.titleblock td { font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--amber); text-shadow: 0 0 6px rgba(255, 181, 71, 0.4); }
#hudStatus { font-family: var(--font-ui); font-weight: 700; color: var(--iron-ink); text-shadow: none; }
#hudStatus.ok { color: #b5e08c; }
#hudStatus.bad { color: #ff8a65; }
#hudStatus.warn { color: #ffcf70; }

.legend {
  position: absolute;
  left: max(10px, env(safe-area-inset-left, 0px));
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--font-plate);
  font-style: italic;
  background: var(--panel);
  border: 1px solid var(--ink);
  padding: 3px 8px;
  z-index: 1;
}
.legend .sw { width: 18px; height: 4px; display: inline-block; }
.legend .sw.tension { background: var(--tension); }
.legend .sw.compression { background: var(--compression); margin-left: 6px; }
.legend-note { color: var(--ink-soft); margin-left: 6px; }

.inspector {
  position: absolute;
  top: 10px;
  right: max(10px, env(safe-area-inset-right, 0px));
  width: min(270px, calc(100% - 20px));
  padding: 9px 11px;
  font-size: 12px;
  z-index: 2;
}
.inspector h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 15px; font-weight: 400; }
.inspector dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; }
.inspector dt { color: var(--ink-soft); font-family: var(--font-plate); font-style: italic; }
.inspector dd { margin: 0; font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; }
.inspector .bar { height: 6px; border: 1px solid var(--ink); margin-top: 6px; overflow: hidden; }
.inspector .bar i { display: block; height: 100%; background: repeating-linear-gradient(45deg, var(--ink) 0 1px, transparent 1px 3px); }
.inspector .bar i.hot { background: var(--compression); }
.inspector .note { color: var(--ink-soft); margin: 6px 0 0; font-size: 11px; }

.toast {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: linear-gradient(180deg, #3a362f, #1d1a17);
  color: var(--amber);
  border: 2px solid var(--copper);
  border-radius: 3px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow), 0 0 16px rgba(255, 181, 71, 0.25);
  z-index: 5;
  text-align: center;
}
.toast.bad { color: #ffb199; border-color: #c2502a; }

/* 아랫판(공구함) */
.dock {
  position: relative;
  padding-block: 9px;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.playbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.playbar > span { display: contents; }
.app[data-mode="build"] .sim-only, .app[data-mode="sim"] .build-only { display: none !important; }
.hint { font-size: 12.5px; color: var(--ink-soft); min-height: 18px; }
.hint b { color: var(--amber); font-weight: 700; }

.tools { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--copper-lo) transparent; padding: 2px 2px 4px; }
.tool {
  appearance: none;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 66px;
  height: 58px;
  padding: 4px 8px;
  border: 2px solid var(--copper-lo);
  border-radius: 6px;
  background: radial-gradient(ellipse at 50% 30%, #4a443c, #23201c 75%);
  color: var(--iron-ink);
  cursor: pointer;
  font-size: 11.5px;
  line-height: 1.2;
  box-shadow: inset 0 0 0 1px rgba(227, 160, 110, 0.4), inset 0 -3px 6px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.6);
}
.tool svg { width: 26px; height: 20px; color: var(--copper-hi); }
.tool:hover { border-color: var(--copper); }
.tool[aria-pressed="true"] {
  border-color: var(--copper-hi);
  color: var(--amber);
  background: radial-gradient(ellipse at 50% 35%, rgba(255, 181, 71, 0.32), #23201c 80%);
  box-shadow: inset 0 0 0 1px var(--copper), 0 0 12px rgba(255, 181, 71, 0.45);
  font-weight: 700;
}
.tool[aria-pressed="true"] svg { color: var(--amber); }
.subopts { display: flex; flex-wrap: wrap; gap: 6px; }
.subopts:empty { display: none; }
.subopts .btn { min-height: 30px; padding: 3px 10px; font-family: var(--font-num); }
.subopts .label { font-size: 12px; color: var(--ink-soft); align-self: center; font-family: var(--font-plate); font-style: italic; }

.controls { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.ctl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 2px 8px;
  border: 1px solid var(--copper-lo);
  border-radius: 4px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.ctl label { font-size: 12.5px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctl output { font-family: var(--font-num); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; color: var(--amber); }
.ctl output.hot { color: var(--compression); }
.ctl input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--copper); margin: 0; height: 26px; }
.ctl .auto { min-height: 26px; padding: 0 8px; font-size: 12px; }
.controls .empty { font-size: 12px; color: var(--ink-soft); }

/* 제어 프로그램 */
.program { display: flex; flex-direction: column; gap: 6px; }
.prog-head {
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 4px solid var(--copper);
  padding: 4px 8px;
  border-radius: 0 3px 3px 0;
  text-wrap: pretty;
}
.prog-head b { color: var(--amber); font-family: var(--font-num); }
.program > .ctl { max-width: 520px; }
.steps { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); max-height: 34vh; overflow-y: auto; }
.step { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 4px; border: 1px solid var(--copper-lo); border-radius: 4px; padding: 3px 4px; background: rgba(0, 0, 0, 0.22); }
.step .ctl { border: 0; background: none; padding: 0 4px; box-shadow: none; }
.step .ctl output { min-width: 34px; font-size: 12px; }
.step .ctl label { font-size: 11.5px; }
.step.sel { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 0 10px rgba(255, 181, 71, 0.3); }
.step-pick { justify-self: start; min-height: 26px; padding: 0 10px; font-size: 12px; }
.prog-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.points { margin: 0; padding-left: 22px; font-size: 12.5px; }
.points .num { font-family: var(--font-num); }
.points .bad { color: var(--compression); }
.points .muted { color: var(--ink-soft); list-style: none; margin-left: -22px; }
/* 계기판 창 */
.readout {
  font-family: var(--font-num);
  font-size: 13px;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 181, 71, 0.12), transparent 70%), var(--scope-bg);
  color: var(--scope-trace);
  border: 3px solid var(--copper);
  outline: 1px solid var(--copper-lo);
  border-radius: 8px;
  padding: 6px 10px;
  text-shadow: 0 0 6px rgba(255, 196, 107, 0.45);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7);
}
.readout b { font-size: 15px; }

/* 시트: 구리 액자 안의 판화 도판 */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet-card {
  background: var(--panel);
  color: var(--ink);
  width: min(760px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  border-radius: 8px 8px 0 0;
  border: 0;
  border-top: 8px solid var(--copper);
  box-shadow: inset 0 1px 0 var(--copper-lo), var(--shadow);
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
@media (min-width: 780px) {
  .sheet { align-items: center; }
  .sheet-card {
    border-radius: 6px;
    border: 8px solid var(--copper);
    border-image: linear-gradient(135deg, var(--copper-hi), var(--copper) 40%, var(--copper-lo) 70%, var(--copper)) 1;
    outline: 1px solid var(--ink);
    outline-offset: -14px;
    padding: 20px 22px;
  }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--ink); padding-bottom: 6px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 400; letter-spacing: 0.03em; text-wrap: balance; }
.sheet .btn.ghost { color: var(--ink); text-shadow: none; background: transparent; border-color: var(--ink); box-shadow: none; }
.sheet .btn.ghost:hover { box-shadow: 0 0 0 1px var(--ink); }
.mission-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.mcard {
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -4px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  background: var(--paper);
}
.mcard.current { border-color: var(--accent); outline: 2px solid var(--accent); }
.mcard h3 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 400; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mcard h3 small { font-family: var(--font-num); font-size: 11px; color: var(--ink-soft); font-weight: 400; }
.mcard p { margin: 0; font-size: 12.5px; color: var(--ink-soft); text-wrap: pretty; }
.mcard .parts { font-size: 11px; color: var(--ink-soft); }
.mcard .best { font-family: var(--font-num); font-size: 12px; color: var(--ok); }
.mcard .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.mcard .presets { display: flex; flex-wrap: wrap; gap: 6px; }
.mcard .presets .btn { min-height: 30px; font-size: 12px; padding: 3px 8px; }

.report #reportBody { font-size: 14px; }
.report #reportBody p { margin: 0 0 6px; text-wrap: pretty; }
.report .stamp {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.14em;
  padding: 2px 12px;
  border: 3px double currentColor;
  border-radius: 3px;
  margin-bottom: 8px;
  transform: rotate(-3deg);
}
.report .stamp.ok { color: var(--ok); }
.report .stamp.bad { color: var(--compression); }
.report .facts { font-family: var(--font-num); font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.report-note { font-size: 11px; color: var(--ink-soft); margin: 10px 0 0; font-family: var(--font-plate); font-style: italic; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* 바닥글: 늘 철판 위 */
.brand {
  padding-block: 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  font-size: 12px;
  color: var(--iron-soft);
  background: var(--iron-lo);
}
.brand-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.brand a { color: var(--iron-ink); }
.brand .wordmark { display: inline-flex; }
.brand .wordmark img { height: 20px; width: auto; display: block; }
.wm-light { display: none !important; }
.brand .ver { font-family: var(--font-num); color: var(--copper-hi); }
.disclaimer { margin: 8px 0 0; max-width: 70ch; }

/* 미션 단계 · 별 · 힌트 */
.concept {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 8px;
  line-height: 18px;
  vertical-align: 1px;
}
.goal-body li .st { color: var(--accent); font-size: 11px; letter-spacing: 1px; }
.goal-body ul.rules { list-style: none; padding-left: 0; }
.hintbtn { color: var(--amber); }
.hintbox {
  border: 1px dashed var(--copper);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.25);
}
.hintbox p { margin: 2px 0; text-wrap: pretty; }
.hintbox b {
  display: inline-grid;
  place-items: center;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--copper-hi), var(--copper-lo));
  color: #1d1914;
  font-size: 10px;
  margin-right: 4px;
}
#hudCount.full { color: #ff8a65; }
.track-head {
  grid-column: 1 / -1;
  margin: 8px 0 -2px;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.16em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}
.track-head::after { content: ""; flex: 1; height: 3px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.mcard .code {
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
  border-radius: 2px;
  padding: 1px 6px;
  margin-right: 4px;
  vertical-align: 2px;
  background: linear-gradient(180deg, var(--copper-hi), var(--copper) 60%, var(--copper-lo));
  color: #fff4e0;
  border: 1px solid var(--copper-lo);
}
.mcard .stars { color: var(--accent); font-size: 16px; letter-spacing: 1px; white-space: nowrap; }
.mcard .concept-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mcard .budget { font-size: 11px; color: var(--ink-soft); }
.mcard.locked { opacity: 0.55; }
.mcard .lock { font-size: 11px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 3px; padding: 0 6px; white-space: nowrap; }
.big-stars { font-size: 32px; color: var(--accent); letter-spacing: 4px; line-height: 1.1; margin: 2px 0; }
.next-star { font-size: 12px; color: var(--ink-soft); margin: 0 0 8px !important; }

@media (max-width: 520px) {
  .legend { bottom: auto; top: 54px; }
  .program { max-height: 34vh; overflow-y: auto; }
  .steps { max-height: none; }
  .titleblock { min-width: 0; font-size: 10px; padding: 5px 8px; }
  .titleblock th, .titleblock td { padding: 1px 4px; }
  .goal { font-size: 12px; }
  .inspector { top: auto; bottom: 86px; }
  .title h1 { font-size: 18px; }
  .chip-draft { font-size: 11.5px; }
  .gear { width: 26px; height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
