:root {
  --ink: #3d2f26;
  --paper: #f7eedd;
  --stage: #f1e3cc;
  --clay: #ffdbac;
  --coral: #e8735a;
  --sky: #2c6c91;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.23, 1, 0.32, 1);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, sans-serif;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .35 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
header {
  max-width: 1600px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px;
  gap: 16px;
}
header a {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--ink);
  text-decoration: none;
}
header a span { color: #a5422c; margin-left: 8px; }
.header-tools { display: flex; gap: 8px; align-items: center; }
button, summary { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 2px solid var(--ink);
  border-radius: 17px;
  padding: 12px 18px;
  min-height: 48px;
  background: var(--clay);
  box-shadow: 3px 4px 0 var(--ink);
  transition: transform 120ms var(--spring), box-shadow 120ms var(--out), background 180ms var(--out);
  touch-action: manipulation;
}
button:hover { background: #ffe4c3; }
button:active { transform: translate(2px, 3px) scale(0.97); box-shadow: 1px 1px 0 var(--ink); }
button:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 5px;
}
[hidden] { display: none !important; }
#workshop {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(350px, 1fr);
  min-height: calc(100svh - 145px);
  padding: 0 32px;
  gap: clamp(24px, 4vw, 64px);
}
#workshop { position: relative; }
#cue {
  position: absolute;
  pointer-events: none;
  z-index: 30;
}
#cue path {
  stroke: var(--ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
#answers.locked button { opacity: 0.45; }
.zone-label { font-size: 14px; opacity: 0.72; margin: 0 0 10px; }
#scene-dock.locked button { opacity: 0.45; }
.dock-label { flex-basis: 100%; text-align: center; font-size: 13px; opacity: 0.72; }
#next:disabled { opacity: 0.7; box-shadow: none; cursor: default; }
#model-stage {
  position: relative;
  min-width: 0;
  min-height: 520px;
  border-radius: 36px;
  background: var(--stage);
  overflow: hidden;
  align-self: stretch;
}
#scene { display: block; width: 100%; height: 100%; position: absolute; inset: 0; }
#ground {
  position: absolute;
  right: 14px;
  top: 14px;
  width: clamp(96px, 26%, 180px);
  aspect-ratio: 1;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 18px;
  box-shadow: 2px 3px 0 var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
}
#scene-dock {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: calc(100% - 20px);
}
#scene-dock button {
  min-height: 46px;
  padding: 9px 14px;
  font-size: 16px;
  background: #fff8ed;
  box-shadow: 2px 3px 0 var(--ink);
}
#scene-dock button[aria-pressed="true"] { background: var(--coral); color: #fff9ef; }
#guide {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 4px;
  min-width: 0;
}
h1 { font-size: clamp(28px, 3vw, 46px); line-height: 1.14; letter-spacing: -0.035em; margin: 0 0 22px; font-weight: 780; }
#step-copy { font-size: clamp(18px, 1.65vw, 23px); line-height: 1.5; margin: 0 0 22px; }
#answers { display: grid; gap: 12px; }
#answers button { text-align: left; font-size: 18px; line-height: 1.3; padding: 15px 17px; }
#answers button[aria-pressed="true"] { background: var(--coral); color: #fff9ef; }
#answers button.correct { border-color: #3f7d46; }
#feedback { font-size: 20px; line-height: 1.5; margin: 20px 0 0; }
#feedback:empty { display: none; }
details { margin-top: 22px; }
summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: #6d5545;
}
details p { font-size: 18px; line-height: 1.55; }
#journey-controls { margin-top: 32px; }
#progress { display: flex; gap: 9px; align-items: center; margin-bottom: 20px; height: 12px; }
#progress i { display: block; width: 9px; height: 9px; background: #cbbba4; border-radius: 50%; }
#progress i.active { background: #a94a34; width: 26px; border-radius: 8px; }
.actions { display: flex; align-items: center; gap: 12px; }
#next {
  background: #a5422c;
  color: #fffaf0;
  font-size: 20px;
  font-weight: 700;
  min-height: 58px;
  flex: 1;
  max-width: 290px;
}
#next:hover { background: #8c3625; }
#next span { margin-left: 10px; }
.icon {
  min-width: 45px;
  min-height: 45px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  font-size: 22px;
}
.icon:hover { background: #ecdac0; }
dialog {
  max-width: 550px;
  width: calc(100% - 32px);
  border: 2px solid var(--ink);
  border-radius: 26px;
  padding: 28px;
  background: #fff5e5;
  color: var(--ink);
}
dialog::backdrop { background: #3d2f2688; }
dialog h2 { line-height: 1.2; }
.answer-enter { animation: answer-in 240ms var(--spring); }
@keyframes answer-in {
  from { opacity: 0.4; transform: translateY(7px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 760px) {
  html, body { height: 100%; overflow: hidden; }
  header { height: 88px; padding: 12px 18px; align-items: flex-start; }
  header a { font-size: 20px; white-space: nowrap; }
  #workshop {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0;
    padding: 0 14px max(12px, env(safe-area-inset-bottom));
    height: calc(100svh - 88px);
  }
  #model-stage { height: 42%; min-height: 230px; flex: none; border-radius: 27px; }
  #guide { flex: 1; min-height: 0; padding: 18px 10px 10px; justify-content: flex-start; }
  #guide-content { overflow: auto; min-height: 0; overscroll-behavior: contain; padding: 0 7px 3px 0; scrollbar-width: thin; }
  #journey-controls { flex: none; margin-top: 15px; }
  #progress { margin-bottom: 12px; }
  h1 { font-size: 27px; }
  #step-copy { font-size: 18px; }
  #answers button { font-size: 17px; padding: 12px 14px; min-height: 48px; }
  #next { min-height: 52px; font-size: 17px; padding: 10px 8px; }
  #feedback { font-size: 19px; }
  .actions { gap: 7px; }
  #scene-dock { bottom: 10px; gap: 8px; }
  #scene-dock button { font-size: 15px; min-height: 46px; padding: 8px 11px; }
}
@media (max-width: 360px) {
  #ground { width: 64px; border-radius: 12px; }
  header { padding: 10px; gap: 8px; }
  header a { font-size: 15px; }
  header a span { display: none; }
  h1 { font-size: 22px; line-height: 1.15; margin-bottom: 14px; }
  .actions { gap: 6px; }
  .icon { width: 40px; min-width: 40px; padding: 0; }
  #next { font-size: 16px; line-height: 1.2; padding: 8px 6px; }
  #next span { display: none; }
  #guide { padding-top: 12px; }
  #journey-controls { margin-top: 10px; }
  #progress { margin-bottom: 8px; }
  #answers { gap: 8px; }
  #answers button { font-size: 16px; padding: 8px 10px; }
  #scene-dock button { font-size: 14px; padding: 7px 9px; }
}
@media (max-width: 760px) and (max-height: 650px) {
  #model-stage { height: 34%; min-height: 300px; }
}
@media (min-width: 761px) and (max-height: 600px) {
  header { padding: 10px 24px; }
  #workshop { height: calc(100svh - 82px); min-height: 290px; padding: 0 24px 12px; gap: 24px; grid-template-columns: minmax(0, 1.1fr) minmax(330px, 1fr); }
  #model-stage { min-height: 0; }
  #guide { min-height: 0; padding: 8px 0 0; justify-content: flex-start; }
  #guide-content { min-height: 0; overflow: auto; padding: 0 7px 4px 0; scrollbar-width: thin; }
  h1 { font-size: 26px; margin-bottom: 12px; }
  #step-copy, #feedback { font-size: 18px; }
  #journey-controls { margin-top: 12px; flex: none; }
  #progress { margin-bottom: 10px; }
  #next { padding: 10px; font-size: 17px; }
  #scene-dock { bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
:root[data-theme="dark"] { --paper: #232221; --stage: #26241f; --ink: #f1e4d0; --clay: #514238; --coral: #ed9979; --sky: #9ccce4; color-scheme: dark; }
:root[data-theme="dark"] body::after { opacity: 0.1; }
:root[data-theme="dark"] button { border-color: #bca48b; background: #514238; box-shadow: 2px 3px 0 #151310; }
:root[data-theme="dark"] button:hover { background: #655040; }
:root[data-theme="dark"] .icon { background: transparent; box-shadow: none; border-color: transparent; }
:root[data-theme="dark"] #next { background: #eaa07d; color: #2f221c; border-color: #eaa07d; }
:root[data-theme="dark"] #next:hover { background: #f2b798; }
:root[data-theme="dark"] summary { color: #d8bea0; }
:root[data-theme="dark"] dialog { background: #39312b; color: #f1e4d0; }
:root[data-theme="dark"] #progress i { background: #80705e; }
:root[data-theme="dark"] #progress i.active { background: #eaa07d; }
:root[data-theme="dark"] #ground { background: #2c2925; border-color: #bca48b; box-shadow: 2px 3px 0 #151310; }
:root[data-theme="dark"] #scene-dock button { background: #39312b; color: #f1e4d0; }
:root[data-theme="dark"] #scene-dock button[aria-pressed="true"] { background: #b3604a; color: #fff4e8; }
:root[data-theme="dark"] header a span { color: #ed9979; }

h1:focus { outline: none; }
#model-stage { touch-action: pan-y; }
@media (max-width: 760px) {
  #scene-dock { gap: 6px; bottom: 8px; }
  #scene-dock button { font-size: 14px; min-height: 42px; padding: 7px 10px; }
}

.answer-enter { animation: none; }
