:root {
  --bg: #d6e3f0;
  --panel: rgba(246, 250, 254, 0.9);
  --panel-border: rgba(79, 111, 145, 0.24);
  --ink: #20364f;
  --muted: #5d7083;
  --accent: #244f7c;
  --danger: #8e3d3d;
  --shadow: 0 20px 40px rgba(35, 63, 92, 0.18);
  --grid-size: min(48vw, 500px);
  --cell-gap: 2px;
  --cell-size: calc((var(--grid-size) - (7 * var(--cell-gap))) / 8);
  --blue: #1292ff;
  --green: #70b528;
  --purple: #7c5cff;
  --yellow: #d8d13b;
  --orange: #e88d2d;
  --pink: #f26bb8;
  --red: #dc4e4e;
  --light-blue: #7fdcfa;
  --brown-block: #6f4624;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 34%),
    linear-gradient(135deg, #afc8e4, #dbe9f5 58%, #aac1da);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  background: #eff6fc;
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(39, 72, 106, 0.16);
}

button.danger {
  background: #f5d7d7;
  color: #6d2222;
}

textarea,
input,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(87, 114, 143, 0.28);
  background: rgba(255, 255, 255, 0.88);
  padding: 0.8rem 0.9rem;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

small {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
}

.app-shell {
  width: min(1540px, calc(100vw - 32px));
  margin: 12px auto;
  padding: 14px;
  border-radius: 24px;
  background: rgba(233, 242, 250, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.topbar,
.panel-header,
.export-header,
.board-help,
.topbar-actions,
.copy-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 12px;
}

.topbar h1,
.panel-header h2,
.export-header h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

.topbar-actions,
.copy-actions {
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) max-content;
  grid-template-areas:
    "palette board"
    "details details";
  gap: 10px;
  align-items: start;
}

.panel,
.board-panel {
  min-height: 660px;
  min-width: 0;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.panel {
  padding: 14px;
}

.panel-header {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 10px;
}

.palette-panel {
  grid-area: palette;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.selected-piece-preview {
  border-radius: 18px;
  border: 1px solid rgba(87, 114, 143, 0.18);
  background: rgba(255, 255, 255, 0.65);
}

.selected-piece-preview {
  padding: 10px;
  margin-bottom: 10px;
  display: grid;
  justify-items: start;
}

.piece-config-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  align-items: center;
  gap: 0.6rem;
  margin-top: 8px;
}

.piece-config-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.piece-config-input {
  padding: 0.55rem 0.7rem;
  text-align: center;
}

.piece-preview-grid,
.mini-piece-grid {
  display: grid;
  gap: 4px;
}

.piece-preview-grid {
  margin-top: 8px;
  width: fit-content;
}

.preview-cell,
.mini-piece-cell {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(24, 53, 81, 0.12);
}

.preview-cell {
  width: 18px;
  height: 18px;
}

.mini-piece-cell {
  width: 10px;
  height: 10px;
}

.palette-root {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.color-group {
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(87, 114, 143, 0.15);
  background: rgba(255, 255, 255, 0.62);
}

.color-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.color-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip-color);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85);
}

.color-chip-neutral::before {
  background: linear-gradient(135deg, #5b88b3, #8ab3d6);
}

.group-count {
  font-size: 0.74rem;
  color: var(--muted);
}

.piece-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, max-content));
  gap: 6px;
}

.piece-card {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(87, 114, 143, 0.14);
  background: rgba(245, 249, 253, 0.95);
}

.piece-card.is-selected {
  border-color: rgba(36, 79, 124, 0.48);
  background: rgba(214, 231, 247, 0.9);
  box-shadow: inset 0 0 0 1px rgba(36, 79, 124, 0.26);
}

.board-panel {
  grid-area: board;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
  align-items: flex-end;
  width: fit-content;
  justify-self: end;
}

.board-header {
  margin-bottom: 14px;
}

.board-status {
  min-height: 24px;
  text-align: right;
  color: var(--muted);
}

.board-wrap {
  display: grid;
  grid-template-columns: 24px var(--grid-size);
  grid-template-rows: 24px var(--grid-size);
  gap: 8px;
  justify-content: end;
  align-self: flex-end;
  max-width: 100%;
}

.axis {
  display: grid;
  gap: var(--cell-gap);
  color: var(--muted);
  font-size: 0.86rem;
}

.axis-top {
  grid-column: 2;
  grid-template-columns: repeat(8, var(--cell-size));
  justify-content: center;
  align-items: center;
}

.axis-left {
  grid-row: 2;
  grid-template-rows: repeat(8, var(--cell-size));
  justify-items: center;
  align-items: center;
}

.board-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--cell-gap);
  padding: 4px;
  border-radius: 22px;
  background: rgba(91, 129, 166, 0.28);
  box-shadow:
    inset 0 14px 26px rgba(255, 255, 255, 0.42),
    inset 0 -12px 20px rgba(98, 133, 168, 0.28);
}

.board-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(102, 131, 159, 0.3);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(122, 156, 189, 0.1));
}

.board-cell::after {
  content: attr(data-piece-id);
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255, 248, 239, 0.95);
  text-shadow: 0 1px 2px rgba(55, 31, 14, 0.5);
}

.board-cell.is-preview-valid {
  outline: 2px solid rgba(47, 138, 57, 0.9);
  outline-offset: -2px;
}

.board-cell.is-preview-invalid {
  outline: 2px solid rgba(175, 50, 50, 0.92);
  outline-offset: -2px;
}

.board-cell.is-preview-remove {
  outline: 2px dashed rgba(148, 58, 58, 0.9);
  outline-offset: -2px;
}

.board-cell.is-filled {
  border-color: rgba(22, 41, 58, 0.24);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -4px 8px rgba(0, 0, 0, 0.16);
}

.is-gem-cell {
  border-color: rgba(73, 42, 20, 0.38);
}

.is-balloon-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.is-firework-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.is-vine-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.is-flower-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.is-apple-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.is-apple-crate-cell {
  border-color: rgba(102, 64, 32, 0.38);
}

.is-curtain-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.is-egg-cell,
.is-gecko-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.piece-icon {
  display: block;
  width: 66%;
  height: 66%;
  border-radius: 3px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.14) 32%, transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--gem-color) 82%, white 18%), var(--gem-color));
  transform: rotate(45deg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 2px 5px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.board-cell .piece-icon {
  width: 54%;
  height: 54%;
}

.balloon-icon {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  width: 82%;
  max-width: 82%;
  justify-items: center;
  align-items: center;
  pointer-events: none;
}

.balloon-dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.14) 32%, transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--balloon-color) 82%, white 18%), var(--balloon-color));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 1px 2px rgba(90, 16, 16, 0.28);
}

.board-cell .balloon-icon {
  width: 78%;
  max-width: 78%;
  gap: 4px;
}

.board-cell .balloon-dot {
  width: 14px;
  height: 14px;
}

.firework-icon {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  align-items: center;
  width: 56%;
  height: 72%;
  pointer-events: none;
}

.firework-head {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 15px solid #ef5353;
  filter: drop-shadow(0 1px 1px rgba(66, 18, 18, 0.28));
}

.firework-stick {
  width: 8px;
  height: 18px;
  margin-top: -1px;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff0e4, #c79462 48%, #8d5a2f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.board-cell .firework-icon {
  width: 48%;
  height: 64%;
}

.board-cell .firework-head {
  border-left-width: 10px;
  border-right-width: 10px;
  border-bottom-width: 18px;
}

.board-cell .firework-stick {
  width: 9px;
  height: 21px;
}

.vine-icon {
  position: relative;
  z-index: 1;
  width: 58%;
  height: 72%;
  pointer-events: none;
}

.vine-stem {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 4px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #5da54c, #2f6d2a);
}

.vine-leaf {
  position: absolute;
  bottom: 14px;
  width: 10px;
  height: 14px;
  background: linear-gradient(180deg, #7fc667, #3e8a34);
}

.vine-leaf-left {
  left: 10px;
  border-radius: 80% 10% 80% 10%;
  transform: rotate(-32deg);
}

.vine-leaf-right {
  right: 10px;
  border-radius: 10% 80% 10% 80%;
  transform: rotate(32deg);
}

.vine-flower {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffcf58 0 24%, transparent 25%),
    radial-gradient(circle at 50% 12%, var(--flower-color) 0 30%, transparent 31%),
    radial-gradient(circle at 84% 36%, var(--flower-color) 0 30%, transparent 31%),
    radial-gradient(circle at 70% 80%, var(--flower-color) 0 30%, transparent 31%),
    radial-gradient(circle at 30% 80%, var(--flower-color) 0 30%, transparent 31%),
    radial-gradient(circle at 16% 36%, var(--flower-color) 0 30%, transparent 31%);
  filter: drop-shadow(0 1px 1px rgba(39, 53, 67, 0.18));
}

.board-cell .vine-icon {
  width: 52%;
  height: 68%;
}

.board-cell .vine-stem {
  height: 24px;
}

.board-cell .vine-flower {
  width: 20px;
  height: 20px;
}

.flower-icon {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.flower-petal {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--flower-color, #f5f7fb) 28%, white 72%),
    color-mix(in srgb, var(--flower-color, #f5f7fb) 82%, white 18%)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 1px 2px rgba(39, 53, 67, 0.18);
}

.flower-petal-top {
  transform: translateY(-8px);
}

.flower-petal-right {
  transform: translateX(8px);
}

.flower-petal-bottom {
  transform: translateY(8px);
}

.flower-petal-left {
  transform: translateX(-8px);
}

.flower-center {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe89c, #f1ba33 58%, #cd8a10);
}

.board-cell .flower-petal {
  width: 16px;
  height: 16px;
}

.board-cell .flower-petal-top {
  transform: translateY(-9px);
}

.board-cell .flower-petal-right {
  transform: translateX(9px);
}

.board-cell .flower-petal-bottom {
  transform: translateY(9px);
}

.board-cell .flower-petal-left {
  transform: translateX(-9px);
}

.apple-icon {
  position: relative;
  z-index: 1;
  width: 54%;
  height: 66%;
  pointer-events: none;
}

.apple-body {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 24px;
  height: 24px;
  transform: translateX(-50%);
  border-radius: 48% 48% 44% 44%;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--apple-color, var(--red)) 28%, white 72%),
    color-mix(in srgb, var(--apple-color, var(--red)) 82%, white 18%)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 2px rgba(39, 53, 67, 0.2);
}

.apple-body::before,
.apple-body::after {
  content: "";
  position: absolute;
  top: -2px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-radius: 50%;
}

.apple-body::before {
  left: 1px;
}

.apple-body::after {
  right: 1px;
}

.apple-leaf {
  position: absolute;
  top: 2px;
  left: 58%;
  width: 10px;
  height: 8px;
  border-radius: 10% 80% 10% 80%;
  background: linear-gradient(180deg, #7fc667, #3e8a34);
  transform: rotate(28deg);
}

.apple-stem {
  position: absolute;
  top: 3px;
  left: 46%;
  width: 3px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #6b4a2a, #3c2412);
}

.board-cell .apple-icon {
  width: 48%;
  height: 60%;
}

.apple-crate-icon {
  position: relative;
  z-index: 1;
  width: 78%;
  height: 76%;
  pointer-events: none;
}

.apple-crate-planks {
  position: absolute;
  inset: 2px 1px 4px;
  border-radius: 4px;
  border: 2px solid rgba(108, 63, 28, 0.92);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, rgba(133, 86, 43, 0.96), rgba(92, 55, 24, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(65, 35, 14, 0.24);
}

.apple-crate-planks::before,
.apple-crate-planks::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  border-radius: 999px;
  background: rgba(73, 42, 20, 0.82);
}

.apple-crate-planks::before {
  top: 30%;
}

.apple-crate-planks::after {
  bottom: 28%;
}

.apple-crate-fruit {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.1) 34%, transparent 36%),
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--apple-crate-color, var(--red)) 24%, white 76%),
      color-mix(in srgb, var(--apple-crate-color, var(--red)) 82%, white 18%)
    );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    0 1px 2px rgba(55, 22, 22, 0.22);
}

.apple-crate-fruit-left {
  left: 10px;
  top: 14px;
}

.apple-crate-fruit-center {
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
}

.apple-crate-fruit-right {
  right: 10px;
  top: 14px;
}

.apple-crate-badge {
  position: absolute;
  right: 2px;
  bottom: -2px;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(255, 247, 235, 0.95);
  color: #6d411e;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 1px 2px rgba(65, 35, 14, 0.18);
}

.board-cell .apple-crate-icon {
  width: 84%;
  height: 80%;
}

.board-cell .apple-crate-planks {
  inset: 2px 1px 5px;
  border-width: 3px;
  border-radius: 5px;
}

.board-cell .apple-crate-fruit {
  width: 13px;
  height: 13px;
}

.board-cell .apple-crate-fruit-left {
  left: 11px;
  top: 15px;
}

.board-cell .apple-crate-fruit-center {
  top: 10px;
}

.board-cell .apple-crate-fruit-right {
  right: 11px;
  top: 15px;
}

.board-cell .apple-crate-badge {
  right: 2px;
  bottom: -1px;
  min-width: 21px;
  font-size: 0.66rem;
}

.curtain-icon {
  position: absolute;
  inset: 2px;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.curtain-drape {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background:
    repeating-linear-gradient(
      90deg,
      color-mix(in srgb, var(--curtain-fill-color, #f0d278) 28%, white 72%) 0 7px,
      color-mix(in srgb, var(--curtain-fill-color, #f0d278) 82%, white 18%) 7px 12px
    );
  opacity: 0.68;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 color-mix(in srgb, var(--curtain-color, #f0d278) 48%, black 52%);
}

.curtain-badge {
  position: relative;
  z-index: 1;
  min-width: 20px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(92, 58, 19, 0.9);
  color: rgba(255, 248, 230, 0.96);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.board-cell .curtain-icon {
  inset: 1px;
}

.board-cell .curtain-badge {
  min-width: 22px;
  font-size: 0.66rem;
}

.egg-icon {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  width: 76%;
  justify-items: center;
  align-items: end;
  pointer-events: none;
}

.egg-dot {
  display: block;
  width: 10px;
  height: 14px;
  border-radius: 50% 50% 46% 46%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.22) 34%, transparent 36%),
    linear-gradient(180deg, #fffaf1, #efe5d4 64%, #ddccb0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 1px 2px rgba(58, 49, 35, 0.2);
}

.board-cell .egg-icon {
  width: 72%;
  gap: 4px;
}

.board-cell .egg-dot {
  width: 12px;
  height: 17px;
}

.gecko-icon {
  position: relative;
  z-index: 1;
  width: 70%;
  height: 58%;
  pointer-events: none;
}

.gecko-body,
.gecko-head,
.gecko-tail,
.gecko-leg {
  position: absolute;
  background: linear-gradient(180deg, #84d76d, #3ca54a 62%, #2d7b38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 1px 2px rgba(23, 73, 39, 0.2);
}

.gecko-body {
  left: 14px;
  top: 8px;
  width: 22px;
  height: 12px;
  border-radius: 999px;
  transform: rotate(-12deg);
}

.gecko-head {
  left: 8px;
  top: 7px;
  width: 12px;
  height: 10px;
  border-radius: 55% 45% 45% 55%;
}

.gecko-tail {
  right: 5px;
  top: 10px;
  width: 18px;
  height: 5px;
  border-radius: 999px;
  transform: rotate(18deg);
}

.gecko-leg {
  width: 10px;
  height: 4px;
  border-radius: 999px;
}

.gecko-leg-front {
  left: 16px;
  top: 4px;
  transform: rotate(-38deg);
}

.gecko-leg-back {
  left: 22px;
  bottom: 5px;
  transform: rotate(28deg);
}

.board-cell .gecko-icon {
  width: 74%;
  height: 60%;
}

.butterfly-icon {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-items: center;
  gap: 2px;
  width: 70%;
  height: 48%;
  pointer-events: none;
}

.butterfly-wing {
  width: 12px;
  height: 14px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--butterfly-wing-color, var(--blue)) 28%, white 72%),
    color-mix(in srgb, var(--butterfly-wing-color, var(--blue)) 78%, white 22%) 54%,
    color-mix(in srgb, var(--butterfly-wing-color, var(--blue)) 88%, black 12%)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 2px rgba(17, 55, 104, 0.24);
}

.butterfly-wing-left {
  border-radius: 85% 50% 75% 40%;
  transform: rotate(-18deg);
}

.butterfly-wing-right {
  border-radius: 50% 85% 40% 75%;
  transform: rotate(18deg);
}

.butterfly-body {
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #244568, #10253c);
}

.board-cell .butterfly-icon {
  width: 62%;
  height: 42%;
}

.board-cell .butterfly-wing {
  width: 14px;
  height: 17px;
}

.board-cell .butterfly-body {
  height: 20px;
}

.box-icon {
  position: absolute;
  inset: 3px;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.box-frame {
  position: absolute;
  inset: 0;
  border: 4px solid #8d5a2f;
  border-radius: 7px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(65, 35, 14, 0.28);
}

.box-frame::before,
.box-frame::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  height: 3px;
  background: rgba(92, 55, 26, 0.9);
}

.box-frame::before {
  top: 28%;
}

.box-frame::after {
  bottom: 28%;
}

.box-level {
  position: relative;
  z-index: 1;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(255, 244, 228, 0.92);
  color: #6e431e;
  font-size: 0.65rem;
  font-weight: 800;
  text-align: center;
}

.board-cell .box-icon {
  inset: 2px;
}

.board-cell .box-frame {
  border-width: 5px;
}

.board-cell .box-level {
  min-width: 20px;
  font-size: 0.7rem;
}

.board-help {
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
  width: 100%;
}

.details-panel {
  grid-area: details;
  min-height: auto;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.details-panel .panel-header {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.details-form,
.goal-fieldset,
.export-section,
.import-section {
  display: grid;
  gap: 14px;
}

.details-form label,
.export-section label {
  display: grid;
  gap: 0.5rem;
  font-weight: 600;
}

.goal-targets-root {
  display: grid;
  gap: 10px;
}

.goal-target-row {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
}

.goal-target-label {
  display: block;
}

.goal-target-controls {
  display: grid;
  gap: 0.6rem;
}

.goal-enabled-row {
  font-weight: 500;
}

.goal-target-input.is-readonly {
  background: rgba(230, 238, 247, 0.9);
}

.goal-empty {
  margin: 0;
  color: var(--muted);
}

.goal-fieldset {
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(87, 114, 143, 0.18);
  background: rgba(255, 255, 255, 0.58);
}

.goal-fieldset legend {
  padding: 0 8px;
  font-weight: 700;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.checkbox-label input {
  width: auto;
}

.export-section {
  margin-top: 0;
}

.import-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(87, 114, 143, 0.18);
}

.export-header {
  justify-content: space-between;
}

.copied {
  background: #d8f0d8;
}

@media (max-width: 1360px) {
  :root {
    --grid-size: min(58vw, 500px);
  }

  .workspace {
    grid-template-columns: minmax(280px, 1fr) max-content;
    grid-template-areas:
      "palette board"
      "details details";
  }

  .panel,
  .board-panel {
    min-height: auto;
  }
}

@media (max-width: 1220px) {
  :root {
    --grid-size: min(76vw, 500px);
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "palette"
      "board"
      "details";
  }

  .details-panel {
    grid-template-columns: 1fr;
  }

  .board-help {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100vw - 16px);
    margin: 8px auto;
    padding: 12px;
    border-radius: 20px;
  }

  .topbar,
  .panel-header,
  .export-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions,
  .copy-actions {
    justify-content: flex-start;
  }

  .board-wrap {
    transform: scale(0.95);
    transform-origin: center top;
  }

  .palette-root {
    grid-template-columns: 1fr;
  }

  .piece-grid {
    grid-template-columns: repeat(auto-fit, minmax(42px, max-content));
  }
}
