:root {
      --bg: #0f1115;
      --panel: #181c23;
      --panel-2: #222834;
      --text: #edf2f7;
      --muted: #a0aec0;
      --accent: #7dd3fc;
      --border: #2f3745;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: linear-gradient(180deg, #0c1016 0%, #111827 100%);
      color: var(--text);
    }
    .wrap {
      max-width: 1400px;
      margin: 0 auto;
      padding: 24px;
    }
    h1 {
      margin: 0 0 8px;
      font-size: 32px;
    }
    p, li {
      color: var(--muted);
      line-height: 1.5;
    }
    .grid {
      display: grid;
      grid-template-columns: 360px 1fr;
      gap: 20px;
      align-items: start;
    }
    .panel {
      background: rgba(24, 28, 35, 0.95);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 18px;
      box-shadow: 0 12px 28px rgba(0,0,0,0.24);
    }
    .panel h2 {
      margin-top: 0;
      margin-bottom: 14px;
      font-size: 18px;
    }
    .hidden { display: none !important; }
    .section-subhead {
      margin: 6px 0 10px;
      font-size: 13px;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .terrain-heading {
      margin-top: 20px !important;
      margin-bottom: 24px !important;
    }
    button:disabled {
      cursor: not-allowed;
      opacity: 0.55;
      transform: none;
    }
    .field {
      margin-bottom: 14px;
    }
    label {
      display: block;
      font-weight: 600;
      margin-bottom: 6px;
    }
    input[type="file"], select, button, input[type="range"], input[type="number"] {
      width: 100%;
    }
    button {
      border: 0;
      padding: 12px 14px;
      border-radius: 12px;
      cursor: pointer;
      font-weight: 700;
      background: #2b3442;
      color: var(--text);
      transition: transform .12s ease, opacity .12s ease;
      margin-bottom: 10px;
    }
    button:hover { transform: translateY(-1px); }
    button.primary {
      background: linear-gradient(90deg, #2563eb, #0891b2);
    }
    button.secondary {
      background: linear-gradient(90deg, #374151, #1f2937);
    }
    button.process-ready {
      background: linear-gradient(90deg, #16a34a, #059669);
    }
    button.download-ready {
      background: linear-gradient(90deg, #2563eb, #0891b2);
    }
    .small {
      font-size: 13px;
      color: var(--muted);
    }
    #existingMapSandNote {
      margin: 4px 0 14px;
    }
    .source-map-preview {
      margin-top: 14px;
      padding-top: 12px;
      border-top: 1px solid var(--border);
    }
    .preview-subhead {
      margin: 0 0 10px;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .terrain-list {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .terrain-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: #131923;
    }
    .swatch {
      width: 16px;
      height: 16px;
      border-radius: 4px;
      border: 1px solid rgba(255,255,255,.2);
      flex: none;
    }
    .row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .row-3 {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 10px;
    }
    .canvas-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(240px, 1fr));
      gap: 16px;
    }
    .canvas-card {
      background: #11161f;
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 14px;
    }
    .canvas-card h3 {
      margin: 0 0 10px;
      font-size: 15px;
    }
    canvas {
      width: 100%;
      background: #0b0f14;
      border-radius: 12px;
      border: 1px solid #293140;
    }
    canvas.pixelated {
      image-rendering: pixelated;
    }
    .status {
      padding: 10px 12px;
      border-radius: 12px;
      background: #11161f;
      border: 1px solid var(--border);
      color: var(--muted);
      white-space: pre-wrap;
    }
    #existingMapSandNote {
      margin-bottom: 14px;
    }
    .changelog {
      margin-top: 14px;
      padding: 12px;
      border-radius: 12px;
      background: #11161f;
      border: 1px solid var(--border);
      color: var(--muted);
    }
    .changelog pre {
      margin: 8px 0 0;
      white-space: pre-wrap;
      font: inherit;
      color: inherit;
    }
    .pill {
      display: inline-block;
      font-size: 12px;
      padding: 3px 8px;
      border-radius: 999px;
      background: #12202c;
      border: 1px solid #21445d;
      color: #b6e3ff;
      margin-right: 6px;
    }
    .footer-note {
      margin-top: 14px;
      padding: 12px;
      border-radius: 12px;
      background: rgba(17,22,31,.75);
      border: 1px dashed var(--border);
    }
    details.advanced-panel {
      margin-top: 12px;
      margin-bottom: 34px;
      border: 1px solid var(--border);
      border-radius: 14px;
      background: #11161f;
      overflow: hidden;
    }
    .cta-link {
      display: block;
      width: 100%;
      text-align: center;
      text-decoration: none;
      border: 0;
      padding: 12px 14px;
      border-radius: 12px;
      cursor: pointer;
      font-weight: 700;
      background: linear-gradient(90deg, #f59e0b, #f97316);
      color: #111827;
      transition: transform .12s ease, opacity .12s ease;
      margin-bottom: 10px;
    }
    .cta-link:hover { transform: translateY(-1px); }
    .cta-link.reddit {
      background: linear-gradient(90deg, #4b5563, #374151);
      color: #f3f4f6;
    }
    .layer-input-stack {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .layer-file {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .layer-caption {
      font-size: 12px;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .layer-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 12px;
    }
    .layer-grid.dual-enabled {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    #sourceMapLayerGrid.dual-enabled {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .layer-slot {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .layer-toggle {
      margin-top: 2px;
    }
    .download-wrap {
      margin-top: 12px;
    }
    .modal.hidden { display: none; }
    .modal {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.6);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      z-index: 1000;
    }
    .modal-card {
      width: min(460px, 100%);
      background: rgba(24, 28, 35, 0.98);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 20px;
      box-shadow: 0 20px 40px rgba(0,0,0,.35);
    }
    .modal-card h3 {
      margin: 0 0 10px;
      font-size: 22px;
    }
    .modal-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-top: 16px;
    }
    .modal-actions .cta-link,
    .modal-actions button {
      margin-bottom: 0;
    }
    details.advanced-panel summary {
      cursor: pointer;
      padding: 12px 14px;
      font-weight: 700;
      list-style: none;
    }
    details.advanced-panel summary::-webkit-details-marker {
      display: none;
    }
    .advanced-body {
      padding: 0 14px 14px;
      border-top: 1px solid var(--border);
    }
    .terrain-advanced-list {
      display: grid;
      gap: 10px;
    }
    .terrain-advanced-item {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 10px;
      background: #131923;
    }
    .terrain-advanced-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;
      font-weight: 700;
    }
    .advanced-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px 10px;
    }
    .advanced-field {
      margin: 0;
    }
    .advanced-field label {
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 4px;
      color: var(--muted);
    }
    a { color: #93c5fd; }

    .geo-map-shell {
      position: relative;
      height: 430px;
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid #293140;
      background: #0b0f14;
      margin-top: 10px;
    }
    #geoMap {
      position: absolute;
      inset: 0;
    }
    .geo-selection-square {
      position: absolute;
      width: 64%;
      aspect-ratio: 1 / 1;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      border: 2px solid rgba(147, 197, 253, 0.95);
      box-shadow: 0 0 0 9999px rgba(4, 10, 18, 0.32), 0 0 0 1px rgba(255,255,255,0.12) inset;
      border-radius: 8px;
      pointer-events: none;
      z-index: 500;
    }
    .geo-selection-square::before,
    .geo-selection-square::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      background: rgba(147, 197, 253, 0.9);
    }
    .geo-selection-square::before { width: 26px; height: 1px; }
    .geo-selection-square::after { width: 1px; height: 26px; }
    .geo-selection-square.hemispheres { width: 82%; aspect-ratio: 2 / 1; }
    .geo-help { margin-top: 10px; }
    .geo-info-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-top: 10px;
    }
    .geo-info-card {
      padding: 8px 10px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: #131923;
      font-size: 12px;
      color: var(--muted);
    }
    .mapping-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      margin-top: 10px;
    }
    .mapping-item {
      padding: 10px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: #131923;
    }
    .mapping-item label {
      margin-bottom: 4px;
      font-size: 13px;
    }
    .preview-geo .canvas-grid {
      grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
    }
    .preview-geo .canvas-card.processed-card {
      display: none;
    }
    .mode-note {
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: #11161f;
      color: var(--muted);
      font-size: 13px;
      margin-bottom: 14px;
    }
    .radio-group {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }
    .radio-option {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: #131923;
      font-weight: 600;
      margin-bottom: 0;
    }
    .radio-option input[type="radio"] {
      width: auto;
      margin: 0;
      accent-color: #7dd3fc;
    }

    .title-row {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 8px;
    }
    .title-row h1 {
      margin: 0;
      display: flex;
      align-items: baseline;
      gap: 0.2em;
      flex-wrap: wrap;
    }
    .title-icon {
      width: 30px;
      height: 30px;
      image-rendering: auto;
      flex: 0 0 auto;
      transform: translateY(-1px);
    }
    .title-muted {
      color: #c4cad3;
    }
    .leaflet-control-attribution { font-size: 10px; }
    @media (max-width: 1050px) {
      .grid { grid-template-columns: 1fr; }
      .canvas-grid { grid-template-columns: 1fr; }
    }


.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
