: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: clamp(320px, 22vw, 420px);
  --cell-gap: 2px;
  --cell-size: calc((var(--grid-size) - (7 * var(--cell-gap))) / 8);
  --palette-column-width: clamp(248px, 17vw, 300px);
  --workspace-gap: 10px;
  --board-inspector-width: clamp(230px, 17vw, 300px);
  --details-column-width: clamp(420px, 27vw, 520px);
  --board-panel-gap: 14px;
  --board-axis-width: 24px;
  --board-panel-padding-x: 20px;
  --workspace-content-width: calc(
    var(--palette-column-width) +
    var(--workspace-gap) +
    var(--board-axis-width) +
    var(--grid-size) +
    var(--board-panel-gap) +
    var(--board-inspector-width) +
    var(--board-panel-padding-x) +
    var(--workspace-gap) +
    var(--details-column-width)
  );
  --blue: #1292ff;
  --green: #70b528;
  --purple: #7c5cff;
  --yellow: #d8d13b;
  --orange: #e88d2d;
  --pink: #f26bb8;
  --red: #dc4e4e;
  --light-blue: #7fdcfa;
  --brown-block: #6f4624;
}

body.theme-dark {
  --bg: #101c27;
  --panel: rgba(23, 36, 49, 0.9);
  --panel-border: rgba(109, 140, 171, 0.2);
  --ink: #e8f1fa;
  --muted: #9fb3c6;
  --accent: #79b8ff;
  --danger: #f2a9a9;
  --shadow: 0 24px 44px rgba(4, 11, 18, 0.42);
}

* {
  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);
}

body.theme-dark {
  background:
    radial-gradient(circle at top left, rgba(118, 166, 214, 0.18), transparent 28%),
    linear-gradient(135deg, #0f1822, #172635 52%, #0d141d);
}

body.is-auth-locked {
  overflow: hidden;
}

.is-hidden {
  display: none !important;
}

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

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

body.theme-dark button {
  background: #223547;
  color: var(--ink);
}

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

button.is-active {
  background: rgba(61, 112, 168, 0.18);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(61, 112, 168, 0.2);
}

body.theme-dark button.is-active {
  background: rgba(97, 154, 214, 0.2);
  color: #d9ecff;
  box-shadow: inset 0 0 0 1px rgba(97, 154, 214, 0.24);
}

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

body.theme-dark button.danger {
  background: rgba(142, 61, 61, 0.26);
  color: #ffcece;
}

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

body.theme-dark textarea,
body.theme-dark input,
body.theme-dark select {
  border-color: rgba(127, 156, 187, 0.24);
  background: rgba(18, 29, 40, 0.88);
  color: var(--ink);
}

textarea {
  resize: vertical;
}

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

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

body.theme-dark .app-shell {
  background: rgba(15, 25, 34, 0.8);
}

.app-shell.is-hidden {
  display: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 36%),
    linear-gradient(135deg, rgba(175, 200, 228, 0.96), rgba(219, 233, 245, 0.98) 58%, rgba(170, 193, 218, 0.98));
}

.auth-gate.is-hidden {
  display: none;
}

.auth-card {
  width: min(520px, 100%);
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(79, 111, 145, 0.24);
  background: rgba(246, 250, 254, 0.92);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

body.theme-dark .auth-card {
  background: rgba(20, 33, 46, 0.94);
}

.auth-card-header h1 {
  margin: 0 0 0.5rem;
}

.auth-gate-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-gate-actions {
  justify-content: flex-start;
}

.topbar,
.panel-header,
.backend-strip,
.topbar-actions,
.copy-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin: 0 0 8px;
}

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

.topbar-title-group {
  display: grid;
  gap: 6px;
}

.tab-strip {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
}

body.theme-dark .tab-strip {
  background: rgba(255, 255, 255, 0.08);
}

.tab-button {
  min-width: 110px;
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  background: transparent;
  box-shadow: none;
}

.tab-button.is-active {
  background: rgba(36, 79, 124, 0.14);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(36, 79, 124, 0.16);
}

body.theme-dark .tab-button.is-active {
  background: rgba(121, 184, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(121, 184, 255, 0.18);
}

.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.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: var(--palette-column-width) minmax(0, 1fr) var(--details-column-width);
  grid-template-areas: "palette board details";
  gap: 8px;
  align-items: start;
  justify-content: stretch;
  width: 100%;
  margin: 0;
  position: relative;
}

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

body.theme-dark .panel,
body.theme-dark .board-panel {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.panel {
  padding: 10px;
}

code {
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 0.94em;
}

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

.palette-panel {
  grid-area: palette;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  background: linear-gradient(180deg, rgba(247, 250, 254, 0.92), rgba(232, 241, 249, 0.82));
}

body.theme-dark .palette-panel {
  background: linear-gradient(180deg, rgba(13, 20, 31, 0.98), rgba(16, 26, 38, 0.92));
}

.editor-panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(87, 114, 143, 0.18);
}

.editor-panel-kicker {
  margin: 0 0 3px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffbf2a;
}

.editor-panel-title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.selected-piece-preview {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.54);
  padding: 10px;
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 10px;
  min-width: 220px;
  border: 1px solid rgba(87, 114, 143, 0.14);
}

body.theme-dark .selected-piece-preview,
body.theme-dark .level-order-table-wrap,
body.theme-dark .color-group,
body.theme-dark .goal-fieldset,
body.theme-dark .backend-badge,
body.theme-dark .goal-target-input.is-readonly {
  background: rgba(255, 255, 255, 0.05);
}

.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;
  overflow: hidden;
}

.palette-root {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "colors"
    "gems"
    "mechanics";
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

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

.color-group--colors {
  grid-area: colors;
}

.color-group--gems {
  grid-area: gems;
}

.color-group--mechanics {
  grid-area: mechanics;
}

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

.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.7rem;
  color: var(--muted);
}

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

.piece-preview-grid,
.mini-piece-grid {
  position: relative;
}

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

body.theme-dark .piece-card {
  border-color: rgba(127, 156, 187, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.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);
}

body.theme-dark .piece-card.is-selected {
  border-color: rgba(121, 184, 255, 0.45);
  background: rgba(121, 184, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(121, 184, 255, 0.18);
}

.piece-card .mini-piece-grid {
  justify-self: center;
  align-self: center;
}

.piece-card .asset-mini-grid .mini-piece-cell {
  width: 24px;
  height: 24px;
}

.piece-card .asset-mini-grid.has-spanning-piece-asset {
  gap: 2px;
}

.piece-card .asset-mini-grid.has-spanning-piece-asset .mini-piece-cell {
  width: 14px;
  height: 14px;
}

.piece-card .has-spanning-piece-asset .apple-crate-spanning-badge {
  min-width: 14px;
  padding: 0 3px;
  font-size: 0.48rem;
}

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

.mini-piece-cell .balloon-icon,
.mini-piece-cell .firework-icon,
.mini-piece-cell .vine-icon,
.mini-piece-cell .flower-icon,
.mini-piece-cell .apple-icon,
.mini-piece-cell .egg-icon,
.mini-piece-cell .gecko-icon,
.mini-piece-cell .butterfly-icon,
.mini-piece-cell .box-icon {
  transform: scale(0.84);
  transform-origin: center;
}

.mini-piece-cell .apple-crate-icon,
.mini-piece-cell .jewelry-icon,
.mini-piece-cell .curtain-icon {
  transform: scale(0.72);
  transform-origin: center;
}

.mini-piece-cell .balloon-dot {
  width: 8px;
  height: 8px;
}

.mini-piece-cell .curtain-badge,
.mini-piece-cell .apple-crate-badge,
.mini-piece-cell .cotton-jar-badge,
.mini-piece-cell .jewelry-badge,
.mini-piece-cell .box-level {
  min-width: 14px;
  padding: 0 3px;
  font-size: 0.48rem;
}

.board-panel {
  grid-area: board;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px;
  padding: 10px;
  overflow: hidden;
  align-items: start;
  width: 100%;
  justify-self: stretch;
  justify-content: start;
  background: linear-gradient(180deg, rgba(247, 250, 254, 0.96), rgba(236, 243, 249, 0.88));
}

body.theme-dark .board-panel {
  background: linear-gradient(180deg, rgba(13, 20, 31, 0.98), rgba(17, 28, 40, 0.92));
}

.board-panel-header {
  grid-column: 1 / -1;
}

.board-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.board-inspector {
  display: grid;
  gap: 10px;
  align-content: start;
  justify-items: stretch;
  padding-left: 0;
  margin-left: 0;
  justify-self: stretch;
}

.board-inspector > * {
  width: min(280px, 100%);
  margin-inline: auto;
}

.board-goals {
  padding-top: 0;
  border-top: 0;
}

.board-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.board-wrap {
  display: grid;
  grid-template-columns: 24px var(--grid-size);
  grid-template-rows: 24px var(--grid-size);
  gap: 6px;
  justify-content: start;
  align-self: flex-start;
  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;
  position: relative;
  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: #2d596f;
  box-shadow:
    inset 0 14px 26px rgba(255, 255, 255, 0.12),
    inset 0 -12px 20px rgba(14, 37, 49, 0.24);
}

body.theme-dark .board-grid {
  background: #1f4456;
  box-shadow:
    inset 0 12px 22px rgba(255, 255, 255, 0.08),
    inset 0 -14px 20px rgba(2, 10, 17, 0.4);
}

.board-cell {
  position: relative;
  display: grid;
  place-items: center;
  z-index: 1;
  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));
}

body.theme-dark .board-cell {
  border-color: rgba(112, 141, 167, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(68, 100, 128, 0.12));
}

.board-cell::after {
  content: attr(data-piece-id);
  position: absolute;
  right: 5px;
  bottom: 4px;
  z-index: 6;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255, 248, 239, 0.98);
  text-shadow:
    -1px 0 0 rgba(0, 0, 0, 0.95),
    1px 0 0 rgba(0, 0, 0, 0.95),
    0 -1px 0 rgba(0, 0, 0, 0.95),
    0 1px 0 rgba(0, 0, 0, 0.95),
    -1px -1px 0 rgba(0, 0, 0, 0.82),
    1px -1px 0 rgba(0, 0, 0, 0.82),
    -1px 1px 0 rgba(0, 0, 0, 0.82),
    1px 1px 0 rgba(0, 0, 0, 0.82);
  pointer-events: none;
}

.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-selected {
  outline: 2px solid rgba(255, 223, 97, 0.94);
  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);
}

.has-spanning-piece-cell {
  background: transparent;
}

.board-cell.has-spanning-piece-cell.is-filled {
  box-shadow: none;
}

.backend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(93, 112, 131, 0.14);
  color: var(--muted);
}

.backend-badge.is-ready {
  background: rgba(63, 133, 84, 0.14);
  color: #24603a;
}

.backend-badge.is-live {
  background: rgba(36, 79, 124, 0.14);
  color: var(--accent);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.backend-actions {
  justify-content: stretch;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.details-form {
  display: grid;
  gap: 12px;
}

.export-section {
  display: grid;
  gap: 12px;
}

.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-jewelry-cell {
  border-color: rgba(34, 82, 143, 0.34);
}

.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;
}

.asset-piece-icon {
  display: block;
  width: 100%;
  height: 100%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
}

.preview-cell .asset-piece-icon,
.mini-piece-cell .asset-piece-icon {
  width: 86%;
  height: 86%;
}

.asset-mini-grid .mini-piece-cell .asset-piece-icon {
  width: 100%;
  height: 100%;
}

.preview-cell .asset-piece-icon {
  width: 100%;
  height: 100%;
}

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

.has-spanning-piece-asset {
  position: relative;
}

.spanning-piece-asset,
.board-spanning-piece,
.board-spanning-piece-asset,
.spanning-piece-asset-shell {
  pointer-events: none;
}

.spanning-piece-asset,
.board-spanning-piece-asset,
.spanning-piece-asset-shell {
  position: absolute;
  inset: 0;
}

.spanning-piece-image {
  background-size: 100% 100%;
}

.spanning-piece-badge {
  top: 2px;
  right: 2px;
  bottom: auto;
  z-index: 2;
}

.board-spanning-piece {
  position: absolute;
  z-index: 0;
}

.board-spanning-piece.is-selected {
  outline: 2px solid rgba(255, 223, 97, 0.94);
  outline-offset: -2px;
  border-radius: 8px;
}

.board-spanning-piece-asset {
  z-index: 0;
}

.spanning-piece-code {
  position: absolute;
  right: 5px;
  bottom: 4px;
  z-index: 6;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255, 248, 239, 0.98);
  text-shadow:
    -1px 0 0 rgba(0, 0, 0, 0.95),
    1px 0 0 rgba(0, 0, 0, 0.95),
    0 -1px 0 rgba(0, 0, 0, 0.95),
    0 1px 0 rgba(0, 0, 0, 0.95),
    -1px -1px 0 rgba(0, 0, 0, 0.82),
    1px -1px 0 rgba(0, 0, 0, 0.82),
    -1px 1px 0 rgba(0, 0, 0, 0.82),
    1px 1px 0 rgba(0, 0, 0, 0.82);
  pointer-events: none;
}

.asset-overlay-icon {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.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;
  top: 2px;
  right: 2px;
  bottom: auto;
  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);
}

.cotton-jar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: auto;
  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 {
  top: 2px;
  right: 2px;
  bottom: auto;
  min-width: 21px;
  font-size: 0.66rem;
}

.board-cell .cotton-jar-badge {
  top: 2px;
  right: 2px;
  bottom: auto;
  min-width: 21px;
  font-size: 0.66rem;
}

.jewelry-icon {
  position: relative;
  z-index: 1;
  width: 80%;
  height: 78%;
  pointer-events: none;
}

.jewelry-frame {
  position: absolute;
  inset: 2px 1px 4px;
  border-radius: 5px;
  border: 3px solid rgba(36, 79, 124, 0.86);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, rgba(86, 161, 238, 0.96), rgba(46, 120, 207, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 0 rgba(18, 63, 112, 0.28);
}

.jewelry-gem {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 20px;
  height: 20px;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 4px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.14) 32%, transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--jewelry-gem-color, var(--green)) 82%, white 18%), var(--jewelry-gem-color, var(--green)));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    0 2px 5px rgba(17, 46, 88, 0.24);
}

.jewelry-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: auto;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(249, 252, 255, 0.96);
  color: #24558b;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 1px 2px rgba(24, 67, 110, 0.18);
}

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

.board-cell .jewelry-frame {
  inset: 2px 1px 5px;
}

.board-cell .jewelry-gem {
  top: 10px;
  width: 22px;
  height: 22px;
}

.board-cell .jewelry-badge {
  top: 2px;
  right: 2px;
  bottom: auto;
  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: absolute;
  top: 2px;
  right: 2px;
  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: absolute;
  top: 2px;
  right: 2px;
  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;
}

.details-panel {
  grid-area: details;
  position: sticky;
  top: 0;
  z-index: 6;
  width: 100%;
  max-width: var(--details-column-width);
  max-height: calc(100vh - 112px);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 680px;
  padding: 12px;
  transition: transform 180ms ease, opacity 180ms ease, visibility 180ms ease;
  transform: none;
  opacity: 1;
  background: linear-gradient(180deg, rgba(247, 250, 254, 0.96), rgba(236, 243, 249, 0.88));
}

body.theme-dark .details-panel {
  background: linear-gradient(180deg, rgba(13, 20, 31, 0.98), rgba(17, 28, 40, 0.92));
}

.details-panel.is-collapsed {
  transform: translateX(calc(100% + 14px));
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.details-sidebar-header {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -2px 0 0;
  padding-bottom: 10px;
  background: transparent;
}

body.theme-dark .details-sidebar-header {
  background: transparent;
}

.details-panel.is-docked {
  transform: none;
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.details-panel-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 164px;
  gap: 12px;
  min-height: 0;
}

.saved-level-bank {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.details-sidebar-controls {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  font-size: 0.9rem;
}

.details-sidebar-controls button,
.details-sidebar-controls input,
.details-sidebar-controls select {
  font-size: 0.84rem;
}

.details-sidebar-controls button {
  padding: 0.48rem 0.56rem;
  border-radius: 12px;
}

.level-order-view {
  display: block;
}

.level-order-panel {
  display: grid;
  gap: 10px;
}

.level-order-toolbar {
  display: grid;
  grid-template-columns: 300px max-content;
  gap: 10px;
  align-items: end;
  justify-content: space-between;
}

.level-order-name-group,
.level-order-range-group,
.level-order-import-strip {
  display: grid;
  gap: 8px;
}

.level-order-name-group {
  grid-template-columns: minmax(160px, 1fr) 118px;
}

.level-order-range-group {
  grid-template-columns: 72px 72px max-content max-content;
  align-items: end;
}

.inline-compact {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

.level-order-actions {
  justify-content: flex-start;
}

#level-order-download {
  margin-left: auto;
}

.level-order-push-status {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-wrap;
}

.level-order-push-status.is-success {
  background: rgba(219, 241, 226, 0.92);
  color: #1f6835;
}

.level-order-push-status.is-error {
  background: rgba(245, 215, 215, 0.92);
  color: #7d2727;
}

.level-order-push-status.is-pending {
  background: rgba(226, 236, 247, 0.92);
  color: #27507d;
}

.level-order-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  justify-items: center;
  align-content: start;
  overflow: auto;
  padding: 88px 20px 20px;
  background: rgba(16, 24, 34, 0.34);
}

.level-order-modal-card {
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.level-order-modal-card-wide {
  width: min(520px, 100%);
}

.add-levels-modal-card {
  width: min(760px, 100%);
  gap: 14px;
}

.level-order-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.level-order-modal-section {
  display: grid;
  gap: 8px;
}

.level-order-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-levels-modal-title-group {
  display: grid;
  gap: 2px;
}

.add-levels-modal-title-group strong {
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-levels-modal-subtitle {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.add-levels-results {
  display: grid;
  gap: 6px;
  max-height: min(62vh, 640px);
  overflow: auto;
  padding-right: 4px;
}

.add-levels-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 14px;
  border: 1px solid rgba(77, 96, 142, 0.22);
  background: rgba(25, 34, 58, 0.86);
}

.add-levels-result-id {
  font-size: 1rem;
}

.add-levels-result-meta {
  color: rgba(207, 214, 234, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.add-levels-result-action {
  min-width: 58px;
  padding: 0.38rem 0.7rem;
  justify-self: end;
  font-weight: 800;
}

.add-levels-empty {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px dashed rgba(87, 114, 143, 0.28);
  color: var(--muted);
}

.multi-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(87, 114, 143, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.42);
  font-weight: 600;
}

body.theme-dark .multi-select-option {
  background: rgba(255, 255, 255, 0.05);
}

.multi-select-option input {
  width: auto;
}

.info-icon {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.level-order-auto-ih-group {
  justify-self: start;
}

.level-order-warning {
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(196, 82, 82, 0.22);
  background: rgba(245, 215, 215, 0.86);
  color: #7d2727;
  font-size: 0.8rem;
  font-weight: 700;
}

.level-order-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
  table-layout: fixed;
}

.level-order-table th,
.level-order-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(87, 114, 143, 0.14);
  text-align: left;
  vertical-align: middle;
}

.level-order-handle-cell {
  width: 28px;
  text-align: center;
}

.level-order-table th:nth-child(4),
.level-order-table td:nth-child(4) {
  width: 92px;
}

.level-order-id-cell {
  position: relative;
  overflow: visible;
}

.level-order-id-field {
  position: relative;
}

.level-order-ih-cell {
  position: relative;
  overflow: visible;
}

.level-order-ih-field {
  position: relative;
}

.level-order-id-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 8;
  display: grid;
  gap: 2px;
  width: min(320px, 44vw);
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(87, 114, 143, 0.18);
  border-radius: 10px;
  background: rgba(20, 24, 31, 0.96);
  box-shadow: 0 10px 24px rgba(8, 12, 19, 0.28);
}

.level-order-ih-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 8;
  display: grid;
  gap: 2px;
  width: min(140px, 20vw);
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(87, 114, 143, 0.18);
  border-radius: 10px;
  background: rgba(20, 24, 31, 0.96);
  box-shadow: 0 10px 24px rgba(8, 12, 19, 0.28);
}

.level-order-id-suggestion {
  justify-content: flex-start;
  padding: 0.42rem 0.56rem;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.level-order-id-suggestion:hover {
  background: rgba(255, 255, 255, 0.08);
}

.level-order-ih-suggestion {
  justify-content: flex-start;
  padding: 0.42rem 0.56rem;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.level-order-ih-suggestion:hover {
  background: rgba(255, 255, 255, 0.08);
}

.level-order-handle {
  display: inline-block;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: -0.15em;
  cursor: grab;
  user-select: none;
}

.level-order-table th {
  font-size: 0.78rem;
  color: var(--muted);
  background: transparent;
  position: sticky;
  top: 0;
}

.level-order-row.is-highlighted {
  background: rgba(255, 233, 171, 0.46);
}

.level-order-row.is-duplicate {
  background: rgba(245, 215, 215, 0.72);
}

.level-order-row.is-highlighted.is-duplicate {
  background:
    linear-gradient(0deg, rgba(245, 215, 215, 0.72), rgba(245, 215, 215, 0.72)),
    linear-gradient(0deg, rgba(255, 233, 171, 0.46), rgba(255, 233, 171, 0.46));
}

.level-order-row.is-dragging {
  opacity: 0.55;
}

.level-order-row.is-drop-target {
  outline: 2px solid rgba(36, 79, 124, 0.44);
  outline-offset: -2px;
}

.mini-danger {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.mini-action {
  padding: 0.34rem 0.56rem;
  font-size: 0.74rem;
}

.details-form,
.goal-fieldset {
  display: grid;
  gap: 8px;
}

.backend-section label,
.details-form label {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.84rem;
}

#saved-level-search {
  margin-top: 4px;
}

.level-picker {
  display: grid;
  gap: 6px;
}

.saved-level-suggestions {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: none;
  min-height: 100%;
  overflow: auto;
  padding: 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.theme-dark .saved-level-suggestions {
  background: transparent;
}

.saved-level-suggestion {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0.46rem;
  text-align: left;
  border-radius: 14px;
  border: 1px solid rgba(87, 114, 143, 0.16);
  background: rgba(255, 255, 255, 0.46);
  box-shadow: none;
}

.saved-level-suggestion.is-selected {
  background: rgba(61, 112, 168, 0.18);
  color: var(--accent);
  border-color: rgba(61, 112, 168, 0.34);
}

body.theme-dark .saved-level-suggestion.is-selected {
  background: rgba(97, 154, 214, 0.2);
  color: #d9ecff;
}

body.theme-dark .saved-level-suggestion {
  background: rgba(255, 255, 255, 0.05);
}

.saved-level-thumb {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(16, 25, 39, 0.96), rgba(9, 17, 28, 0.98));
  border: 1px solid rgba(87, 114, 143, 0.18);
  overflow: hidden;
}

.saved-level-thumb-image {
  width: 48px;
  height: 48px;
  display: block;
  image-rendering: pixelated;
}

.saved-level-thumb-fallback {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #dfeeff;
}

.saved-level-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.saved-level-title {
  display: block;
  font-size: 0.9rem;
  line-height: 1.15;
}

.saved-level-subtitle {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.backend-section,
.details-form {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.backend-section {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 8px;
  min-height: 0;
}

.backend-actions {
  gap: 0.38rem;
}

.backend-badge {
  min-width: 92px;
  padding: 0.26rem 0.56rem;
  font-size: 0.7rem;
}

.backend-status {
  font-size: 0.74rem;
}

.details-sidebar-controls #level-name-input,
.details-sidebar-controls #user-select,
.details-sidebar-controls #saved-level-search {
  padding: 0.54rem 0.62rem;
}

.saved-level-bank #load-selected-level {
  width: 100%;
}

.saved-level-versions {
  display: grid;
  gap: 10px;
}

.saved-level-versions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(87, 114, 143, 0.18);
}

.saved-level-version-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.saved-level-version-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.saved-level-version-card,
.saved-level-version-empty {
  border-radius: 14px;
  border: 1px solid rgba(87, 114, 143, 0.16);
  background: rgba(255, 255, 255, 0.46);
}

body.theme-dark .saved-level-version-card,
body.theme-dark .saved-level-version-empty {
  background: rgba(255, 255, 255, 0.05);
}

.saved-level-version-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.saved-level-version-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.saved-level-version-title {
  font-size: 1rem;
}

.saved-level-version-date {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.saved-level-version-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-level-version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid rgba(87, 114, 143, 0.22);
}

.saved-level-version-badge.is-active {
  background: rgba(61, 112, 168, 0.18);
  color: var(--accent);
}

.saved-level-version-badge.is-loaded {
  background: rgba(53, 92, 170, 0.22);
  color: #dce9ff;
}

.saved-level-version-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-level-version-action {
  padding: 0.44rem 0.78rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.saved-level-version-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.delete-level-button {
  width: 100%;
}

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

.goal-target-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 74px;
  align-items: center;
  gap: 0.42rem;
  font-weight: 600;
}

.goal-target-label {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  line-height: 1.05;
}

.goal-enabled-row {
  font-weight: 500;
  white-space: nowrap;
  gap: 0.24rem;
  font-size: 0.74rem;
}

.goal-target-input {
  width: 100%;
  min-width: 0;
  padding: 0.44rem 0.5rem;
  font-size: 0.8rem;
}

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

.goal-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.editor-mechanic-warning {
  margin: 0;
  color: #9c2424;
  font-size: 0.81rem;
  font-weight: 700;
  line-height: 1.4;
}

.goal-fieldset {
  padding: 8px 0 0;
  border-radius: 0;
  border: 0;
  border-top: 1px solid rgba(87, 114, 143, 0.18);
  background: transparent;
}

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

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

@media (max-width: 980px) {
  .goal-target-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .goal-target-label {
    grid-column: 1 / -1;
  }
}

.checkbox-label input {
  width: auto;
}

.level-history-view {
  display: block;
}

.level-history-panel {
  display: grid;
  gap: 12px;
}

.level-history-header,
.level-history-detail-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.level-history-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  min-height: 520px;
}

.level-history-list,
.level-history-details {
  min-width: 0;
}

.level-history-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 70vh;
  overflow: auto;
  padding-right: 4px;
}

.level-history-list-item,
.level-history-list-empty,
.level-history-detail-card,
.level-history-empty {
  border-radius: 14px;
  border: 1px solid rgba(87, 114, 143, 0.16);
  background: rgba(255, 255, 255, 0.46);
}

body.theme-dark .level-history-list-item,
body.theme-dark .level-history-list-empty,
body.theme-dark .level-history-detail-card,
body.theme-dark .level-history-empty {
  background: rgba(255, 255, 255, 0.05);
}

.level-history-list-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  text-align: left;
  box-shadow: none;
}

.level-history-list-item.is-selected {
  background: rgba(61, 112, 168, 0.18);
  border-color: rgba(61, 112, 168, 0.34);
}

body.theme-dark .level-history-list-item.is-selected {
  background: rgba(97, 154, 214, 0.18);
  border-color: rgba(97, 154, 214, 0.34);
}

.level-history-list-meta,
.level-history-detail-meta,
.level-history-item-meta,
.modal-copy {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.level-history-empty,
.level-history-list-empty {
  padding: 14px;
}

.level-history-detail-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.level-history-items {
  display: grid;
  gap: 8px;
}

.level-history-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.3);
}

body.theme-dark .level-history-item {
  background: rgba(255, 255, 255, 0.04);
}

.level-history-item-order {
  font-weight: 800;
  color: var(--muted);
}

.level-history-item-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.modal-actions-vertical {
  display: grid;
  gap: 8px;
}

.level-order-range-group input:invalid {
  border-color: rgba(185, 63, 63, 0.72);
  background: rgba(255, 237, 237, 0.92);
}

body.theme-dark .level-order-range-group input:invalid {
  border-color: rgba(237, 118, 118, 0.84);
  background: rgba(86, 33, 33, 0.88);
  color: #ffe7e7;
}

.backend-strip {
  justify-content: space-between;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.backend-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.25;
  font-size: 0.78rem;
}

.backend-status:empty {
  display: none;
}

@media (max-width: 1360px) {
  :root {
    --grid-size: clamp(290px, 24vw, 350px);
    --palette-column-width: 220px;
    --board-inspector-width: 210px;
    --details-column-width: 360px;
  }

  .workspace {
    grid-template-columns: var(--palette-column-width) minmax(0, 1fr) var(--details-column-width);
    grid-template-areas: "palette board details";
  }

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

  .board-panel {
    grid-template-columns: max-content minmax(0, 1fr);
  }

  .details-panel-body {
    grid-template-columns: minmax(0, 1fr) 150px;
  }
}

@media (max-width: 1560px) {
  :root {
    --grid-size: clamp(300px, 23vw, 380px);
    --palette-column-width: 232px;
    --board-inspector-width: 220px;
    --details-column-width: 400px;
  }

  .topbar-actions {
    gap: 0.34rem;
  }

  .topbar-actions button {
    padding: 0.48rem 0.66rem;
    font-size: 0.88rem;
  }

  .workspace {
    grid-template-columns: var(--palette-column-width) minmax(0, 1fr) var(--details-column-width);
  }

  .board-panel {
    grid-template-columns: max-content minmax(0, 1fr);
  }

  .details-panel-body {
    grid-template-columns: minmax(0, 1fr) 156px;
  }

  .details-sidebar-controls {
    gap: 8px;
  }
}

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

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "palette"
      "board";
    width: 100%;
    margin: 0;
  }

  .topbar {
    width: 100%;
    margin: 0 0 8px;
  }

  .details-panel {
    position: fixed;
    top: 88px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: calc(100vh - 104px);
    min-height: auto;
  }

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

  .board-panel {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .board-main {
    align-items: stretch;
  }

  .board-wrap {
    justify-content: start;
    align-self: start;
  }

  .level-order-toolbar,
  .level-order-name-group {
    grid-template-columns: 1fr;
  }

  .level-order-range-group {
    grid-template-columns: repeat(2, minmax(0, 120px));
  }

  .level-history-layout {
    grid-template-columns: 1fr;
  }
}

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

  .topbar,
  .backend-strip {
    flex-direction: column;
    align-items: flex-start;
  }

  .tab-strip {
    width: 100%;
  }

  .tab-button {
    min-width: 0;
    flex: 1 1 0;
  }

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

  .auth-grid {
    grid-template-columns: 1fr;
  }

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

  .palette-root {
    grid-template-columns: 1fr;
    grid-template-areas:
      "colors"
      "gems"
      "mechanics";
  }

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