html, body {
      margin: 0;
      padding: 0;
      font-family: 'Inter', system-ui, sans-serif;
      background-color: #020617;
      color: #f8fafc;
      overflow-x: clip;
    }

    #viewport {
      width: 100%;
      height: 100%;
      min-height: 360px;
    }

    #sketchCanvas {
      touch-action: none;
    }

    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }
    ::-webkit-scrollbar-track {
      background: #0f172a;
    }
    ::-webkit-scrollbar-thumb {
      background: #334155;
      border-radius: 9999px;
    }
    ::-webkit-scrollbar-thumb:hover {
      background: #475569;
    }

    input[type="range"] {
      -webkit-appearance: none;
      appearance: none;
      background: #1e293b;
      height: 6px;
      border-radius: 9999px;
      outline: none;
    }
    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: #38bdf8;
      cursor: pointer;
      border: 2px solid #0f172a;
      box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
      transition: transform 0.15s ease;
    }
    input[type="range"]::-webkit-slider-thumb:hover {
      transform: scale(1.15);
    }
    input[type="color"] {
      -webkit-appearance: none;
      border: none;
      padding: 0;
      background: none;
      cursor: pointer;
    }
    input[type="color"]::-webkit-color-swatch-wrapper {
      padding: 0;
    }
    input[type="color"]::-webkit-color-swatch {
      border: 1px solid #334155;
      border-radius: 0.375rem;
    }

    /* ---------- MOBILE LAYOUT ---------- */
    @media (max-width: 767px) {
      /* 3D view on top, pinned while the controls scroll underneath */
      #appMain { position: sticky; top: 0; z-index: 30; height: 44dvh; min-height: 280px; flex: none; border-bottom: 1px solid #1e293b; }
      #viewport { min-height: 0; }
      #controlsAside { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
      #controlsAside > .sticky { position: static; }
      /* Download button always reachable at the bottom of the screen */
      #downloadBar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
      /* 16px stops iPhone from zooming in when a field is tapped */
      input[type="text"], textarea, select { font-size: 16px !important; }
      /* Keep the 3D view clear: fewer stats, one scrollable row of view buttons */
      .hud-extra { display: none !important; }
      #hudBar { flex-direction: column; align-items: stretch; top: 8px; left: 8px; right: 8px; }
      #camBar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
      #camBar::-webkit-scrollbar { display: none; }
      #camBar button { flex: none; }
      #toast { bottom: calc(80px + env(safe-area-inset-bottom)); max-width: 92vw; text-align: center; }
      #buildingBadge { bottom: 8px; left: 8px; }
    }
    /* Bigger touch targets on phones and tablets */
    @media (pointer: coarse) {
      input[type="range"] { height: 8px; }
      input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; }
      input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; }
      input[type="checkbox"] { width: 22px; height: 22px; }
      button { touch-action: manipulation; }
    }
  
    [data-tool-off] { display: none !important; }
