:root {
  --ink: #251638;
  --ink-2: #3b2454;
  --cream: #fff4d6;
  --paper: #f6dfb2;
  --coral: #ff655d;
  --coral-dark: #c63e45;
  --lemon: #ffd84c;
  --teal: #2dd4bd;
  --blue: #5478ff;
  --muted: #9d88aa;
  --shadow: #160d24;
  --display: "Arial Black", "Avenir Next Condensed", "Franklin Gothic Heavy", sans-serif;
  --wordmark: "Staatliches", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --body: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
}

@font-face {
  font-family: "Staatliches";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/staatliches.woff2") format("woff2");
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--cream);
  background:
    radial-gradient(circle at 48% 24%, #4d2d68 0, #2d1a42 36%, #1c112a 76%),
    var(--ink);
  font-family: var(--body);
  font-weight: 700;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .11;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  z-index: 90;
}
button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible { outline: 4px solid var(--lemon); outline-offset: 4px; }
[hidden] { display: none !important; }

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--ink);
}
.boot-shutter {
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(50% + 2px);
  background:
    radial-gradient(circle at 50% 42%, rgba(84,120,255,.16), transparent 34%),
    repeating-linear-gradient(90deg, transparent 0 62px, rgba(255,244,214,.025) 62px 64px),
    linear-gradient(135deg, #38204f, #1c112a 72%);
  transition: transform .62s cubic-bezier(.72,0,.2,1);
}
.boot-shutter::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255,244,214,.11);
  box-shadow: inset 0 0 70px rgba(0,0,0,.26);
}
.boot-shutter::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(90deg, transparent, rgba(255,216,76,.32), transparent);
  box-shadow: 0 0 28px rgba(255,216,76,.12);
}
.boot-shutter--left { left: 0; }
.boot-shutter--left::after { right: -4px; }
.boot-shutter--right { right: 0; }
.boot-shutter--right::after { left: -4px; }
.boot-backdrop-orbits {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity .2s ease;
}
.boot-backdrop-orbit {
  position: absolute;
  width: 390px;
  height: 390px;
  border: 2px solid rgba(255,244,214,.1);
  border-radius: 50%;
}
.boot-backdrop-orbit::before, .boot-backdrop-orbit::after {
  content: "";
  position: absolute;
  border: inherit;
  border-radius: inherit;
}
.boot-backdrop-orbit::before { inset: 18%; }
.boot-backdrop-orbit::after {
  inset: 42%;
  background: rgba(255,216,76,.045);
}
.boot-backdrop-orbit--left { left: -195px; top: 8%; }
.boot-backdrop-orbit--right { right: -215px; bottom: -75px; transform: scale(1.35); }
.boot-plate {
  position: relative;
  z-index: 2;
  width: min(390px, calc(100vw - 44px));
  padding: 20px 26px 22px;
  background:
    linear-gradient(120deg, rgba(255,255,255,.58), transparent 26%),
    var(--paper);
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow:
    0 10px 0 #b99762,
    0 16px 0 var(--ink),
    0 31px 60px rgba(7,2,12,.62),
    inset 0 -7px 0 #d2af73;
  transition: opacity .25s ease .06s, transform .38s cubic-bezier(.65,0,.3,1);
}
.boot-plate::before, .boot-plate::after {
  content: "";
  position: absolute;
  top: 54px;
  bottom: 52px;
  width: 4px;
  background: repeating-linear-gradient(var(--ink) 0 2px, transparent 2px 8px);
  opacity: .18;
}
.boot-plate::before { left: 10px; }
.boot-plate::after { right: 10px; }
.boot-bolt {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #ad8f62;
}
.boot-bolt::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 2px;
  height: 1px;
  background: var(--ink);
  transform: rotate(-35deg);
}
.boot-bolt--tl { top: 10px; left: 10px; }
.boot-bolt--tr { top: 10px; right: 10px; }
.boot-bolt--bl { bottom: 10px; left: 10px; }
.boot-bolt--br { right: 10px; bottom: 10px; }
.boot-wordmark {
  width: 154px;
  margin: 4px auto 0;
  font-family: var(--wordmark);
  text-align: center;
  transform: rotate(-1deg);
}
.boot-wordmark strong {
  display: block;
  font: 400 50px/.8 var(--wordmark);
  letter-spacing: .005em;
}
.boot-wordmark em {
  display: flex;
  justify-content: space-between;
  margin-top: -.05em;
  padding: 0 4.5%;
  color: var(--coral-dark);
  font: 400 23px/1 var(--wordmark);
  font-style: normal;
  -webkit-text-stroke: .055em currentColor;
}
.boot-wordmark em i { font-style: normal; }
.boot-scenes {
  position: relative;
  height: 210px;
  margin: 6px 4px 0;
  overflow: hidden;
  border-top: 2px solid rgba(37,22,56,.16);
  border-bottom: 2px solid rgba(37,22,56,.16);
}
.boot-scene { position: absolute; inset: 0; }
.boot-docks {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 23px;
  display: flex;
  justify-content: space-between;
}
.boot-docks i {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  color: rgba(37,22,56,.36);
  border: 3px dashed rgba(37,22,56,.36);
  border-radius: 50%;
}
.boot-docks b { font-size: 22px; }
.boot-game-orbs { position: absolute; inset: 0; }
.boot-game-orb {
  position: absolute;
  bottom: 31px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 50%;
  font: 900 20px/1 var(--body);
  box-shadow: 0 4px 0 rgba(37,22,56,.24);
  animation: boot-orb-settle 2.4s cubic-bezier(.45,0,.25,1) infinite;
}
.boot-game-orb--coral { left: 28px; background: var(--coral); }
.boot-game-orb--teal { left: calc(50% - 26px); background: var(--teal); animation-delay: -.8s; }
.boot-game-orb--lemon { right: 28px; background: var(--lemon); animation-delay: -1.6s; }
.boot-rail {
  position: relative;
  height: 15px;
  margin: 14px 4px 12px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(37,22,56,.2) 0 2px, transparent 2px 15px),
    rgba(37,22,56,.09);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: inset 0 2px 3px rgba(37,22,56,.22);
}
.boot-rail i {
  position: absolute;
  inset: 2px;
  width: 38%;
  background: linear-gradient(90deg, transparent, var(--lemon), transparent);
  filter: drop-shadow(0 0 4px var(--lemon));
  animation: boot-rail-scan 1.25s ease-in-out infinite;
}
.boot-rail b {
  position: absolute;
  inset: 0;
  background: var(--teal);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .18s ease-out;
}
.boot-status {
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.boot-status-lamp {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  background: var(--lemon);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 7px var(--lemon);
  animation: boot-lamp-pulse .7s ease-in-out infinite alternate;
}
.boot-status-label, .boot-status-ready {
  display: none;
  font: 900 9px/12px var(--body);
  letter-spacing: .13em;
}
.boot-status-label--orbs { display: inline; }
.boot-screen.is-ready .boot-rail b { transform: scaleX(1); }
.boot-screen.is-ready .boot-status-lamp {
  background: var(--teal);
  box-shadow: 0 0 9px var(--teal);
  animation: none;
}
.boot-screen.is-ready .boot-status-label { display: none; }
.boot-screen.is-ready .boot-status-ready { display: inline; }
.boot-screen.is-leaving .boot-backdrop-orbits { opacity: 0; }
.boot-screen.is-leaving .boot-shutter--left { transform: translateX(-101%); }
.boot-screen.is-leaving .boot-shutter--right { transform: translateX(101%); }
.boot-screen.is-leaving .boot-plate { opacity: 0; transform: scale(.82) rotate(-2deg); }

@keyframes boot-orb-settle {
  0% { transform: translateY(-145px) rotate(-18deg); }
  56% { transform: translateY(5px) rotate(4deg); }
  70%, 100% { transform: translateY(0) rotate(0); }
}
@keyframes boot-rail-scan {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(260%); }
}
@keyframes boot-lamp-pulse { to { opacity: .34; } }

.ambient {
  position: fixed;
  width: 340px;
  height: 340px;
  border: 2px solid rgba(255,244,214,.08);
  border-radius: 50%;
  pointer-events: none;
}
.ambient::before, .ambient::after {
  content: "";
  position: absolute;
  inset: 20%;
  border: inherit;
  border-radius: inherit;
}
.ambient::after { inset: 43%; background: rgba(255,216,76,.06); }
.ambient-a { left: -170px; top: 12%; }
.ambient-b { right: -210px; bottom: -70px; transform: scale(1.6); }

#app { min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }
.masthead {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(255,244,214,.16);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  padding: 4px;
  text-align: left;
  transform: rotate(-1deg);
}
.brand > span:last-child { display: flex; flex-direction: column; line-height: .75; }
.brand strong { font: 400 32px/1 var(--wordmark); letter-spacing: .005em; }
.brand em {
  color: var(--coral);
  font: 400 14px/1 var(--wordmark);
  margin-top: -.15em;
  display: flex;
  justify-content: space-between;
  /* Inset by half a GRAVITY letter so S centres under G and T under Y
     instead of their outer edges flushing to the wordmark's edges. */
  padding: 0 4.5%;
  /* Staatliches has one weight, so font-weight would only synthesise a bold
     that differs per engine. Stroking the glyphs thickens them deterministically
     and is paint-only, so the centring above is unaffected. */
  -webkit-text-stroke: .055em currentColor;
}
.brand em i { font-style: normal; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 auto; display: block; }
.workshop-stamp {
  color: rgba(255,244,214,.5);
  font: 900 10px/1.1 var(--body);
  letter-spacing: .25em;
  text-align: center;
}
.workshop-stamp small { font-size: 7px; letter-spacing: .2em; }
.header-actions { display: flex; gap: 9px; }
.icon-button {
  width: 39px;
  height: 39px;
  padding: 0;
  border: 2px solid rgba(255,244,214,.3);
  background: rgba(18,8,28,.26);
  border-radius: 50%;
  font: 900 17px/1 var(--display);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.1);
}
.icon-button:hover { border-color: var(--cream); transform: rotate(4deg); }
.audio-menu-wrap { position: relative; }
.audio-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 12px);
  right: 0;
  width: 205px;
  padding: 8px;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 5px 6px 0 rgba(18,8,28,.45);
}
.audio-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 12px;
  width: 12px;
  height: 12px;
  background: var(--cream);
  border-left: 3px solid var(--ink);
  border-top: 3px solid var(--ink);
  transform: rotate(45deg);
}
.audio-menu-label {
  padding: 2px 5px 7px;
  color: var(--coral-dark);
  font: 900 8px/1 var(--body);
  letter-spacing: .18em;
}
.audio-option {
  width: 100%;
  min-height: 39px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(37,22,56,.18);
  font: 900 10px/1.1 var(--body);
  letter-spacing: .06em;
  text-align: left;
}
.audio-option:hover { background: var(--paper); }
.audio-state {
  min-width: 36px;
  padding: 5px 4px;
  color: var(--ink);
  background: var(--teal);
  border: 2px solid var(--ink);
  border-radius: 10px;
  font: 900 8px/1 var(--body);
  text-align: center;
}
.audio-option[aria-pressed="true"] .audio-state {
  color: var(--cream);
  background: var(--coral-dark);
}

.game-layout {
  flex: 1;
  width: min(1180px, 100%);
  margin: auto;
  padding: clamp(18px, 4vh, 46px) 24px 18px;
  display: grid;
  grid-template-columns: minmax(155px, 210px) minmax(400px, 640px) minmax(150px, 205px);
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vw, 44px);
}
.eyebrow {
  color: var(--coral);
  font: 900 9px/1 var(--body);
  letter-spacing: .25em;
}
.status-card { align-self: center; transform: rotate(-1.3deg); }
.level-number { display: flex; align-items: baseline; margin-top: 12px; }
.level-number span {
  color: var(--muted);
  font: 900 10px/1 var(--body);
  letter-spacing: .12em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin-right: 7px;
}
.level-number strong { color: var(--lemon); font: 900 clamp(58px, 6.7vw, 91px)/.85 var(--display); letter-spacing: -.09em; }
.status-card h1 { margin: 12px 0 6px; font: 900 21px/1.05 var(--display); letter-spacing: -.04em; }
.divider { display: flex; align-items: center; gap: 7px; margin: 22px 0 16px; }
.divider span { height: 1px; background: rgba(255,244,214,.25); flex: 1; }
.divider i { width: 6px; height: 6px; border: 1px solid var(--coral); transform: rotate(45deg); }
.move-readout { display: flex; gap: 28px; }
.move-readout div { display: flex; flex-direction: column; }
.move-readout small { color: var(--muted); font-size: 9px; line-height: 1; letter-spacing: .18em; }
.move-readout strong { font: 900 25px/1 var(--display); margin-top: 3px; }
.text-button {
  margin-top: 23px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid rgba(255,244,214,.35);
  background: none;
  font-size: 11px;
  letter-spacing: .18em;
}
.text-button span { color: var(--coral); font-size: 16px; margin-left: 5px; vertical-align: -1px; }

.machine {
  filter: drop-shadow(0 24px 30px rgba(8,3,15,.45));
  min-width: 0;
}
.machine-top {
  width: 88%;
  height: 34px;
  margin: 0 auto -1px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  box-shadow: inset 0 4px 0 rgba(255,255,255,.4);
}
.machine-label { font: 900 8px/1 var(--body); letter-spacing: .18em; }
.indicator { display: flex; align-items: center; gap: 5px; font-size: 7px; letter-spacing: .1em; }
.indicator i { width: 7px; height: 7px; background: var(--teal); border: 1px solid var(--ink); border-radius: 50%; box-shadow: 0 0 7px var(--teal); }
.indicator i.busy { background: var(--lemon); box-shadow: 0 0 7px var(--lemon); }
.machine-body {
  position: relative;
  padding: clamp(18px, 3.5vw, 30px);
  padding-bottom: clamp(31px, 5vw, 44px);
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(255,255,255,.24), transparent 28%),
    var(--paper);
  border: 4px solid var(--ink);
  border-radius: 26px 26px 19px 19px;
  box-shadow: inset 0 -8px 0 #d4b47b, inset 0 5px 0 #fff9e9;
}
.screw {
  width: 10px; height: 10px; position: absolute;
  border: 2px solid var(--ink); border-radius: 50%;
  background: #bfa273;
}
.screw::after { content: ""; position: absolute; left: 1px; right: 1px; top: 2px; height: 1px; background: var(--ink); transform: rotate(-30deg); }
.screw-tl { left: 10px; top: 10px; } .screw-tr { right: 10px; top: 10px; }
.screw-bl { left: 10px; bottom: 11px; } .screw-br { right: 10px; bottom: 11px; }
.board-bezel {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  background: var(--ink);
  border: clamp(8px, 1.5vw, 14px) solid var(--ink-2);
  border-radius: 20px;
  box-shadow:
    0 0 0 3px var(--ink),
    0 7px 0 #b39769,
    inset 0 0 35px rgba(7,2,12,.7);
}
#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.canvas-vignette {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 28px rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,255,255,.08);
  border-radius: 9px;
}
.machine-meter {
  height: 18px; display: flex; align-items: center; justify-content: center; gap: 7px;
  position: absolute; left: 32%; right: 32%; bottom: 10px;
  font: 900 6px/1 var(--body); color: #88714f;
}
.machine-meter div { width: 66px; height: 10px; border-top: 2px solid var(--ink); border-radius: 50%; position: relative; }
.machine-meter i { position: absolute; left: 50%; top: -3px; width: 2px; height: 8px; background: var(--coral); transform-origin: 50% 100%; transition: transform .25s; }
.control-deck {
  width: 91%;
  margin: -2px auto 0;
  padding: 13px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: #e8c98f;
  border: 4px solid var(--ink);
  border-radius: 0 0 24px 24px;
  box-shadow: inset 0 -6px 0 #bb9865;
}
.turn-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
.rotate-button {
  min-height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--cream);
  background: linear-gradient(#ff786f, var(--coral));
  border: 3px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 5px 0 var(--ink), inset 0 3px 0 rgba(255,255,255,.3);
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.rotate-button:hover:not(:disabled) { filter: brightness(1.08); }
.rotate-button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink), inset 0 3px 0 rgba(255,255,255,.25); }
.rotate-button:disabled { filter: grayscale(.5); opacity: .55; }
.rotate-button.hinted {
  color: var(--ink);
  background: linear-gradient(#ffe880, var(--lemon));
  animation: hint-pulse .85s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 5px 0 var(--ink), 0 0 0 0 rgba(255,216,76,.55); }
  50% { transform: translateY(-2px) scale(1.025); box-shadow: 0 7px 0 var(--ink), 0 0 0 8px rgba(255,216,76,0); }
}
.rotate-icon { font: 900 35px/1 var(--display); }
.rotate-button small {
  max-width: 42px;
  font: 900 10px/1.1 var(--body);
  letter-spacing: .1em;
  text-align: left;
}
.utility-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 12px;
  border-top: 2px solid rgba(37,22,56,.18);
}
.utility-controls button {
  min-width: 0;
  min-height: 40px;
  padding: 7px 6px;
  color: var(--ink);
  background: rgba(255,244,214,.62);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.45);
  font-size: 10px;
  letter-spacing: .08em;
}
.utility-controls button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.35);
}
.utility-controls button:disabled { opacity: .36; cursor: default; }
.utility-controls span { color: var(--coral-dark); font-size: 15px; vertical-align: -1px; }
#hint-button { background: rgba(255,216,76,.55); border-color: #a47a24; }
#hint-button span { color: #7c4fa0; }
#restart-button.hinted-reset {
  color: var(--cream);
  background: var(--coral-dark);
  border-color: var(--ink);
  animation: reset-pulse .72s ease-in-out infinite;
}
@keyframes reset-pulse {
  50% { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(198,62,69,.18); }
}

.onboarding-guide {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}
.onboarding-catcher {
  position: absolute;
  inset: 0;
  z-index: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
}
.onboarding-catcher:focus-visible { outline: none; }
.onboarding-target {
  position: fixed;
  z-index: 1;
  padding: 0;
  border: 4px solid var(--lemon);
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 0 0 5px rgba(255,216,76,.2),
    0 0 0 9999px rgba(17,8,28,.74);
  pointer-events: none;
}
.onboarding-guide[data-step="turn"] .onboarding-target {
  border-radius: 15px;
  pointer-events: auto;
  box-shadow:
    0 0 0 5px rgba(255,216,76,.2),
    0 0 0 9999px rgba(17,8,28,.74);
}
.onboarding-copy {
  position: fixed;
  z-index: 2;
  width: min(225px, calc(100vw - 24px));
  padding: 14px 16px 12px;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 11px;
  box-shadow: 0 5px 0 var(--ink);
  pointer-events: none;
}
.onboarding-copy::before {
  content: "";
  position: absolute;
  left: var(--onboarding-arrow-left, 18px);
  top: -9px;
  width: 14px;
  height: 14px;
  background: var(--cream);
  border-left: 3px solid var(--ink);
  border-top: 3px solid var(--ink);
  transform: rotate(45deg);
}
.onboarding-guide[data-placement="above"] .onboarding-copy::before {
  top: auto;
  bottom: -9px;
  border: 0;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
}
.onboarding-copy h2 {
  margin: 7px 0 4px;
  font: 900 18px/1.05 var(--display);
  letter-spacing: -.035em;
}
.onboarding-copy p {
  margin: 0;
  color: #6f5b72;
  font-size: 12px;
  line-height: 1.35;
}

.instruction-card {
  align-self: center;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  padding: 21px 18px;
  transform: rotate(1.7deg);
  box-shadow: 9px 10px 0 rgba(10,4,17,.28);
  position: relative;
}
.instruction-card::before {
  content: ""; width: 54px; height: 13px; position: absolute; left: 50%; top: -10px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(255,216,76,.75); box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.orbit-diagram { height: 86px; position: relative; margin-bottom: 17px; }
.orbit-diagram i { position: absolute; inset: 12px 24px; border: 2px solid var(--ink); border-radius: 50%; transform: rotate(-25deg); }
.orbit-diagram .orbit-two { transform: rotate(38deg); border-color: var(--coral); }
.orbit-diagram i::after { content: ""; position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--teal); left: -5px; top: 50%; border: 2px solid var(--ink); }
.orbit-diagram .orbit-two::after { background: var(--lemon); left: auto; right: 2px; top: 3px; }
.orbit-diagram b { position: absolute; left: 50%; top: 50%; width: 25px; height: 25px; transform: translate(-50%,-50%); background: var(--coral); border: 3px solid var(--ink); border-radius: 50%; }
.instruction-card h2 { font: 900 19px/1.02 var(--display); letter-spacing: -.045em; margin: 10px 0; }
.instruction-card p { color: #745f79; font-size: 13px; line-height: 1.45; }
.key-hint { border-top: 1px dashed #b9a484; margin-top: 18px; padding-top: 13px; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 4px; }
kbd { border: 1px solid var(--ink); border-bottom-width: 3px; border-radius: 4px; padding: 2px 5px; font: 900 10px/1 var(--body); }
.key-hint span { font-size: 8px; letter-spacing: 0; margin-left: 3px; }

footer {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 clamp(20px, 4vw, 64px);
  color: rgba(255,244,214,.32);
  font-size: 6px;
  letter-spacing: .2em;
}
.footer-rule { height: 1px; flex: 1; background: rgba(255,244,214,.1); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(19,10,29,.78);
  backdrop-filter: blur(7px);
}
.modal {
  width: min(410px, 94vw);
  position: relative;
  color: var(--ink);
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: 14px 16px 0 rgba(0,0,0,.3);
}
#complete-overlay { isolation: isolate; }
.win-confetti {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.completion-modal { z-index: 1; }
.win-confetti-piece {
  position: absolute;
  top: var(--confetti-top);
  width: 15px;
  height: 11px;
  opacity: 0;
  --confetti-color: var(--coral);
  background: var(--confetti-color);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(19,10,29,.22);
  animation-duration: var(--confetti-duration);
  animation-delay: var(--confetti-delay);
  animation-timing-function: cubic-bezier(.35,0,.65,1);
  animation-fill-mode: both;
}
.win-confetti-piece.from-left {
  left: -24px;
  animation-name: confetti-from-left;
}
.win-confetti-piece.from-right {
  right: -24px;
  animation-name: confetti-from-right;
}
.win-confetti-piece.color-coral { --confetti-color: var(--coral); }
.win-confetti-piece.color-teal { --confetti-color: var(--teal); }
.win-confetti-piece.color-lemon { --confetti-color: var(--lemon); }
.win-confetti-piece.color-blue { --confetti-color: var(--blue); }
.win-confetti-piece.color-cream { --confetti-color: var(--cream); }
.win-confetti-piece.shape-chip { width: 15px; height: 11px; border-radius: 1px; }
.win-confetti-piece.shape-strip { width: 7px; height: 20px; border-radius: 2px; }
.win-confetti-piece.shape-arc {
  width: 18px;
  height: 9px;
  background: transparent;
  border-color: var(--confetti-color);
  border-width: 4px;
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: none;
}
.completion-modal {
  padding: 42px 35px 30px;
  text-align: center;
  transform: rotate(-.6deg);
  transition: box-shadow .24s, border-color .24s;
}
.completion-modal.staging {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.completion-modal:not(.revealing) #complete-title,
.completion-modal:not(.revealing) #complete-summary,
.completion-modal:not(.revealing) #complete-tier-copy { opacity: 0; transform: translateY(8px); }
.completion-modal.revealing #complete-title,
.completion-modal.revealing #complete-summary,
.completion-modal.revealing #complete-tier-copy { opacity: 1; transform: translateY(0); transition: opacity .22s, transform .22s; }
.completion-modal.revealing #complete-summary { transition-delay: .06s; }
.completion-modal.revealing #complete-tier-copy { transition-delay: .1s; }
.modal h2 { margin: 10px 0; font: 900 36px/.95 var(--display); letter-spacing: -.06em; }
.result-badges { min-height: 70px; display: flex; justify-content: center; align-items: center; gap: 12px; margin: 10px 0 2px; }
.orbit-badge {
  width: 57px;
  height: 57px;
  position: relative;
  display: grid;
  place-items: center;
  opacity: .2;
  border: 3px dashed #a8957d;
  border-radius: 50%;
  transform: scale(.55) rotate(-35deg);
}
.orbit-badge.earned {
  opacity: 0;
  color: var(--lemon);
  background: radial-gradient(circle, #fff09a 0 16%, var(--lemon) 17% 48%, #c58a22 49% 55%, transparent 56%);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 3px #fff09a, 0 5px 0 var(--ink);
}
.orbit-badge.earned::before, .orbit-badge.earned::after {
  content: "";
  position: absolute;
  inset: 8px 1px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  transform: rotate(45deg);
}
.orbit-badge.earned::after { transform: rotate(-45deg); }
.orbit-badge.earned i { position: absolute; width: 8px; height: 8px; background: var(--teal); border: 2px solid var(--ink); border-radius: 50%; }
.orbit-badge.earned i:first-child { left: -5px; }
.orbit-badge.earned i:last-child { right: -5px; background: var(--coral); }
.orbit-badge.earned b { width: 10px; height: 10px; background: var(--cream); border: 2px solid var(--ink); border-radius: 50%; z-index: 1; }
.orbit-badge.earned.assembled { opacity: 1; transform: scale(1) rotate(0); transition: opacity .16s, transform .28s cubic-bezier(.2,1.65,.35,1); animation: badge-orbit-pulse .4s ease-out; }
.tier-1 .orbit-badge.earned { background: radial-gradient(circle, #ffc56e 0 16%, #d9914e 17% 48%, #7b3e3d 49% 55%, transparent 56%); }
.tier-2 .orbit-badge.earned { background: radial-gradient(circle, #8cebd7 0 16%, var(--teal) 17% 48%, #147b7b 49% 55%, transparent 56%); }
@keyframes badge-orbit-pulse {
  50% { box-shadow: inset 0 0 0 3px #fff09a, 0 5px 0 var(--ink), 0 0 0 10px rgba(255,216,76,.18); }
}
.perfect-stamp {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 8px 12px;
  border: 4px double var(--coral);
  border-radius: 8px;
  color: var(--coral);
  font-weight: 800;
  font-size: 13px;
  line-height: 1.25;
  letter-spacing: .14em;
  text-align: center;
  transform: rotate(9deg);
  opacity: 0;
  pointer-events: none;
}
.perfect-stamp.slammed { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .perfect-stamp.slammed { animation: stamp-slam .34s cubic-bezier(.2, 1.5, .4, 1); }
  .board-bezel.win-thump { animation: chamber-thump .38s cubic-bezier(.2, 1.4, .4, 1); }
}
@keyframes stamp-slam {
  0% { transform: rotate(-4deg) scale(2.2); opacity: 0; }
  55% { transform: rotate(11deg) scale(.94); opacity: 1; }
  100% { transform: rotate(9deg) scale(1); opacity: 1; }
}
@keyframes chamber-thump {
  0% { transform: scale(1); }
  30% { transform: scale(1.028); }
  100% { transform: scale(1); }
}
@keyframes confetti-from-left {
  0% { opacity: 0; transform: translate3d(0, -6vh, 0) rotate(0); }
  12% { opacity: 1; }
  68% {
    opacity: 1;
    transform: translate3d(calc(var(--confetti-travel) - 12vw), calc(var(--confetti-fall) - 14vh), 0) rotate(calc(var(--confetti-spin) - 120deg));
  }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--confetti-travel), var(--confetti-fall), 0) rotate(var(--confetti-spin)); }
}
@keyframes confetti-from-right {
  0% { opacity: 0; transform: translate3d(0, -6vh, 0) rotate(0); }
  12% { opacity: 1; }
  68% {
    opacity: 1;
    transform: translate3d(calc(12vw - var(--confetti-travel)), calc(var(--confetti-fall) - 14vh), 0) rotate(calc(120deg - var(--confetti-spin)));
  }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(calc(-1 * var(--confetti-travel)), var(--confetti-fall), 0) rotate(calc(-1 * var(--confetti-spin))); }
}
.completion-modal p { color: #7c6680; font-size: 14px; }
.completion-modal .complete-tier-copy { min-height: 18px; margin: 4px 0 0; color: var(--ink); font-weight: 900; }
.primary-button {
  width: 100%;
  margin-top: 16px;
  padding: 15px;
  color: #fff;
  background: var(--coral);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 5px 0 var(--ink);
  font: 900 11px/1 var(--body);
  letter-spacing: .13em;
}
.primary-button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.primary-button span { margin-left: 6px; font-size: 15px; }
.modal-link { margin-top: 16px; border: 0; background: none; color: #745f79; font-size: 9px; letter-spacing: .1em; text-decoration: underline; }
#next-level-button { font-size: 12px; }
#replay-button { font-size: 12px; }
.modal-close {
  position: absolute; right: 15px; top: 14px; width: 35px; height: 35px;
  color: var(--ink); border: 2px solid var(--ink); background: transparent; border-radius: 50%; font-size: 23px; line-height: 1;
}
.help-modal { padding: 40px; transform: rotate(.6deg); }
.help-modal ol { list-style: none; padding: 0; margin: 25px 0 7px; }
.help-modal li { display: grid; grid-template-columns: 39px 1fr; gap: 12px; align-items: center; border-top: 1px dashed #cdbb98; padding: 13px 0; font-size: 12px; }
.help-modal li b { color: var(--coral); font: 900 18px/1 var(--display); }
.toolkit-review-button { display: block; width: 100%; }
.toolkit-review-button[hidden] { display: none; }

.toolkit-modal {
  padding: 34px 36px 30px;
  text-align: center;
  transform: rotate(-.5deg);
  overflow: hidden;
}
.toolkit-modal::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  right: -66px;
  top: -68px;
  border: 2px solid rgba(37,22,56,.1);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(37,22,56,.04), 0 0 0 38px rgba(37,22,56,.025);
}
.toolkit-tag {
  display: inline-block;
  margin-bottom: 17px;
  padding: 6px 10px 5px;
  color: var(--cream);
  background: var(--ink);
  font: 900 8px/1 var(--body);
  letter-spacing: .16em;
  transform: rotate(1deg);
}
.toolkit-demo {
  display: block;
  width: 100%;
  height: 140px;
  margin: 0 0 22px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.25);
}
.toolkit-modal h2 { margin: 10px 0 8px; font-size: 30px; }
.toolkit-modal > p { margin: 0 auto 4px; max-width: 310px; color: #745f79; font-size: 12px; line-height: 1.5; }

.drawer-overlay { place-items: end center; padding-bottom: 0; }
.level-drawer {
  width: min(720px, 100%);
  max-height: 84vh;
  overflow: auto;
  color: var(--ink);
  background: var(--cream);
  border: 4px solid var(--ink);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 27px;
  box-shadow: 0 -15px 40px rgba(0,0,0,.3);
  animation: drawer-in .28s ease-out;
}
@keyframes drawer-in { from { transform: translateY(100%); } }
.level-drawer header { display: flex; justify-content: space-between; position: relative; }
.level-drawer h2 { margin: 8px 0 22px; font: 900 31px/1 var(--display); letter-spacing: -.05em; }
.level-drawer .modal-close { position: static; }
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.level-tile {
  min-height: 100px;
  padding: 11px;
  text-align: left;
  color: var(--ink);
  background: #f0d9a8;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 4px 0 var(--ink);
}
.level-tile:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.level-tile:disabled { opacity: .43; }
.level-tile.current { background: var(--lemon); }
.level-tile strong { display: block; font: 900 24px/1 var(--display); }
.level-tile .level-name { display: block; font-size: 10px; margin-top: 6px; letter-spacing: .08em; }
.level-tile small { display: block; margin-top: 10px; color: var(--coral-dark); letter-spacing: 1px; }
.level-tile .tile-badges {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  color: #87620e;
  font-size: 11px !important;
  letter-spacing: 2px !important;
}
.level-tile .tile-badge {
  width: 6px;
  height: 6px;
  border: 1.5px solid rgba(135, 98, 14, .5);
  border-radius: 50%;
  box-sizing: border-box;
  flex-shrink: 0;
}
.level-tile .tile-badge.earned {
  width: 10px;
  height: 10px;
  background: #87620e;
  border-color: #87620e;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: 130px minmax(360px, 580px); }
  .instruction-card { display: none; }
}
@media (max-width: 640px) {
  body { min-height: 100svh; }
  .boot-plate {
    width: min(350px, calc(100vw - 28px));
    padding: 17px 21px 19px;
    border-radius: 20px;
  }
  .boot-wordmark { width: 140px; }
  .boot-wordmark strong { font-size: 45px; }
  .boot-wordmark em { font-size: 21px; }
  .boot-scenes { height: 195px; }
  .boot-docks { left: 12px; right: 12px; }
  .boot-game-orb--coral { left: 20px; }
  .boot-game-orb--lemon { right: 20px; }
  .boot-rail { margin-block: 14px 11px; }
  .masthead { height: 66px; padding: 0 14px; }
  .header-actions { gap: 5px; }
  .header-actions .icon-button { width: 36px; height: 36px; }
  .brand strong { font-size: 26px; }
  .brand em { font-size: 11px; }
  .brand-mark { width: 35px; height: 35px; }
  .workshop-stamp { display: none; }
  .game-layout { display: flex; flex-direction: column; padding: 16px 10px 10px; gap: 14px; justify-content: flex-start; }
  .machine { width: min(100%, 510px, calc(100svh - 358px)); order: 1; }
  .status-card { width: min(100%, 500px); order: 0; display: grid; grid-template-columns: auto 1fr auto; gap: 8px 13px; align-items: center; transform: none; }
  .status-card .eyebrow, .status-card .divider, .status-card .text-button { display: none; }
  .level-number { margin: 0; }
  .level-number span { font-size: 7px; }
  .level-number strong { font-size: 49px; }
  .status-card h1 { margin: 0; font-size: 19px; }
  .move-readout { gap: 15px; justify-self: end; grid-column: 3; }
  .move-readout strong { font-size: 19px; }
  .machine-top { height: 27px; }
  .machine-body { padding: 16px; padding-bottom: 32px; border-width: 3px; }
  .board-bezel { border-width: 8px; }
  .control-deck {
    width: 94%;
    padding: 10px 11px 14px;
    gap: 12px;
    border-width: 3px;
  }
  .turn-controls { gap: 8px; }
  .rotate-button { min-height: 56px; border-width: 2px; }
  .rotate-icon { font-size: 30px; }
  .rotate-button small { font-size: 10px; }
  .utility-controls {
    gap: 6px;
    padding-top: 10px;
  }
  .utility-controls button {
    min-height: 44px;
    padding-inline: 3px;
    font-size: 10px;
  }
  .utility-controls span { font-size: 13px; }
  .onboarding-copy { padding: 12px 14px 10px; }
  .onboarding-copy h2 { font-size: 16px; }
  footer { display: none; }
  .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) and (max-height: 700px) {
  .masthead { height: 50px; }
  .game-layout { padding-block: 6px; gap: 6px; }
  .machine { width: min(100%, 510px, calc(100svh - 260px)); }
  .level-number strong { font-size: 38px; }
  .status-card h1 { font-size: 16px; }
  .move-readout strong { font-size: 16px; }
  .machine-top { height: 22px; }
  .machine-body { padding: 10px; padding-bottom: 26px; }
  .control-deck { padding: 6px 8px 9px; gap: 6px; }
  .rotate-button { min-height: 44px; }
  .rotate-icon { font-size: 24px; }
  .rotate-button small { font-size: 9px; }
  .utility-controls { padding-top: 6px; }
}
@media (max-height: 1030px) and (min-width: 901px) {
  .masthead { height: 68px; }
  .game-layout { min-height: 0; padding-top: 15px; padding-bottom: 8px; }
  .machine { width: min(600px, calc(100svh - 310px)); justify-self: center; }
  .machine-body { padding: 20px; padding-bottom: 35px; }
  .board-bezel { border-width: 10px; }
  .control-deck { padding: 9px 13px 13px; gap: 10px; }
  .utility-controls { padding-top: 8px; }
  .rotate-button { min-height: 57px; }
  .rotate-icon { font-size: 31px; }
  footer { height: 25px; }
}
@media (max-height: 710px) and (min-width: 641px) {
  .boot-plate { transform: scale(.82); }
  .boot-screen.is-leaving .boot-plate { transform: scale(.7) rotate(-2deg); }
  .masthead { height: 66px; }
  .game-layout { padding-top: 8px; padding-bottom: 5px; }
  .machine { width: min(350px, calc(100svh - 277px)); max-width: 100%; justify-self: center; }
  .machine-top { height: 27px; }
  .machine-body { padding: 16px; padding-bottom: 31px; border-width: 3px; }
  .board-bezel { border-width: 8px; }
  .control-deck { padding: 8px 11px 12px; gap: 9px; border-width: 3px; }
  .turn-controls { gap: 8px; }
  .utility-controls { gap: 5px; padding-top: 7px; }
  .utility-controls button { min-height: 36px; }
  .rotate-button { min-height: 52px; }
  .rotate-icon { font-size: 29px; }
  .status-card .divider { margin: 13px 0 10px; }
  .status-card .text-button { margin-top: 12px; }
  footer { height: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .win-confetti-piece { display: none; }
  .boot-screen.is-leaving .boot-plate { opacity: 0; }
}
