/* ═══════════════════════════════════════
   SKETCH TO WORLD — draw directly on the world grid
   ═══════════════════════════════════════ */

/* ── Card ── */
.stw-card-draw {
  max-width: 1400px;
}

.stw-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #2a2a3e;
}

.stw-grid-size {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
}

.stw-grid-size .form-input {
  width: 100%;
}

.stw-tool-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.stw-tool-btn {
  padding: 4px 12px;
  font-size: 0.85em;
}

.stw-tool-btn.stw-tool-active {
  background: #1b5e3a;
  border-color: #2b8a3e;
  color: #b2f2bb;
}

/* ── Stamp Palette ── */
.stw-stamp-palette {
  margin-bottom: 14px;
}

.stw-stamp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.stw-stamp-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  color: #e9ecef;
  cursor: pointer;
  font-size: 0.85em;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s;
  border-left: 4px solid var(--stamp-color, #51cf66);
}

.stw-stamp-btn:hover {
  background: #232438;
}

.stw-stamp-btn:active {
  transform: translateY(1px);
}

.stw-stamp-btn.stw-stamp-active {
  background: color-mix(in srgb, var(--stamp-color, #51cf66) 25%, #1a1a2e);
  border-color: var(--stamp-color, #51cf66);
  color: #fff;
}

.stw-stamp-icon {
  font-size: 1.3em;
  line-height: 1;
}

.stw-stamp-label {
  font-weight: 500;
}

/* ── Background Picker ── */
.stw-bg-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}

.stw-bg-picker .form-label {
  margin: 0;
}

.stw-bg-select {
  max-width: 200px;
}

.stw-bg-hint {
  color: #6c757d;
  font-size: 0.85em;
}

/* ── Canvas ── */
.stw-canvas-wrap {
  position: relative;
  margin: 8px 0;
  overflow: auto;
  max-height: 75vh;
}

.stw-canvas {
  display: block;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  background: #f7fbff;
  touch-action: none;
}

.stw-canvas-hint {
  position: absolute;
  top: 8px;
  left: 8px;
  color: #6c757d;
  font-size: 0.8em;
  pointer-events: none;
}

/* ── Footer ── */
.stw-canvas-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.stw-counts {
  color: #adb5bd;
  font-size: 0.9em;
}

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

.stw-zoom-label {
  color: #adb5bd;
  font-size: 0.9em;
  min-width: 44px;
  text-align: center;
  user-select: none;
}

.stw-status {
  margin-top: 12px;
  font-size: 0.9em;
  color: #6c757d;
  min-height: 1.2em;
}

/* ── Editor ── */
.stw-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stw-table {
  width: 100%;
  font-size: 0.9em;
}

.stw-edit-input {
  padding: 4px 8px;
  font-size: 0.85em;
  width: 100%;
  min-width: 100px;
}

.stw-edit-select {
  padding: 4px 8px;
  font-size: 0.85em;
  min-width: 90px;
}

.stw-remove-btn {
  padding: 2px 8px;
  font-size: 0.8em;
  color: #ff6b6b;
  border-color: #5c1a1a;
}

.stw-remove-btn:hover {
  background: #3d1010;
}

.stw-results-empty {
  color: #6c757d;
  font-size: 0.9em;
  padding: 24px;
  text-align: center;
}

/* ── Generate ── */
.stw-generate-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* ── Responsive ── */
@media (max-width: 800px) {
  .stw-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .stw-tool-picker {
    margin-left: 0;
  }
}

/* ── World preview ── */
.stw-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stw-preview-wrap {
  margin-top: 4px;
  overflow: auto;
  max-height: 80vh;
}

.stw-preview-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stw-preview-zoom-label {
  color: #adb5bd;
  font-size: 0.9em;
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stw-preview-canvas {
  display: block;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  background: #0f0f1c;
  image-rendering: pixelated;
}

.stw-preview-hint {
  color: #6c757d;
  font-size: 0.85em;
  margin-top: 8px;
  min-height: 1.2em;
}

.stw-preview-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #adb5bd;
  font-size: 0.9em;
  margin: 6px 0 10px;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}

.stw-preview-slider {
  width: 160px;
}

.stw-preview-slider-val {
  min-width: 1.25em;
  font-variant-numeric: tabular-nums;
  color: #ced4da;
  font-weight: 600;
}

.stw-preview-toggle-hint {
  color: #6c757d;
  font-size: 0.85em;
}


/* ── Tile column in Zones table ── */
.stw-tile-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stw-tile-thumb {
  width: 56px;
  height: auto;
  border: 1px solid #2a2a3e;
  border-radius: 4px;
  background: #0f0f1c;
  image-rendering: pixelated;
}

/* Prop thumbnail sits next to the ground thumbnail; smaller + tinted edge
   so it reads as an overlay/prop rather than another ground swatch. */
.stw-tile-thumb-prop {
  width: 40px;
  border-color: #2b8a3e;
  margin-left: 4px;
}

.stw-tile-empty {
  color: #6c757d;
  font-size: 0.9em;
}

.stw-pick-tile-btn {
  font-size: 0.8em;
  padding: 4px 10px;
}

/* ── Background row above Zones table ── */
.stw-bg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #121220;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
}

.stw-bg-row-label {
  flex: 1;
}

/* ── Tile picker modal ── */
.stw-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.stw-picker-modal {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  max-width: 980px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stw-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a3e;
}

.stw-picker-head h3 {
  margin: 0;
}

.stw-picker-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid #2a2a3e;
  flex-wrap: wrap;
}

.stw-picker-search {
  flex: 1;
  min-width: 160px;
}

.stw-picker-pack {
  min-width: 180px;
  max-width: 280px;
}

.stw-picker-toggle {
  color: #adb5bd;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.stw-picker-count {
  color: #6c757d;
  font-size: 0.85em;
  margin-left: auto;
}

.stw-picker-body {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stw-picker-section {
  display: flex;
  flex-direction: column;
}

.stw-picker-section-head {
  margin: 0;
  padding: 10px 16px 6px;
  font-size: 0.85em;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #0d0d14;
  border-top: 1px solid #2a2a3e;
  position: sticky;
  top: 0;
  z-index: 1;
}

.stw-picker-section:first-child .stw-picker-section-head {
  border-top: none;
}

.stw-picker-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.stw-picker-cell {
  position: relative;
}

.stw-picker-kind-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.65em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  background: #2b8a3e;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stw-picker-cell {
  background: #12121a;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  text-align: center;
  color: #ced4da;
  transition: background 120ms, border-color 120ms;
}

.stw-picker-cell:hover {
  background: #1a1a2e;
  border-color: #4a7bff;
}

.stw-picker-cell img {
  width: 96px;
  height: auto;
  image-rendering: pixelated;
  background: #0f0f1c;
  border: 1px solid #2a2a3e;
  border-radius: 4px;
}

.stw-picker-cell-name {
  font-weight: 600;
  font-size: 0.9em;
}

.stw-picker-cell-sub {
  font-size: 0.75em;
  color: #6c757d;
}

.stw-picker-cell-desc {
  font-size: 0.75em;
  color: #adb5bd;
  line-height: 1.2;
  max-height: 2.6em;
  overflow: hidden;
}

.stw-picker-empty {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: #6c757d;
  font-size: 0.9em;
}

.stw-picker-empty code {
  background: #0f0f1c;
  padding: 1px 6px;
  border-radius: 3px;
}

.stw-picker-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid #2a2a3e;
}
