  :root {
    --bg: #05070d;
    --bg-2: #0b1020;
    --panel: #111522;
    --panel-2: #171c2a;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --text: #f5f7fb;
    --muted: #9aa3b7;
    --accent: #f35ac7;
    --accent-2: #6fdaf5;
    --good: #8fffc1;
    --dark-chip: rgba(255, 255, 255, 0.03);
    --mint-text: #0a0a10;

    --btn-controls-a: #15e85a;
    --btn-controls-b: #ece63a;
    --btn-mint-a: #f85bbf;
    --btn-mint-b: #67d7f2;
    --btn-generate-a: #ffd94c;
    --btn-generate-b: #f06292;

    --btn-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
    --btn-shadow-strong: 0 18px 42px rgba(0, 0, 0, 0.34);
  }

  * {
    box-sizing: border-box;
  }

  html,
  body {
    margin: 0;
    height: 100%;
    background:
      radial-gradient(circle at top, rgba(121, 230, 255, 0.08), transparent 28%),
      radial-gradient(
        circle at 20% 20%,
        rgba(255, 90, 214, 0.08),
        transparent 30%
      ),
      linear-gradient(180deg, var(--bg-2), var(--bg));
    color: var(--text);
    font-family:
      Inter,
      ui-sans-serif,
      system-ui,
      -apple-system,
      BlinkMacSystemFont,
      "Segoe UI",
      sans-serif;
  }

  body {
    min-height: 100vh;
  }


/* =========================
   PRELOAD OVERLAY
   ========================= */

.preload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(111, 218, 245, 0.12), transparent 30%),
    radial-gradient(circle at bottom, rgba(243, 90, 199, 0.12), transparent 30%),
    #05070d;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.preload-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.preload-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preload-panel {
  width: min(100%, 560px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 24px 22px;
  background: rgba(10, 14, 24, 0.88);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    0 0 40px rgba(111, 218, 245, 0.08);
  backdrop-filter: blur(12px);
}

.preload-kicker {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9aa3b7;
  margin-bottom: 10px;
}

.preload-title {
  margin: 0 0 6px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: #f5f7fb;
}

.preload-subtitle {
  font-size: 13px;
  color: #9aa3b7;
  margin-bottom: 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preload-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 12px;
}

.preload-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f35ac7 0%, #6fdaf5 100%);
  transition: width 0.2s ease;
}

.preload-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #c8d0df;
  margin-bottom: 16px;
}

.preload-log {
  margin: 0;
  padding: 14px;
  min-height: 120px;
  max-height: 180px;
  overflow: auto;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #8fffc1;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  .preload-panel {
    padding: 20px 18px;
    border-radius: 18px;
  }

  .preload-log {
    min-height: 96px;
    max-height: 140px;
    font-size: 11px;
  }
}


  .app {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.01)
    );
    border-right: 1px solid var(--line);
    padding: 16px;
    overflow-y: auto;
    backdrop-filter: blur(12px);
    z-index: 4;
  }

  .brand,
  .section,
  .artifact-panel {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.01)
    );
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  }

  .brand {
    padding: 16px;
    margin-bottom: 14px;
    background: linear-gradient(
      180deg,
      rgba(255, 90, 214, 0.08),
      rgba(121, 230, 255, 0.04)
    );
  }

  .kicker {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
  }

  h1 {
    margin: 8px 0 6px;
    font-size: 24px;
    line-height: 1.05;
  }

  .sub {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
  }

  .section {
    margin-top: 14px;
    padding: 14px;
  }

  .section h2 {
    margin: 0 0 12px;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .control {
    margin-bottom: 0;
  }

  .section .control + .control {
    margin-top: 14px;
  }

  .label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 12px;
    font-size: 13px;
  }

  .value {
    color: var(--accent-2);
    font-variant-numeric: tabular-nums;
  }

  input[type="range"] {
    width: 100%;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
      90deg,
      rgba(255, 90, 214, 0.6),
      rgba(121, 230, 255, 0.6)
    );
    outline: none;
  }

  input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #121420;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    cursor: pointer;
  }

  select,
  button {
    width: 100%;
    font-size: 14px;
  }

  select {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 18px;
    padding: 12px 14px;
  }

  button {
    border: none;
    border-radius: 22px;
    padding: 16px 18px;
    color: var(--text);
    background: var(--panel-2);
    cursor: pointer;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition:
      transform 0.16s ease,
      box-shadow 0.16s ease,
      filter 0.16s ease,
      opacity 0.14s ease,
      background 0.16s ease;
  }

  button:hover {
    transform: translateY(-1px);
    box-shadow: var(--btn-shadow);
    filter: saturate(1.03);
  }

  button:active {
    transform: translateY(0);
  }

  button:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.72);
    outline-offset: 2px;
  }

  button.primary {
    background: linear-gradient(
      90deg,
      rgba(248, 91, 191, 0.24),
      rgba(103, 215, 242, 0.18)
    );
  }

  button.ghost {
    background: rgba(255, 255, 255, 0.04);
  }

  button.mint,
  button.mint-main {
    background: linear-gradient(90deg, var(--btn-mint-a), var(--btn-mint-b));
    color: var(--mint-text);
    box-shadow: var(--btn-shadow);
  }

  button.shuffle-main,
  button.generate-btn {
    background: linear-gradient(
      90deg,
      var(--btn-generate-a),
      var(--btn-generate-b)
    );
    color: var(--mint-text);
    box-shadow: var(--btn-shadow);
  }

  button.controls-btn,
  button#toggleControls {
    background: linear-gradient(
      90deg,
      var(--btn-controls-a),
      var(--btn-controls-b)
    );
    color: var(--mint-text);
    box-shadow: var(--btn-shadow);
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .button-row.single-row {
    grid-template-columns: 1fr;
    margin-top: 10px;
  }

  .preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .preset-grid button {
    min-height: 54px;
    text-align: left;
    font-size: 12px;
    line-height: 1.25;
    text-transform: none;
    letter-spacing: 0;
  }

  .main {
    position: relative;
    min-width: 0;
    height: 100vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    overflow: hidden;
  }

  .mobile-bar {
    display: none;
  }

  .topbar {
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(5, 7, 13, 0.38);
    backdrop-filter: blur(10px);
    min-height: 62px;
  }

  .stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .stat {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--dark-chip);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .stat .ok,
  .ok {
    color: var(--good);
  }

  .stat.dim {
    opacity: 0.8;
  }

  .stat.clickable {
    cursor: pointer;
  }

  .stage-wrap {
    min-height: 0;
    padding: 12px 18px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  .stage {
    width: min(100%, 920px);
    max-height: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    background: #050507;
    position: relative;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  }

  canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #0b0b12;
    transition: opacity 0.12s ease;
  }

  .decision-bar {
    width: min(100%, 920px);
    margin: 0 auto;
    padding: 0 18px 12px;
    display: grid;
    grid-template-columns: 1fr 1.18fr;
    gap: 12px;
    align-items: center;
  }

  .decision-bar button {
    min-height: 58px;
    width: 100%;
    text-align: center;
  }

  .mint-main {
    opacity: 0.95;
  }

  .shuffle-main {
    min-height: 64px;
    font-size: 15px;
    letter-spacing: 0.1em;
    transform: scale(1.01);
    box-shadow: var(--btn-shadow-strong);
  }

  .shuffle-main:hover {
    transform: translateY(-1px) scale(1.02);
  }

  .artifact-panel {
    margin: 0 18px 10px;
    padding: 10px 12px;
  }

  .artifact-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
  }

  .artifact-item {
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
  }

  .artifact-item span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 5px;
  }

  .artifact-item strong {
    display: block;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .footer {
    padding: 0 18px 10px;
    color: var(--muted);
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }

  /* desktop floating controls */
  @media (min-width: 981px) {
    .mobile-bar {
      display: block;
      position: absolute;
      top: 78px;
      right: 28px;
      z-index: 30;
      width: auto;
      pointer-events: none;
    }

    .mobile-bar button {
      width: auto;
      min-height: 0;
      padding: 9px 13px;
      border-radius: 999px;
      font-size: 11px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      background: rgba(7, 10, 18, 0.54);
      color: #eef6ff;
      border: 1px solid rgba(255, 255, 255, 0.14);
      box-shadow: none;
      backdrop-filter: blur(10px);
      opacity: 0.9;
      pointer-events: auto;
    }

    .mobile-bar button:hover {
      transform: translateY(-1px);
      background: rgba(7, 10, 18, 0.72);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
      filter: none;
      opacity: 1;
    }
  }

  @media (max-width: 1280px) {
    .artifact-grid {
      grid-template-columns: repeat(3, 1fr);
    }

    .stage {
      width: min(100%, 860px);
    }
  }

  @media (max-width: 980px) {
    html,
    body {
      height: auto;
      min-height: 100%;
    }

    .app {
      display: flex;
      flex-direction: column;
      height: auto;
      overflow: visible;
    }

    .main {
      order: 1;
      display: flex;
      flex-direction: column;
      height: auto;
      overflow: visible;
    }

    .sidebar {
      order: 2;
      border-right: 0;
      border-top: 1px solid var(--line);
      max-height: none;
      display: none;
    }

    .sidebar.open {
      display: block;
    }

    .mobile-bar {
      display: block;
      order: 2;
      position: static;
      width: min(100%, 720px);
      margin: 0 auto 14px;
      padding: 10px 12px 0;
      pointer-events: auto;
    }

    .mobile-bar button {
      width: 100%;
      min-height: 58px;
      padding: 16px 18px;
      border-radius: 22px;
      font-size: 14px;
      background: linear-gradient(
        90deg,
        var(--btn-controls-a),
        var(--btn-controls-b)
      );
      color: var(--mint-text);
      border: none;
      box-shadow: var(--btn-shadow);
      opacity: 1;
    }

    .topbar {
      order: 3;
      min-height: 0;
      padding: 12px 10px;
    }

    .stage-wrap {
      order: 1;
      padding: 10px 10px 12px;
      min-height: auto;
    }

    .stage {
      width: 100%;
      border-radius: 20px;
    }

    .decision-bar {
      order: 2;
      width: 100%;
      padding: 0 10px 12px;
      grid-template-columns: 1fr;
      gap: 12px;
    }

    .decision-bar button {
      min-height: 56px;
    }

    .shuffle-main {
      min-height: 56px;
      font-size: 14px;
      transform: none;
    }

    .shuffle-main:hover {
      transform: translateY(-1px);
    }

    .artifact-panel {
      order: 4;
      margin: 0 10px 12px;
    }

    .artifact-grid {
      grid-template-columns: repeat(2, 1fr);
    }

    .footer {
      order: 5;
      padding: 0 10px 14px;
      font-size: 12px;
    }
  }

  @media (max-width: 640px) {
    .sidebar {
      padding: 12px;
    }

    .section .control + .control {
      margin-top: 12px;
    }

    .stats {
      gap: 6px;
    }

    .stat {
      font-size: 11px;
      padding: 7px 9px;
    }

    .artifact-grid {
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    .artifact-item {
      padding: 9px 10px;
    }

    .artifact-item strong {
      font-size: 13px;
    }

    .button-row {
      grid-template-columns: 1fr;
    }

    .preset-grid {
      grid-template-columns: 1fr 1fr;
    }

    .decision-bar button,
    .mobile-bar button {
      min-height: 56px;
      padding: 14px;
      font-size: 13px;
      letter-spacing: 0.07em;
    }
  }

  @media (min-width: 981px) {
    .sidebar {
      display: block;
      width: 320px;
      min-width: 320px;
      transition:
        width 0.22s ease,
        min-width 0.22s ease,
        padding 0.22s ease,
        opacity 0.18s ease,
        border-color 0.18s ease;
    }

    .sidebar:not(.open) {
      width: 0;
      min-width: 0;
      padding-left: 0;
      padding-right: 0;
      border-right-color: transparent;
      overflow: hidden;
      opacity: 0;
    }

    .app {
      grid-template-columns: auto minmax(0, 1fr);
    }
  }

  /* =========================
     DESKTOP BUTTON HIERARCHY
     MINT > GENERATE > CONTROL
     ========================= */

  @media (min-width: 981px) {
    .decision-bar {
      grid-template-columns: 1.38fr 0.82fr;
      gap: 14px;
    }

    .mint-main {
      min-height: 54px;
      font-size: 14px;
      letter-spacing: 0.12em;
      transform: none;
      opacity: 1;
      filter: saturate(1.08) brightness(1.02);
      box-shadow: 0 22px 54px rgba(0, 0, 0, 0.48);
    }

    .mint-main:hover {
      transform: translateY(-1px);
      filter: saturate(1.12) brightness(1.04);
      box-shadow: 0 24px 58px rgba(0, 0, 0, 0.52);
    }

    .shuffle-main {
      min-height: 54px;
      font-size: 14px;
      letter-spacing: 0.08em;
      transform: none;
      opacity: 0.88;
      color: rgba(10, 10, 16, 0.92);
      background: linear-gradient(90deg, #d6b84a, #b86a86);
      box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
      filter: saturate(0.72) brightness(0.92);
    }

    .shuffle-main:hover {
      transform: translateY(-1px);
      opacity: 0.95;
      box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
      filter: saturate(0.8) brightness(0.95);
    }

    .mobile-bar button {
      opacity: 0.62;
    }
  }

  /* =========================
     MOBILE POPUP CONTROLS PATCH
     ========================= */

  .mobile-controls-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 40;
  }

  .mobile-controls-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-mobile-head {
    display: block;
  }

  .sidebar-close {
    display: none;
  }

  .floating-controls-btn {
    display: none;
  }

  body.controls-modal-open {
    overflow: hidden;
    touch-action: none;
  }

  @media (max-width: 980px) {
    .mobile-bar {
      display: none !important;
    }

    .floating-controls-btn {
      display: inline-flex;
      position: fixed;
      right: 12px;
      bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
      z-index: 60;
      width: auto;
      min-height: 44px;
      padding: 0 14px;
      border-radius: 999px;
      align-items: center;
      justify-content: center;
      gap: 8px;
      background: rgba(9, 13, 22, 0.78);
      color: rgba(245, 247, 251, 0.96);
      border: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.035);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.11em;
      text-transform: uppercase;
      transition:
        transform 0.16s ease,
        background 0.16s ease,
        border-color 0.16s ease,
        box-shadow 0.16s ease,
        opacity 0.16s ease;
    }

    .floating-controls-btn::before {
      content: "";
      width: 6px;
      height: 6px;
      margin-right: 0;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      box-shadow: 0 0 10px rgba(243, 90, 199, 0.18);
      flex: 0 0 auto;
    }

    .floating-controls-btn:hover,
    .floating-controls-btn:active {
      transform: translateY(1px);
      background: rgba(11, 16, 27, 0.9);
      border-color: rgba(255, 255, 255, 0.14);
      box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }

    .sidebar {
      display: block;
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      top: auto;
      width: 100%;
      max-width: none;
      height: min(92dvh, 920px);
      padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
      border-top: 1px solid var(--line);
      border-right: 0;
      border-radius: 22px 22px 0 0;
      background: linear-gradient(
        180deg,
        rgba(10, 14, 24, 0.98),
        rgba(7, 10, 18, 0.985)
      );
      box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.45);
      transform: translateY(104%);
      transition: transform 0.24s ease;
      z-index: 50;
      overflow-y: auto;
      overscroll-behavior: contain;
    }

    .sidebar.open {
      display: block;
      transform: translateY(0);
    }

    .sidebar-mobile-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }

    .sidebar-close {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 40px;
      min-width: 40px;
      padding: 0;
      border: 1px solid var(--line-2);
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.03);
      color: var(--text);
      font-size: 18px;
      line-height: 1;
      box-shadow: none;
    }

    .brand {
      padding: 16px;
    }

    .section:last-child {
      margin-bottom: 84px;
    }

    .button-row.single-row {
      position: sticky;
      bottom: 0;
      padding-top: 12px;
      padding-bottom: 2px;
      background: linear-gradient(
        180deg,
        rgba(8, 10, 16, 0),
        rgba(8, 10, 16, 0.98) 34%
      );
      z-index: 2;
    }

    .decision-bar {
      padding-bottom: 92px;
    }
  }

  @media (min-width: 981px) {
    .mobile-controls-overlay {
      display: none;
    }

    .floating-controls-btn {
      display: inline-flex;
      position: absolute;
      top: 78px;
      right: 28px;
      z-index: 30;
      width: auto;
      min-height: 0;
      padding: 9px 13px;
      border-radius: 999px;
      font-size: 11px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      background: rgba(7, 10, 18, 0.54);
      color: #eef6ff;
      border: 1px solid rgba(255, 255, 255, 0.14);
      box-shadow: none;
      backdrop-filter: blur(10px);
      opacity: 0.62;
    }

    .floating-controls-btn::before {
      display: none;
    }

    .floating-controls-btn:hover {
      transform: translateY(-1px);
      background: rgba(7, 10, 18, 0.72);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
      filter: none;
      opacity: 1;
    }
  }
/* =========================
   V1.6 UI REFRAME
   mobile mockup + desktop palette refresh
   ========================= */

:root {
  --bg: #050814;
  --bg-2: #0a0f1f;
  --panel: #0e1424;
  --panel-2: #151c31;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #f6f7fb;
  --muted: #9ba7c0;
  --accent: #ee5bc5;
  --accent-2: #41d8ff;
  --good: #75ffbd;
  --dark-chip: rgba(255, 255, 255, 0.035);
  --mint-text: #08101a;

  --btn-mint-a: #d38bff;
  --btn-mint-b: #ff8fd4;
  --btn-connect-a: #008ff6;
  --btn-connect-b: #17d5ff;
  --btn-generate-a: #ffbe6b;
  --btn-generate-b: #f48d8f;
  --btn-controls-a: #f1ea3f;
  --btn-controls-b: #1fe25a;

  --panel-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --soft-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

html,
body {
  background:
    radial-gradient(circle at 16% 12%, rgba(126, 84, 255, 0.14), transparent 24%),
    radial-gradient(circle at 78% 18%, rgba(0, 215, 255, 0.11), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(255, 79, 179, 0.08), transparent 28%),
    linear-gradient(180deg, #0b1122 0%, #060a14 100%);
}

.brand,
.section,
.artifact-panel,
.topbar,
.stage,
.live-meta {
  box-shadow: var(--panel-shadow);
}

.main {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 0;
  padding: 0 0 8px;
}

.topbar {
  margin: 10px 10px 12px;
  padding: 14px 18px;
  min-height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(22, 27, 48, 0.96), rgba(12, 16, 30, 0.94)),
    linear-gradient(90deg, rgba(255, 92, 197, 0.07), rgba(65, 216, 255, 0.05));
}

.topbar-brand {
  min-width: 0;
}

.topbar-title {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 0.96;
  letter-spacing: -0.03em;
}

.wallet-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 14px;
  line-height: 1.05;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-align: right;
  letter-spacing: 0.01em;
}

.wallet-line {
  display: block;
  white-space: nowrap;
}

.live-meta {
  margin: 0 10px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 20, 36, 0.88), rgba(10, 14, 26, 0.86));
}

.live-meta .stats {
  gap: 10px;
}

.stat {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #aeb8cc;
  font-weight: 600;
}

.stage-wrap {
  padding: 0 10px 14px;
}

.stage {
  width: min(100%, 960px);
  border-radius: 30px;
  border-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(11, 14, 24, 0.98), rgba(7, 9, 16, 1));
}

.decision-bar {
  width: min(100%, 960px);
  padding: 0 10px 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.decision-bar button {
  min-height: 62px;
  border-radius: 18px;
  font-size: 14px;
  letter-spacing: 0.09em;
  color: #08101a;
  box-shadow: var(--soft-shadow);
}

.mint-main,
.connect-main,
.shuffle-main,
.controls-main {
  filter: saturate(1.02);
}

.mint-main {
  background: linear-gradient(90deg, var(--btn-mint-a), var(--btn-mint-b));
}

.connect-main {
  background: linear-gradient(90deg, var(--btn-connect-a), var(--btn-connect-b));
}

.shuffle-main {
  background: linear-gradient(90deg, var(--btn-generate-a), var(--btn-generate-b));
  transform: none;
  opacity: 1;
}

.controls-main {
  background: linear-gradient(90deg, var(--btn-controls-a), var(--btn-controls-b));
}

.shuffle-main:hover,
.mint-main:hover,
.connect-main:hover,
.controls-main:hover {
  transform: translateY(-1px);
  opacity: 1;
  filter: saturate(1.06) brightness(1.02);
}

.artifact-panel {
  margin: 0 10px 10px;
  padding: 12px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(13, 17, 31, 0.92), rgba(8, 12, 23, 0.92));
}

.artifact-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.artifact-item {
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
}

.artifact-item span {
  margin-bottom: 3px;
}

.footer {
  padding: 0 10px 6px;
}

.floating-controls-btn,
.mobile-bar {
  display: none !important;
}

@media (min-width: 981px) {
  .app {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .sidebar {
    padding: 14px;
    background: linear-gradient(180deg, rgba(12, 16, 29, 0.98), rgba(8, 12, 24, 0.98));
  }

  .sidebar:not(.open) {
    width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .topbar {
    margin: 16px 18px 12px;
    padding: 16px 20px;
  }

  .live-meta,
  .artifact-panel,
  .footer {
    margin-left: 18px;
    margin-right: 18px;
  }

  .stage-wrap {
    padding: 0 18px 16px;
  }

  .decision-bar {
    width: min(100%, 1080px);
    padding: 0 18px 18px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .decision-bar button {
    min-height: 58px;
    font-size: 13px;
  }

  .topbar-title {
    font-size: 32px;
  }
}

@media (max-width: 980px) {
  .main {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  }

  .topbar {
    order: 1;
    margin: 4px 4px 10px;
    padding: 12px 14px;
    min-height: 74px;
    border-radius: 16px;
  }

  .topbar .kicker {
    font-size: 10px;
    letter-spacing: 0.16em;
  }

  .topbar-title {
    font-size: 21px;
    line-height: 1;
  }

  .wallet-status {
    font-size: 11px;
    line-height: 1.05;
  }

  .live-meta {
    order: 4;
    margin: 0 4px 8px;
    padding: 10px 10px 8px;
    border-radius: 16px;
  }

  .live-meta .stats {
    gap: 8px;
  }

  .stage-wrap {
    order: 2;
    padding: 0 4px 14px;
  }

  .stage {
    border-radius: 24px;
  }

  .decision-bar {
    order: 3;
    padding: 0 12px 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 14px;
  }

  .decision-bar button {
    min-height: 62px;
    padding: 14px 10px;
    font-size: 12px;
    letter-spacing: 0.07em;
  }

  .artifact-panel {
    order: 5;
    margin: 0 4px 8px;
    border-radius: 16px;
    overflow-x: auto;
  }

  .artifact-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
    width: max-content;
    min-width: 100%;
  }

  .artifact-item {
    min-width: 0;
    border-radius: 999px;
  }

  .footer {
    order: 6;
    padding: 0 8px 0;
  }

  .sidebar {
    height: min(90dvh, 900px);
    border-radius: 24px 24px 0 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    margin: 4px 4px 10px;
  }

  .live-meta,
  .artifact-panel {
    margin-left: 4px;
    margin-right: 4px;
  }

  .stat {
    font-size: 10px;
    padding: 7px 10px;
  }

  .decision-bar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .artifact-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}


/* desktop cleanup: hide duplicate sidebar title and expand canvas when controls are hidden */
@media (min-width: 981px) {
  .brand {
    display: none;
  }

  .sidebar {
    padding-top: 16px;
  }

  .sidebar .section:first-of-type {
    margin-top: 0;
  }

  .app.controls-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .app.controls-collapsed .sidebar {
    width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-color: transparent;
    overflow: hidden;
  }

  .app.controls-collapsed .topbar,
  .app.controls-collapsed .live-meta,
  .app.controls-collapsed .artifact-panel,
  .app.controls-collapsed .footer {
    margin-left: 14px;
    margin-right: 14px;
  }

  .app.controls-collapsed .stage-wrap {
    padding-left: 14px;
    padding-right: 14px;
  }

  .app.controls-collapsed .stage {
    width: min(100%, 1240px);
  }

  .app.controls-collapsed .decision-bar {
    width: min(100%, 1240px);
  }
}

/* =========================
   V1.7 MINI APP + MOBILE CLEANUP PATCH
   ========================= */

.wallet-status.is-connected {
  color: #f6fbff;
}

.wallet-status.is-connected .wallet-line:first-child {
  color: var(--good);
}

.wallet-status.is-error .wallet-line:first-child {
  color: #ff8f9f;
}

.stat-mobile-show,
.stat-mobile-hide {
  display: inline-flex;
}

@media (max-width: 980px) {
  .live-meta {
    margin-bottom: 10px;
  }

  .stats {
    gap: 8px;
  }

  .stat-mobile-hide {
    display: none;
  }

  .stat-mobile-show {
    display: inline-flex;
  }

  .live-meta .stats {
    justify-content: flex-start;
  }
}

@media (min-width: 981px) {
  .stat-mobile-hide,
  .stat-mobile-show {
    display: inline-flex;
  }

  .app.controls-collapsed .stage {
    width: min(100%, 1360px);
  }

  .app.controls-collapsed .decision-bar {
    width: min(100%, 1360px);
  }
}

.decision-bar button.is-busy {
  opacity: 0.72;
  cursor: progress;
  pointer-events: none;
}

.connect-main.is-connected {
  background: linear-gradient(90deg, #0d1d39, #123b67);
  color: #e8f7ff;
}

.mint-main.is-ready {
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}

.footer {
  align-items: center;
}
/* Mode buttons micro-interaction */
.preset-btn,
.mode-btn,
button[data-mode] {
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    opacity 0.18s ease;
}

.preset-btn:hover,
.mode-btn:hover,
button[data-mode]:hover {
  transform: translateY(-1px);
}

.preset-btn:active,
.mode-btn:active,
button[data-mode]:active {
  transform: translateY(0) scale(0.985);
}

.preset-btn.is-active,
.mode-btn.is-active,
button[data-mode].is-active,
.preset-btn[aria-pressed="true"],
.mode-btn[aria-pressed="true"],
button[data-mode][aria-pressed="true"] {
  position: relative;
  transform: translateY(-1px);
  border-color: rgba(111, 218, 245, 0.55);
  box-shadow:
    0 0 0 1px rgba(111, 218, 245, 0.18) inset,
    0 8px 24px rgba(111, 218, 245, 0.14),
    0 4px 14px rgba(243, 90, 199, 0.10);
}

.preset-btn.is-active::after,
.mode-btn.is-active::after,
button[data-mode].is-active::after,
.preset-btn[aria-pressed="true"]::after,
.mode-btn[aria-pressed="true"]::after,
button[data-mode][aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 18px rgba(111, 218, 245, 0.12);
  animation: modeActiveGlow 2.2s ease-in-out infinite;
}

@keyframes modeActiveGlow {
  0%, 100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preset-btn,
  .mode-btn,
  button[data-mode] {
    transition: none;
  }

  .preset-btn.is-active::after,
  .mode-btn.is-active::after,
  button[data-mode].is-active::after,
  .preset-btn[aria-pressed="true"]::after,
  .mode-btn[aria-pressed="true"]::after,
  button[data-mode][aria-pressed="true"]::after {
    animation: none;
  }
}

/* =========================
   FINAL PATCH
   ========================= */

#presetGrid button {
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    opacity 0.18s ease;
}

#presetGrid button:hover {
  transform: translateY(-1px);
}

#presetGrid button:active {
  transform: translateY(0) scale(0.985);
}

#presetGrid button.is-active,
#presetGrid button[aria-pressed="true"] {
  position: relative;
  transform: translateY(-1px);
  border-color: rgba(111, 218, 245, 0.55);
  box-shadow:
    0 0 0 1px rgba(111, 218, 245, 0.18) inset,
    0 8px 24px rgba(111, 218, 245, 0.14),
    0 4px 14px rgba(243, 90, 199, 0.10);
}

#presetGrid button.is-active::after,
#presetGrid button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 18px rgba(111, 218, 245, 0.12);
  animation: modeActiveGlow 2.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  #presetGrid button {
    transition: none;
  }

  #presetGrid button.is-active::after,
  #presetGrid button[aria-pressed="true"]::after {
    animation: none;
  }
}



/* =========================
   MINT OVERLAY + WALLET FALLBACK
   ========================= */

body.overlay-open {
  overflow: hidden;
}

.mint-overlay,
.wallet-fallback {
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  background: rgba(5, 7, 13, 0.86) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  z-index: 9999 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.25s ease, visibility 0.25s ease !important;
}

.mint-overlay.is-visible,
.wallet-fallback.is-visible {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.mint-status-panel,
.wallet-fallback-panel {
  width: min(92vw, 420px);
  max-width: 420px;
  padding: 22px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(12,16,30,0.98), rgba(8,12,24,0.98));
  border: 1px solid rgba(255,255,255,0.12);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.42);
}

.mint-status-kicker,
.wallet-fallback-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.mint-status-title {
  font-size: 22px;
  line-height: 1.05;
  margin: 0 0 8px;
  color: var(--text);
}

.mint-status-desc,
.wallet-fallback-note {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 14px;
}

.mint-status-loader {
  margin: 18px auto 14px;
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255,255,255,0.14);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: mintSpin 1s linear infinite;
}

@keyframes mintSpin {
  to { transform: rotate(360deg); }
}

.mint-status-links,
.wallet-fallback-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.mint-status-links a,
.wallet-fallback-actions a {
  display: block;
  color: var(--accent-2);
  text-decoration: none;
  font-size: 13px;
  word-break: break-word;
}

.mint-status-links a:hover,
.wallet-fallback-actions a:hover {
  text-decoration: underline;
}

.mint-status-close,
.wallet-fallback-close {
  margin-top: 16px;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: none;
}

.mint-status-panel-success {
  border-color: rgba(117,255,189,0.3);
}

.mint-status-panel-error {
  border-color: rgba(255,143,159,0.28);
}

.mint-status-panel-success .mint-status-title {
  color: var(--good);
}

.mint-status-panel-error .mint-status-title {
  color: #ff8f9f;
}

@media (max-width: 640px) {
  .mint-status-panel,
  .wallet-fallback-panel {
    width: min(94vw, 360px);
    padding: 18px;
    border-radius: 18px;
  }

  .mint-status-title {
    font-size: 20px;
  }
}
