* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #4fa8f5 0%, #9fd8ff 55%, #e6f6ff 100%);
  transition: background 0.6s ease;
}

body.night-mode {
  background: linear-gradient(180deg, #060919 0%, #0f1738 55%, #1c2854 100%);
}

body.play-mode {
  transition: none;
}

.play-only { display: none !important; }
body.play-mode .play-only { display: flex !important; }
body.play-mode .build-only,
body.play-mode .bottom-dock,
body.play-mode .delete-banner,
body.play-mode .line-banner,
body.play-mode .prefab-banner,
body.play-mode .touch-confirm-bar {
  display: none !important;
}

#canvas-container { position: fixed; inset: 0; width: 100%; height: 100%; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* TOP BAR */
.top-bar {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-group, .action-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: auto;
  align-items: center;
}

.counter-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
  border-radius: 20px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  color: #2b2d42;
}

/* LINE / AREA TOOL PILL */
.tool-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  border-radius: 18px;
  padding: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 48px;
}
.tool-sub-btn {
  border: none;
  background: transparent;
  color: #334155;
  font-weight: 800;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.tool-sub-btn.active {
  background: #0ea5e9;
  color: #ffffff;
  box-shadow: 0 2px 0 #0284c7;
}

/* HEIGHT & SLICE CONTROLS */
.height-pill, .slice-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  border-radius: 18px;
  padding: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
}
.mini-round-btn {
  width: 32px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: #3b82f6;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 3px 0 #1d4ed8;
}
.mini-round-btn.mini-teal {
  background: #0d9488;
  box-shadow: 0 3px 0 #0f766e;
}
.mini-round-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1d4ed8; }
.height-val-btn, .slice-val-btn {
  border: none;
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 800;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 56px;
  white-space: nowrap;
}
.slice-val-btn.active {
  background: #99f6e4;
  color: #0f766e;
}

/* CHUNKY BUTTONS */
.toy-btn {
  appearance: none;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  min-width: 48px;
  height: 48px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.24), 0 6px 12px rgba(0, 0, 0, 0.14);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.toy-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.24); }
.toy-btn svg { width: 22px; height: 22px; flex-shrink: 0; }

.btn-blue   { background: #0077e6; }
.btn-yellow { background: #ffb703; color: #2b2d42; }
.btn-green  { background: #16a34a; }
.btn-red    { background: #e63946; }
.btn-purple { background: #7c3aed; }
.btn-teal   { background: #0d9488; }
.btn-orange { background: #ea580c; }
.btn-hero   { background: linear-gradient(135deg, #ec4899, #8b5cf6); font-size: 15px; }
.btn-prefab { background: linear-gradient(135deg, #0284c7, #16a34a); font-size: 15px; }
.btn-white  { background: #ffffff; color: #2b2d42; }
.btn-play   { background: linear-gradient(135deg, #10b981, #059669); font-size: 15px; padding: 0 14px; }
.btn-stop   { background: linear-gradient(135deg, #f97316, #ea580c); font-size: 15px; padding: 0 14px; }
.btn-citizens { background: #ffffff; color: #334155; font-size: 13px; padding: 0 12px; }
.btn-citizens.active-toggle { background: #dcfce7; border-color: #16a34a; color: #166534; outline: 3px solid #4ade80; }

/* PLAY MODE HUD */
.play-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sim-clock-wrap {
  position: relative;
}
.sim-clock-pill {
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  border-radius: 18px;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
}
.clock-readout-btn {
  border: none;
  background: #f1f5f9;
  color: #0f172a;
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.clock-readout-btn:hover { background: #e2e8f0; }
.clock-phase-badge {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  background: #ffffff;
  padding: 2px 6px;
  border-radius: 8px;
}
.sim-speed-group {
  display: flex;
  align-items: center;
  gap: 3px;
}
.speed-btn {
  border: none;
  background: transparent;
  color: #334155;
  font-weight: 800;
  font-size: 13px;
  padding: 7px 9px;
  border-radius: 11px;
  cursor: pointer;
}
.speed-btn:hover { background: #f1f5f9; }
.speed-btn.active {
  background: #0ea5e9;
  color: #ffffff;
  box-shadow: 0 2px 0 #0284c7;
}
.clock-presets-menu {
  position: absolute;
  top: 54px;
  left: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 3px solid #ffffff;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 175px;
  z-index: 30;
}
.clock-presets-menu.open { display: flex; }
.clock-preset-item {
  border: none;
  background: #f8fafc;
  color: #1e293b;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 11px;
  text-align: left;
  cursor: pointer;
}
.clock-preset-item:hover {
  background: #e0f2fe;
  color: #0369a1;
}

.sim-scan-wrap { position: relative; }
.btn-scan-report { font-size: 13px; padding: 0 12px; color: #0f172a; }
.scan-report-menu {
  position: absolute;
  top: 54px;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 3px solid #ffffff;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  padding: 12px 14px;
  display: none;
  flex-direction: column;
  gap: 8px;
  min-width: 260px;
  max-width: 320px;
  z-index: 30;
  color: #1e293b;
  font-size: 13px;
}
.scan-report-menu.open { display: flex; }
.scan-sec-title { font-size: 11px; font-weight: 900; text-transform: uppercase; color: #64748b; letter-spacing: 0.4px; }
.scan-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.scan-chip {
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px 8px;
  font-weight: 800;
  font-size: 12px;
  color: #0f172a;
}
.scan-empty { color: #94a3b8; font-weight: 700; font-size: 12px; }

/* Phase 5: Play Roster & Citizen/Vehicle Inspector */
.play-roster-wrap { position: relative; }
.btn-play-roster { font-size: 13px; padding: 0 11px; color: #0f172a; gap: 5px; }
.roster-count-pill {
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 900;
}
.play-roster-menu {
  position: absolute;
  top: 54px;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 3px solid #ffffff;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 250px;
  max-width: 310px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 32;
}
.play-roster-menu.open { display: flex; }
.roster-sec-title {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.4px;
  margin-top: 4px;
}
.roster-item {
  border: none;
  background: #f8fafc;
  border-radius: 12px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.12s ease;
}
.roster-item:hover { background: #e0f2fe; transform: translateX(2px); }
.roster-item.active { background: #dbeafe; outline: 2px solid #0ea5e9; }
.roster-item-icon { font-size: 18px; flex-shrink: 0; }
.roster-item-info { display: flex; flex-direction: column; min-width: 0; }
.roster-item-name { font-size: 13px; font-weight: 800; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-item-sub { font-size: 11px; font-weight: 700; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.play-inspector-card {
  position: fixed;
  left: 16px;
  bottom: 20px;
  width: 315px;
  max-width: calc(100vw - 32px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border: 3px solid #ffffff;
  border-radius: 20px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.28);
  padding: 12px 14px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 28;
  color: #0f172a;
}
.play-inspector-card.visible { display: flex; }
.insp-header { display: flex; align-items: center; gap: 10px; }
.insp-icon {
  font-size: 26px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.insp-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.insp-title { font-size: 15px; font-weight: 900; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.insp-badge {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 999px;
}
.insp-badge.badge-player { background: #fef3c7; color: #b45309; }
.insp-badge.badge-auto { background: #e0f2fe; color: #0369a1; }
.insp-badge.badge-vehicle { background: #fee2e2; color: #b91c1c; }
.insp-close-btn {
  border: none;
  background: #f1f5f9;
  color: #475569;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
}
.insp-close-btn:hover { background: #e2e8f0; color: #0f172a; }
.insp-status {
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  background: #f8fafc;
  padding: 7px 10px;
  border-radius: 12px;
}
.insp-meta {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  padding: 0 2px;
}
.insp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.insp-action-btn {
  flex: 1;
  min-width: 120px;
  border: none;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: transform 0.12s ease, filter 0.14s ease;
}
.insp-action-btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
.insp-btn-follow { background: #0ea5e9; color: #ffffff; box-shadow: 0 2px 0 #0284c7; }
.insp-btn-follow.following { background: #eab308; color: #1e293b; box-shadow: 0 2px 0 #ca8a04; }
.insp-btn-nudge { background: #f1f5f9; color: #0f172a; box-shadow: 0 2px 0 #cbd5e1; }
@media (max-width: 780px) {
  .play-inspector-card { left: 10px; right: 10px; bottom: 12px; width: auto; }
  .play-roster-menu { right: -40px; min-width: 230px; }
}

.btn-daynight {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1e293b;
}
.btn-daynight.is-night {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: #fde047;
  border-color: #fde047;
}

.toy-btn.active-mode { outline: 4px solid #ffd500; transform: scale(1.05); }
.toy-btn.active-toggle { background: #e0f2fe; border-color: #0284c7; color: #0369a1; outline: 3px solid #38bdf8; }
.rot-badge { background: rgba(0, 0, 0, 0.22); border-radius: 9px; padding: 2px 6px; font-size: 12px; }

/* BANNERS */
.delete-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #e63946;
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(230, 57, 70, 0.4);
  z-index: 9;
  display: none;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.delete-banner.visible { display: flex; }

.line-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #0284c7;
  color: #ffffff;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.45);
  z-index: 9;
  display: none;
  pointer-events: none;
}
.line-banner.visible { display: flex; }

.prefab-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f766e;
  color: #ffffff;
  padding: 7px 14px 7px 18px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.45);
  z-index: 9;
  display: none;
  align-items: center;
  gap: 10px;
  border: 2px solid #ffffff;
}
.prefab-banner.visible { display: flex; }
.banner-cancel-btn {
  border: none;
  background: #e63946;
  color: #fff;
  border-radius: 12px;
  padding: 6px 11px;
  font-weight: 800;
  cursor: pointer;
}

/* TOUCH PREVIEW CONFIRM BAR */
.touch-confirm-bar {
  position: fixed;
  bottom: 186px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 8px 12px 8px 16px;
  border-radius: 22px;
  border: 3px solid #38bdf8;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 12;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
.touch-confirm-bar.visible { display: flex; }
.touch-place-btn {
  border: none;
  background: #16a34a;
  color: #ffffff;
  border-radius: 14px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #15803d;
}
.touch-place-btn:active { transform: translateY(2px); }

/* BOTTOM DOCK */
.bottom-dock {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 1020px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 3px solid rgba(255, 255, 255, 0.98);
  border-radius: 26px;
  padding: 8px 12px 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 10;
}

.category-row, .color-row {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding: 3px 2px;
}
.category-row::-webkit-scrollbar, .color-row::-webkit-scrollbar { height: 5px; }
.category-row::-webkit-scrollbar-thumb, .color-row::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 10px;
}

.cat-pill {
  appearance: none;
  border: 2px solid #cbd5e1;
  background: #f1f5f9;
  color: #334155;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.cat-pill.active {
  background: #0077e6;
  color: #ffffff;
  border-color: #005bb5;
  box-shadow: 0 3px 0 #004c99;
}

.color-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), inset 0 -4px 0 rgba(0,0,0,0.18), inset 0 4px 4px rgba(255,255,255,0.35);
  cursor: pointer;
  position: relative;
}
.color-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: inherit;
  box-shadow: 0 2px 3px rgba(0,0,0,0.28), inset 0 2px 2px rgba(255,255,255,0.4);
}
.color-btn.selected { transform: translateY(-3px) scale(1.15); outline: 4px solid #2b2d42; }

.brick-scroll-wrap { display: flex; align-items: center; gap: 6px; }
.scroll-arrow-btn {
  width: 38px;
  height: 62px;
  flex-shrink: 0;
  border-radius: 14px;
  border: 2px solid #cbd5e1;
  background: #e2e8f0;
  color: #1e293b;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #94a3b8;
}
.scroll-arrow-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #94a3b8; }

.brick-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 6px;
  scroll-behavior: smooth;
}
.brick-row::-webkit-scrollbar { height: 7px; }
.brick-row::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 10px; }
.brick-row::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 10px; }

.brick-btn {
  min-width: 78px;
  height: 64px;
  border-radius: 16px;
  border: 3px solid #e2e8f0;
  background: #f8fafc;
  box-shadow: 0 4px 0 #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}
.brick-btn span { font-size: 11px; font-weight: 800; color: #334155; white-space: nowrap; }
.brick-btn.selected { background: #fffbeb; border-color: #ffb703; box-shadow: 0 4px 0 #d97706; transform: translateY(-2px); }
.brick-btn svg { width: 44px; height: 32px; }

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 22px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
  border: 4px solid #ffd500;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.modal-card.modal-wide { max-width: 520px; }
.modal-card.modal-xl { max-width: 920px; text-align: left; }
.modal-card h2 { margin: 0 0 8px; font-size: 22px; color: #1e293b; }
.modal-card p { margin: 0 0 16px; color: #64748b; font-weight: 600; font-size: 14px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .toy-btn { flex: 1; height: 52px; font-size: 16px; }

.size-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.size-option-btn {
  border: 3px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 18px;
  padding: 12px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 4px 0 #cbd5e1;
  font-family: inherit;
}
.size-option-btn.active { border-color: #0d9488; background: #f0fdfa; box-shadow: 0 4px 0 #0f766e; }
.size-option-btn strong { font-size: 17px; color: #0f172a; }
.size-option-btn span { font-size: 13px; font-weight: 700; color: #475569; }

.save-input-row { display: flex; gap: 8px; margin-bottom: 14px; }
.save-input-row input, .char-name-input {
  flex: 1;
  border: 3px solid #cbd5e1;
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.saves-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; text-align: left; }
.save-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px 12px;
  gap: 8px;
}
.save-item-info strong { display: block; color: #1e293b; font-size: 15px; }
.save-item-info small { color: #64748b; font-weight: 600; }
.save-item-btns { display: flex; gap: 6px; }
.mini-btn { border: none; border-radius: 10px; padding: 8px 12px; font-weight: 800; cursor: pointer; color: #fff; }

/* PREFABS MODAL */
.prefab-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.prefab-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}
.prefab-subcats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  margin-top: -4px;
  margin-bottom: 10px;
  background: #f1f5f9;
  border-radius: 14px;
}
.prefab-subcats .cat-pill {
  padding: 5px 11px;
  font-size: 12px;
}
.prefab-layout {
  display: flex;
  gap: 14px;
  flex: 1;
  overflow: hidden;
  min-height: 320px;
}
.prefab-grid {
  flex: 1.25;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 9px;
  overflow-y: auto;
  padding-right: 4px;
  align-content: start;
}
.prefab-card {
  border: 3px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 16px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  box-shadow: 0 3px 0 #cbd5e1;
}
.prefab-card.active {
  border-color: #0284c7;
  background: #e0f2fe;
  box-shadow: 0 3px 0 #0369a1;
}
.prefab-card-icon { font-size: 28px; }
.prefab-card strong { font-size: 13px; color: #0f172a; }
.prefab-card small { font-size: 11px; color: #64748b; font-weight: 700; }

.prefab-sidebar {
  flex: 1;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.prefab-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.p-opt-group { display: flex; flex-direction: column; gap: 6px; }
.p-opt-label { font-size: 12px; font-weight: 900; text-transform: uppercase; color: #64748b; }
.p-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.p-pill {
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.p-pill.active {
  background: #0284c7;
  border-color: #0369a1;
  color: #ffffff;
}
.prefab-summary {
  background: #e0f2fe;
  color: #0c4a6e;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}
.prefab-size-warn {
  background: #fef2f2;
  border: 2px solid #fecaca;
  color: #991b1b;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* CHARACTER CREATOR OVERLAY */
.creator-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #0f172a 100%);
  z-index: 40;
  display: none;
  flex-direction: column;
}
.creator-overlay.open { display: flex; }

.creator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  gap: 10px;
  flex-wrap: wrap;
}
.creator-title { color: #fff; font-size: 21px; font-weight: 900; }
.char-name-input { max-width: 190px; }

.creator-body { flex: 1; display: flex; overflow: hidden; gap: 12px; padding: 12px; }
.creator-stage {
  flex: 1;
  min-width: 260px;
  background: radial-gradient(circle at center, rgba(129, 140, 248, 0.35), rgba(15, 23, 42, 0.8));
  border-radius: 26px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#creator-canvas-wrap { flex: 1; width: 100%; height: 100%; }

.preset-bar {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.32);
  align-items: center;
}
.preset-label { color: #cbd5e1; font-size: 12px; font-weight: 800; white-space: nowrap; }
.preset-chip {
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 14px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.preset-chip:hover { background: rgba(255, 255, 255, 0.25); }
.preset-chip.active { background: #7c3aed; border-color: #c4b5fd; }

.creator-panel {
  width: 470px;
  max-width: 54%;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.creator-tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  background: #f1f5f9;
  overflow-x: auto;
  border-bottom: 2px solid #e2e8f0;
}
.ctab-btn {
  border: 2px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 14px;
  padding: 8px 11px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ctab-btn.active { background: #7c3aed; color: #fff; border-color: #5b21b6; }

.creator-controls {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ctrl-section-title {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}
.part-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.part-pill {
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 12px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  color: #1e293b;
}
.part-pill.active { background: #ffb703; border-color: #d97706; }

.swatch-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.swatch-btn.active { outline: 3px solid #0f172a; transform: scale(1.12); }

.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.opt-card {
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 14px;
  padding: 9px 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1e293b;
}
.opt-card.active { background: #ede9fe; border-color: #7c3aed; color: #4c1d95; }

#error-overlay {
  position: fixed;
  inset: 0;
  background: #1e293b;
  color: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 100;
}

@media (max-width: 1180px) {
  .delete-banner, .line-banner, .prefab-banner { top: 118px; }
}

@media (max-width: 780px) {
  .creator-body { flex-direction: column; }
  .creator-panel { width: 100%; max-width: 100%; height: 54%; }
  .creator-stage { min-height: 210px; }
  .prefab-layout { flex-direction: column; }
  .prefab-grid { max-height: 170px; }
  .btn-text-hide-sm { display: none; }
  .toy-btn { min-width: 44px; height: 44px; padding: 0 8px; }
  .touch-confirm-bar { bottom: 178px; font-size: 13px; }
}