@font-face {
  font-family: Fraunces;
  src: url('./fonts/Fraunces-latin-var.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Fraunces, Georgia, serif;
  color: #ffe7b9;
  background: #242a20;
  --ink: #372414;
  --paper: #efdaac;
  --cream: #ffedc8;
  --teal: #174e49;
  --edge-top: max(env(safe-area-inset-top, 0px), var(--kids-inset-top, 0px));
  --edge-bottom: max(env(safe-area-inset-bottom, 0px), var(--kids-inset-bottom, 0px));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #fbd987; outline-offset: 3px; }
p, h1, h2 { margin: 0; }

#workshop {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(64px + var(--edge-top)) max(8px, var(--kids-inset-right, 0px)) var(--edge-bottom) max(8px, var(--kids-inset-left, 0px));
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 52% 29%, #55563d, #282c22 68%, #1e231c);
}

#workshop .pk-bar {
  --kit-bar-h: 64px;
  --kit-bar-ink: #ffebc8;
  --kit-bar-tint: #262a21ee;
  --kit-bar-line: #c2a37b49;
  --kit-bar-font: 650 17px/1 Fraunces, Georgia, serif;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
}
#workshop .pk-bar-btn { width: 64px; height: 64px; }
#workshop .pk-bar-title { grid-column: 2; grid-row: 1; }
#workshop[data-screen='bench'] .pk-bar-more { grid-column: 1; grid-row: 1; }

.title-screen {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  text-align: center;
  color: var(--ink);
  width: min(100%, 590px);
  min-height: min(750px, calc(100dvh - 64px - var(--edge-top) - var(--edge-bottom) - 8px));
  padding: clamp(46px, 9vh, 100px) 8% clamp(36px, 7vh, 67px);
  background: url('./art/bench.webp') center / 100% 100% no-repeat;
}
.title-copy, .title-actions { position: relative; z-index: 1; }
.edition { font-size: 12px; font-weight: 750; letter-spacing: .14em; line-height: 1.3; }
.title-copy h2 {
  margin: .08em 0 .18em;
  font-size: clamp(40px, 12vw, 78px);
  font-weight: 740;
  letter-spacing: -.065em;
  line-height: .88;
  text-shadow: 0 1px #fff3c3bf;
  color: #422719;
}
.title-copy > p:last-child { font-size: clamp(15px, 2.3vw, 20px); }
.title-actions { display: grid; justify-items: center; grid-template-rows: auto auto; gap: 1px; align-self: end; }
#workshop:is([data-screen='home'], [data-screen='loading']) { grid-template-columns: minmax(0, 1fr); padding-top: max(8px, var(--edge-top)); }
#home, #loading {
  background: radial-gradient(ellipse at 8% 19%, #72501f84, transparent 52%), linear-gradient(#1e2015, #2b2418 61%, #4a2d1b);
}
#loading { grid-template: 1fr / 1fr; padding: 0; }
.loading-seed { width: 54px; height: 54px; align-self: center; opacity: .75; background: url('./art/seed.webp') center / contain no-repeat; }
#home {
  width: min(100%, 580px);
  height: min(740px, calc(100dvh - 16px - var(--edge-top) - var(--edge-bottom)));
  padding: 67px 7px 12px;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: #ffebc6;
  border-radius: 10px;
  overflow: hidden;
  overflow: clip;
  box-shadow: 0 16px 38px #15150fb0;
}
.home-title {
  grid-row: 1;
  position: relative;
  z-index: 1;
  width: min(92%, 487px);
  aspect-ratio: 1040 / 395;
  display: grid;
  place-items: center;
  font-size: clamp(30px, 10vw, 60px);
  line-height: .9;
  letter-spacing: -.045em;
  text-shadow: 0 3px 9px #1b110ac9;
  transform-origin: 50% 5%;
  pointer-events: none;
}
.home-title img { display: block; position: relative; width: 100%; height: auto; filter: drop-shadow(0 8px 5px #170d0799); }
.home-title:has(img:not([hidden])) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.home-title:has(img:not([hidden]))::before, .home-title:has(img:not([hidden]))::after {
  content: '';
  position: absolute;
  bottom: 95%;
  width: 3px;
  height: 100dvh;
  background: repeating-linear-gradient(135deg,#49291b 0 2px,#af7745 2px 4px,#795139 4px 5px);
  box-shadow: 2px 0 4px #150d09a0;
}
.home-title::before { left: 27.8%; }
.home-title::after { left: 72.8%; bottom: 92%; }
#home[data-title-drop] .home-title { animation: hang-workshop-sign 590ms both; }
@keyframes hang-workshop-sign {
  0% { transform: translateY(calc(-100% - 78px)) rotate(-4deg); }
  15% { transform: translateY(calc(-100% - 65px)) rotate(-4deg); }
  62% { transform: translateY(7px) rotate(1.7deg); animation-timing-function: cubic-bezier(.15,.8,.45,1); }
  78% { transform: translateY(-5px) rotate(-1deg); }
  91% { transform: translateY(1px) rotate(.35deg); }
  100% { transform: none; }
}
#home .title-actions { grid-row: 3; gap: 3px; width: min(calc(100% - 26px), 355px); }
#home .start-plaque { width: 100%; }
#home button:focus-visible { outline-color: #ffe9bc; }
.home-scene {
  grid-row: 2;
  align-self: stretch;
  width: min(100%, 550px);
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.home-wind {
  position: relative;
  width: 100%;
  width: min(100%, calc(100cqh * 480 / 465));
  aspect-ratio: 480 / 465;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
}
.home-wind canvas {
  display: block;
  width: 100%;
  height: auto;
  mask-image: linear-gradient(transparent, #000 11%, #000 90%, transparent);
  mask-image: linear-gradient(transparent, #000 11%, #000 90%, transparent),
    linear-gradient(90deg, transparent, #000 4.5%, #000 95.5%, transparent);
  mask-composite: intersect;
}
.home-wind:disabled { cursor: default; }
.home-wind:not([data-rendered]) {
  background: url('./art/workshop-home.webp') center 55% / cover no-repeat;
}
.home-wind:not([data-rendered]) canvas, .home-wind:disabled span { visibility: hidden; }
.home-wind span {
  position: absolute;
  right: 7%;
  bottom: 3%;
  padding: 3px 8px 4px;
  border: 1px solid #b48b57a8;
  border-radius: 5px;
  color: #ffeac3;
  background: #2f2419e8;
  font-size: clamp(11px, 3.35cqw, 14px);
  font-weight: 690;
  line-height: 1.2;
  box-shadow: 0 2px 5px #190e09ad;
}
#home[data-arrival] .home-wind span { opacity: 0; }
.workshop-options {
  position: absolute;
  top: 9px;
  left: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 54px;
  padding: 0 10px 0 6px;
  border: 1px solid #c98d576b;
  border-radius: 9px;
  color: #ffe9bf;
  background: #2f2118e8;
  box-shadow: inset 0 1px #e1a46836, 0 3px 7px #180e0b82;
  font-size: 14px;
  font-weight: 690;
}
.workshop-options span {
  width: 27px;
  height: 27px;
  background: url('./art/cog.webp') center / contain no-repeat;
  transition: transform 160ms ease-out;
}
.workshop-options:active span { transform: rotate(25deg); }
.start-plaque {
  position: relative;
  width: min(100%, 285px);
  min-height: 61px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 5px 19px 5px 10px;
  border: 2px solid #d8ad6b;
  border-radius: 20px 10px 10px 20px;
  color: #fff1cd;
  background: radial-gradient(ellipse at 35% -30%, #528178, transparent 85%), linear-gradient(#245953, #143b37);
  box-shadow: inset 0 0 0 2px #1d3830, inset 0 -5px #13322b, 0 0 0 2px #533522, 0 6px 0 #261911, 0 10px 14px #21160e9e;
  text-align: left;
  text-shadow: 0 2px #132f28;
  transition: transform 140ms ease-out;
}
.start-plaque::after {
  content: '';
  position: absolute;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: linear-gradient(#f4cc85, #91502a);
  box-shadow: 0 1px 1px #251e15;
}
.start-plaque img { width: 45px; filter: drop-shadow(0 2px 2px #12221b); transition: transform 150ms ease-out; }
.start-plaque:active { transform: translateY(3px); }
.start-plaque:active img { transform: rotate(-12deg); }
.start-copy { display: grid; gap: 3px; }
.start-copy strong { font-size: clamp(17px, 5.1vw, 23px); font-weight: 760; line-height: 1.01; letter-spacing: -.025em; }
.start-copy small { font-size: 13px; line-height: 1.05; color: #f3d6a0; }
.map-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: #ffe7b4;
  background: #301e14b8;
  text-shadow: 0 1px 2px #221307;
  font-size: 15px;
  font-weight: 700;
}
.map-tab span {
  width: 35px;
  height: 28px;
  background: url('./art/washer.webp') 72% 60% / 10px no-repeat, url('./art/paper.webp') center / contain no-repeat;
  filter: drop-shadow(0 2px 1px #27160b);
  transform: rotate(-10deg);
  transition: transform 150ms ease-out;
}
.map-tab:active span { transform: rotate(3deg); }

.primary, .quiet, .room {
  min-height: 54px;
  min-width: 54px;
  border-radius: 12px;
  padding: .5em 1em;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 690;
  line-height: 1.14;
  transition: transform 140ms ease-out, filter 140ms ease-out;
}
.primary {
  border-color: #ad8b54;
  color: #fff0cc;
  background: linear-gradient(#28655d, #194c46);
  box-shadow: inset 0 1px #a2c3a75c, inset 0 -3px #153a33, 0 3px 7px #291b1640;
}
.quiet { background: transparent; }
.quiet span { margin-right: .15em; font-family: Fraunces, Georgia, serif; font-size: 20px; }
.primary:active, .quiet:active, .room:active { transform: scale(.97); }
.primary:hover, .quiet:hover, .room:not(:disabled):hover { filter: brightness(1.12); }
.title-screen button:focus-visible, dialog button:focus-visible { outline-color: #31554a; }

#bench {
  width: min(100%, 1120px);
  display: grid;
  grid-template-areas: 'field' 'instruction' 'tools';
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
}
.instruction {
  grid-area: instruction;
  text-align: center;
  align-self: center;
  padding: 5px 2px 1px;
  color: var(--cream);
  width: 100%;
}
.instruction .edition { color: #e6bd82; font-size: 11px; }
.instruction h2 { font-size: clamp(23px, 6.2vw, 37px); line-height: 1.05; letter-spacing: -.035em; font-weight: 670; margin: 3px 0 5px; }
#room-note { min-height: 2.35em; max-width: 38ch; margin: 0 auto; font-size: clamp(14px, 3.8vw, 17px); line-height: 1.17; color: #f1dbb8; }

#playfield {
  grid-area: field;
  width: min(100%, 590px, calc((100dvh - 204px - var(--edge-top) - var(--edge-bottom)) * .84));
  aspect-ratio: 420 / 500;
  position: relative;
  background: url('./art/cabinet.webp') center / 100% 100% no-repeat;
  border-radius: 8px;
  box-shadow: 0 15px 30px #100e0b8c, 0 2px 1px #ba834968;
  user-select: none;
}
#playfield[data-material]:not([data-material='sage'])::before {
  content: '';
  position: absolute;
  inset: 7.35% 4.8% 14.5%;
  border-radius: 7% 7% 5% 5% / 5%;
  background: var(--cloth-tint, #263f6d58);
  mix-blend-mode: multiply;
  pointer-events: none;
}
#playfield[data-material='umber'] { --cloth-tint: #98542d46; }
#machine, #mechanisms { position: absolute; inset: 0; width: 100%; height: 100%; }
#mechanisms { pointer-events: none; container-type: inline-size; }
.mechanism {
  position: absolute;
  display: grid;
  place-items: center;
  transform: translate(calc(-50% + var(--control-shift, 0px)), -50%);
  width: clamp(54px, 15%, 88px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  color: #174b43;
  pointer-events: auto;
}
.mechanism:focus-visible { outline-color: #ffe7b4; outline-offset: 0; }
.mechanism[data-action='spring'] { width: clamp(58px, 20%, 105px); }
.mechanism[data-action='release'] { width: clamp(60px, 18.5%, 100px); }
.mechanism[data-cue] { border-style: dashed; border-color: #ffe2a5; background: #f7d1851c; }
.mechanism:active { background: #2d807549; }
.bench-tag {
  display: block;
  position: absolute;
  left: calc(50% + var(--caption-x, 0px) - var(--control-shift, 0px));
  top: calc(50% + var(--caption-y));
  transform: translate(-50%, -50%);
  padding: .32em .65em .36em;
  white-space: nowrap;
  border: 1px solid #c69960;
  border-radius: 6px;
  background: linear-gradient(#426250, #263f36);
  box-shadow: inset 0 1px #ebc68850, 0 2px 3px #2a241c9e;
  color: #fff0c6;
  font-size: clamp(13px, 4.15cqw, 19px);
  font-weight: 780;
  line-height: 1;
  pointer-events: auto;
}
.bench-tag::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 48px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}
.mechanism[data-lead] {
  border-color: #ffe2a0;
  box-shadow: 0 0 0 2px #51402691, 0 0 10px #ffd57a75;
}
.mechanism:is([data-lead], [data-cue]) .bench-tag {
  background: linear-gradient(#fae5ac, #dcaa61);
  border-color: #fff0bc;
  color: #392819;
}
.mechanism[aria-pressed='true']:not([data-lead]) .bench-tag { border-color: #e6cc8d; background: linear-gradient(#4b715d, #254b3d); }

.tools {
  grid-area: tools;
  display: flex;
  width: min(100%, 590px);
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 2px 0;
  color: var(--cream);
}
.tools .primary { min-width: min(100%, 205px); }
#bench[data-phase='miss'] #reset {
  border-color: #b6855a;
  background: #534231;
  box-shadow: inset 0 1px #e9ba8761;
}

#map {
  --map-gap: clamp(10px, 2vw, 18px);
  --map-row-gap: var(--map-gap);
  --room-height: clamp(70px, 12dvh, 112px);
  grid-template-rows: auto 1fr auto;
  align-items: center;
  padding: clamp(30px, 5.4vh, 55px) clamp(24px, 7vw, 65px) clamp(42px, 10vh, 88px);
  color: #fff0c8;
  background-image: url('./art/cabinet.webp');
  filter: drop-shadow(0 13px 16px #17180fb0);
}
.map-copy {
  display: grid;
  place-items: center;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  text-shadow: 0 2px 4px #27230d;
}
.map-copy h2 { font-size: clamp(26px, 7.1vw, 43px); line-height: .97; letter-spacing: -.045em; margin: 0 0 5px; }
#workshop-tabs { display: flex; gap: 4px; }
#workshop-tabs button {
  min-width: 52px;
  min-height: 52px;
  border: 1px solid #b08b54;
  border-radius: 9px;
  background: linear-gradient(#414338, #282d27);
  color: #ffe9b4;
  font-size: 17px;
  font-weight: 750;
  box-shadow: inset 0 1px #f5d09339, 0 2px 4px #30211275;
}
#workshop-tabs button[aria-current] { color: #3a2918; background: linear-gradient(#f9e5af, #dca76a); border-color: #ffdf92; }
#map-title:focus { outline: none; }
#map-note { font-size: clamp(13px, 3.6vw, 16px); font-weight: 650; }
#rooms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--map-row-gap) var(--map-gap);
  width: min(100%, 490px);
  padding: 0;
  margin: 14px 0 9px;
  list-style: none;
}
#rooms li { --rail: #675a3c; position: relative; grid-column: var(--col, 1); grid-row: var(--row, 1); }
#rooms li:nth-child(n + 3) { --row: 2; }
#rooms li:nth-child(n + 5) { --row: 3; }
#rooms li:nth-child(n + 7) { --row: 4; }
#rooms li:is(:nth-child(4n + 2), :nth-child(4n + 3)) { --col: 2; }
#rooms li[data-live] { --rail: #e4b260; }
#rooms li:not(:last-child)::after {
  content: '';
  pointer-events: none;
  position: absolute;
  top: 47%;
  left: calc(100% - 1px);
  width: calc(var(--map-gap) + 2px);
  border-top: 3px solid var(--rail);
  filter: drop-shadow(0 2px 1px #2e2719a6);
}
#rooms li:is(:nth-child(3), :nth-child(7))::after { left: auto; right: calc(100% - 1px); }
#rooms li:is(:nth-child(2), :nth-child(4), :nth-child(6))::after {
  width: 11px;
  height: calc(100% + var(--map-row-gap) + 3px);
  border: 3px solid var(--rail);
  border-left: 0;
  border-radius: 0 9px 9px 0;
}
#rooms li:nth-child(4)::after { left: auto; right: calc(100% - 1px); transform: scaleX(-1); }
#rooms li[data-next-link] { --rail: #ffdda2; }
#rooms li[data-next-link]::after { filter: drop-shadow(0 0 3px #ffbe5d) drop-shadow(0 2px 1px #2e2719a6); }
.room {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: var(--room-height);
  padding: 0;
  overflow: hidden;
  border: 1px solid #6d5739;
  border-radius: 9px;
  background: linear-gradient(145deg, #444536, #292c25);
  color: #e4d8b3;
  box-shadow: inset 0 1px #ffe0a72e, 0 3px 4px #2a20172b;
  font-size: clamp(11px, 3.1vw, 15px);
  line-height: 1.05;
}
.room-scene {
  display: block;
  position: relative;
  overflow: hidden;
  margin: 3px 14px 0;
  background: radial-gradient(ellipse at 50% 96%, #eec77c28, transparent 70%);
}
.room-scene::before {
  content: '';
  position: absolute;
  inset: auto 4% 1px;
  height: 6px;
  background: url('./art/ramp.webp') center / 100% 100% no-repeat;
}
.room-scene img {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--w);
  height: 93%;
  object-fit: contain;
  transform: translate(-50%, -50%) rotate(var(--tilt));
  filter: drop-shadow(1px 2px 1px #1d160f9e);
  pointer-events: none;
}
.room-label {
  display: grid;
  align-content: center;
  min-height: 28px;
  padding: 3px 4px;
  border-top: 1px solid #d1a67238;
  background-color: #262820;
}
.room-label small { margin-top: 2px; font-size: 11px; font-weight: 720; color: #fff1a3; }
.room-number {
  position: absolute;
  left: 5px;
  top: 5px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid #be9e6768;
  border-radius: 50%;
  color: #ffedc3;
  background: #333224;
  font-size: 11px;
  font-weight: 760;
}
.room-signal { position: absolute; top: 7px; right: 7px; width: 12px; height: 12px; }
.room:disabled { cursor: default; }
.room:disabled .room-scene { opacity: .77; filter: saturate(.48) brightness(.92); }
.room:disabled .room-signal { height: 8px; width: 10px; top: 12px; border-radius: 2px; background: #b9a780; }
.room:disabled .room-signal::before { content: ''; position: absolute; inset: -5px 2px 5px; border: 1.5px solid #b9a780; border-radius: 5px; }
.room[data-worked] {
  border-color: #c08d50;
  background: radial-gradient(ellipse at 55% 48%, #7b6139, transparent 78%), #3d3c28;
  color: #ffedc6;
}
.room[data-worked] .room-signal { width: 8px; height: 8px; border-radius: 50%; background: #ffd480; box-shadow: 0 0 9px #ffb958; }
.room[data-spare] .room-signal { top: 5px; right: 5px; width: 16px; height: 16px; background: url('./art/washer.webp') center / contain no-repeat; box-shadow: none; }
.room[data-ready] {
  border: 2px solid #ffe7a0;
  background: radial-gradient(ellipse at 65% 42%, #617361, transparent 87%), #25483e;
  color: #fff4d5;
  box-shadow: 0 0 0 2px #73491e, 0 1px 13px #ffd17954;
}
.room[data-ready] .room-label { background: #204b41; }
.room[data-ready] .room-signal {
  width: 20px;
  height: 20px;
  top: 4px;
  right: 5px;
  background: url('./art/seed.webp') center / contain no-repeat;
  filter: drop-shadow(0 1px 2px #18251e);
}
#map .room:focus-visible { outline-color: #fff1b4; }
#collection { display: flex; align-items: flex-end; justify-content: space-evenly; width: min(100%, 335px); padding: 0 12px 3px; background: url('./art/ramp.webp') center bottom / 100% 7px no-repeat; }
#collection img { width: clamp(28px, 7vw, 46px); aspect-ratio: 1; object-fit: contain; filter: drop-shadow(1px 3px 2px #67421872); }

dialog {
  border: 1px solid #6c4828;
  border-radius: 22px;
  width: min(calc(100% - 34px), 392px);
  padding: 0;
  color: var(--ink);
  background: var(--paper) url('./art/bench.webp') center / 180% 180% no-repeat;
  box-shadow: inset 0 0 0 5px #bc9553ad, 0 15px 60px #150d0b9e;
  text-align: center;
}
dialog::backdrop { background: #21180fc2; }
.sheet-content { padding: 28px 20px 18px; }
#sheet-edition {
  display: grid;
  place-items: center;
  min-height: 42px;
  background: url('./art/paper.webp') center / min(100%, 225px) auto no-repeat;
}
#sheet-name { margin: 7px 0; font-size: clamp(27px, 8vw, 36px); line-height: 1; letter-spacing: -.035em; }
#sheet-note { font-size: 16px; line-height: 1.3; }
#sheet-note:empty { display: none; }
#sheet-actions { display: grid; gap: 6px; margin-top: 15px; }
#sheet-actions button { width: 100%; }
#sheet:not([data-kind='pause']) .sheet-content { padding-top: 20px; }
#sheet:not([data-kind='pause']) #sheet-edition { display: none; }
#sheet:not([data-kind='pause']) #sheet-name {
  min-height: 42px;
  display: flex;
  align-items: center;
  margin: 0;
  padding-right: 46px;
  text-align: left;
}
#sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  color: #563720;
  background: transparent;
}
#sheet-close::before, #sheet-close::after {
  content: '';
  position: absolute;
  width: 17px;
  height: 2px;
  left: calc(50% - 8.5px);
  top: calc(50% - 1px);
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}
#sheet-close::after { transform: rotate(-45deg); }
#sheet-close:active { background: #97613328; }
#sheet-close:focus-visible { outline-width: 2px; outline-offset: -6px; }
.setting { background: #f8e9bf; border-color: #ad8246; }
.leave-workshop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #54331d;
  background: linear-gradient(#e6c995, #d8b37e);
  border-color: #9c7546;
  box-shadow: inset 0 1px #fff1cb, inset 0 -2px #a678484f;
}
.leave-workshop::before {
  content: '';
  width: 25px;
  height: 24px;
  background: url('./art/latch.webp') center / contain no-repeat;
}

@media (hover: hover) and (pointer: fine) {
  .workshop-options:hover span { transform: rotate(15deg); }
  .start-plaque:hover img { transform: rotate(-7deg); }
  .map-tab:hover span { transform: rotate(-3deg); }
}

@media (orientation: portrait) and (max-width: 560px) {
  #workshop:is([data-screen='home'], [data-screen='loading']) {
    place-items: stretch center;
    padding: 0 max(env(safe-area-inset-right, 0px), var(--kids-inset-right, 0px)) 0 max(env(safe-area-inset-left, 0px), var(--kids-inset-left, 0px));
    background: #241a11;
  }
  #home {
    width: 100%;
    height: 100dvh;
    padding: calc(68px + var(--edge-top)) 0 calc(9px + var(--edge-bottom));
    border-radius: 0;
    box-shadow: none;
  }
  #home .workshop-options { top: calc(9px + var(--edge-top)); left: 12px; }
  #home .title-actions {
    width: min(calc(100% - 36px), 355px);
    gap: 6px;
  }
  #home .map-tab { background-color: #2e1f1580; }
}

@media (orientation: landscape) and (min-width: 580px) {
  #bench {
    grid-template-areas: 'field instruction' 'field tools';
    grid-template-columns: minmax(0, 1fr) clamp(220px, 29vw, 340px);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    height: calc(100dvh - 64px - var(--edge-top) - var(--edge-bottom));
    column-gap: clamp(8px, 4vw, 55px);
    padding: 6px clamp(14px, 4vw, 40px);
  }
  #playfield { width: min(100%, 610px, calc((100dvh - 80px - var(--edge-top) - var(--edge-bottom)) * .84)); }
  .instruction { align-self: end; padding: 20px 0; }
  .tools { align-self: start; }
  .title-screen { min-height: min(720px, calc(100dvh - 70px - var(--edge-top) - var(--edge-bottom))); }
}

@media (orientation: landscape) and (min-width: 520px) {
  #home {
    width: min(100%, 1030px);
    min-height: 0;
    height: min(710px, calc(100dvh - 16px - var(--edge-top) - var(--edge-bottom)));
    grid-template: minmax(0, 1fr) auto auto minmax(0, 1fr) / minmax(0, .88fr) minmax(0, 1fr);
    padding: 30px 14px;
    align-items: center;
  }
  #home .home-title { grid-column: 1; grid-row: 2; }
  #home .home-scene { grid-column: 2; grid-row: 1 / -1; }
  #home .title-actions { grid-column: 1; grid-row: 3; align-self: start; margin-top: 14px; }
}

@media (orientation: landscape) and (max-height: 510px) {
  /* The finale's two handles sit close together on a short board. The plaques stay attached to the art. */
  #mechanisms:has([data-action='cradle']) [data-action='fan'] { --control-shift: max(0px, calc(28px - 10.35cqw)); }
  #mechanisms:has([data-action='fan']) [data-action='cradle'] { --control-shift: min(0px, calc(10.35cqw - 28px)); }
  .title-screen { width: min(100%, 580px); grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; padding: 35px 9%; }
  .title-copy { align-self: end; }
  .title-copy h2 { font-size: clamp(30px, 6vw, 47px); }
  #home { width: min(100%, 790px); padding: 60px 9px 9px; }
  #home .title-actions { margin-top: 4px; gap: 0; }
  #home .start-copy strong { font-size: clamp(17px, 3.05vw, 21px); }
  .instruction { padding: 8px 0; }
  .instruction h2 { font-size: clamp(22px, 4vw, 30px); }
  #room-note { font-size: 14px; }
  #map { --map-row-gap: 8px; --room-height: clamp(60px, 19dvh, 92px); grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; padding: 18px 10% 19px; }
  .map-copy { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
  .map-copy h2 { font-size: clamp(21px, 4vw, 26px); margin: 0 0 3px; text-wrap: balance; }
  #rooms { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 7px 0; }
  #rooms li:nth-child(n) { --row: 1; }
  #rooms li:nth-child(n + 5) { --row: 2; }
  #rooms li:is(:nth-child(1), :nth-child(8)) { --col: 1; }
  #rooms li:is(:nth-child(2), :nth-child(7)) { --col: 2; }
  #rooms li:is(:nth-child(3), :nth-child(6)) { --col: 3; }
  #rooms li:is(:nth-child(4), :nth-child(5)) { --col: 4; }
  #rooms li:not(:last-child)::after { left: calc(100% - 1px); right: auto; width: calc(var(--map-gap) + 2px); height: 0; transform: none; border: 0; border-top: 3px solid var(--rail); border-radius: 0; }
  #rooms li:nth-child(4)::after { height: calc(100% + var(--map-row-gap) + 3px); width: 11px; border: 3px solid var(--rail); border-left: 0; border-radius: 0 9px 9px 0; }
  #rooms li:nth-child(n + 5)::after { left: auto; right: calc(100% - 1px); }
  .room { font-size: 12px; }
  #collection img { width: 27px; }
  #sheet-edition { display: none; }
  .sheet-content { padding: 13px 14px 12px; }
  #sheet-name { font-size: 31px; margin: 4px 0; }
  #sheet-actions { gap: 4px; margin-top: 9px; }
}

@media (prefers-reduced-motion: reduce) { button { transition: none !important; } }
[data-reduced] button { transition: none !important; }
[data-reduced] #home .home-title { animation: none; }
[data-reduced] :is(.start-plaque, .workshop-options, .map-tab) :is(img, span) { transition: none; }
[data-reduced] .start-plaque:active, [data-reduced] :is(.start-plaque img, .workshop-options span) { transform: none; }
[data-reduced] .map-tab span { transform: rotate(-10deg); }
