*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a1a;
  --panel: #242424;
  --panel2: #2c2c2c;
  --border: #383838;
  --accent: #4c9eff;
  --accent2: #e8a020;
  --green: #56b870;
  --red: #e05252;
  --gold: #f0c040;
  --text: #e0e0e0;
  --text-dim: #888;
  --topbar-h: 40px;
  --toolbar-w: 46px;
  --panel-left-w: 198px;
  --panel-right-w: 238px;
  --bottom-h: 180px;
  --statusbar-h: 24px;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 12px; }

.builder-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* TOP BAR */
.builder-topbar {
  height: var(--topbar-h); background: #1f1f1f; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 10px; gap: 8px; flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; }
.logo { font-weight: 800; font-size: 13px; color: var(--accent); letter-spacing: 1px; margin-right: 8px; }
.topbar-nav { display: flex; align-items: center; gap: 0; }
.menu-wrapper { position: relative; }
.nav-btn { background: none; border: none; color: var(--text-dim); font-size: 12px; padding: 4px 8px; cursor: pointer; border-radius: 4px; position: relative; }
.nav-btn:hover, .nav-btn.menu-open { background: var(--panel2); color: var(--text); }

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.menu-dropdown.open { display: block; }

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.menu-item:hover { background: var(--accent); color: #fff; }
.menu-item .shortcut { color: var(--text-dim); font-size: 11px; margin-left: 24px; }
.menu-item:hover .shortcut { color: rgba(255,255,255,0.7); }
.menu-item.disabled { opacity: 0.4; pointer-events: none; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-item .check-mark { width: 14px; display: inline-block; margin-right: 4px; }
.topbar-breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); }
.topbar-breadcrumb .bc-sep { color: #555; }
.topbar-breadcrumb span:last-child { color: var(--text); }
.topbar-btn { background: none; border: 1px solid var(--border); color: var(--text-dim); width: 28px; height: 28px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.topbar-btn:hover { background: var(--panel2); color: var(--text); }
.topbar-btn svg { width: 14px; height: 14px; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.btn-test { background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 500; }
.btn-test:hover { background: #38383a; }
.btn-publish { background: var(--accent); border: none; color: #fff; padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; }
.btn-publish:hover { background: #3a8ee0; }

/* MAIN AREA */
.builder-main {
  display: flex; flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* TOOLBAR */
.builder-toolbar {
  width: var(--toolbar-w); background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; flex-shrink: 0;
}
.tool-btn {
  width: 34px; height: 34px; background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-dim); cursor: pointer; display: flex; flex-direction: column; align-items: center;
  justify-content: center; position: relative; transition: background 0.1s, color 0.1s;
}
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:hover { background: var(--panel2); color: var(--text); border-color: var(--border); }
.tool-btn.active { background: rgba(76,158,255,0.15); border-color: var(--accent); color: var(--accent); }
.key-hint { font-size: 8px; color: var(--text-dim); line-height: 1; margin-top: 1px; }
.tool-sep { width: 24px; height: 1px; background: var(--border); margin: 4px 0; }
.toolbar-spacer { flex: 1; }

/* LEFT PANEL */
.builder-panel-left {
  width: var(--panel-left-w); background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.panel-section { border-bottom: 1px solid var(--border); }
.panel-header {
  padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.5px; display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  background: var(--panel);
}
.panel-header:hover { background: var(--panel2); }
.collapse-icon { width: 10px; height: 6px; stroke: var(--text-dim); fill: none; transition: transform 0.2s; }
.panel-content { padding: 4px 0; }

/* Layer rows */
.layer-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; cursor: pointer;
  border-radius: 4px; margin: 1px 4px;
}
.layer-row:hover { background: var(--panel2); }
.layer-row.active-layer { background: rgba(76,158,255,0.1); }
.layer-eye, .layer-lock {
  background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 2px;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.layer-eye svg, .layer-lock svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.layer-eye.active { color: var(--text); }
.layer-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.layer-name { font-size: 12px; color: var(--text); }

/* Room rows */
.room-row {
  padding: 6px 12px; cursor: pointer; border-radius: 4px; margin: 1px 4px; display: flex;
  align-items: center; justify-content: space-between;
}
.room-row:hover { background: var(--panel2); }
.room-row.active-room { background: rgba(76,158,255,0.12); border-left: 2px solid var(--accent); padding-left: 10px; }
.room-name { font-size: 12px; color: var(--text); }
.add-room-btn { background: none; border: none; color: var(--accent); font-size: 16px; cursor: pointer; padding: 0 4px; }

/* CANVAS AREA */
.builder-canvas-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #141414; position: relative;
}
.canvas-toolbar {
  height: 32px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 10px; gap: 12px; flex-shrink: 0;
}
.toggle-label { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); cursor: pointer; }
.toggle-label input { accent-color: var(--accent); }
.toggle-label:hover { color: var(--text); }
.toggle-label-text { font-size: 11px; color: var(--text-dim); }
.canvas-toolbar-sep { width: 1px; height: 16px; background: var(--border); }
.seg-control { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg-btn { background: none; border: none; color: var(--text-dim); font-size: 11px; padding: 2px 8px; cursor: pointer; }
.seg-btn.active { background: var(--panel2); color: var(--text); }
.canvas-cursor-pos { font-size: 10px; color: var(--text-dim); font-family: monospace; min-width: 50px; }
.zoom-controls { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.zoom-controls button { background: none; border: 1px solid var(--border); color: var(--text-dim); width: 20px; height: 20px; border-radius: 3px; cursor: pointer; }
#zoom-level { color: var(--text-dim); min-width: 36px; text-align: center; }

.canvas-scroll-container {
  flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 20px; background: #141414;
}
#builder-canvas { display: block; cursor: crosshair; image-rendering: pixelated; }

/* Tool toast */
.tool-toast {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 16px; border-radius: 20px; pointer-events: none; opacity: 0;
  transition: opacity 0.2s; white-space: nowrap; z-index: 20;
}
.tool-toast.visible { opacity: 1; }

/* RIGHT PANEL */
.builder-panel-right {
  width: var(--panel-right-w); background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.properties-section { flex: 1; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); }
.ptab {
  flex: 1; background: none; border: none; color: var(--text-dim); padding: 7px 0; cursor: pointer;
  font-size: 11px; font-weight: 500; border-bottom: 2px solid transparent;
}
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ptab-content { display: none; padding: 10px; }
.ptab-content.active { display: block; }
.prop-group { margin-bottom: 10px; }
.prop-group label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.prop-input {
  width: 100%; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 5px 8px; border-radius: 4px; font-size: 12px;
}
.prop-input:focus { outline: none; border-color: var(--accent); }
.prop-select {
  width: 100%; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 5px 8px; border-radius: 4px; font-size: 12px;
}
.prop-range { width: 100%; accent-color: var(--accent); }
.prop-empty { color: var(--text-dim); font-size: 11px; padding: 8px 0; }
.section-label { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

/* Preview */
.preview-section { flex-shrink: 0; border-top: 1px solid var(--border); }
.preview-toggle-btn { background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.preview-viewport {
  position: relative; width: 100%; padding-top: 100%;
  background: #000; overflow: hidden;
}
.preview-viewport iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.preview-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center; color: var(--text-dim); font-size: 11px;
  pointer-events: none;
}
.preview-overlay.hidden { display: none; }

/* BOTTOM BAR */
.builder-bottom {
  height: var(--bottom-h); display: flex; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* Mini-map */
.builder-minimap {
  width: 244px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
#minimap-canvas { display: block; margin: 8px auto; cursor: pointer; }
.minimap-legend { padding: 0 8px 6px; display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--text-dim); flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 2px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.gold { background: var(--gold); }
.dot.amber { background: #e8a020; }

/* Library */
.builder-library { flex: 1; background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.library-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none; }
.library-tabs::-webkit-scrollbar { display: none; }
.lib-tab { background: none; border: none; color: var(--text-dim); padding: 7px 8px; cursor: pointer; font-size: 11px; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; flex-shrink: 0; }
.lib-tab:hover { color: var(--text); }
.lib-empty-msg { padding: 12px 16px; color: #888; font-size: 11px; text-align: center; width: 100%; }
.lib-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.library-content { flex: 1; overflow-x: auto; overflow-y: hidden; padding: 8px; display: flex; gap: 6px; align-items: flex-start; }

/* Tile/Object cells in library */
.lib-tile {
  width: 48px; min-height: 48px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex-shrink: 0; background: var(--panel2); transition: border-color 0.1s; padding: 4px 2px;
}
.lib-tile:hover { border-color: var(--accent); }
.lib-tile.active { border-color: var(--accent); background: rgba(76,158,255,0.12); }
.lib-tile-label { font-size: 9px; color: var(--text-dim); margin-top: 3px; text-align: center; line-height: 1.2; }

/* STATUS BAR */
.builder-statusbar {
  height: var(--statusbar-h); background: #1a1a1a; border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px; gap: 8px; font-size: 10px; color: var(--text-dim); flex-shrink: 0;
}
.status-sep { color: #444; }

/* Upload button in library */
.lib-upload-btn {
  width: 48px; min-height: 48px; border: 1px dashed var(--accent); border-radius: 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex-shrink: 0; background: transparent; color: var(--accent); font-size: 18px; font-weight: 700;
  transition: background 0.15s;
}
.lib-upload-btn:hover { background: rgba(76,158,255,0.1); }
.lib-upload-label { font-size: 8px; color: var(--accent); margin-top: 2px; }

/* Animation Editor Modal */
.anim-editor-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 9000;
}
.anim-editor-inner {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: 800px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.anim-editor-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; color: var(--text);
}
.anim-close-btn { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }
.anim-editor-body { display: flex; flex: 1; overflow: hidden; }
.anim-left { flex: 1; overflow: auto; padding: 12px; border-right: 1px solid var(--border); }
.anim-right { width: 240px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.anim-settings-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 11px; color: var(--text-dim); flex-wrap: wrap; }
.anim-settings-row input { width: 48px; background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 4px; border-radius: 4px; font-size: 12px; }
.anim-settings-row button { background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.anim-frames-grid { display: grid; gap: 2px; }
.anim-frame-cell {
  border: 1px solid var(--border); cursor: pointer; border-radius: 2px;
  image-rendering: pixelated; transition: border-color 0.1s;
}
.anim-frame-cell:hover { border-color: var(--accent); }
.anim-frame-cell.selected { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.anim-preview { text-align: center; margin-bottom: 8px; }
#ae-preview { image-rendering: pixelated; border: 1px solid var(--border); border-radius: 4px; background: #000; }
.anim-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.anim-row {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px;
  cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 11px; flex-wrap: wrap;
}
.anim-row.active { border-color: var(--accent); background: rgba(76,158,255,0.1); }
.anim-name { font-weight: 600; color: var(--text); flex: 0 0 auto; }
.anim-frames-count { color: var(--text-dim); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 10px; }
.anim-fps-input { width: 36px; background: var(--panel); border: 1px solid var(--border); color: var(--accent); padding: 2px 4px; border-radius: 3px; font-size: 10px; text-align: center; }
.anim-fps-label { color: var(--accent); font-size: 10px; flex: 0 0 auto; }
.anim-loop { display: flex; align-items: center; gap: 4px; color: var(--text-dim); font-size: 10px; }
.anim-del-btn { background: none; border: none; color: var(--red); cursor: pointer; padding: 0 4px; font-size: 12px; }
.anim-add-btn { background: var(--panel2); border: 1px solid var(--border); color: var(--accent); padding: 6px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.anim-bitmask-btn { background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 6px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.anim-save-btn { background: var(--accent); border: none; color: #fff; padding: 8px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; }
.anim-editor-footer { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

/* Gameplay tab */
.add-btn { background: var(--panel2); border: 1px solid var(--border); color: var(--accent); padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; width: 100%; text-align: center; }
.add-btn:hover { border-color: var(--accent); }
.delete-small { background: none; border: 1px solid var(--border); color: var(--red, #e05252); cursor: pointer; font-size: 10px; padding: 1px 5px; border-radius: 3px; line-height: 1; }
.delete-small:hover { border-color: var(--red, #e05252); }
.prop-row { display: flex; align-items: center; gap: 6px; }
.prop-row label { font-size: 10px; color: var(--text-dim); white-space: nowrap; }

.resize-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 9500;
}
.resize-modal.hidden { display: none; }
.resize-modal-inner {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: 340px; max-width: 95vw;
}
.resize-modal-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.resize-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.resize-field { display: flex; flex-direction: column; gap: 4px; }
.resize-field label { font-size: 11px; color: var(--text-dim); }
.resize-field input {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: 5px; font-size: 13px; width: 100%;
}
.resize-anchor-section { display: flex; flex-direction: column; gap: 6px; }
.resize-anchor-section > label { font-size: 11px; color: var(--text-dim); }
.resize-anchor-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  width: 120px;
}
.anchor-btn {
  width: 36px; height: 36px; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 5px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all 0.1s;
}
.anchor-btn:hover { border-color: var(--accent); color: var(--text); }
.anchor-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.resize-preview {
  font-size: 11px; color: var(--text-dim); padding: 8px;
  background: var(--panel2); border-radius: 5px; min-height: 20px;
}
.resize-actions { display: flex; gap: 8px; justify-content: flex-end; }
.resize-cancel-btn {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 16px; border-radius: 5px; cursor: pointer; font-size: 12px;
}
.resize-cancel-btn:hover { background: #383838; }
.resize-apply-btn {
  background: var(--accent); border: none; color: #fff;
  padding: 6px 16px; border-radius: 5px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.resize-apply-btn:hover { filter: brightness(1.1); }

.wc-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 9500;
}
.wc-modal.hidden { display: none; }
.wc-modal-inner {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: 420px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column;
}
.wc-modal-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.wc-modal-close {
  background: none; border: none; color: #aaa; font-size: 1.4rem;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.wc-modal-close:hover { color: #fff; }
.wc-modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.wc-modal-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.wc-field { margin-bottom: 12px; }
.wc-field label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.wc-field select,
.wc-field input[type="number"] {
  width: 100%; padding: 6px 10px; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; font-size: 13px;
}
.wc-hint { font-size: 10px; color: #666; margin-top: 3px; }
.wc-star-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.sel-section { padding: 8px 0; }
.sel-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.sel-type-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 4px;
}
.enemy-badge  { background: #3a1a1a; color: #ff6b6b; }
.coin-badge   { background: #2a2200; color: #ffcc44; }
.generic-badge{ background: #1a2a3a; color: #6baaff; }

.btn-icon-danger {
  background: none; border: 1px solid #552222; color: #ff6b6b;
  border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 14px; line-height: 1;
}
.btn-icon-danger:hover { background: #3a1212; }

.form-divider { border: none; border-top: 1px solid #2a2a2a; margin: 12px 0; }
.field-hint { font-size: 10px; color: #666; margin: 3px 0 0; line-height: 1.4; }
.unit { font-size: 10px; color: #888; font-weight: 400; }

.form-row { display: flex; gap: 8px; }
.form-group { margin-bottom: 10px; }
.form-group.half { flex: 1; }
.range-readout { text-align: right; font-size: 11px; color: #aaa; margin-top: 2px; }

.lib-picker-card {
  background: #1a1a22;
  border: 2px solid #2a2a3a;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s;
}
.lib-picker-card:hover { border-color: #5a6aff; }
.lib-picker-swatch {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  margin: 0 auto 6px;
  border: 1px solid rgba(255,255,255,.1);
}
.lib-picker-name {
  font-size: 11px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-picker-cat {
  font-size: 9px;
  color: #555;
  text-transform: capitalize;
  margin-top: 2px;
}

/* ─── Game Settings Modal ─── */

.gs-modal-box {
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.gs-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.gs-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.gs-close-btn:hover { color: #ddd; }

/* Publish section */
.gs-publish-section {
  background: #0e0e18;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.gs-publish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gs-publish-label {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 3px;
}

.gs-publish-hint {
  font-size: 11px;
  color: #666;
}

.gs-publish-toggle {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.gs-publish-toggle.published {
  background: #1a3a1a;
  color: #5aaa5a;
  border: 1px solid #2a5a2a;
}
.gs-publish-toggle.published:hover { background: #2a1a1a; color: #e05252; border-color: #5a2a2a; }
.gs-publish-toggle.draft {
  background: #4a4aaa;
  color: #fff;
}
.gs-publish-toggle.draft:hover { background: #5a5abb; }

/* Lock section */
.gs-lock-section {
  background: #0e0e18;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.gs-publish-toggle.gs-lock-active {
  background: #3a2a00;
  color: #e5a820;
  border: 1px solid #6a4a00;
}
.gs-publish-toggle.gs-lock-active:hover { background: #1a2a1a; color: #5aaa5a; border-color: #2a5a2a; }

/* Public URL row */
.gs-url-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.gs-url-input {
  flex: 1;
  background: #16161f;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  color: #888;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
}

.gs-copy-btn {
  background: #2a2a3a;
  color: #aaa;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.gs-copy-btn:hover { background: #3a3a5a; color: #ddd; }

/* Secondary actions (duplicate / delete) */
.gs-secondary-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.gs-secondary-actions .sm-btn-ghost,
.gs-secondary-actions .sm-btn-danger {
  flex: 1;
}

/* ─── Background Settings Modal ─── */
.bg-modal-box { max-width: 380px; width: 95%; }

.bg-preview-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  border: 1px solid #2a2a38;
  margin-bottom: 16px;
  background: #0e0e14;
  image-rendering: pixelated;
}

.bg-color-input {
  width: 44px !important;
  height: 32px;
  padding: 2px;
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.bg-image-row { display: flex; align-items: center; gap: 10px; }

.bg-image-thumb {
  width: 88px;
  height: 56px;
  border-radius: 5px;
  border: 1px solid #2a2a38;
  background: #14141c;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bg-image-btns { display: flex; flex-direction: column; gap: 6px; }

.bg-range { width: 100%; margin-top: 6px; accent-color: #4c9eff; }

.bg-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #555;
  margin-top: 3px;
}

.bg-radio-group { display: flex; gap: 20px; margin-top: 6px; }

.bg-radio-label {
  font-size: 13px;
  color: #aaa;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.bg-radio-label input { cursor: pointer; accent-color: #4c9eff; }
