/* Original block-world UI. Scope every rule to this game. */
#craft {
  --cw-ink: #243e38;
  --cw-muted: #52645b;
  --cw-paper: #f6f2df;
  --cw-card: #fffdf2;
  --cw-line: #c7cfb7;
  --cw-wood: #4e3b2b;
  --cw-wood-light: #795b3d;
  --cw-teal: #17655f;
  --cw-teal-dark: #104c49;
  --cw-turquoise: #70dfc9;
  --cw-gold: #eec766;
  --cw-gold-ink: #674817;
  display: none;
  align-self: center;
  width: calc(100% + 24px);
  max-width: calc(100vw - 16px);
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 64px;
  scrollbar-width: thin;
  scrollbar-color: #849b7d transparent;
  border: 1px solid #a3b79a;
  border-radius: 20px;
  background: var(--cw-paper);
  color: var(--cw-ink);
  text-align: left;
  isolation: isolate;
}
#craft.on { display: block; }
#craft *, #craft *::before, #craft *::after { box-sizing: border-box; }
#craft [hidden] { display: none !important; }
#craft button, #craft input, #craft select { font-family: inherit; }
#craft button {
  min-height: 48px;
  min-width: 48px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--cw-line);
  border-bottom-width: 3px;
  border-radius: 9px;
  color: var(--cw-ink);
  background: var(--cw-card);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
#craft button:not(:disabled):active { transform: translateY(1px); }
#craft button:disabled { cursor: default; opacity: .48; filter: saturate(.55); }
#craft :is(button, input, select, summary):focus-visible {
  outline: 3px solid #08728a;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px #fffdf2;
}
#craft :is(h1, h2, h3, p) { overflow-wrap: anywhere; }
#craft :is(h1, h2, h3) { margin: 0; color: var(--cw-ink); line-height: 1.5; }
#craft h1 { font-size: 25px; font-weight: 900; }
#craft h2 { font-size: 22px; font-weight: 900; }
#craft h3 { font-size: 19px; }
#craft p { margin: 9px 0; font-size: 17px; line-height: 1.8; }
#craft small { font-size: 14px; line-height: 1.6; }
#craft .cw-app { min-height: 100%; width: 100%; background: var(--cw-paper); }
#craft .cw-nav {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 4px 10px;
  border-bottom: 3px solid #362a22;
  color: #fff8de;
  background:
    linear-gradient(0deg, transparent 48%, #ffffff07 50%, transparent 52%) 0 0 / 100% 8px,
    linear-gradient(105deg, #4e3b2b, #665038 55%, #4b3829);
  box-shadow: 0 3px 0 #222e2730;
}
#craft .cw-nav > :is(span, strong, h1) { min-width: 0; font-size: 17px; color: #fff8de; line-height: 1.4; }
#craft .cw-nav > button { flex: 0 0 auto; padding: 8px; border-color: transparent; background: transparent; color: #fff8de; }
#craft .cw-nav .cw-stars { flex: 0 0 auto; margin-left: auto; padding: 6px 9px; border: 1px solid #a58b4b; border-radius: 7px; background: #2e2b21; color: #ffe394; white-space: nowrap; }
#craft .cw-stage {
  position: relative;
  height: clamp(280px, 43dvh, 370px);
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(#8bcddd, #d7f0e5 65%, #89be76);
  border-bottom: 3px solid #678b64;
  isolation: isolate;
}
#craft .cw-world-host { position: absolute; inset: 0; min-width: 0; overflow: hidden; }
#craft .cw-world-host > :is(canvas, svg) { display: block; width: 100%; height: 100%; touch-action: none; }
#craft .cw-world-host svg { max-width: 100%; }
#craft .cw-hud {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
  pointer-events: none;
}
#craft .cw-hud > :is(span, div, p, button) { margin: 0; padding: 7px 9px; border: 1px solid #6b81656b; border-radius: 8px; background: #fffdf0ed; color: #294b3e; font-size: 16px; line-height: 1.45; box-shadow: 0 2px 7px #21453020; }
#craft .cw-hud button { pointer-events: auto; }
#craft .cw-hud .cw-stars { color: var(--cw-gold-ink); background: #fff2beeF; }
#craft .cw-world-caption { position: absolute; bottom: 9px; left: 10px; right: 10px; z-index: 3; margin: 0; padding: 7px 9px; border-radius: 7px; background: #1c3f38df; color: #fff9e5; font-size: 16px; line-height: 1.5; pointer-events: none; }
#craft .cw-world-caption:empty, #craft .cw-world-status:empty { display: none; }
#craft .cw-world-status { margin: 0; padding: 9px 12px; background: #fff0c7; border-bottom: 1px solid #dcc68c; color: #6c5128; font-size: 16px; line-height: 1.7; }
#craft .cw-world-status button { margin-top: 6px; background: #fff9e5; color: #684b20; }
#craft .cw-controls { display: flex; flex-direction: column; gap: 8px; padding: 10px 10px 0; }
#craft .cw-mode-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
#craft .cw-mode-controls button { padding: 9px 5px; border-color: #93a591; background: #e8ead7; }
#craft .cw-mode-controls button[aria-pressed="true"] { border-color: #1c776b; border-bottom-color: #104c49; color: #fffdf0; background: #17655f; box-shadow: inset 0 1px #80e3c14d; }
#craft .cw-camera { display: flex; flex-wrap: wrap; gap: 6px; }
#craft .cw-camera button { flex: 1 1 66px; padding: 8px 6px; background: #fbf8e8; }
#craft .cw-panel { min-width: 0; padding: 16px 12px calc(20px + env(safe-area-inset-bottom, 0px)); }
#craft .cw-panel > :last-child { margin-bottom: 0; }
#craft .cw-heading, #craft .cw-card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
#craft .cw-heading > :is(h1, h2), #craft .cw-card-header > :is(h2, h3) { flex: 1 1 150px; }
#craft .cw-heading > button { flex: 0 0 auto; }
#craft .cw-toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; }
#craft .cw-toolbar button { min-width: 0; padding: 10px 4px; border-color: #aab79e; border-bottom-color: #829573; background: linear-gradient(#fbf8e8, #e6e5ce); font-size: 16px; }
#craft .cw-toolbar button[aria-pressed="true"] { border-color: #216c60; color: #174f45; background: #d5ece0; }
#craft .cw-primary, #craft .cw-secondary, #craft .cw-danger { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 52px; border-radius: 9px; font-size: 18px; }
#craft .cw-primary { border: 1px solid #195c53; border-bottom: 4px solid #103e37; color: #fffbe8; background: linear-gradient(#247c6f, #17655f); box-shadow: inset 0 1px #b5f2c33b, 0 2px #99ac8d4d; }
#craft .cw-secondary { border-color: #bca366; border-bottom-color: #927336; background: linear-gradient(#f9e8a8, #eec766); color: #5a4319; }
#craft .cw-danger { border-color: #b17d65; border-bottom-color: #82523d; background: #f5dfca; color: #733c29; }
#craft .cw-text { border-color: transparent; background: transparent; color: #285f53; }
#craft .cw-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 12px 0; }
#craft .cw-actions > button { flex: 1 1 120px; width: auto; }
#craft .cw-card { min-width: 0; padding: 15px; border: 1px solid #c5ccb0; border-bottom: 4px solid #b7bea1; border-radius: 12px; margin-bottom: 14px; background: #fffdf2; box-shadow: 0 2px 0 #dedcc8; }
#craft .cw-card-header { margin-bottom: 8px; }
#craft .cw-card > p { color: var(--cw-muted); }
#craft .cw-card > button { margin-top: 10px; }
#craft .cw-card.is-complete { border-color: #8ca886; background: #f4f8e8; }
#craft .cw-card.is-locked { background: #eeeedf; }
#craft .cw-reward-chip, #craft .cw-tier, #craft .cw-tag { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 8px; border: 1px solid #d8be71; border-radius: 6px; background: #fff0bb; color: #654c1c; font-size: 16px; line-height: 1.5; }
#craft .cw-tier { border-color: #b7c9ae; background: #e6eedb; color: #395e42; }
#craft .cw-stars { font: 800 18px/1.5 system-ui, sans-serif; color: var(--cw-gold-ink); white-space: nowrap; }
#craft .cw-muted, #craft .cw-fine { color: var(--cw-muted); font-size: 16px; line-height: 1.7; }
#craft .cw-notice { padding: 12px; border-left: 4px solid #a37a40; border-radius: 4px; background: #f5e8c6; color: #684b27; font-size: 17px; line-height: 1.8; }
#craft .cw-npcs { display: grid; grid-template-columns: 1fr; gap: 12px; }
#craft .cw-npc { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; min-height: 102px; padding: 12px; text-align: left; background: #fffdf2; border-color: #b8c3a7; }
#craft .cw-npc > :is(svg, img), #craft .cw-npc-icon { width: 56px; height: 64px; object-fit: contain; }
#craft .cw-npc > div { min-width: 0; }
#craft .cw-npc :is(b, strong) { display: block; font-size: 20px; line-height: 1.5; }
#craft .cw-npc p, #craft .cw-npc-reward { margin: 4px 0 0; font-size: 16px; line-height: 1.6; color: #52645b; }
#craft .cw-npc .cw-tier { margin-top: 5px; }
#craft .cw-question { padding: 0; }
#craft .cw-question > p { font-size: 18px; margin: 7px 0; line-height: 1.7; }
#craft .cw-equation { margin: 10px 0; text-align: center; color: #174d43; font: 800 clamp(28px, 8vw, 40px)/1.3 system-ui, sans-serif; letter-spacing: 1px; overflow-wrap: anywhere; }
#craft .cw-answer-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
#craft .cw-answer-row > label { flex: 0 0 auto; font-size: 17px; }
#craft .cw-input { width: 100%; min-width: 0; min-height: 52px; padding: 7px 10px; border: 2px solid #8daca0; border-bottom: 4px solid #5f8979; border-radius: 8px; background: #fffef7; color: #244e43; text-align: center; font: 800 30px/1.2 system-ui, sans-serif; letter-spacing: 2px; caret-color: #17655f; }
#craft .cw-input::placeholder { color: #667c70; }
#craft .cw-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 10px 0 12px; }
#craft .cw-keypad > button { min-width: 0; min-height: 50px; padding: 7px; background: linear-gradient(#fffef5, #e8ecdc); border: 1px solid #bcc7ad; border-bottom: 4px solid #98ad8d; box-shadow: 0 1px #d1d7bd; color: #234c3d; font: 800 26px/1 system-ui, sans-serif; }
#craft .cw-keypad > button[data-action="confirm"], #craft .cw-keypad > button[data-action="answer"] { color: #fffbe8; background: #17655f; border-color: #195c53; border-bottom-color: #103e37; font-family: inherit; font-size: 17px; font-weight: 800; line-height: 1.4; }
#craft .cw-keypad > button[data-action="erase"], #craft .cw-keypad > button[data-action="clear"] { font-family: inherit; font-size: 17px; }
#craft .cw-explanation { margin: 12px 0 16px; padding: 12px; border: 1px solid #becbab; border-left: 4px solid #56876e; border-radius: 6px; background: #edf3df; color: #3a5a45; font-size: 18px; line-height: 1.85; }
#craft .cw-explanation p { margin: 0; font-size: inherit; line-height: inherit; }
#craft .cw-feedback { padding: 16px; border: 1px solid #b6c8ab; border-bottom: 4px solid #92ae89; border-radius: 12px; background: #fbfff0; margin-bottom: 14px; }
#craft .cw-feedback.is-learning { border-color: #d3b77a; border-bottom-color: #b1955c; background: #fff7e0; }
#craft .cw-feedback > h2 { margin-bottom: 10px; }
#craft .cw-feedback .cw-equation { margin-top: 12px; }
#craft .cw-material-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
#craft .cw-material { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 0; min-height: 104px; padding: 9px 5px; background: #fdfbed; text-align: center; }
#craft .cw-material[aria-pressed="true"] { background: #dff0dd; border-color: #348172; box-shadow: 0 0 0 2px #a9d9b8; }
#craft .cw-material :is(b, strong) { font-size: 16px; line-height: 1.5; }
#craft .cw-material small { font: 800 16px/1.3 system-ui, sans-serif; color: #52645b; }
#craft .cw-swatch { display: inline-block; flex: 0 0 auto; width: 28px; height: 28px; border: 1px solid #173c373d; border-radius: 3px; background-color: var(--material-color, #8f9875); box-shadow: inset 4px 4px #ffffff3d, inset -4px -4px #00000021, 1px 2px 0 #203d3529; }
#craft .cw-material > .cw-swatch { width: 36px; height: 36px; }
#craft .cw-inventory-strip { display: flex; gap: 7px; overflow-x: auto; overscroll-behavior-x: contain; padding: 8px 3px 10px; margin: 0 0 6px; scrollbar-width: thin; scrollbar-color: #8da380 transparent; }
#craft .cw-inventory-strip > button { display: grid; grid-template-columns: 25px auto; grid-template-rows: auto auto; align-items: center; gap: 1px 6px; flex: 0 0 auto; min-width: 94px; min-height: 58px; padding: 7px; border-color: #78886b; border-bottom-color: #536649; color: #f9f5de; background: linear-gradient(#5c6c4f, #475a3e); text-align: left; }
#craft .cw-inventory-strip > button[aria-pressed="true"] { border-color: #208a79; box-shadow: 0 0 0 2px #74d6ba; color: #faffea; background: #225c4b; }
#craft .cw-inventory-strip .cw-swatch { grid-row: 1 / 3; width: 24px; height: 24px; }
#craft .cw-inventory-strip :is(b, span) { font-size: 16px; line-height: 1.3; }
#craft .cw-inventory-strip small { font: 800 14px/1.2 system-ui, sans-serif; color: #f4e6b9; }
#craft .cw-costs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; margin: 9px 0; color: #536457; font-size: 16px; line-height: 1.65; }
#craft .cw-costs > span { display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px; background: #ecefdd; border-radius: 5px; }
#craft .cw-costs .cw-swatch { width: 19px; height: 19px; }
#craft .cw-item-icon { display: grid; place-items: center; flex: 0 0 auto; width: 72px; height: 72px; border: 1px solid #c4cdb1; border-radius: 8px; background: linear-gradient(135deg, #e6ecd8, #fffbe9); }
#craft .cw-item-icon :is(svg, img) { display: block; width: 64px; height: 64px; object-fit: contain; }
#craft .cw-output { display: flex; align-items: center; gap: 9px; font-size: 17px; color: #375e48; margin: 10px 0; }
#craft .cw-progress { width: 100%; height: 13px; overflow: hidden; border: 1px solid #879e7a; border-radius: 4px; background: #dce4cc; margin: 10px 0; }
#craft .cw-progress > span { display: block; height: 100%; max-width: 100%; background: linear-gradient(90deg, #438168, #8fc58c); }
#craft .cw-edit { margin: 9px 0 0; padding: 12px; border: 1px solid #a6b79b; border-radius: 10px; background: #e8ecd7; }
#craft .cw-target { margin: 0 0 10px; color: #355447; font-size: 17px; line-height: 1.7; }
#craft .cw-coordinates { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px; margin: 10px 0; }
#craft .cw-coordinates > :is(label, div) { display: flex; align-items: center; gap: 5px; font-size: 16px; }
#craft .cw-coordinates input { width: 58px; min-height: 48px; padding: 7px 4px; text-align: center; color: #244b3b; border: 1px solid #9fb194; border-radius: 6px; background: #fffef2; font: 800 20px/1.3 system-ui, sans-serif; }
#craft .cw-coordinates select { max-width: 100%; min-height: 48px; padding: 7px 9px; border: 1px solid #9fb194; border-radius: 6px; background: #fffef2; color: #244b3b; font-size: 16px; }
#craft .cw-stepper { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 8px; margin: 10px 0; }
#craft .cw-stepper > :is(span, output) { text-align: center; font-size: 18px; }
#craft .cw-stepper > button { padding: 5px; font-size: 23px; }
#craft .cw-machine-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 11px 0; }
#craft .cw-machine-actions > button { flex: 1 1 110px; min-width: 0; }
#craft .cw-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 12px 0 18px; }
#craft .cw-stat-grid > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 13px 8px; border: 1px solid #c7ceb3; border-radius: 8px; background: #fffdf0; text-align: center; }
#craft .cw-stat-grid b { font: 800 29px/1.3 system-ui, sans-serif; color: #336d52; }
#craft .cw-stat-grid span { font-size: 16px; color: #536457; }
#craft .cw-history { margin: 14px 0; }
#craft .cw-history > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 7px; padding: 12px 0; border-bottom: 1px solid #ccd3ba; font-size: 16px; line-height: 1.6; }
#craft .cw-toast { position: sticky; z-index: 10; bottom: 8px; margin: 12px; padding: 12px 13px; border: 1px solid #0d514b; border-radius: 8px; box-shadow: 0 3px 13px #183e3533; color: #fffce7; background: #205f53; font-size: 17px; line-height: 1.7; pointer-events: none; }
#craft .cw-toast:empty { display: none; }
#craft .is-pending .cw-panel, #craft .is-conflict .cw-panel { background: #f5efda; }
#craft .cw-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; }
#craft .cw-app:is([data-page="question"], [data-page="feedback"]) .cw-stage { height: 110px; }
#craft .cw-app:is([data-page="question"], [data-page="feedback"]) :is(.cw-controls, .cw-toolbar, .cw-edit, .cw-hud, .cw-world-caption) { display: none; }
#craft .cw-app:is([data-page="question"], [data-page="feedback"]) .cw-panel { padding-top: 12px; }
#craft .cw-app:is([data-page="inventory"], [data-page="recipes"], [data-page="challenges"], [data-page="scores"]) .cw-stage { height: 180px; }
#craft .cw-app:is([data-page="inventory"], [data-page="recipes"], [data-page="challenges"], [data-page="scores"]) :is(.cw-controls, .cw-edit) { display: none; }
#craft .cw-app:is([data-page="pending"], [data-page="conflict"]) .cw-stage { height: 160px; }
#craft .cw-app:is([data-page="pending"], [data-page="conflict"]) :is(.cw-controls, .cw-edit, .cw-toolbar) { display: none; }
#craft .cw-app[data-scene="hidden"] .cw-stage { display: none; }
@media (max-width: 360px) {
  #craft .cw-nav { padding: 4px 7px; gap: 5px; }
  #craft .cw-nav > :is(span, strong, h1) { font-size: 16px; }
  #craft .cw-nav > button { padding: 7px 5px; }
  #craft .cw-nav .cw-stars { padding: 6px; font-size: 16px; }
  #craft .cw-stage { height: 280px; }
  #craft .cw-panel { padding-left: 10px; padding-right: 10px; }
  #craft .cw-controls { padding-left: 8px; padding-right: 8px; }
  #craft .cw-toolbar { gap: 6px; }
  #craft .cw-card, #craft .cw-feedback { padding: 12px; }
  #craft h1 { font-size: 23px; }
  #craft h2 { font-size: 21px; }
  #craft .cw-card-header { gap: 7px; }
  #craft .cw-material-grid { gap: 6px; }
  #craft .cw-material { min-height: 100px; padding: 8px 3px; }
  #craft .cw-keypad { gap: 6px; }
  #craft .cw-keypad > button { min-height: 48px; }
  #craft .cw-equation { font-size: 30px; }
  #craft .cw-item-icon { width: 62px; height: 62px; }
  #craft .cw-item-icon :is(svg, img) { width: 54px; height: 54px; }
  #craft .cw-app:is([data-page="question"], [data-page="feedback"]) .cw-stage { height: 96px; }
  #craft .cw-app:is([data-page="inventory"], [data-page="recipes"], [data-page="challenges"], [data-page="scores"]) .cw-stage { height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  #craft, #craft * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Explicit coordinate/grid editing is also usable without WebGL or precise tracing. */
#craft .cw-coordinates { display:flex; gap:8px; flex-wrap:wrap; align-items:end; margin:12px 0; }
#craft .cw-coordinates label { flex:1 1 66px; min-width:0; display:grid; gap:5px; font-size:16px; }
#craft .cw-coordinates input,#craft .cw-coordinates select,#craft #cwFacing { box-sizing:border-box; width:100%; min-height:48px; border:2px solid #b5c8bd; border-radius:10px; background:#fffdf4; color:#203e37; font:inherit; font-size:18px; padding:6px; }
#craft .cw-flat-map { margin-top:16px; }
#craft .cw-flat-map summary { padding:12px 0; min-height:48px; box-sizing:border-box; font-weight:700; cursor:pointer; }
#craft .cw-grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:3px; }
#craft .cw-grid-cell { min-width:0; width:100%; min-height:52px; padding:4px 1px; display:flex; flex-direction:column; justify-content:center; align-items:center; font-size:16px; line-height:1.25; }
#craft .cw-grid-cell small { font-size:14px; }
#craft .cw-grid-cell[aria-pressed="true"] { outline:3px solid #b07c24; outline-offset:-3px; background:#d9f0df; }
#craft .cw-tool { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
#craft .cw-tool .cw-item-icon { width:72px; height:72px; flex:0 0 72px; }
#craft .cw-tool .cw-item-icon svg { width:100%; height:100%; }
#craft .cw-farm-status { display:block; min-height:24px; font-size:17px; }
#craft #openCraftScores { min-height:48px; }

#craft .cw-camera button { flex:1 1 44px; min-width:48px; padding:8px 4px; }
#craft .cw-toolbar { grid-template-columns:repeat(4,minmax(0,1fr)); padding:10px; margin:0; }
#craft .cw-npc.cw-card { display:block; }
#craft .cw-instruction { margin:0 0 10px; font-size:16px; line-height:1.65; }
#craft .cw-keypad > button[data-action="submit"] { color:#fffbe8; background:#17655f; border-color:#195c53; border-bottom-color:#103e37; font-family:inherit; font-size:18px; }
#craft .cw-build-dock { position:fixed; bottom:calc(8px + env(safe-area-inset-bottom,0px)); z-index:14; padding:8px; border:2px solid #a8c59e; border-radius:12px; background:#273f30f5; color:#fffbe6; box-shadow:0 -3px 15px #18372844; }
#craft .cw-build-dock > span { display:block; margin-bottom:6px; font-size:16px; line-height:1.4; }
#craft .cw-build-dock > div { display:grid; grid-template-columns:2fr 1fr; gap:8px; }
#craft .cw-app[data-page="world"] .cw-panel { padding-bottom:130px; }
#openCraftScores { min-height:64px; width:100%; border:1px solid #9dbc8a; border-radius:12px; margin-bottom:12px; padding:12px; background:#e5edcf; color:#244d35; font-size:22px; font-weight:800; }

#craft .cw-math-row { display:flex; align-items:center; justify-content:center; gap:8px; margin:8px 0; }
#craft .cw-math-row .cw-equation { margin:0; white-space:nowrap; font-size:clamp(26px,8vw,34px); }
#craft .cw-math-row .cw-input { flex:0 1 110px; width:110px; min-width:80px; min-height:50px; }
#craft .cw-app[data-page="question"] .cw-panel { padding-top:10px; padding-bottom:10px; }
#craft .cw-app[data-page="question"] .cw-question { line-height:1.5; margin:4px 0 8px; }
#craft .cw-app[data-page="question"] .cw-keypad { margin:6px 0; }
#craft .cw-app[data-page="question"] .cw-actions { margin:6px 0; }

#craft .cw-build-dock { left:50%; width:min(398px,calc(100vw - 32px)); transform:translateX(-50%); }

/* Keep the editing dock clear of camera and navigation on short Telegram viewports. */
#craft .cw-app[data-page="world"][data-editing="true"] .cw-stage { height:clamp(160px,calc(100dvh - 408px),330px); }

/* Blueprint workshop: exact building previews and one clear next action. */
#craft .cw-toolbar { grid-template-columns:repeat(5,minmax(0,1fr)); gap:5px; padding:9px 8px; }
#craft .cw-toolbar button { padding:9px 2px; }
#craft .cw-blueprints { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
#craft .cw-blueprint-card { min-width:0; padding:10px; border:1px solid #afbea2; border-bottom:4px solid #9aab8b; border-radius:14px; background:#fffdf2; box-shadow:0 4px 0 #72856318; }
#craft .cw-blueprint-card h3 { margin:4px 0; font-size:18px; }
#craft .cw-blueprint-card p { margin:5px 0; color:var(--cw-muted); font-size:15px; }
#craft .cw-blueprint-card .cw-stars { display:inline-block; margin:3px 0; font-size:15px; }
#craft .cw-blueprint-card .cw-primary { min-height:48px; margin-top:4px; }
#craft .cw-blueprint-art { display:flex; align-items:center; justify-content:center; overflow:hidden; aspect-ratio:1.12; border-radius:9px; background:radial-gradient(ellipse at 50% 65%,#e2ecd0,#eef2dd 65%); }
#craft .cw-blueprint-art svg { display:block; width:100%; height:auto; max-height:100%; }
#craft .cw-heading > .cw-secondary { flex:0 1 auto; width:auto; min-height:48px; font-size:16px; }
#craft .cw-panel > .cw-primary,#craft .cw-panel > .cw-secondary { margin-top:10px; }
#craft .cw-app[data-page="placement"] .cw-stage { height:clamp(170px,calc(100dvh - 390px),330px); }
#craft .cw-app[data-page="project"] .cw-stage { height:clamp(140px,calc(100dvh - 450px),280px); }
#craft .cw-app:is([data-page="placement"],[data-page="project"]) :is(.cw-mode-controls,.cw-toolbar,.cw-hud) { display:none; }
#craft .cw-app:is([data-page="placement"],[data-page="project"]) .cw-controls { padding-top:8px; }
#craft .cw-app[data-page="placement"] .cw-panel { padding-bottom:145px; }
#craft .cw-app[data-page="project"] .cw-panel { padding-bottom:28px; }
#craft .cw-app:is([data-page="blueprints"],[data-page="projects"],[data-page="map"]) :is(.cw-controls,.cw-toolbar) { display:none; }
#craft .cw-app:is([data-page="blueprints"],[data-page="projects"]) .cw-panel { padding-top:14px; }
#craft .cw-bill { list-style:none; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin:10px 0 16px; padding:0; }
#craft .cw-bill li { display:flex; align-items:center; flex-wrap:wrap; min-width:0; gap:6px; padding:8px; border:1px solid #d0d8bf; border-radius:8px; background:#fffdf4; font-size:15px; }
#craft .cw-bill li b { margin-left:auto; font-variant-numeric:tabular-nums; }
#craft .cw-bill .cw-swatch { flex:0 0 16px; width:16px; height:16px; border:1px solid #29493d44; border-radius:3px; }
#craft .cw-panel details > summary { min-height:48px; padding:10px 0; cursor:pointer; font-size:17px; font-weight:800; }
#craft progress { display:block; appearance:none; -webkit-appearance:none; width:100%; height:18px; margin:10px 0 16px; border:2px solid #92aa8d; border-radius:7px; overflow:hidden; background:#e4e9d7; color:#2b7c62; }
#craft progress::-webkit-progress-bar { background:#e4e9d7; }
#craft progress::-webkit-progress-value { background:repeating-linear-gradient(90deg,#3d8c65 0 13px,#5ca879 13px 15px); }
#craft progress::-moz-progress-bar { background:#3d8c65; }
#craft .cw-progress-label { font-weight:800; }
#craft .cw-cancel-confirm { margin-top:16px; padding:14px; border:2px solid #b88855; border-radius:12px; background:#fff1d5; }
#craft .cw-cancel-confirm .cw-button { margin-top:8px; }
#craft .cw-map { display:block; width:100%; aspect-ratio:1; padding:0; overflow:hidden; border:3px solid #4d725c; border-radius:14px; background:#a3c494; touch-action:manipulation; }
#craft .cw-map svg { display:block; width:100%; height:100%; }
#craft .cw-landmarks { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-top:12px; }
#craft .cw-landmarks button { font-size:17px; }
@media(max-width:360px) {
  #craft .cw-blueprints { gap:8px; }
  #craft .cw-blueprint-card { padding:8px; }
  #craft .cw-blueprint-card h3 { font-size:17px; }
  #craft .cw-app[data-page="placement"] .cw-stage { height:clamp(170px,calc(100dvh - 390px),260px); }
  #craft .cw-app[data-page="project"] .cw-stage { height:clamp(140px,calc(100dvh - 450px),260px); }
}
