:root {
  --bg-0: #1a1410;
  --bg-1: #221a14;
  --bg-2: #2b211a;
  --bg-3: #38291f;
  --ink-0: #f5ead7;
  --ink-1: #d9c9a7;
  --ink-2: #a08a6b;
  --ink-3: #6e5b44;
  --accent: #e8b16a;
  --accent-2: #f1c98b;
  --danger: #e07a6b;
  --good: #7fcf8a;
  --line: #3d2e23;
  --line-strong: #5a4332;
  --shadow-1: 0 1px 0 rgba(255, 220, 170, 0.06) inset, 0 6px 18px rgba(0, 0, 0, 0.35);
  --board-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px #6e4d33 inset;
  --radius: 10px;
  --radius-sm: 6px;
  --tool-h: 36px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 30% -10%, #2a2018 0%, var(--bg-0) 60%) fixed;
  color: var(--ink-0);
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.4;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--accent); }

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #2a201a, #1f1812);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand h1 {
  font-size: 14px;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, #fff 0%, #cfd3d6 20%, #6f7377 70%, #2c2f31 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 -2px 4px rgba(0,0,0,0.4);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Pack picker in the centre of the topbar */
.pack-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  flex: 0 1 520px;
  min-width: 0;
}
.pack-picker select,
.pack-picker input[type="text"] {
  appearance: none;
  background: transparent;
  color: var(--ink-0);
  border: 0;
  height: 28px;
  padding: 0 8px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.pack-picker select { flex: 0 0 160px; cursor: pointer; color: var(--ink-1); }
.pack-picker select:hover { color: var(--ink-0); }
.pack-picker input[type="text"] {
  flex: 1 1 auto;
  border-left: 1px solid var(--line);
}
.pack-picker input:focus,
.pack-picker select:focus { outline: none; }
.pack-picker .btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 5px;
}

/* "Loaded pack" indicator (right side of topbar) */
.loaded-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(232, 177, 106, 0.10);
  color: var(--ink-1);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.loaded-indicator .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-2);
  flex: 0 0 auto;
}
.loaded-indicator.dirty .dot {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(232, 177, 106, 0.6);
}
.loaded-indicator.saved .dot { background: var(--good); }
.loaded-indicator.new .dot { background: #6e9ad6; }

.icon-btn-lg { width: 32px; height: 32px; font-size: 16px; }

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--tool-h);
  padding: 0 14px;
  font: inherit;
  font-weight: 500;
  color: var(--ink-0);
  background: linear-gradient(180deg, #3b2c22, #2a1f17);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-1);
}
.btn:hover { background: linear-gradient(180deg, #4a3729, #34281e); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #2a1a0c;
  border-color: #b88040;
}
.btn-primary:hover {
  background: linear-gradient(180deg, #ffd7a0, #ecbd7c);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: rgba(255, 220, 170, 0.05); }
.btn-danger {
  background: linear-gradient(180deg, #6a2a25, #4a1c19);
  border-color: #8b3a32;
}
.btn-danger:hover { background: linear-gradient(180deg, #823129, #5a221d); }

.icon-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #2a1f17;
  color: var(--ink-1);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.icon-btn:hover { background: #38291f; color: var(--ink-0); }
.icon-btn-danger:hover { color: var(--danger); border-color: #8b3a32; }

/* ---------- Layout ---------- */
.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  min-height: 0;
}

.panel {
  background: linear-gradient(180deg, #221a14, #1c150f);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-right {
  border-right: none;
  border-left: 1px solid var(--line);
}

.panel-section {
  padding: 14px 14px 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.panel-section h2 {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.panel-section-grow {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: none;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-actions { display: flex; gap: 4px; }

/* ---------- Fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.field > span {
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}
.field input,
.field select,
.field-inline select {
  appearance: none;
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font: inherit;
  color: var(--ink-0);
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.field input:focus,
.field select:focus,
.field-inline select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 177, 106, 0.25);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}
.field-inline select { height: 28px; width: auto; padding-right: 24px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ink-1);
  font-size: 12px;
}
.check input { accent-color: var(--accent); }

/* ---------- Pack overview (2x5 level grid) ----------
   Mirrors the in-game level select view. Click a tile to enter the level
   editor for it, or drag a tile onto another slot to swap their positions. */
.pack-overview {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 28px 28px;
  overflow: auto;
}
.overview-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.overview-header h2 {
  font-size: 22px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-0);
  margin: 0 0 2px;
}
.overview-hint {
  text-align: right;
  max-width: 260px;
  line-height: 1.5;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  gap: 16px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  align-content: center;
  flex: 1 1 auto;
}

.level-tile {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #3b2c22, #2a1f17);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 10px 8px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 220, 170, 0.05);
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.level-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--accent) inset;
}
.level-tile.dragging {
  opacity: 0.35;
  cursor: grabbing;
}
.level-tile.drop-target {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2) inset, 0 8px 20px rgba(232, 177, 106, 0.25);
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.tile-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 1px 7px;
}
.tile-empty-badge {
  color: var(--ink-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.tile-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  overflow: hidden;
  background: #14100c;
  border: 1px solid var(--line);
}
.tile-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.tile-empty .tile-thumb {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 220, 170, 0.025) 0 6px,
      transparent 6px 12px
    ),
    #221a14;
}

.tile-name {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-meta {
  margin-top: 2px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
}

/* ---------- Level-editor view header ---------- */
.level-editor {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #221a14, #1c150f);
}
.editor-title {
  font-size: 13px;
  color: var(--ink-1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.editor-title b {
  font-variant-numeric: tabular-nums;
  color: var(--ink-0);
}
.editor-title-sep { color: var(--ink-3); padding: 0 2px; }
.editor-header-spacer { flex: 1 1 auto; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* Pack/level-view-aware sidebar visibility:
   - The right panel (Level / Selection / Stats) only makes sense when an
     individual level is open. Hide it in the pack overview.
   - Same for the per-level toolbar (it lives inside .level-editor already). */
body[data-view="pack"]  .panel-right { display: none; }
body[data-view="empty"] .panel-right { display: none; }

/* Before a pack is opened/created there's nothing to configure, so hide the
   left Pack panel (name / author / password) too and let the empty-state
   board fill the full width. */
body[data-view="empty"] .panel-left { display: none; }
body[data-view="empty"] .layout { grid-template-columns: 1fr; }

/* ---------- Board ---------- */
.board-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(800px 400px at 50% -20%, #2c211a 0%, transparent 70%),
    #19120d;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #221a14, #1c150f);
}
.toolbar-spacer { flex: 1 1 auto; }

.tool-group {
  display: inline-flex;
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-1);
  height: 30px;
  padding: 0 10px;
  font: inherit;
  border-radius: 5px;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.tool:hover { color: var(--ink-0); background: rgba(255, 220, 170, 0.05); }
.tool.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #2a1a0c;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.canvas-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  touch-action: none;
}
.canvas-stage.tool-select-scroll {
  /* Native page scroll on empty board; object drags block scroll via touchstart. */
  touch-action: pan-x pan-y;
  cursor: default;
}
#board {
  display: block;
  background: #c9a67a;
  border-radius: 14px;
  box-shadow: var(--board-shadow);
  image-rendering: -webkit-optimize-contrast;
  touch-action: none;
  pointer-events: none;
  /* Scale up the 480x320 logical pixels nicely. Width set by JS responsively. */
  width: min(960px, 100%);
  height: auto;
  aspect-ratio: 3 / 2;
}

.hint {
  padding: 8px 16px 14px;
  font-size: 11px;
  color: var(--ink-2);
  text-align: center;
}
.hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #14100c;
  border: 1px solid var(--line-strong);
  color: var(--ink-0);
}

/* ---------- Selection ---------- */
#sel-form {
  display: flex;
  flex-direction: column;
}
.sel-kind {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(232, 177, 106, 0.15);
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.sel-actions {
  display: flex;
  gap: 8px;
  order: 10;
  margin-top: 12px;
}
.seg {
  display: inline-flex;
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-1);
  padding: 4px 10px;
  font: inherit;
  border-radius: 4px;
  cursor: pointer;
}
.seg-btn.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #2a1a0c;
  font-weight: 600;
}

/* ---------- Stats ---------- */
.stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stats li {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.stats li span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}
.stats li b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink-0);
}

.muted { color: var(--ink-2); font-size: 12px; }

/* Force the HTML `hidden` attribute to always beat any class rule.
   Without this `.modal { display: flex }` (and friends) override the UA
   stylesheet's `[hidden] { display: none }` and the modal stays visible
   even when JS / markup says it shouldn't be. */
[hidden] { display: none !important; }

/* ---------- Toast / overlay ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: #14100c;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  color: var(--ink-0);
  font-size: 12px;
  z-index: 50;
}
.toast.error { color: var(--danger); border-color: #8b3a32; }
.toast.ok { color: var(--good); border-color: #3f6b46; }

/* ---------- Empty board state ---------- */
.board-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  flex: 1 1 auto;
}
.board-empty-card {
  text-align: center;
  max-width: 360px;
  padding: 28px 32px;
  background: linear-gradient(180deg, #221a14, #1a130e);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.board-empty-card h2 {
  font-size: 16px;
  color: var(--ink-0);
  margin-bottom: 6px;
}
.board-empty-card p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}
.board-empty-card strong { color: var(--accent-2); font-weight: 600; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 5, 3, 0.7);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  background: linear-gradient(180deg, #2a201a, #1c150f);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-card-sm { width: min(440px, 100%); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { font-size: 14px; letter-spacing: 0.02em; }
.modal-body {
  padding: 6px 16px 14px;
  overflow-y: auto;
}
.modal-section {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}
.modal-section:last-child { border-bottom: none; }
.modal-section h3 {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.modal-section .muted { margin: 0 0 10px; font-size: 12px; }
.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(20, 16, 12, 0.5);
}
.modal-footer-spacer { flex: 1 1 auto; }

.saved-body { text-align: center; }
.saved-id-block {
  padding: 8px 0 12px;
}
.saved-id-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.saved-id-num {
  display: block;
  font-size: 52px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
  line-height: 1;
  letter-spacing: 0.04em;
}
.save-hint {
  margin: 0;
  line-height: 1.5;
  text-align: center;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-3);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.status-dot-ok      { background: var(--good); }
.status-dot-error   { background: var(--danger); }
.status-dot-warn    { background: #e8c46a; }
.status-dot-unknown { background: var(--ink-3); }
.status-text { color: var(--ink-1); font-size: 13px; }

.field small,
.help-list a {
  color: var(--ink-2);
  font-size: 11px;
}
.field code, .help-list code {
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-1);
}
.help {
  margin-top: 8px;
  padding: 8px 10px;
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.help summary {
  cursor: pointer;
  color: var(--ink-1);
  font-size: 12px;
}
.help-list {
  margin: 8px 0 0 18px;
  padding: 0;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.55;
}
.help-list li { margin-bottom: 4px; }

/* ---------- Sidebar: password row ---------- */
.pwd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: #14100c;
  border: 1px solid var(--line);
  border-radius: 5px;
  min-height: 28px;
}
.pwd-status {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.pwd-status-locked { color: var(--accent-2); }
.pwd-status-open   { color: var(--ink-1); }

.btn-sm {
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 4px;
}

.pwd-field > span { color: var(--ink-2); }

.pwd-error {
  color: var(--danger);
  min-height: 14px;
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

/* ---------- Scrollbars (mac-friendly) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #3a2c22;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #4d3a2c; background-clip: padding-box; }

/* ---------- Small screens ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px 1fr 240px; }
}
@media (max-width: 900px) {
  /* Single scrolling column: panels and board stack vertically and the page
     scrolls, so the Pack details panel scrolls away instead of pinning at
     the top. Keep board-wrap / level-editor from stretching to viewport
     height — otherwise the right panel (par/dev time) ends up overlapped
     by the full-height canvas area.
     Use block flow (not flex) on body so scrolling doesn't fight flex sizing
     and cause violent scroll jitter when panning from the canvas. */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-anchor: none;
  }
  body {
    display: block;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .topbar { position: sticky; top: 0; z-index: 50; }
  .layout {
    display: flex;
    flex-direction: column;
  }
  .board-wrap {
    flex: 0 0 auto;
    min-height: auto;
  }
  .level-editor {
    flex: 0 0 auto;
    min-height: auto;
  }
  .panel {
    border: none;
    border-bottom: 1px solid var(--line);
    max-height: none;
    overflow: visible;
    flex: 0 0 auto;
  }
  .panel-right { border-bottom: none; border-top: 1px solid var(--line); }
  .canvas-stage { flex: 0 0 auto; overflow: visible; padding: 16px; }
  .sel-actions {
    order: -1;
    margin-top: 0;
    margin-bottom: 12px;
  }
}
