:root {
  color-scheme: light;
  --surface: #eae6f1;
  --ink: #252642;
  --soft: #454764;
  --brass: #605181;
  --gold: #ffe080;
  --lilac: #d3baff;
  --silver: #b1e7da;
  --muted: #545573;
  --rule: #b5aacb;
  --letter: Georgia, "Times New Roman", serif;
  --focus: #64409a;
  --sans: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--surface);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: var(--surface);
}
button, summary { -webkit-tap-highlight-color: transparent; }
body:has(dialog[open]) { overflow: hidden; }
a, button, summary { touch-action: manipulation; }
a { color: inherit; }
button { font: inherit; color: inherit; }
button:not(:disabled), summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
:disabled { cursor: default; }
[hidden] { display: none !important; }
.shell { width: min(578px, calc(100% - 32px)); margin-inline: auto; padding: clamp(8px, 3.5vh, 34px) 0 20px; }
.topbar {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: clamp(6px, 2vw, 17px);
  align-items: center;
}
.topbar .shelf { grid-area: 1 / 2; }
.topbar .sound { grid-area: 1 / 3; }
.shelf {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  min-height: 44px;
  font-size: .875rem;
  text-decoration: none;
}
.shelf:hover { text-decoration: underline; text-underline-offset: .24em; }
.text-button {
  border: 0;
  padding: 6px;
  min-height: 44px;
  background: transparent;
  font-size: .875rem;
  font-weight: 650;
  color: var(--soft);
}
.text-button:hover:not(:disabled) { color: var(--focus); text-decoration: underline; text-underline-offset: .23em; }
.text-button:disabled { color: #6c6786; }
.sound {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  width: 44px;
}
.sound svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sound[aria-pressed="false"] path { stroke-dasharray: 15 2; }
.topbar h1 {
  grid-area: 1 / 1;
  font: 400 clamp(2.12rem, 5vw, 3.5rem)/1 var(--letter);
  letter-spacing: -.055em;
  color: #252642;
  margin: 0;
  position: relative;
}
.room { margin: 4px 0 14px; }
.room-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.room p { margin: 0; }
.room-number { color: var(--brass); font-size: .86rem; white-space: nowrap; }
.room-picker { flex: none; padding-inline: 6px 3px; }
.room-picker::after { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 .2em .21em .43em; border-bottom: 1px solid; border-right: 1px solid; transform: rotate(45deg); }
.room h2 { font: 700 clamp(1rem, 2vw, 1.2rem)/1.2 var(--sans); margin: 0; }
.room .brief { font-size: .92rem; color: var(--soft); line-height: 1.35; }
.cabinet { width: 100%; }
.optics { --size: 5; position: relative; }
.optics[data-size="6"] { --size: 6; }
.optics[data-size="7"] { --size: 7; }
.glazing {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 1;
  background: #c1b5d8;
}
.beam-layer, .board { position: absolute; inset: 0; width: 100%; height: 100%; }
.beam-layer { pointer-events: none; overflow: hidden; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--size), minmax(0, 1fr));
  z-index: 2;
}
.cell {
  display: grid;
  position: relative;
  place-items: center;
  border-right: 1px solid #6a52893d;
  border-bottom: 1px solid #6a52893d;
  min-width: 0;
  min-height: 0;
}
.cell[data-edge-x] { border-right: 0; }
.cell[data-edge-y] { border-bottom: 0; }
.cell[data-spare]::after {
  content: "";
  position: absolute;
  inset: calc(50% - 1px);
  border-radius: 50%;
  background: #66508054;
  pointer-events: none;
  z-index: -1;
}
.glass-button {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 3px;
  color: var(--soft);
}
.glass-button:hover, .glass-button:focus-visible { background: #f7effb48; }
.glass-button:active { background: #a68db84a; }
.glass-button:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; z-index: 1; }
.piece { width: 84%; height: 84%; overflow: visible; }
.glass-button .piece { width: 86%; height: 86%; }
.glass-base { fill: #171d3b; stroke: #a7acd7; stroke-width: 2; }
.glass-inset { fill: #313861; }
.glass-bolt { fill: #939ace; }
.glass-axis { transform-origin: 50px 50px; transition: transform .155s cubic-bezier(.2, .75, .4, 1); }
.glass-axis[data-turn="1"] { transform: rotate(90deg); }
.glass-axis .mirror-edge { fill: #606da7; }
.glass-axis .mirror-face { fill: #a8baff; }
.glass-axis .mirror-shine { fill: #f2f4ff; }
.glass-button:hover .glass-base, .glass-button:focus-visible .glass-base { stroke: #f2ecff; stroke-width: 2; }
.piece[data-fed="true"] .mirror-face { fill: #e1d8ff; }
.split-mark { fill: #fff4df; stroke: #31345c; stroke-width: 1.25; }
.glass-link circle { fill: #21263f; stroke: #ffcf95; stroke-width: 2; }
.glass-link text { fill: #fff5dc; font: 800 18px system-ui, sans-serif; }
.lamp.gold, .plant.gold { color: var(--gold); }
.lamp.lilac, .plant.lilac { color: var(--lilac); }
.plant.graft { color: var(--silver); }
.lamp-seat, .plant-seat { fill: #171c39; stroke: #a3a9d6; stroke-width: 1.8; }
.lamp .seat-ring { fill: #313455; stroke: currentColor; stroke-width: 1.3; opacity: .75; }
.lamp .lamp-bulb { fill: currentColor; }
.lamp .bulb-core { fill: #fff7dd; }
.lamp .direction { fill: currentColor; stroke: #483b5b; stroke-width: 1.2; }
.plant-seat { fill: #1a2043; }
.plant .stem { stroke: currentColor; stroke-width: 2.5; fill: none; }
.plant .leaf { fill: currentColor; }
.plant .flower {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1;
  transform-origin: 50px 45px;
  transform: scale(.61);
  opacity: .75;
  transition: transform .19s cubic-bezier(.18, .85, .2, 1.25), opacity .18s;
}
.plant[data-bloom="true"] .flower { transform: scale(1.22); opacity: 1; }
.plant-mark { fill: currentColor; }
.piece .plant-mark { stroke: #483b5b; stroke-width: 1.2; }
.graft-signal.gold { color: var(--gold); }
.graft-signal.lilac { color: var(--lilac); }
.graft-signal .plant-mark { fill: #222743; stroke: currentColor; stroke-width: 1.8; }
.plant[data-gold="true"] .graft-signal.gold .plant-mark,
.plant[data-lilac="true"] .graft-signal.lilac .plant-mark { fill: currentColor; filter: drop-shadow(0 0 4px currentColor); }
.flower-center { fill: #30324b; }
.flower-dot { fill: #fff5df; }
.seeds { opacity: 0; fill: currentColor; }
.plant[data-bloom="true"] .seeds { animation: lift .64s cubic-bezier(.11, .82, .34, 1) both; }
@keyframes lift { 40% { opacity: .9; } to { opacity: 0; transform: translateY(-12px); } }
.beam { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.beam.gold { color: var(--gold); }
.beam.lilac { color: #f1eaff; }
.beam.halo { stroke: #8d643b; stroke-width: 9; }
.beam.halo.lilac { stroke: #594376; }
.beam.path { stroke: currentColor; stroke-width: 4.8; }
.beam.path.lilac { stroke-dasharray: 7 7; }
.beam.flash { stroke: #fff5e5; stroke-width: 1; animation: sparkle .18s ease-out both; }
.beam.link-trace { stroke: #edb87d; stroke-width: 4; stroke-dasharray: 8 9; animation: link-pulse .19s ease-out both; }
@keyframes sparkle { from { stroke-width: 5; opacity: .9; } to { stroke-width: 1; opacity: 0; } }
@keyframes link-pulse { to { stroke-dashoffset: -26; opacity: 0; } }
.cabinet[data-bloomed="true"] .glazing { background: #d2c4e3; }
.board-footer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 55px; border-bottom: 1px solid var(--rule);
  gap: 7px;
}
.play-tools { display: contents; }
.bloom-status { grid-area: 1 / 1; color: var(--ink); font-weight: 650; font-size: .86rem; margin: 0; }
.cabinet[data-bloomed="true"] .bloom-status,
.completed-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.action-buttons { grid-area: 1 / 2; display: flex; gap: 5px; }
.cabinet[data-bloomed="true"] #reset { display: none; }
.targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 5px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .875rem;
  color: var(--soft);
}
.target { display: flex; align-items: center; min-height: 25px; gap: 7px; }
.target-icon { color: #835111; width: 15px; height: 15px; flex: none; overflow: visible; }
.target[data-color="lilac"] .target-icon { color: var(--focus); }
.target[data-color="graft"] .target-icon { color: #35685d; }
.target-check {
  margin-left: auto;
  display: inline-flex;
  color: #35685d;
  width: 12px;
  padding-right: 2px;
}
.target[data-live="false"] .target-check { visibility: hidden; }
.target[data-live="true"] .target-icon { filter: drop-shadow(0 0 4px currentColor); }
.actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-height: 49px; }
.turn-tally { display: flex; flex-wrap: wrap; align-items: baseline; align-content: center; min-height: 44px; gap: 2px 9px; }
.turns, .par, .undo-count { margin: 0; }
.turns { font-size: .87rem; font-weight: 700; }
.par, .undo-count { font-size: .78rem; color: var(--muted); }
.completion { grid-area: 1 / 1; min-width: 0; }
.completion-card { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.completion h3 { font: 400 clamp(1.02rem, 2.4vw, 1.55rem)/1.02 var(--letter); color: var(--ink); margin: 0; animation: bloom-label .17s ease-out; }
@keyframes bloom-label { from { transform: translateY(4px); } }
.complete-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.complete-actions .text-button { min-width: 44px; padding-inline: 4px; }
.filled-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #34365c;
  color: #fff7ea;
  border: 1px solid #34365c;
  padding: 6px 11px;
  min-height: 44px;
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 800;
  border-radius: 2px;
}
.filled-button:hover { background: #4c4d7d; }
.room-nav { margin-top: 10px; }
.room-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 5px; }
.room-buttons button {
  position: relative;
  min-width: 0;
  min-height: 44px;
  padding: 2px;
  border: 1px solid #aea0c8;
  border-radius: 2px;
  background: #e3d8f2;
  color: var(--ink);
  font-size: .93rem;
}
.room-buttons button:not(:disabled):hover { background: #d7c9ef; }
.room-buttons button[aria-current] { border: 1px solid #6c539b; background: #d9ccef; }
.room-buttons button:disabled { color: #6d6282; background: #e5ddee; border-color: #b5aacb; }
.room-buttons button[data-clear="true"]::after { content: ""; position: absolute; width: .28em; height: .28em; border-radius: 50%; top: 5px; right: 5px; background: var(--focus); }
.read-board { margin-top: 10px; border-bottom: 1px solid var(--rule); }
.read-board summary { display: list-item; padding: 12px 0; min-height: 44px; color: var(--soft); font-size: .875rem; font-weight: 650; }
.read-board summary:hover { color: var(--focus); }
#board-text { color: var(--soft); font-size: .89rem; line-height: 1.5; }
#board-text p { margin: 0 0 5px; }
#board-text ul { margin: 0 0 13px; padding-inline-start: 17px; }
dialog {
  width: min(100% - 28px, 450px);
  max-height: calc(100% - 28px);
  overflow: auto;
  padding: 17px 23px 22px;
  border: 1px solid #a59bb8;
  color: var(--ink);
  background: #f2edf8;

}
dialog::backdrop { background: #191b3a9e; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
dialog h2 { margin: 0; font: 400 2.45rem/1 var(--letter); letter-spacing: -.055em; }
dialog p { margin: 0; font-size: .93rem; line-height: 1.5; color: var(--soft); }
.guide-legend { list-style: none; padding: 0; margin: 17px 0; border-top: 1px solid var(--rule); }
.guide-legend li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; border-bottom: 1px solid var(--rule); padding: 7px 0; }
.guide-legend li > span { text-align: center; color: #835111; font-size: 1.2rem; }
.guide-legend li .legend-mirror, .guide-legend li .legend-split { color: var(--focus); font-size: 1.05rem; }
.guide-legend li .legend-split { border: 1px dotted var(--focus); }
.guide-legend li .legend-flower { color: #35685d; }
.guide-legend strong { font-size: .92rem; }
.guide-keys { font-size: .865rem; }
noscript { position: fixed; bottom: 15px; left: 15px; right: 15px; padding: 14px; background: #f2edf8; color: var(--ink); }
@media (max-width: 540px) {
  .shell { width: calc(100% - 26px); padding-top: 4px; }
  .topbar { min-height: 58px; }
  .shelf, .sound { gap: 4px; }
  .room { margin-bottom: 10px; }
  .room .brief { font-size: .86rem; }
}
@media (max-width: 340px) {
  .shell { width: calc(100% - 14px); }
  .room-number { font-size: .76rem; }
  .board-footer .text-button, .filled-button { font-size: .78rem; min-width: 44px; }
  .filled-button { padding-inline: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .beam.link-trace { animation: none !important; }
}
