:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #10141e;
  color: #e9eef1;
  --gold: #ffcd90;
  --teal: #9df5da;
  --muted: #b5c0ce;
  --edge: #55483c;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 16% 14%, #23454b70, transparent 45%),
    radial-gradient(ellipse at 88% 0%, #7b4f302d, transparent 40%),
    #10141e;
}
.shell { max-width: 1080px; margin: auto; padding: 26px clamp(14px, 4vw, 40px) 16px; }
.masthead, .frameHead { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.masthead { margin-bottom: 22px; }
.brand, .kicker { margin: 0 0 .35rem; font-size: .76rem; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; color: var(--gold); }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-family: Georgia, serif; font-weight: 600; }
h1 { font-size: clamp(2.2rem, 6vw, 4.25rem); line-height: .98; }
h2 { font-size: clamp(1.65rem, 4vw, 2.7rem); line-height: 1.08; }
button, summary { cursor: pointer; font: inherit; touch-action: manipulation; }
button {
  min-height: 46px; padding: .56rem .88rem; border: 1px solid #746259;
  border-radius: 9px; background: #282a33; color: #f4f1ef; font-weight: 680;
}
button:hover:enabled { background: #3c3b44; }
button:disabled { opacity: .46; cursor: default; }
button:focus-visible, summary:focus-visible { outline: 3px solid #ffdc8e; outline-offset: 3px; }
.primary { color: #1e1916; background: #ffce91; border-color: #ffdbac; }
.primary:hover:enabled { background: #ffe4b8; }
.welcome, .frame, .console, details { border: 1px solid var(--edge); border-radius: 19px; background: #181d29; }
.welcome { display: grid; grid-template-columns: 1.26fr 1fr; overflow: hidden; }
.welcome img { display: block; width: 100%; height: 100%; object-fit: cover; }
.intro { display: grid; align-content: center; justify-items: start; gap: 15px; padding: clamp(21px,4vw,44px); }
.intro p, .console p, details { line-height: 1.55; }
.intro p:not(.kicker), .console p, details { color: var(--muted); }
.play { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,.84fr); align-items: start; gap: 16px; }
.frame {
  --light: #a1f3d5; --glass: #14444a;
  padding: clamp(12px,3vw,24px);
  background: radial-gradient(ellipse at 55% 0%, color-mix(in srgb,var(--glass),#161924 57%), #151924 78%);
}
.frame[data-workshop="1"] { --light: #ffcf8a; --glass: #60391e; }
.frame[data-workshop="2"] { --light: #a3dcff; --glass: #253f71; }
.frame[data-workshop="3"] { --light: #f2bfff; --glass: #552e64; }
.frameHead { color: var(--muted); margin-bottom: 10px; }
.frameHead p { margin: 0; }
.board { display: grid; grid-template-columns: repeat(var(--cols),minmax(0,1fr)); gap: 7px; }
.tile {
  --turn: 0deg; --target: 0deg;
  display: grid; place-items: center; position: relative; isolation: isolate;
  aspect-ratio: 1; padding: 0; min-height: 0; min-width: 0;
  border-color: #685446; overflow: visible;
  background: linear-gradient(145deg,#373132,#1a202b 65%);
  color: #f7f3e8;
  box-shadow: inset 0 0 0 3px #181a22, inset 0 0 0 4px #4d4848;
}
.tile:hover:enabled { background: #49404a; }
.tile[data-lit] { background: linear-gradient(145deg,var(--glass),#20212e); border-color: var(--light); box-shadow: inset 0 0 14px color-mix(in srgb,var(--light),transparent 70%); }
.tile[data-linked] { outline: 2px dashed #94d7e7; outline-offset: -5px; }
.tile[data-reverse] { outline-color: #f2bfff; }
.tile[data-hint] { box-shadow: 0 0 0 3px #ffcf82, 0 0 16px #ffb96890; }
.rotor, .notch { position: absolute; pointer-events: none; }
.rotor {
  width: 67%; height: 67%; border-radius: 50%;
  display: grid; place-items: center; transform: rotate(var(--turn));
  transition: transform .19s cubic-bezier(.2,.8,.15,1);
  background: conic-gradient(from -.11turn, #eaf7fe71, #658a9b39 22%, #252d3c 40%, #101923 53%, #8ab0b849 69%, #35415c 85%, #eaf7fe71);
  box-shadow: inset 0 0 0 1px #cadce266, inset 0 0 0 7px #0f172477, 0 2px 9px #080c16;
}
[data-lit] .rotor {
  background: conic-gradient(from -.11turn, var(--light), var(--glass), var(--light), var(--glass), var(--light));
  box-shadow: inset 0 0 0 1px #fff7, inset 0 0 0 6px #10192555, 0 0 12px color-mix(in srgb,var(--light),transparent 55%);
}
.rotor::before {
  content: ""; position: absolute; top: 3%; width: 36%; height: 34%;
  clip-path: polygon(50% 0%, 100% 100%, 50% 76%, 0 100%);
  background: #f1fcff; filter: drop-shadow(0 0 3px #10262b);
}
.notch { inset: 3px; transform: rotate(var(--target)); }
.notch::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 28%; height: 13%;
  transform: translateX(-50%); background: #ffb66c;
  clip-path: polygon(0 0,100% 0,50% 100%); filter: drop-shadow(0 0 2px #000);
}
.gear { z-index: 1; width: 32%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: clamp(.8rem,3vw,1.55rem); line-height: 1; color: #fff4e4; background: #171d27; border: 1px solid #927b67; }
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 12px; text-align: center; }
.stats dt { color: var(--muted); font-size: .76rem; }
.stats dd { font-weight: 760; font-variant-numeric: tabular-nums; color: var(--light); }
.console { padding: 20px; display: grid; gap: 10px; }
.console .preview { padding: .68rem .78rem; border-left: 2px solid #a8886d; background: #101721; min-height: 3.9em; }
.toolbar { display: flex; flex-wrap: wrap; gap: 7px; }
.console .feedback { min-height: 1.55em; color: var(--gold); }
.success { padding: 15px; border: 1px solid #83735a; border-radius: 12px; background: #283835; }
.success h3 { margin-bottom: 10px; font-size: 1.4rem; }
.success .earned { color: var(--gold); letter-spacing: .14em; }
details { margin-top: 13px; padding: 0 15px 0; }
details[open] { padding-bottom: 14px; }
summary { min-height: 46px; line-height: 46px; color: #f3e8dc; font-weight: 680; }
summary span { color: var(--muted); margin-left: .5em; font-weight: 460; }
details p + p { margin-top: .7em; }
.roomList { display: grid; grid-template-columns: repeat(auto-fill,minmax(97px,1fr)); gap: 7px; }
.roomList button { min-height: 49px; font-variant-numeric: tabular-nums; padding: .4em; }
.roomList button[aria-current="true"] { border-color: var(--teal); }
.roomList span { color: var(--gold); margin-left: .3em; }
.legend { padding-left: 1.25rem; }
.legend b { color: var(--gold); }
footer { color: var(--muted); margin-top: 16px; font-size: .85rem; }
.frame[data-complete] { animation: shine .7s ease-out both; }
@keyframes shine { 40% { box-shadow: 0 0 32px color-mix(in srgb,var(--light),transparent 47%); } }
@media(max-width:680px) {
  .shell { padding-top: 13px; }
  .masthead { margin-bottom: 13px; }
  .welcome, .play { grid-template-columns: 1fr; gap: 0; }
  .welcome img { height: min(43vw,245px); }
  .intro { padding: 18px; gap: 10px; }
  .play { gap: 10px; }
  .console { padding: 13px; gap: 7px; }
  .console h2 { font-size: 1.5rem; }
  .frame { padding: 11px; }
  .tile { min-height: 50px; }
  .toolbar { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
  .toolbar button { font-size: .87rem; padding-inline: 4px; }
}
@media(prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
