
:root {
  --bg: #ECEBE8; --ink: #111111; --soft: rgba(17, 17, 17, .58); --faint: rgba(17, 17, 17, .32);
  --line: rgba(17, 17, 17, .14); --panel: rgba(255, 255, 255, .86); --on: #111111; --on-ink: #FFFFFF;
  --accent: #F26A0F;
  color-scheme: light dark;
}
:root[data-theme="dark"] {
  --bg: #121212; --ink: #F2F2F0; --soft: rgba(242, 242, 240, .6); --faint: rgba(242, 242, 240, .34);
  --line: rgba(242, 242, 240, .16); --panel: rgba(22, 22, 22, .84); --on: #F2F2F0; --on-ink: #111111;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --ink: #F2F2F0; --soft: rgba(242, 242, 240, .6); --faint: rgba(242, 242, 240, .34);
    --line: rgba(242, 242, 240, .16); --panel: rgba(22, 22, 22, .84); --on: #F2F2F0; --on-ink: #111111;
  }
}
/* lit: the room is dark whatever the theme */
body.lit {
  --ink: #F2F2F0; --soft: rgba(242, 242, 240, .6); --faint: rgba(242, 242, 240, .34);
  --line: rgba(242, 242, 240, .16); --panel: rgba(16, 15, 14, .72); --on: #F2F2F0; --on-ink: #111111;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; transition: background-color 1.6s ease; }
body.lit { background: #0B0A09; }
#app { position: fixed; inset: 0; overflow: hidden; }
#gl, #ov { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gl { touch-action: none; outline: none; opacity: 0; transition: opacity .9s ease; }
#gl.ready { opacity: 1; }
#gl.fade { opacity: 0; transition: opacity .3s ease; }
#ov { pointer-events: none; }
#ui { position: absolute; inset: 0; pointer-events: none; }
button, input { font: inherit; color: inherit; }
.lab { font-size: 9.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }

.brand { position: absolute; top: max(16px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); user-select: none; line-height: 1; }
.brand .wm { font-family: "Inter Tight", Inter, sans-serif; font-weight: 600; font-size: 15px; letter-spacing: .32em; }
.brand .sub { margin-top: 6px; color: var(--soft); }

.top { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); display: flex; gap: 6px; pointer-events: auto; }
.ib { appearance: none; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; border-radius: 0; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.ib svg { width: 15px; height: 15px; display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ib:hover { border-color: var(--faint); }
.ib[aria-pressed="false"] .on, .ib[aria-pressed="true"] .off { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dock { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 12px; transition: opacity .45s ease, transform .45s ease; }
.dock[hidden] { display: flex; opacity: 0; transform: translateY(10px); pointer-events: none; visibility: hidden; transition: opacity .3s ease, transform .3s ease, visibility 0s .3s; }
.dock[hidden] * { pointer-events: none !important; }
.hint { min-height: 17px; font-size: 12.5px; font-weight: 500; color: var(--soft); text-align: center; user-select: none; text-wrap: balance; transition: opacity .3s ease; }
.hint.fade { opacity: 0; }
.row { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 6px; pointer-events: auto; }
.grp { display: flex; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn { appearance: none; border: 0; background: transparent; height: 38px; padding: 0 13px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); transition: background-color .2s ease, color .2s ease; }
.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.btn + .btn { border-left: 1px solid var(--line); }
.btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn[aria-pressed="true"] { background: var(--on); color: var(--on-ink); }
.btn:disabled { opacity: .35; cursor: default; background: transparent; }
.btn.primary { background: var(--on); color: var(--on-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--on) 86%, var(--bg)); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.size { display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 38px; }
.size input { width: 96px; accent-color: var(--ink); cursor: pointer; }
.size .v { min-width: 44px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* pick */
.pick { gap: 14px; }
.pinfo { display: flex; align-items: flex-end; gap: 18px; pointer-events: auto; user-select: none; }
.pinfo .arrow { appearance: none; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pinfo .arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.pinfo .arrow:disabled { opacity: .3; cursor: default; }
.ptext { min-width: 236px; max-width: 330px; text-align: center; }
.ptext .idx { color: var(--soft); }
.ptext .nm { margin: 7px 0 6px; font-family: "Inter Tight", Inter, sans-serif; font-weight: 600; font-size: 34px; letter-spacing: -.02em; line-height: 1; }
.ptext .nm sup { font-size: 11px; font-weight: 600; letter-spacing: .08em; vertical-align: top; margin-left: 4px; color: var(--soft); }
.ptext .bl { font-size: 12.5px; line-height: 1.5; color: var(--soft); min-height: 38px; text-wrap: balance; }
.fact { font-size: 11px; color: var(--faint); text-align: center; user-select: none; }

/* faces menu */
.menu { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); pointer-events: auto; min-width: 220px; }
.menu[hidden] { display: none; }
.menu .btn { justify-content: flex-start; border-left: 0; }
.menu .btn:nth-child(2n) { border-left: 1px solid var(--line); }
.menu .btn:nth-child(n+3) { border-top: 1px solid var(--line); }
.anchor { position: relative; display: flex; }

.help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px)); max-height: calc(100% - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); padding: 22px 24px 20px; pointer-events: auto; transition: opacity .3s ease, transform .3s ease; }
.help[hidden] { display: block; opacity: 0; transform: translate(-50%, -48%); pointer-events: none; visibility: hidden; transition: opacity .3s ease, transform .3s ease, visibility 0s .3s; }
.help h2 { margin: 0 0 12px; }
.help dl { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 12.5px; line-height: 1.45; }
.help dt { font-weight: 600; }
.help dd { margin: 0; color: var(--soft); }
.help ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.help li { position: relative; padding-left: 14px; font-size: 12.5px; line-height: 1.5; }
.help li::before { content: ""; position: absolute; left: 0; top: .6em; width: 5px; height: 5px; background: var(--accent); border-radius: 50%; }
.help .keys { margin-top: 14px; font-size: 11px; color: var(--soft); line-height: 1.6; }
.help kbd { font: inherit; font-weight: 600; padding: 0 4px; border: 1px solid var(--line); }
.help .x { position: absolute; top: 10px; right: 10px; }

.nogl { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 24px; text-align: center; font-size: 14px; line-height: 1.6; }
.nogl.on { display: flex; }

@media (max-width: 640px) {
  .btn .t { display: none; }
  .btn { padding: 0 11px; }
  .btn.keep .t { display: inline; }
  .size input { width: 72px; }
  .size { padding: 0 9px; gap: 7px; }
  .ptext { min-width: 0; }
  .ptext .nm { font-size: 28px; }
  .pinfo { gap: 10px; }
}
@media (max-width: 400px) {
  .brand .sub { display: none; }
  .btn { padding: 0 9px; height: 36px; }
  .size input { width: 58px; }
  .size .v { min-width: 36px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .dock { gap: 6px; bottom: max(8px, env(safe-area-inset-bottom)); }
  .btn { height: 32px; }
  .size { height: 32px; }
  .ptext .nm { font-size: 24px; margin: 4px 0; }
  .ptext .bl { min-height: 0; }
  .fact { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  body, #gl, .dock, .hint, .help { transition: none !important; }
}
/* Portrait workshop: keep the canvas and controls in separate safe areas. */
html, body { background: #d8d4cd; }
#app { --stage-top: 138px; --stage-bottom: 216px; position: absolute; inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(100vw, 75dvh, 750px); aspect-ratio: 3 / 4; background: var(--bg); box-shadow: 0 20px 100px rgba(48,35,19,0.1490); container-type: inline-size; }
#app[data-mode="template"] { --stage-bottom: 216px; }
#app[data-mode="carve"] { --stage-bottom: 216px; }
#app[data-mode="carve"][data-sized="true"] { --stage-bottom: 252px; }
#app[data-mode="lit"], #app[data-mode="seq"] { --stage-bottom: 136px; }
#gl, #ov { inset: calc(var(--stage-top) + 8px) 16px var(--stage-bottom); width: calc(100% - 32px); height: calc(100% - var(--stage-top) - var(--stage-bottom) - 8px); border-radius: 20px; }
body.lit #app { background: #0B0A09; }
#app { transition: background-color 1.6s ease; }
.brand { top: 23px; left: 26px; }
.brand .wm { font-size: 18px; letter-spacing: .23em; }
.brand .sub { display: block; font-size: 10px; letter-spacing: .12em; margin-top: 7px; }
.top { top: 23px; right: 24px; gap: 8px; }
.ib { width: 34px; height: 34px; border-radius: 50%; background: transparent; }
.steps { position: absolute; top: 79px; left: 26px; right: 26px; display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11px; }
.steps span { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.steps i { font-style: normal; font-size: 9px; border: 1px solid var(--line); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.steps .active { color: var(--ink); font-weight: 600; }
.steps .active i { background: var(--accent); color: white; border-color: var(--accent); }
.steps b { flex: 1; height: 1px; background: var(--line); }
.stage-caption { position: absolute; top: 119px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--soft); }
.dock { bottom: 20px; padding: 0 24px; gap: 12px; }
.pick { gap: 16px; }
.pinfo { width: 100%; justify-content: space-between; align-items: center; gap: 14px; }
.ptext { flex: 1; max-width: none; min-width: 0; }
.ptext .nm { font-size: 32px; margin: 9px 0; }
.ptext .nm sup { display: none; }
.ptext .bl { min-height: 22px; font-size: 12px; }
.pinfo .arrow { border-radius: 50%; width: 42px; height: 42px; flex: none; }
.fact { font-size: 10px; letter-spacing: .02em; }
.btn { letter-spacing: .02em; text-transform: none; font-size: 12px; height: 42px; padding: 0 14px; border-radius: 9px; }
.btn .t { display: inline; }
.grp { border-radius: 10px; background: transparent; }
.btn + .btn { border-left: 0; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #d95908; }
#dPick > .row, #dPick > .row .grp, #pGo { width: 100%; }
#pGo { justify-content: center; height: 48px; }
#dCarve { gap: 10px; }
#dCarve > .row { width: 100%; display: flex; gap: 9px; }
#dCarve .toolbox { width: 100%; display: flex; padding: 4px; background: var(--panel); }
.toolbox .btn { flex: 1; justify-content: center; flex-direction: column; gap: 4px; padding: 6px 0; height: 56px; font-size: 10px; }
.toolbox .btn svg { width: 20px; height: 20px; }
.toolbox .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.template-panel { width: 100%; }
#dTemplate > .row, #dTemplate > .row .grp { width: 100%; }
#dTemplate > .row .btn { flex: 1; justify-content: center; height: 46px; }
.carve-summary { font-size: 11px; color: var(--soft); }
.template-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.template-heading strong { font-size: 12px; font-weight: 600; }
#guideStatus { font-size: 10px; color: var(--soft); }
#faces.menu { position: static; transform: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; border: 0; min-width: 0; background: none; backdrop-filter: none; }
#faces .btn { flex-direction: column; justify-content: center; padding: 5px 0; height: 65px; border: 1px solid var(--line); font-size: 10px; gap: 4px; background: var(--panel); }
#faces .btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
#faces img, #faces .free-icon { width: 34px; height: 30px; object-fit: contain; }
#faces img { background: #f4e5d1; border-radius: 5px; }
.free-icon { display: grid; place-items: center; font-size: 24px; font-weight: 400; }
.hint { font-size: 11px; min-height: 16px; }
.work-actions { display: flex; width: 100%; gap: 9px; pointer-events: auto; }
.work-actions .grp { flex: 1; }
.work-actions .btn { flex: 1; justify-content: center; padding: 0 9px; height: 40px; font-size: 11px; }
.size { width: 100%; height: 32px; justify-content: center; border: 0; padding: 0; }
.size input { flex: 1; max-width: 230px; accent-color: var(--accent); }
.size .v { min-width: 48px; }
#dLit .row { width: 100%; gap: 8px; }
#dLit .grp { flex: 1; }
#dLit .btn { flex: 1; justify-content: center; padding: 0 10px; font-size: 11px; }
.help { border-radius: 16px; }
@container (max-width: 480px) {
  #ui .brand { top: 16px; left: 18px; }
  #ui .top { top: 15px; right: 16px; gap: 6px; }
  #ui .brand .wm { font-size: 15px; }
  #ui .brand .sub { font-size: 8px; }
  #ui .steps { top: 62px; left: 18px; right: 18px; font-size: 10px; gap: 8px; }
  #ui .stage-caption { top: 94px; font-size: 10px; }
  #ui .dock { bottom: 12px; padding: 0 16px; gap: 8px; }
  #ui .ptext .nm { font-size: 25px; margin: 6px 0; }
  #ui .ptext .bl { font-size: 10px; min-height: 16px; }
  #ui .ptext .idx { font-size: 8px; letter-spacing: .06em; }
  #ui #pGo { height: 40px; }
  #ui .pinfo .arrow { width: 34px; height: 34px; }
  #ui .fact { font-size: 8px; }
  #ui .template-heading { margin-bottom: 6px; }
  #ui .template-heading strong { font-size: 11px; }
  #ui #guideStatus { font-size: 9px; }
  #ui #faces { gap: 5px; }
  #ui #faces .btn { height: 49px; font-size: 9px; gap: 1px; border-radius: 7px; }
  #ui #faces img, #ui #faces .free-icon { width: 27px; height: 24px; }
  #ui .toolbox .btn { height: 43px; font-size: 9px; gap: 3px; }
  #ui .toolbox .btn svg { width: 16px; height: 16px; }
  #ui .work-actions .btn { height: 34px; font-size: 10px; padding: 0 6px; gap: 5px; }
  #ui .hint { font-size: 9px; min-height: 13px; }
  #ui .size { height: 25px; }
  #ui #dLit .btn { font-size: 9px; padding: 0 7px; gap: 4px; }
}
@media (max-width: 480px), (max-height: 640px) {
  #app { --stage-top: 110px; --stage-bottom: 170px; }
  #app[data-mode="template"] { --stage-bottom: 190px; }
  #app[data-mode="carve"] { --stage-bottom: 170px; }
  #app[data-mode="carve"][data-sized="true"] { --stage-bottom: 204px; }
  #app[data-mode="lit"], #app[data-mode="seq"] { --stage-bottom: 112px; }
}


html, body { background: #140c20; }
body { font-family: "Microsoft YaHei", "Microsoft YaHei", sans-serif; background: radial-gradient(ellipse at 50% 30%, #3b214b, #130b1e 75%); }
body.lit { background: #100a19; }
#app, body.lit #app {
  --bg: #25132e; --ink: #fff0c9; --soft: #dcb7d2; --faint: #a681a6;
  --line: #92658d; --panel: #2b1738; --on: #ff9d32; --on-ink: #fff1cf; --accent: #ff8c24;
  --stage-top: 22%; --stage-bottom: 32%;
  background: #281737; color: var(--ink); box-shadow: 0 0 100px rgba(0,0,0,0.5333); isolation: isolate;
  font-family: "Microsoft YaHei", "Microsoft YaHei", sans-serif;
}
#app[data-mode="pick"] { --stage-bottom: 32%; }
#app[data-mode="template"] { --stage-bottom: 32%; }
#app[data-mode="carve"] { --stage-bottom: 32%; }
#app[data-mode="carve"][data-sized="true"] { --stage-bottom: 32%; }
#app[data-mode="lit"], #app[data-mode="seq"] { --stage-bottom: 32%; }
#app::before { content: ""; position: absolute; inset: 0; z-index: 0; background: url("assets/halloween-background.webp") center / 100% 100%; filter: brightness(var(--scene-brightness, 1)); pointer-events: none; }
#app::after { content: ""; position: absolute; left: 29%; top: 62.5%; width: 42%; height: 3.5%; z-index: 0; border-radius: 50%; background: radial-gradient(ellipse, rgba(23,7,25,0.6667), transparent 70%); filter: blur(5px); pointer-events: none; }
#gl, #ov { z-index: 1; inset: var(--stage-top) 0 var(--stage-bottom); width: 100%; height: calc(100% - var(--stage-top) - var(--stage-bottom)); border-radius: 0; }
#gl { mask-image: linear-gradient(to bottom, transparent 0%, #000 4%, #000 94%, transparent 100%); }
#gl { transition: opacity .9s ease, transform .65s ease; }
#ov { transition: transform .65s ease; }
/* 8% of the 46%-high canvas moves the display down by 3.7% of the frame. */
#app[data-mode="seq"] #gl, #app[data-mode="seq"] #ov,
#app[data-mode="lit"] #gl, #app[data-mode="lit"] #ov { transform: translateY(8%); }
#app[data-mode="seq"]::after, #app[data-mode="lit"]::after { top: 66.2%; }
#ov { z-index: 2; }
#ui { z-index: 3; }
.brand, #ui .brand { top: .2%; left: 17%; width: 64%; }
.brand .wm { display: block; margin: 0; }
.brand .wm img { width: 100%; height: auto; display: block; filter: drop-shadow(0 3px 3px rgba(27,9,43,0.5333)); }
.brand .sub { display: none; }
.top, #ui .top { top: 2%; right: 2%; gap: calc(var(--u) * .7); flex-direction: column; }
.ib { width: calc(var(--u) * 4.7); height: calc(var(--u) * 4.7); min-width: 25px; min-height: 25px; color: #ffe6ab; border: 1px solid #ba8b69; background: linear-gradient(#41213f, #21132f); box-shadow: inset 0 0 0 2px #1c1025, 0 2px 4px rgba(13,6,28,0.6000); }
.ib svg { width: calc(var(--u) * 2.7); height: calc(var(--u) * 2.7); min-width: 13px; min-height: 13px; }
.ib:hover { border-color: #ffe4b2; background: #53304e; }
.sound-status { position: absolute; top: 17%; right: 3%; z-index: 6; padding: 8px 12px; border: 1px solid #c79574; border-radius: 14px; color: #ffebbf; background: rgba(41,22,48,0.9490); box-shadow: 0 4px 14px rgba(18,8,28,0.5333); font-size: calc(var(--u) * 2); }
.sound-status[hidden] { display: none; }
.steps, #ui .steps { top: 13.8%; left: 9%; right: 9%; font-size: calc(var(--u) * 1.85); gap: calc(var(--u) * .9); text-shadow: 0 2px 2px #170b25; color: #c5a0c7; }
.steps span { gap: calc(var(--u) * .65); border-radius: calc(var(--u) * 4); background: rgba(36,16,48,0.4392); padding-right: calc(var(--u) * .5); }
.steps i { width: calc(var(--u) * 4); height: calc(var(--u) * 4.5); min-width: 20px; min-height: 22px; font: inherit; border: 1.5px solid #bd8bb6; background: rgba(53,32,63,0.8667); }
.steps b { background: #b884ac; opacity: .6; }
.steps .active { color: #fff1c8; font-weight: normal; }
.steps .active i { color: #fff8d3; background: linear-gradient(#ffb64e, #f1750a); border: 1.5px solid #fff0b2; box-shadow: 0 0 12px rgba(255,132,23,0.7333); }
.stage-caption, #ui .stage-caption { top: 18.9%; left: 6%; right: 6%; color: #ffedbf; font-size: calc(var(--u) * 2.7); line-height: 1.3; text-shadow: 0 2px 3px #13081d; }
.stage-caption::before, .stage-caption::after { content: "✦"; color: #ffc865; margin: 0 calc(var(--u) * 1.5); font-size: calc(var(--u) * 2); }
.dock, #ui .dock {
  left: 2%; right: 2%; width: 96%; bottom: 2%; padding: calc(var(--u) * 3) calc(var(--u) * 3) calc(var(--u) * 2.6); gap: calc(var(--u) * 1.4);
  border: calc(var(--u) * 2.1) solid transparent; border-image: url("assets/panel-frame.webp") 35 38 40 38 stretch;
  background: radial-gradient(ellipse at top, rgba(70,38,65,0.8745), rgba(29,16,44,0.9686) 80%) padding-box;
  border-radius: calc(var(--u) * 3.5); filter: drop-shadow(0 4px 7px rgba(17,9,28,0.6000));
}
.dock[hidden] { visibility: hidden; }
.lab { font-weight: normal; text-transform: none; letter-spacing: .03em; font-size: calc(var(--u) * 1.7); }
.btn, #ui .work-actions .btn, #ui #dLit .btn { font-family: "Microsoft YaHei", sans-serif; font-weight: normal; font-size: calc(var(--u) * 2.15); letter-spacing: .02em; color: #ffedc5; }
.btn:focus-visible, .ib:focus-visible, .arrow:focus-visible { outline: 2px solid #ffdd8c; outline-offset: 3px; }
.grp { border: 0; border-radius: calc(var(--u) * 2.3); }
.btn.primary, #ui .btn.primary { color: #fff2cd; background: linear-gradient(#ffab35, #f47b11 65%, #e16a07); text-shadow: 0 2px 1px #a34018; box-shadow: inset 0 0 13px rgba(255,226,146,0.3333), 0 2px 4px rgba(16,6,29,0.4000); }
.btn.primary:hover { background: linear-gradient(#ffbf54, #ff951c); }
.btn.primary, #ui #pGo, #dTemplate > .row .btn, .work-actions .btn, #dLit .btn {
  border: calc(var(--u) * 1.5) solid transparent; border-image: url("assets/button-purple.webp") 23 45 24 45 stretch;
  border-radius: calc(var(--u) * 4); background-color: #44213f; height: calc(var(--u) * 7.5); min-height: 34px; justify-content: center;
}
.btn.primary, #ui #pGo, #dTemplate > .row .primary { border-image-source: url("assets/button-orange.webp"); }
.btn:disabled { opacity: .4; cursor: default; }
.btn svg { width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8); }
.btn .dot { background: #fff3ba; box-shadow: 0 0 8px #fff3ba; width: calc(var(--u) * 1); height: calc(var(--u) * 1); }
#dTemplate > .row .btn { height: calc(var(--u) * 7.7); font-size: calc(var(--u) * 2.9); }
#dTemplate > .row .grp { gap: calc(var(--u) * 2); }
#dTemplate > .row #bTemplateNew { flex: .8; }
#dTemplate > .row #tGo { flex: 1.2; }
.template-heading { margin-bottom: calc(var(--u) * 1.6); }
.template-heading strong, #ui .template-heading strong { font-size: calc(var(--u) * 3.1); font-weight: normal; }
.template-heading strong span { display: inline-block; font-size: calc(var(--u) * 1.65); padding: calc(var(--u) * .5) calc(var(--u) * 1); border: 1px solid #b37aab; border-radius: calc(var(--u) * 2); margin-left: calc(var(--u) * .5); background: #66355d; color: #f7d8ec !important; }
#guideStatus, #ui #guideStatus { color: #e7bed9; font-size: calc(var(--u) * 1.7); }
#faces.menu { gap: calc(var(--u) * 1.2); }
#faces .btn, #ui #faces .btn {
  height: calc(var(--u) * 12.6); padding: calc(var(--u) * 1.2) calc(var(--u) * .3); border: 1.5px solid #9d6c9b; border-radius: calc(var(--u) * 2); gap: calc(var(--u) * .7);
  background: linear-gradient(125deg, #50304f, #2c1b3c); box-shadow: inset 0 0 9px rgba(187,121,163,0.0941);
  font-size: calc(var(--u) * 2); color: #fff0d2;
}
#faces .btn[aria-pressed="true"], #ui #faces .btn[aria-pressed="true"] { border-color: #fff1af; background: linear-gradient(125deg, #9a4a22, #4e2537); box-shadow: 0 0 0 2px #ff8c21, inset 0 0 12px rgba(255,152,60,0.4667), 0 0 10px rgba(255,138,46,0.5333); color: #fff2d1; }
#faces img, #ui #faces img { width: calc(var(--u) * 7); height: calc(var(--u) * 5.9); background: none; border-radius: 0; filter: none; }
#faces .free-icon, #ui #faces .free-icon { width: calc(var(--u) * 7); height: calc(var(--u) * 5.9); font-size: calc(var(--u) * 5.5); color: #ffeac0; }
.hint, #ui .hint { font-size: calc(var(--u) * 1.9); color: #dbb3d0; min-height: 0; line-height: 1.35; }
#dTemplate .hint { margin: calc(var(--u) * .7) 0; }
.carve-summary { color: #ffe1ad; font-size: calc(var(--u) * 2.2); }
#dCarve { gap: calc(var(--u) * 1.3); }
#dCarve .toolbox { padding: calc(var(--u) * .6); border: 1px solid #89537c; background: rgba(40,22,46,0.8627); border-radius: calc(var(--u) * 2); }
.toolbox .btn, #ui .toolbox .btn { height: calc(var(--u) * 8); min-height: 41px; gap: calc(var(--u) * .7); padding: calc(var(--u) * .6) 0; font-size: calc(var(--u) * 1.9); border-radius: calc(var(--u) * 1.5); }
.toolbox .btn svg, #ui .toolbox .btn svg { width: calc(var(--u) * 3); height: calc(var(--u) * 3); }
.toolbox .btn[aria-pressed="true"] { background: linear-gradient(#d58136, #8f452a); color: #fff0cd; box-shadow: inset 0 0 0 1px #e9ac65; }
.work-actions { gap: calc(var(--u) * 1.2); }
.work-actions .grp { gap: calc(var(--u) * .7); }
.work-actions .grp:first-child { flex: .7; }
.work-actions .grp:last-child { flex: 2; }
.work-actions .btn, #ui .work-actions .btn { height: calc(var(--u) * 7); padding: 0 calc(var(--u) * .6); font-size: calc(var(--u) * 2); gap: calc(var(--u) * .5); }
.size, #ui .size { height: calc(var(--u) * 4.1); padding: 0; gap: calc(var(--u) * 2); }
.size .v { font-size: calc(var(--u) * 1.9); min-width: calc(var(--u) * 6); }
.size input { accent-color: #ffa33b; max-width: calc(var(--u) * 43); }
.pinfo { gap: calc(var(--u) * 1.4); }
.ptext .nm, #ui .ptext .nm { font-family: "Microsoft YaHei", sans-serif; font-weight: normal; font-size: calc(var(--u) * 4.6); color: #ffe2a0; margin: calc(var(--u) * 1) 0; }
.ptext .idx, #ui .ptext .idx { font-size: calc(var(--u) * 1.7); letter-spacing: .03em; color: #cc9fc1; }
.ptext .bl, #ui .ptext .bl { font-size: calc(var(--u) * 2); line-height: 1.4; min-height: 0; }
.pinfo .arrow, #ui .pinfo .arrow { width: calc(var(--u) * 6); height: calc(var(--u) * 6); background: linear-gradient(#67375a, #2a1636); border-color: #dca077; color: #ffe7b6; }
#ui #pGo { height: calc(var(--u) * 7.4); font-size: calc(var(--u) * 2.6); }
.fact, #ui .fact { font-size: calc(var(--u) * 1.6); color: #bf91b3; }
#dLit .row { gap: calc(var(--u) * 1); }
#dLit .btn, #ui #dLit .btn { height: calc(var(--u) * 7); font-size: calc(var(--u) * 1.8); padding: 0 calc(var(--u) * .7); gap: calc(var(--u) * .5); }
.help { background: rgba(41,23,49,0.9608); color: #ffe8c8; border: 1px solid #cb976d; box-shadow: 0 10px 60px rgba(11,6,29,0.8000); }
.help h2 { font-size: 20px; }
.help dt { font-weight: normal; color: #ffc36b; }
.help .x { width: 28px; height: 28px; }
.help .keys, .help dd { color: #e4bfda; }
@media (prefers-reduced-motion: reduce) { #app, #app::before { transition: none !important; } }

/* The phone toolbar occupies its own row, away from native back/share controls. */
:root { --device-top: 0px; --device-bottom: 0px; }
@supports (padding: env(safe-area-inset-top)) {
  :root { --device-top: env(safe-area-inset-top); --device-bottom: env(safe-area-inset-bottom); }
}
#phoneTools { display: none; }
@media (max-width: 600px) {
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  #app { position: relative; left: auto; top: auto; right: auto; bottom: auto; transform: none; margin-left: auto; margin-right: auto; }
  #phoneTools { display: flex; position: absolute; left: 0; right: 0; justify-content: center; z-index: 8; }
  #phoneTools .top { position: static; display: flex !important; flex-direction: row !important; gap: 0 !important; }
  #phoneTools .ib { width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin: 0 8px; border-radius: 50%; }
  #phoneTools .ib svg { width: 21px; height: 21px; }
  #ui .pinfo .arrow { width: 44px; height: 44px; flex-shrink: 0; }
  #ui #pGo, #ui #dTemplate .row .btn { min-height: 44px; }
  #ui .help .x { width: 44px; height: 44px; }
  #ui .sound-status { top: auto; bottom: 34%; right: 5%; }
}

:root { --toy-style-ready:1; --device-top:0px; --device-bottom:0px; }
@supports (padding:env(safe-area-inset-top)) { :root {--device-top:env(safe-area-inset-top);--device-bottom:env(safe-area-inset-bottom);} }
html {height:100%;touch-action:manipulation}
html,body {overflow-x:hidden;overflow-y:auto}
body {height:auto;min-height:100%;-webkit-touch-callout:none}
#app {position:relative;left:auto;top:auto;transform:none;max-width:100%;margin-left:auto;margin-right:auto;aspect-ratio:auto;container-type:normal;overflow:hidden}
#ui {position:absolute;top:0;left:0;right:0;bottom:0}
#app::before {top:0;left:0;right:0;bottom:0}
#gl,#ov {position:absolute;top:var(--stage-top);left:0;bottom:var(--stage-bottom);right:0}
#gl {touch-action:none}
.top {display:flex!important;flex-direction:column!important;top:8px!important;right:8px!important}
.top .ib {width:32px;height:32px;margin-bottom:5px}
.top .ib svg {width:18px;height:18px}
.help {width:calc(100% - 24px);max-height:82%;overflow-y:auto;touch-action:pan-y;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;z-index:9;padding:20px 16px}
.help .x {width:36px;height:36px;top:6px;right:6px}
.help h2 {margin-right:34px}
.help dl {grid-gap:7px 12px}
.btn:focus,.ib:focus,.arrow:focus {outline:2px solid #ffdd8c;outline-offset:2px}
.row,.grp,.steps,.pinfo,.template-heading,.work-actions {min-width:0}
.row,.grp,.steps,.pinfo,.top,.dock,.btn,.work-actions {gap:0!important}
.steps > * + * {margin-left:calc(var(--u) * .9)}
.steps span > * + * {margin-left:calc(var(--u) * .65)}
.dock > * + * {margin-top:calc(var(--u) * 1.3)}
.row > * + *, .work-actions > * + * {margin-left:calc(var(--u) * 1)}
.grp > .btn + .btn {margin-left:calc(var(--u) * .7)}
.btn > * + * {margin-left:calc(var(--u) * .6)}
#faces {grid-gap:calc(var(--u) * 1.2)}
.work-actions {display:flex}
#dLit .row {flex-wrap:wrap}
#dLit .row > .grp {margin-bottom:6px}
.sound-status {font-size:12px}
.steps,#ui .steps {font-size:10px}
.lab,.fact,#ui .fact {font-size:10px}
.btn.primary:hover {background-color:#a75827}
