/* Talebound puzzle workbench — styled on VVCL's dark forest palette */
.puzzles-main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 18px 24px 36px;
}

.puzzle-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.puzzle-hero-title {
  margin: 5px 0 4px;
  font-size: clamp(20px, 2.3vw, 26px);
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}

.puzzle-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.share-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 20px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.share-dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}

.share-dialog form {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.share-dialog label {
  width: 100%;
}

.share-dialog input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* Zone tabs & puzzle sub-navigation */
.zone-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.maptab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 14px 9px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px 6px 0 0;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.maptab:hover {
  color: var(--text);
  background: #17201a;
}

.maptab.current {
  color: var(--text);
  border-bottom-color: var(--zone-tone, var(--green));
  background: #16211a;
}

.maptab .zone-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--zone-tone, var(--green));
  flex-shrink: 0;
}

.maptab .zone-ach {
  font-size: 10px;
  color: #7d9685;
  padding: 1px 6px;
  border-radius: 10px;
  background: #131b16;
  border: 1px solid #29362d;
}

.maptab.current .zone-ach {
  color: #b7d2bf;
  border-color: #3a4f41;
}

.toolnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pnav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 13px;
  background: #151c17;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #9cb2a3;
  font-size: 12px;
  font-weight: 500;
}

.pnav:hover {
  background: #1d2921;
  color: var(--text);
  border-color: #3d5244;
}

.pnav.active {
  background: #21382a;
  color: var(--green);
  border-color: #4f7f60;
}

.puzzle-head {
  margin: 0 0 14px;
}

.puzzle-head h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.puzzle-head h3 small {
  font-size: 11px;
  font-weight: 500;
  color: var(--green);
  background: #1a2d21;
  border: 1px solid #355742;
  border-radius: 4px;
  padding: 1px 7px;
}

.puzzle-head p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Two-column workbench layout + bottom solution card */
.builderbody,
.workbody {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(300px, 0.96fr);
  gap: 16px;
  align-items: start;
}

.stage,
.control,
.board-side,
.supply-side,
.answers {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  min-width: 0;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 13px;
  font: 600 12px/1.4 ui-monospace, 'SFMono-Regular', Consolas, monospace;
  color: #9bb8a5;
  letter-spacing: 0.04em;
}

.step-title span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #203428;
  border: 1px solid #41654e;
  color: var(--green);
  font-size: 11px;
}

.supply-side h4,
.control h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Reusable button & control primitives */
.pbtn,
.bbtn,
.seg button,
.gemtarget button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 10px;
  background: #151e18;
  border: 1px solid #35473b;
  border-radius: 5px;
  color: #c5d9cb;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.pbtn:hover:not(:disabled),
.bbtn:hover:not(:disabled),
.seg button:hover:not(:disabled),
.gemtarget button:hover:not(:disabled) {
  background: #233328;
  border-color: #4d6b57;
  color: var(--text);
}

.pbtn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #0e2416;
  font-weight: 600;
  padding: 5px 15px;
}

.pbtn.primary:hover:not(:disabled) {
  background: #b5f1cd;
  border-color: #b5f1cd;
  color: #0b1e12;
}

.pbtn.danger {
  background: #351d1a;
  border-color: #7b423c;
  color: #f3beb7;
}

.pbtn.danger:hover:not(:disabled) {
  background: #472521;
}

.pbtn.quiet,
.bbtn.quiet {
  background: transparent;
  border-color: #2f3e34;
  color: var(--muted);
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.seg button.sel,
.bbtn.is-on {
  background: #213a2b;
  border-color: #548967;
  color: var(--green);
}

.brow,
.bhead,
.bactions,
.boardfoot,
.presetline,
.dimline,
.portrow,
.placebar,
.actionrow,
.stepper,
.orientation,
.legend {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.bhead,
.boardfoot,
.portrow {
  justify-content: space-between;
}

.btop {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.bactions,
.actionrow {
  margin-bottom: 12px;
}

.presetline strong,
.dimline label,
.fieldlabel {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.fieldlabel {
  margin: 12px 0 6px;
}

.dimline label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.puzzles-main input[type='number'],
.puzzles-main input[type='text'],
.puzzles-main textarea {
  border: 1px solid #35473b;
  border-radius: 5px;
  color: var(--text);
  background: #111813;
  padding: 4px 7px;
  min-width: 0;
  font-size: 12px;
}

.dimline input[type='number'] {
  width: 56px;
  height: 30px;
}

.puzzles-main textarea {
  display: block;
  width: 100%;
  margin: 8px 0;
  font: 12px/1.55 ui-monospace, 'SFMono-Regular', Consolas, monospace;
  resize: vertical;
}

.puzzles-main input[type='checkbox'] {
  accent-color: var(--green);
}

.ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ic svg {
  width: 1.15em;
  height: 1.15em;
}

.inline-feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  border-left: 3px solid var(--green);
  padding: 7px 10px;
  background: #14221a;
  border-radius: 0 5px 5px 0;
  margin: 0 0 12px;
  font-size: 12px;
  color: #cbe2d3;
}

.inline-feedback.is-error {
  border-left-color: var(--red);
  background: #271816;
  color: #f3c4bd;
}

.inline-feedback.is-busy {
  border-left-color: var(--amber);
  background: #241f14;
  color: #f0d7a6;
}

.inline-feedback .pbtn {
  min-height: 25px;
  padding: 2px 8px;
  font-size: 11px;
}

/* Board & coordinate axes */
.canvasmat,
.stagearea {
  margin: 12px 0 10px;
}

.zoomline {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 4px;
}

.zoomline .pbtn {
  border: 0;
  background: transparent;
  color: #88a794;
  font-size: 11px;
  min-height: 22px;
  padding: 1px 4px;
}

.zoomline .pbtn:hover {
  color: var(--green);
  background: transparent;
}

.board-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.board-scroll.zoomed .axisframe {
  width: max(100%, calc(var(--cols) * 58px + 25px));
}

/* Boards mirror the in-game grid, so they never flip in right-to-left languages. */
.axisframe,
.gemtarget,
.draft-grid {
  direction: ltr;
}

.axisframe {
  display: grid;
  width: min(100%, calc(var(--board-size, 620px) + 25px));
  grid-template-columns: 22px minmax(0, 1fr);
  grid-template-rows: 18px auto;
  gap: 3px;
  user-select: none;
  margin: 0 auto;
}

.axis-x,
.axis-y {
  display: grid;
  align-items: center;
  justify-items: center;
  font: 11px ui-monospace, monospace;
  color: #6f8a79;
}

.axis-x {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 3px;
}

.axis-y {
  grid-column: 1;
  grid-row: 2;
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 3px;
}

.drawboard,
.board {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}

.drawboard {
  touch-action: none;
  -webkit-user-select: none;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  width: 100%;
  padding: 0;
  border: 1px solid #2a372e;
  border-radius: 5px;
  background: #141c17;
  color: var(--text);
  overflow: hidden;
  transition: filter 0.08s;
}

.cell:hover:not(:disabled) {
  filter: brightness(1.12);
}

.cell.usable {
  background: #28392f;
  border-color: #415d4b;
}

.cell.hole,
.cell.off {
  background: #101512;
  border-color: #1d2620;
  opacity: 0.65;
}

.cell svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Crate seamless polyomino rendering */
.drawboard.crate-board {
  --crate-line: #0e1410;
  --crate-edge: 2px;
  --crate-gap: 3px;
  gap: var(--crate-gap);
}

.crate-board .cell.occupied,
.crate-board .cell.ghost {
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.crate-board .cell.occupied:hover,
.crate-board .cell.ghost:hover {
  filter: none;
}

.crate-board .cell.muted-piece {
  opacity: 0.24;
}

.crate-board .cell.occupied:focus-visible,
.crate-board .cell.blocked {
  outline: 2px solid #fff;
  outline-offset: -3px;
  z-index: 2;
}

.crate-board .cell.blocked {
  outline-color: #ff6b6b;
}

.crate-face {
  position: absolute;
  inset: 0;
  background: inherit;
  display: grid;
  place-items: center;
  pointer-events: none;
  border: 0 solid var(--crate-line);
  color: #fff;
  font: 700 clamp(11px, 1.35vw, 18px) / 1 ui-monospace, monospace;
  text-shadow: 0 1px 3px #0a100c, 0 0 4px #0a100c;
  box-sizing: border-box;
}

.crate-face:not([data-edges*='e']) {
  right: calc(0px - var(--crate-gap));
}

.crate-face:not([data-edges*='s']) {
  bottom: calc(0px - var(--crate-gap));
}

.crate-face[data-edges*='n'] {
  border-top-width: var(--crate-edge);
}

.crate-face[data-edges*='e'] {
  border-right-width: var(--crate-edge);
}

.crate-face[data-edges*='s'] {
  border-bottom-width: var(--crate-edge);
}

.crate-face[data-edges*='w'] {
  border-left-width: var(--crate-edge);
}

.drawboard .cell.ghost {
  background: var(--ghost-color);
  opacity: 0.85;
}

.crate-preview {
  background: var(--ghost-color);
  box-shadow: inset 0 0 0 2px #ffffff88;
}

/* Crate shelf, custom draft & legend */
.tile-shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 9px 0 12px;
}

.shelf-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: auto auto;
  gap: 3px 9px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid #29362d;
  border-radius: 6px;
  background: #131a15;
}

.tile-thumb {
  grid-row: 1 / 3;
  width: 40px;
  height: 40px;
  padding: 5px;
  background: #19241d;
  cursor: grab;
}

.tile-svg {
  width: 100%;
  height: 100%;
  max-width: 28px;
  max-height: 28px;
  display: block;
}

.shape-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.shape-name small {
  color: var(--muted);
  font: 10px ui-monospace, monospace;
  margin-left: 3px;
}

.stepper {
  gap: 5px;
}

.stepper .bbtn {
  min-height: 24px;
  width: 26px;
  padding: 0;
}

.stepper output {
  min-width: 22px;
  text-align: center;
  font: 600 12px ui-monospace, monospace;
  color: var(--text);
}

.draft {
  margin: 10px 0;
  padding: 12px;
  border: 1px solid #354b3c;
  border-radius: 6px;
  background: #131c16;
}

.draft b {
  font-size: 12px;
  color: var(--green);
}

.draft p {
  margin: 4px 0 8px;
  font-size: 11px;
  color: var(--muted);
}

.draft-grid {
  display: grid;
  grid-template-columns: repeat(5, 32px);
  gap: 4px;
  margin-bottom: 10px;
}

.draft-grid .bbtn {
  width: 32px;
  height: 32px;
  padding: 0;
  min-height: 0;
}

.draft-grid .bbtn.painted {
  background: var(--green);
  border-color: var(--green);
}

.placebar {
  margin: 8px 0 4px;
  padding: 7px 10px;
  border: 1px solid #3b5845;
  border-radius: 6px;
  background: #16241b;
  font-size: 12px;
  color: #cbe2d3;
}

.placebar .tile-svg {
  width: 24px;
  height: 24px;
}

.instance-details {
  margin-top: 10px;
}

.instance-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.instance-list .bbtn {
  padding: 4px 8px;
  font-size: 11px;
}

.instance-list .tile-svg {
  width: 18px;
  height: 18px;
}

.secondary-tools {
  margin: 10px 0;
}

.pcheck {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #c8dccf;
  cursor: pointer;
  margin: 4px 0 8px;
}

.matchok {
  color: var(--green);
  font-weight: 600;
}

.notice {
  color: var(--amber);
  font-weight: 500;
}

/* Board footer, hints, legends, details */
.legend,
.boardfoot,
.hinttext,
.muted,
.shelfnote,
.status,
.custom p,
.portrow {
  font-size: 12px;
  color: var(--muted);
}

.boardfoot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #242f28;
}

.boardfoot b {
  color: var(--text);
}

.legend {
  gap: 8px 14px;
  margin: 8px 0;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.hinttext,
.shelfnote {
  margin: 6px 0;
  line-height: 1.6;
}

details.custom {
  margin-top: 12px;
  border: 1px solid #28352c;
  border-radius: 6px;
  padding: 8px 11px;
  background: #131a15;
}

details.custom > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #bdd3c4;
}

details.custom > summary small {
  color: var(--muted);
  margin-left: 5px;
}

/* Pipe styling */
.cell.wet {
  background: #172b24;
  border-color: #366857;
}

.cell.dry {
  background: #18201b;
  border-color: #2f3d34;
}

.cell.bad {
  border-color: #d65a4b;
  box-shadow: inset 0 0 0 1px #d65a4b88;
}

.cell.rotated {
  border-color: #548967;
}

.porttag,
.turntag {
  position: absolute;
  line-height: 1.2;
  border-radius: 4px;
  pointer-events: none;
}

.porttag {
  bottom: 2px;
  left: 2px;
  color: #fff;
  background: #216653;
  padding: 1px 4px;
  font: 700 clamp(8px, 1vw, 11px) ui-monospace, monospace;
}

.porttag.p1 {
  left: auto;
  right: 2px;
  background: #8a5624;
}

.turntag {
  top: 2px;
  right: 2px;
  min-width: 18px;
  text-align: center;
  padding: 1px 4px;
  background: var(--green);
  color: #0d2215;
  font: 700 clamp(9px, 1.1vw, 12px) ui-monospace, monospace;
}

.turntag.zero {
  background: #29362e;
  color: #7e9787;
}

.fitting-shelf {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 10px;
}

.fitting-btn {
  flex-direction: column;
  padding: 6px 4px;
  gap: 3px;
  font-size: 11px;
}

.fitting {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--red);
}

.fitting svg {
  width: 100%;
  height: 100%;
}

.orientation {
  margin: 8px 0;
}

.orientation span {
  font-size: 11px;
  color: var(--muted);
}

.portsettings {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #26332a;
}

.portrow {
  margin: 6px 0;
}

.portrow b {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #1d3528;
  color: var(--green);
  font-size: 10px;
  margin-right: 4px;
}

/* Vine styling */
.cell.seed,
.cell.lit {
  background: #19221c;
  border-color: #2f3e34;
}

.cell.lit {
  background: #1c2c21;
  border-color: #3f6a4b;
}

.seedring {
  border: clamp(3px, 0.45vw, 6px) solid #65bd79;
  background: #23472d;
  width: 54%;
  height: 54%;
  border-radius: 50%;
  box-shadow: 0 0 10px #65bd7955;
}

.clickmark {
  position: absolute;
  right: 5%;
  top: 5%;
  background: var(--amber);
  color: #1c1506;
  font: 700 clamp(10px, 1.15vw, 13px) ui-monospace, monospace;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 99px;
  display: grid;
  place-items: center;
}

/* Flower styling */
.flower-dimensions {
  gap: 8px 12px;
  margin-bottom: 12px;
}

.flower-dimensions input {
  width: 56px;
}

.flower-brushes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 12px;
}

.flower-brush {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #141c17;
  border: 1px solid #304136;
  border-radius: 6px;
  color: var(--text);
}

.flower-brush b {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  font: 700 13px ui-monospace, monospace;
  color: #101913;
}

.flower-brush span {
  font: 11px ui-monospace, monospace;
  color: var(--muted);
}

.flower-brushes [aria-pressed='true'] {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
  background: #1d3225;
}

.flower-fit {
  scroll-margin-block: 8px;
}

.flower-fit .axisframe {
  width: min(100%, var(--flower-width), calc(max(1px, 100dvh - 36px) * var(--cols) / var(--rows) + 25px));
  grid-template-columns: 22px minmax(0, 1fr);
}

.flower-fit .board,
.flower-fit .axis-x,
.flower-fit .axis-y {
  gap: 0;
}

.flower-board {
  position: relative;
  isolation: isolate;
}

.flower-fit .cell {
  min-height: 0;
  height: auto;
  aspect-ratio: 1;
}

.flower-fit .cell:focus-visible {
  outline-offset: -2px;
}

.flower-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flower-overlay text {
  fill: #101913;
  font: 700 .35px ui-monospace, monospace;
  text-anchor: middle;
}

/* Mirror plane styling */
.mirror-plane {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  aspect-ratio: var(--cols) / var(--rows);
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #35473b;
  border-radius: 6px;
  background-color: #121a15;
  background-image:
    linear-gradient(to right, #233028 1px, transparent 1px),
    linear-gradient(to bottom, #233028 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) calc(100% / var(--rows));
  touch-action: none;
}

.m-ray {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.m-ray line {
  stroke: #78c9a8;
  stroke-width: 0.085;
  stroke-linecap: round;
  opacity: 0.78;
}

.m-ray.final-ray line {
  stroke: #f3c868;
  stroke-width: 0.1;
  opacity: 0.95;
}

.m-ray-arrows path {
  fill: #9ee8bc;
}

.m-ray.final-ray .m-ray-arrows path {
  fill: #ffe29a;
}

.m-token,
.m-ghost {
  width: calc(83% / var(--cols));
  aspect-ratio: 1;
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 1px solid transparent;
  border-radius: 30%;
  background: transparent;
  touch-action: none;
  user-select: none;
  display: grid;
  place-items: center;
  cursor: grab;
}

.m-token:active {
  cursor: grabbing;
}

.m-token.picked {
  border-color: var(--green);
  background: #9ee8bc18;
  box-shadow: 0 0 0 2px #9ee8bc44;
}

.m-token svg,
.m-ghost svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.m-ghost {
  pointer-events: none;
  opacity: 0.72;
  z-index: 5;
}

.m-ghost.invalid {
  filter: hue-rotate(-40deg) saturate(1.8);
  outline: 2px solid var(--red);
}

.m-name,
.m-count {
  position: absolute;
  font: 700 10px ui-monospace, monospace;
  line-height: 1.25;
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: none;
}

.m-name {
  bottom: -4px;
  left: -4px;
  background: #101712e6;
  color: #d6e8dc;
  border: 1px solid #35473b;
}

.m-count {
  top: -5px;
  right: -5px;
  background: var(--green);
  color: #0e2416;
}

.m-count.still {
  background: #2b3830;
  color: #88a090;
}

.m-palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0;
}

.m-palette button {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 7px 4px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  font-size: 11px;
}

.m-palette svg {
  width: 30px;
  height: 30px;
  pointer-events: none;
}

.m-selection,
.m-rules {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #2b3930;
  border-radius: 6px;
  background: #131a15;
}

.m-selection strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
}

.m-selection .brow {
  margin-top: 8px;
}

.m-rules .fieldlabel {
  margin-top: 0;
}

.m-rules .dimline {
  margin-top: 8px;
}

/* Gem styling */
.gem-goal {
  grid-column: 2;
  grid-row: 3;
}

.gem-goal .port {
  margin: 9px 0 4px;
  color: var(--muted);
  font-size: 11px;
}

.gemtarget {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 3px;
}

.gemtarget button {
  background: #151e18;
  border-color: #3a4f41;
  padding: 0;
  font-size: 22px;
  min-height: 44px;
}

.gem-board .cell:disabled,
.gemtarget button:disabled {
  cursor: default;
  opacity: 1;
}

.gem-demo p {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
}

/* Answers card */
.answers {
  margin-top: 16px;
  scroll-margin: 16px;
}

.answers p {
  margin: 6px 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: #cddfd3;
}

.answers .status {
  font-size: 13px;
  color: #a6c4b0;
}

.answers .status:empty {
  display: none;
}

.piece-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.piece-results > div {
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #29362d;
  border-radius: 6px;
  background: #131a15;
}

.piece-results .tile-svg {
  grid-row: 1 / 3;
  width: 28px;
  height: 28px;
}

.piece-results strong {
  font-size: 12px;
  color: var(--text);
}

.piece-results span {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.coord,
.movechip,
.clickchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #1a261e;
  border: 1px solid #304437;
  font: 11px ui-monospace, monospace;
  color: #cbe2d3;
}

.clickchip b {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  background: var(--amber);
  color: #1c1506;
  font-size: 10px;
}

.movechip b {
  color: var(--green);
}

.answerchips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.answerline {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid #242f28;
}

.answerline strong {
  font-size: 12px;
  color: var(--green);
}

.answerline > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.pathsep {
  color: #5e7867;
  font-size: 11px;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 8px;
}

.answers table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.answers th,
.answers td {
  padding: 6px 9px;
  border: 1px solid #28352c;
  text-align: center;
}

.answers th {
  background: #141e17;
  color: #9bb8a5;
  font-weight: 600;
}

.answers td.turn {
  background: #1d3527;
  color: var(--green);
  font-weight: 700;
}

.answers td.zero {
  color: #7c9584;
}

.answers td.empty {
  color: #495b4f;
}

.matrixdetails {
  margin-top: 12px;
}

.matrixdetails summary {
  cursor: pointer;
  font-size: 12px;
  color: #bdd3c4;
}

.matrixdetails small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

ol.moves {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
  padding: 0;
  margin: 10px 0 12px;
  counter-reset: step;
}

ol.moves li {
  counter-increment: step;
  padding: 5px 10px;
  border: 1px solid #2e4034;
  border-radius: 5px;
  background: #141c17;
  font-size: 12px;
  color: #c5dbcc;
}

ol.moves li::before {
  content: counter(step) '. ';
  color: #7b9684;
  font: 600 11px ui-monospace, monospace;
}

ol.moves li.now {
  background: #213c2c;
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 960px) {
  .builderbody,
  .workbody {
    grid-template-columns: minmax(0, 1fr);
  }
  .puzzles-main {
    padding: 14px 14px 28px;
  }
}

@media (max-width: 680px) {
  .puzzle-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .stage,
  .control,
  .board-side,
  .supply-side,
  .answers {
    padding: 12px;
  }
  .tile-shelf {
    grid-template-columns: minmax(0, 1fr);
  }
  .drawboard.crate-board {
    --crate-edge: 1px;
    --crate-gap: 2px;
  }
  .m-token {
    width: calc(93% / var(--cols));
  }
  .m-name,
  .m-count {
    font-size: 9px;
    padding: 0 3px;
  }
  .maptab .zone-ach {
    display: none;
  }
}
.puzzles-main .about-grid h3 { margin: 0 0 4px; font-size: 14px; }
@media (min-width: 901px) {
  .puzzles-main .about-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#answer-choices { margin-block: 12px 6px; }
.choice-title, .answer-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.choice-title { margin-block-end: 6px; font-size: 13px; }
.answer-choice { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; text-align: start; background: var(--panel, #202823); border: 1px solid #4d6255; border-radius: 6px; color: var(--text); padding: 4px 10px; cursor: pointer; }
.answer-choice:hover, .answer-choice:focus-visible { border-color: var(--green); }
.answer-choice small { display: block; color: var(--muted); }
