/* ============================================================
   CUSTOM STYLES — Carousel + Workspace
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --page-bg: #f6f7fb;
  --panel-bg: rgba(255,255,255,0.92);
  --panel-border: #eef0f6;
  --text-main: #111827;
  --text-muted: #8b93a7;
  --accent: #8b5cf6;
  --accent-light: #f4efff;
  --shadow-soft: 0 18px 60px rgba(31, 41, 55, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

/* ============================================================
   ATTRACT LAYER
   ============================================================ */
#attract-layer {
  position: fixed; inset: 0; z-index: 100;
  overflow-x: hidden;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
#attract-layer.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}

#attract-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; display: none;
}

/* ============================================================
   CAROUSEL — 3D Cylinder Ring
   ============================================================ */
.bg-gradient-custom {
  background: radial-gradient(circle at 70% 30%, #f0eaff 0%, #fcfbfe 40%, #f3efff 100%);
}

.perspective-scene {
  position: fixed; inset: 0;
  perspective: 1800px;
  pointer-events: none;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.cylinder-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(20px) scale(2.2);
  transform-style: preserve-3d;
  pointer-events: auto;
}

.cylinder {
  position: relative;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  animation: spin 60s infinite linear;
}

.cylinder-container:hover .cylinder {
  animation-play-state: paused;
}

@keyframes spin {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

.panel {
  position: absolute;
  top: -210px; left: -125px;
  width: 250px;
  height: 420px;
  transform-style: preserve-3d;
  background: linear-gradient(to bottom, rgba(225,210,255,0.9) 0%, rgba(245,240,255,0.95) 15%, rgba(245,240,255,0.95) 85%, rgba(225,210,255,0.9) 100%);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,0.9);
  border-bottom: 1px solid rgba(255,255,255,0.9);
  transform: rotateY(calc(var(--i) * 22.5deg)) translateZ(620px);
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel::before,
.panel::after {
  content: '';
  position: absolute;
  left: 0; right: 0; height: 14px;
  background-image: repeating-linear-gradient(90deg, transparent 0, transparent 12px, rgba(255,255,255,0.85) 12px, rgba(255,255,255,0.85) 24px);
}
.panel::before { top: 10px; }
.panel::after { bottom: 10px; }

.picture-card {
  background: white;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(139,92,246,0.1);
  transform: translateZ(2px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 220px;
  height: 270px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.picture-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.picture-card:hover {
  transform: translateZ(15px) scale(1.05) !important;
  box-shadow: 0 10px 30px rgba(139,92,246,0.2);
}

.btn-glow {
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
  transition: all 0.3s ease;
}
.btn-glow:hover {
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.6);
  transform: translateY(-2px);
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.1); opacity: 0.8;}
}
.star-float {
  animation: float 4s ease-in-out infinite;
}

.hero-title-glow {
  position: relative;
  display: inline-block;
  isolation: isolate;
  z-index: 0;
}
.hero-title-glow::before {
  content: none;
}

/* ============================================================
   ATTRACT HERO — responsive title + CTA layout
   ============================================================ */
.hero-stage {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(88px, 10vh, 150px) clamp(20px, 4vw, 56px) clamp(58px, 8vh, 120px);
}
.hero-copy {
  width: min(92vw, 1380px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero-title {
  margin: 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.hero-title-top {
  position: relative;
  display: inline-block;
  margin-bottom: 0;
  font-size: clamp(52px, 5.8vw, 120px);
  line-height: 1.06;
}
.hero-title-top .hero-underline {
  position: absolute;
  left: 50%;
  bottom: clamp(-11px, -0.8vw, -6px);
  transform: translateX(-50%);
  width: 98%;
  height: clamp(14px, 1.6vw, 22px);
  pointer-events: none;
}
.hero-title-bottom {
  display: inline-flex;
  justify-content: center;
  align-items: baseline;
  gap: clamp(8px, 0.9vw, 18px);
  margin-top: clamp(28px, 4vh, 72px);
  white-space: nowrap;
  font-size: clamp(52px, 5.8vw, 120px);
  line-height: 1.02;
}
.hero-title-ai {
  color: #8b5cf6;
  font-size: clamp(74px, 6.8vw, 142px);
  line-height: 0.94;
  text-shadow: 0 2px 12px rgba(0,0,0,0.35);
}
.hero-title-rest {
  display: inline-block;
}
.hero-cta {
  margin-top: clamp(54px, 8vh, 120px);
  padding: clamp(16px, 2vh, 22px) clamp(34px, 3.1vw, 52px);
  border-radius: 999px;
  font-size: clamp(22px, 2vw, 32px);
}
.hero-cta .hero-cta-arrow {
  font-size: 1em;
}

@media (max-width: 900px) {
  .hero-stage {
    padding-top: 104px;
    padding-bottom: 72px;
  }
  .hero-copy {
    width: min(94vw, 860px);
  }
  .hero-title {
    line-height: 1.08;
  }
  .hero-title-bottom {
    margin-top: clamp(18px, 3.2vh, 36px);
  }
  .hero-cta {
    margin-top: clamp(38px, 6vh, 72px);
  }
}

@media (max-width: 640px) {
  .hero-stage {
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 96px;
    padding-bottom: 64px;
  }
  .hero-copy {
    width: min(96vw, 640px);
  }
  .hero-title-top {
    font-size: clamp(40px, 10.5vw, 68px);
  }
  .hero-title-bottom {
    gap: 6px;
    margin-top: 16px;
    font-size: clamp(40px, 10vw, 68px);
  }
  .hero-title-ai {
    font-size: clamp(56px, 12vw, 88px);
  }
  .hero-cta {
    margin-top: 34px;
    padding: 14px 28px;
    font-size: 22px;
  }
}

@media (min-width: 1800px) {
  .hero-copy {
    width: min(88vw, 1540px);
  }
  .hero-stage {
    padding-top: clamp(110px, 10vh, 170px);
    padding-bottom: clamp(70px, 9vh, 140px);
  }
}

/* ============================================================
   WORKSPACE
   ============================================================ */
#app {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  background: linear-gradient(180deg, #f2ecff 0%, #ebe3ff 52%, #e5dcff 100%);
}

#workspace {
  position: relative;
  width: min(97vw, 1360px);
  height: min(95vh, 900px);
  background: linear-gradient(180deg, rgba(248,249,252,0.98) 0%, rgba(240,243,249,0.98) 100%);
  border: 1px solid rgba(203,210,223,0.92);
  border-radius: var(--radius-lg);
  box-shadow: none;
  overflow: hidden;
}

.top-action {
  border: none; background: transparent; color: #303445;
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; opacity: 0.88;
  transition: transform .15s ease, opacity .15s ease, color .15s ease;
}
.top-action svg { width: 16px; height: 16px; stroke-width: 2; }
.top-action:hover { opacity: 1; color: var(--accent); }
.top-action:active { transform: scale(0.94); }
.top-action.disabled { color: #aeb4c2; cursor: default; }
.top-action.disabled:hover { color: #aeb4c2; }

#side-toolbar {
  position: absolute;
  top: 150px; left: 28px;
  width: 62px;
  padding: 8px 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(31,41,55,0.06);
  display: flex; flex-direction: column; align-items: center;
  z-index: 25;
}
.side-tool {
  width: 54px; height: 62px;
  border: none; background: transparent;
  color: #1f2937;
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.side-tool svg { width: 18px; height: 18px; stroke-width: 2; }
.side-tool:hover, .side-tool.active {
  background: var(--accent-light); color: var(--accent);
}
.side-tool:active { transform: scale(0.94); }
.side-tool.disabled { color: #aeb4c2; cursor: default; }
.side-tool.disabled:hover { background: transparent; color: #aeb4c2; }

#canvas-area {
  position: absolute;
  left: 20px; right: 20px;
  top: 20px; bottom: 20px;
  border-radius: 26px;
  background: #fff;
  border: 2px solid rgba(20,24,38,0.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.9);
  overflow: hidden;
  cursor: crosshair;
}
#canvas-area::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(#d5dbe8 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: .95;
  pointer-events: none;
  z-index: 0;
}
#canvas-area::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 24px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.95), inset 0 0 28px rgba(31,41,55,0.025);
  pointer-events: none;
  z-index: 3;
}
#draw-canvas, #overlay-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
#draw-canvas { background: transparent; z-index: 1; }
#overlay-canvas { pointer-events: none; z-index: 2; }

#bottom-controls {
  position: absolute;
  left: 28px; right: 28px; bottom: 28px;
  display: grid;
  grid-template-columns: max-content 230px;
  justify-content: center;
  gap: 22px;
  align-items: center;
  z-index: 30;
}
#control-card {
  width: max-content;
  height: 62px;
  background: rgba(30,30,40,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.18);
  backdrop-filter: blur(20px);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 18px;
}
.toolbar-section {
  display: flex; align-items: center; gap: 11px;
  flex-shrink: 0;
}
.toolbar-divider {
  width: 1px; height: 30px;
  background: rgba(255,255,255,0.15);
}
#color-palette { gap: 10px; }
.color-swatch {
  width: 21px; height: 21px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: none;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  flex-shrink: 0;
}
.color-swatch:nth-child(10) { border-color: rgba(255,255,255,0.65); }
.color-swatch.active {
  transform: scale(1.14);
  border-color: #ffffff;
  box-shadow: 0 0 20px currentColor;
}

.brush-group-title {
  color: rgba(255,255,255,0.88); font-size: 13px; font-weight: 700;
  white-space: nowrap;
}
.brush-btn {
  width: 22px; height: 22px;
  padding: 0;
  border: none; background: transparent;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.brush-btn span:not(.brush-dot) { display: none; }
.brush-btn.active { box-shadow: 0 0 0 5px rgba(255,107,157,0.18); }
.brush-btn:active { transform: scale(0.92); }
.brush-dot { border-radius: 50%; background: #ffffff; display: block; }
.brush-dot.small { width: 5px; height: 5px; }
.brush-dot.medium { width: 9px; height: 9px; }
.brush-dot.large { width: 13px; height: 13px; }

/* Action buttons inside dark control card */
#control-card .action-section { gap: 8px; }
#control-card .top-action {
  min-width: 58px; height: 38px;
  padding: 0 10px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.88);
  font-size: 12px; font-weight: 700;
  opacity: 1; justify-content: center;
}
#control-card .top-action svg { width: 14px; height: 14px; }
#control-card .top-action:hover,
#control-card .top-action:active {
  color: #fff;
  background: rgba(255,107,157,0.22);
  border-color: rgba(255,107,157,0.55);
}
#control-card .top-action.disabled {
  color: rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.035);
  border-color: rgba(255,255,255,0.08);
  cursor: default;
}
#control-card .top-action.disabled:hover {
  color: rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.035);
  border-color: rgba(255,255,255,0.08);
}

#btn-generate {
  height: 62px; width: 100%;
  border: 1px solid rgba(167,139,250,0.72);
  border-radius: 14px;
  background: #a78bfa;
  color: #ffffff;
  box-shadow: 0 10px 26px rgba(139,92,246,0.24);
  font-size: 17px; font-weight: 800;
  letter-spacing: .5px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
#btn-generate:hover { background: #9775f5; box-shadow: 0 12px 32px rgba(139,92,246,0.32); }
#btn-generate:active { transform: scale(0.97); }
#btn-generate:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.2); }

/* Loading overlay */
#loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: #f6f7fb;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  overflow: hidden;
}
#loading-overlay.show { opacity: 1; visibility: visible; }
#loading-blur-bg {
  position: absolute; inset: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: blur(26px);
  transform: scale(1.06);
  opacity: 0.92;
  z-index: 0;
}
#loading-blur-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(246,247,251,0.70);
}
#loading-particles,
#loading-text,
#loading-subtitle { position: relative; z-index: 1; }
#loading-particles {
  width: min(82vw, 980px); height: min(82vw, 980px);
  pointer-events: none;
  position: fixed !important;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}
#loading-text {
  color: #1f2937; font-size: clamp(22px, 3vw, 34px); font-weight: 800;
  position: fixed; left: 50%; top: 66%;
  transform: translate(-50%, -50%);
  margin: 0; text-align: center; white-space: nowrap;
}
#loading-subtitle {
  color: #8b93a7; font-size: 14px;
  position: fixed; left: 50%; top: calc(66% + 58px);
  transform: translate(-50%, -50%);
  margin: 0; text-align: center; white-space: nowrap;
}

/* Result overlay */
#result-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(17,24,39,0.34);
  backdrop-filter: blur(18px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}

#result-overlay.show { opacity: 1; visibility: visible; }
#result-overlay {
  overflow: hidden;
}
#result-celebration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
#result-container {
  position: relative;
  z-index: 2;
}
#result-celebration .result-halo {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 1080px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(.78);
  border-radius: 50%;
  background:
    radial-gradient(circle,
      rgba(178, 145, 255, .22) 0%,
      rgba(178, 145, 255, .16) 18%,
      rgba(245, 181, 226, .12) 34%,
      rgba(178, 145, 255, .06) 50%,
      rgba(178, 145, 255, 0) 72%);
  opacity: 0;
}

#result-celebration .result-firework {
  position: absolute;
  width: 230px;
  height: 230px;
  transform: translate3d(-50%, -50%, 0) scale(.18);
  transform-origin: center center;
  opacity: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
}
#result-celebration .result-firework::before,
#result-celebration .result-firework::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
#result-celebration .result-firework::before {
  background:
    repeating-conic-gradient(
      from -10deg,
      rgba(179,145,255,0) 0deg 14deg,
      rgba(179,145,255,.95) 14deg 17deg,
      rgba(245,181,226,.95) 17deg 20deg,
      rgba(255,255,255,.82) 20deg 21.5deg,
      rgba(179,145,255,0) 21.5deg 30deg
    );
  -webkit-mask: radial-gradient(circle, transparent 0 24%, #000 25% 39%, transparent 40% 100%);
          mask: radial-gradient(circle, transparent 0 24%, #000 25% 39%, transparent 40% 100%);
  filter: drop-shadow(0 0 10px rgba(179,145,255,.18));
}
#result-celebration .result-firework::after {
  background:
    radial-gradient(circle, rgba(255,255,255,.94) 0%, rgba(255,255,255,.62) 8%, rgba(245,181,226,.34) 18%, rgba(179,145,255,.12) 30%, rgba(179,145,255,0) 50%);
  transform: scale(.58);
}
#result-celebration .f1 { left: 9%; top: 18%; width: 300px; height: 300px; }
#result-celebration .f2 { left: 86%; top: 14%; width: 190px; height: 190px; }
#result-celebration .f3 { left: 14%; top: 78%; width: 235px; height: 235px; }
#result-celebration .f4 { left: 91%; top: 82%; width: 340px; height: 340px; }
#result-celebration .f5 { left: 74%; top: 11%; width: 255px; height: 255px; }

#result-celebration .result-star {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 34%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.80) 16%, rgba(245,181,226,.72) 36%, rgba(179,145,255,.70) 58%, rgba(179,145,255,0) 100%);
  box-shadow: 0 0 16px rgba(179,145,255,.24);
  opacity: 0;
  transform: translate(0,0) scale(var(--scale,1));
}
#result-celebration .result-star::before,
#result-celebration .result-star::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(255,255,255,.82);
  border-radius: 999px;
  transform: translate(-50%, -50%);
}
#result-celebration .result-star::before { width: 2px; height: 18px; }
#result-celebration .result-star::after { width: 18px; height: 2px; }

#result-celebration .sp1  { left: 27%; top: 18%; --burst-x: -18px; --burst-y: 24px; --float-x: 8px;  --float-y: -9px;  --scale: .95; }
#result-celebration .sp2  { left: 38%; top: 12%; --burst-x: -10px; --burst-y: 26px; --float-x: -6px; --float-y: 10px;  --scale: .82; }
#result-celebration .sp3  { left: 50%; top: 10%; --burst-x: 0px;   --burst-y: 28px; --float-x: 0px;  --float-y: -10px; --scale: 1.05; }
#result-celebration .sp4  { left: 63%; top: 13%; --burst-x: 12px;  --burst-y: 24px; --float-x: 7px;  --float-y: 8px;   --scale: .90; }
#result-celebration .sp5  { left: 75%; top: 19%; --burst-x: 20px;  --burst-y: 22px; --float-x: -8px; --float-y: -8px;  --scale: 1.00; }
#result-celebration .sp6  { left: 18%; top: 39%; --burst-x: 18px;  --burst-y: 8px;  --float-x: -7px; --float-y: 7px;   --scale: .88; }
#result-celebration .sp7  { left: 82%; top: 38%; --burst-x: -18px; --burst-y: 8px;  --float-x: 6px;  --float-y: -8px;  --scale: .96; }
#result-celebration .sp8  { left: 18%; top: 64%; --burst-x: 18px;  --burst-y: -10px; --float-x: 7px; --float-y: 8px;   --scale: .84; }
#result-celebration .sp9  { left: 82%; top: 63%; --burst-x: -18px; --burst-y: -10px; --float-x: -8px; --float-y: -8px; --scale: .92; }
#result-celebration .sp10 { left: 27%; top: 83%; --burst-x: -18px; --burst-y: -24px; --float-x: 8px;  --float-y: 9px;   --scale: .92; }
#result-celebration .sp11 { left: 50%; top: 88%; --burst-x: 0px;   --burst-y: -28px; --float-x: 0px;  --float-y: -9px;  --scale: 1.00; }
#result-celebration .sp12 { left: 73%; top: 82%; --burst-x: 18px;  --burst-y: -24px; --float-x: -7px; --float-y: 9px;  --scale: .88; }

#result-overlay.show #result-celebration .result-halo {
  animation: resultHaloOneShot 2.45s ease-out 0s 1 both;
}
#result-overlay.show #result-celebration .result-firework.f1 {
  animation: resultFireworkOneShot 1.36s ease-out .02s 1 both;
}
#result-overlay.show #result-celebration .result-firework.f2 {
  animation: resultFireworkOneShot 1.28s ease-out .03s 1 both;
}
#result-overlay.show #result-celebration .result-firework.f3 {
  animation: resultFireworkOneShot 1.34s ease-out .04s 1 both;
}
#result-overlay.show #result-celebration .result-firework.f4 {
  animation: resultFireworkOneShot 1.50s ease-out .02s 1 both;
}
#result-overlay.show #result-celebration .result-firework.f5 {
  animation: resultFireworkOneShot 1.32s ease-out .05s 1 both;
}
#result-overlay.show #result-celebration .result-star.sp1  { animation: resultStarOneShot 1.34s ease-out .02s 1 both; }
#result-overlay.show #result-celebration .result-star.sp2  { animation: resultStarOneShot 1.32s ease-out .03s 1 both; }
#result-overlay.show #result-celebration .result-star.sp3  { animation: resultStarOneShot 1.36s ease-out .02s 1 both; }
#result-overlay.show #result-celebration .result-star.sp4  { animation: resultStarOneShot 1.33s ease-out .04s 1 both; }
#result-overlay.show #result-celebration .result-star.sp5  { animation: resultStarOneShot 1.35s ease-out .02s 1 both; }
#result-overlay.show #result-celebration .result-star.sp6  { animation: resultStarOneShot 1.31s ease-out .03s 1 both; }
#result-overlay.show #result-celebration .result-star.sp7  { animation: resultStarOneShot 1.34s ease-out .02s 1 both; }
#result-overlay.show #result-celebration .result-star.sp8  { animation: resultStarOneShot 1.33s ease-out .04s 1 both; }
#result-overlay.show #result-celebration .result-star.sp9  { animation: resultStarOneShot 1.35s ease-out .03s 1 both; }
#result-overlay.show #result-celebration .result-star.sp10 { animation: resultStarOneShot 1.32s ease-out .02s 1 both; }
#result-overlay.show #result-celebration .result-star.sp11 { animation: resultStarOneShot 1.36s ease-out .03s 1 both; }
#result-overlay.show #result-celebration .result-star.sp12 { animation: resultStarOneShot 1.34s ease-out .02s 1 both; }

@keyframes resultHaloOneShot {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.56);
  }
  26% {
    opacity: .88;
    transform: translate(-50%, -50%) scale(1.03);
  }
  58% {
    opacity: .68;
    transform: translate(-50%, -50%) scale(1.10);
  }
  82% {
    opacity: .38;
    transform: translate(-50%, -50%) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.18);
  }
}

@keyframes resultFireworkOneShot {
  0% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(.18);
  }
  18% {
    opacity: .98;
    transform: translate3d(-50%, -50%, 0) scale(.82);
  }
  36% {
    opacity: 1;
    transform: translate3d(-50%, -50%, 0) scale(1.08);
  }
  58% {
    opacity: .88;
    transform: translate3d(-50%, -50%, 0) scale(1.24);
  }
  80% {
    opacity: .38;
    transform: translate3d(-50%, -50%, 0) scale(1.36);
  }
  100% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(1.44);
  }
}

@keyframes resultStarOneShot {
  0% {
    opacity: 0;
    transform: translate(var(--burst-x), var(--burst-y)) scale(.24);
  }
  18% {
    opacity: .98;
    transform: translate(calc(var(--burst-x) * .35), calc(var(--burst-y) * .35)) scale(calc(var(--scale,1) * .92));
  }
  36% {
    opacity: .96;
    transform: translate(0, 0) scale(calc(var(--scale,1) + .10));
  }
  58% {
    opacity: .70;
    transform: translate(calc(var(--float-x) * .55), calc(var(--float-y) * .55)) scale(calc(var(--scale,1) + .08));
  }
  82% {
    opacity: .26;
    transform: translate(calc(var(--float-x) * .92), calc(var(--float-y) * .92)) scale(var(--scale,1));
  }
  100% {
    opacity: 0;
    transform: translate(var(--float-x), var(--float-y)) scale(calc(var(--scale,1) * .96));
  }
}

#result-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  max-width: 92vw; max-height: 86vh;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(31,41,55,.2);
}
#comparison-slider { position: relative; border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 10px 35px rgba(31,41,55,.14); }
#comparison-slider canvas { position: absolute; inset: 0; width: 100%; height: 100%; background: #fff; }
#comparison-before { z-index: 1; clip-path: inset(0 50% 0 0); }
#comparison-after { z-index: 2; clip-path: inset(0 0 0 50%); }
#comparison-handle { position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; background: #fff; z-index: 3; transform: translateX(-50%); box-shadow: 0 0 18px rgba(0,0,0,.12); pointer-events: none; }
#comparison-handle::after { content: '↔'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; display:flex; align-items:center; justify-content:center; background: var(--accent); color:#fff; font-size:24px; box-shadow: 0 12px 28px rgba(139,92,246,.35); }
#result-info {
  width: 100%;
  min-width: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#result-finish-text {
  color: #8b93a7;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .2px;
}
#result-actions {
  display:flex;
  flex-direction:column;
  align-items: center;
  gap:12px;
}
.result-btn { height: 64px; min-width: 320px; padding: 0 40px; border-radius: 999px; border: 1px solid #e6e8f0; background: #fff; color: #1f2937; font-size: 22px; font-weight: 800; cursor:pointer; }
.result-btn.primary { background: var(--accent); color: #fff; border: none; box-shadow: 0 12px 28px rgba(139,92,246,.26); }
#result-label-before, #result-label-after { position:absolute; top:12px; z-index:4; padding:8px 14px; border-radius:999px; font-size:13px; font-weight:800; color:#fff; pointer-events:none; }
#result-label-before { left:12px; background:rgba(17,24,39,.72); }
#result-label-after { right:12px; background: var(--accent); }

#eraser-indicator {
  position: fixed; border-radius: 50%; border: 2px solid rgba(139,92,246,0.8);
  background: rgba(139,92,246,0.08); pointer-events: none; z-index: 60;
  transform: translate(-50%, -50%); opacity: 0; transition: opacity .1s;
}
.toast {
  position: fixed; top: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(17,24,39,.88); color: #fff;
  padding: 10px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 700; z-index: 400;
  opacity: 0; animation: toastIn 2s ease forwards; pointer-events: none;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
  15%, 75% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}

/* ============================================================
   RESPONSIVE — Workspace
   ============================================================ */
@media (max-width: 1024px) {
  #workspace { width: 100vw; height: 100vh; border-radius: 0; }
  #canvas-area { left: 12px; right: 12px; top: 12px; bottom: 12px; border-radius: 20px; }
  #canvas-area::after { border-radius: 18px; }
  #bottom-controls { grid-template-columns: 1fr; justify-content: stretch; gap: 12px; }
  #btn-generate { height: 54px; }
  #control-card { width: 100%; overflow-x: auto; }
}
@media (max-width: 700px) {
  .top-action { font-size: 12px; }
  #side-toolbar { left: 12px; top: 118px; }
  #canvas-area { left: 8px; right: 8px; top: 8px; bottom: 8px; }
  #bottom-controls { left: 12px; right: 12px; bottom: 12px; }
  #control-card { height: 70px; padding: 0 14px; gap: 18px; }
  .color-swatch { width: 18px; height: 18px; }
  #loading-particles {
    width: min(96vw, 680px) !important;
    height: min(96vw, 680px) !important;
  }
  #loading-text { white-space: normal; width: 88vw; }
  #loading-subtitle { top: calc(66% + 48px); }
}

@media (min-width: 1600px) {
  #app { padding: 24px; }
  #workspace { width: min(95vw, 1760px); height: min(93vh, 1080px); border-radius: 30px; }
  #side-toolbar { top: 190px; left: 42px; width: 78px; padding: 10px 0; border-radius: 18px; }
  .side-tool { width: 68px; height: 78px; border-radius: 16px; font-size: 13px; gap: 7px; }
  .side-tool svg { width: 22px; height: 22px; }
  #canvas-area { left: 26px; right: 26px; top: 26px; bottom: 26px; border-radius: 32px; }
  #canvas-area::before { background-size: 22px 22px; }
  #canvas-area::after { border-radius: 30px; }
  #bottom-controls { left: 42px; right: 42px; bottom: 38px; grid-template-columns: max-content 280px; justify-content: center; gap: 28px; }
  #control-card { height: 76px; border-radius: 18px; padding: 0 26px; gap: 24px; }
  .toolbar-section { gap: 14px; }
  .toolbar-divider { height: 38px; }
  #color-palette { gap: 12px; }
  .color-swatch { width: 28px; height: 28px; }
  .brush-group-title { font-size: 15px; }
  .brush-btn { width: 28px; height: 28px; }
  .brush-dot.small { width: 7px; height: 7px; }
  .brush-dot.medium { width: 12px; height: 12px; }
  .brush-dot.large { width: 17px; height: 17px; }
  #control-card .top-action { min-width: 70px; height: 46px; padding: 0 12px; font-size: 15px; border-radius: 14px; }
  #control-card .top-action svg { width: 17px; height: 17px; }
  #btn-generate { height: 76px; border-radius: 18px; font-size: 21px; }
  #loading-particles { width: min(70vw, 1120px) !important; height: min(70vw, 1120px) !important; }
}

@media (min-width: 2200px) {
  #workspace { width: min(93vw, 2220px); height: min(91vh, 1280px); }
  #side-toolbar { top: 230px; left: 56px; width: 92px; }
  .side-tool { width: 80px; height: 90px; font-size: 15px; }
  .side-tool svg { width: 26px; height: 26px; }
  #canvas-area { left: 32px; right: 32px; top: 32px; bottom: 32px; }
  #bottom-controls { left: 56px; right: 56px; bottom: 48px; grid-template-columns: max-content 320px; justify-content: center; gap: 32px; }
  #control-card { height: 86px; padding: 0 30px; gap: 28px; }
  #color-palette { gap: 14px; }
  .color-swatch { width: 32px; height: 32px; }
  #control-card .top-action { min-width: 82px; height: 52px; font-size: 17px; padding: 0 14px; }
  #btn-generate { height: 86px; font-size: 24px; }
}

@media (min-width: 2800px) {
  #workspace { width: min(90vw, 2700px); height: min(88vh, 1480px); }
}

/* ============================================================
   ATTRACT LAYER RESPONSIVE
   ============================================================ */
@media (min-width: 1600px) {
  .cylinder-container { transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(20px) scale(2.5); }
  .perspective-scene { perspective: 2000px; }
}
@media (min-width: 2200px) {
  .cylinder-container { transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(20px) scale(2.8); }
  .perspective-scene { perspective: 2200px; }
}
@media (min-width: 2800px) {
  .cylinder-container { transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(20px) scale(3.2); }
  .perspective-scene { perspective: 2500px; }
}

/* ============================================================
   ENTER TRANSITION
   ============================================================ */
#app {
  position: relative;
  opacity: 1;
  background: transparent !important;
  overflow: hidden;
}

#app::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #f2ecff 0%, #ebe3ff 52%, #e5dcff 100%);
  opacity: 0;
  transition: opacity 1.05s ease-out 0.46s;
  pointer-events: none;
}

#app.enter-transition {
  visibility: visible !important;
  background: transparent !important;
}

#app.enter-transition::before {
  opacity: 1;
}

#app.enter-transition #workspace {
  position: relative;
  z-index: 1;
  animation: workspaceFrameSlideInOnly 0.95s ease-out both;
}

#app.enter-transition #canvas-area {
  opacity: 1;
  transform: none;
}

#app.enter-transition #side-toolbar,
#app.enter-transition #bottom-controls {
  opacity: 0;
  transform: translateY(8px);
  will-change: opacity, transform;
  animation: toolsFadeInWithBackground 1.05s ease-out forwards;
  animation-delay: 0.46s;
}

@keyframes workspaceFrameSlideInOnly {
  0% {
    opacity: 0;
    transform: translateY(-34vh);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toolsFadeInWithBackground {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading particles bigger */
html body #loading-particles {
  width: min(92vw, 1240px) !important;
  height: min(92vw, 1240px) !important;
  left: 50% !important;
  top: 40% !important;
  transform-origin: center center !important;
}

@media (min-width: 1600px) {
  html body #loading-particles {
    width: min(78vw, 1400px) !important;
    height: min(78vw, 1400px) !important;
  }
}

@media (max-width: 700px) {
  html body #loading-particles {
    width: min(110vw, 760px) !important;
    height: min(110vw, 760px) !important;
  }
}

/* ============================================================
   GLOBAL RESPONSIVE FIX
   ============================================================ */
:root {
  --ui-scale: clamp(0.86, 0.78 + 0.24vw, 1.18);
  --page-pad: clamp(8px, 1.4vw, 28px);
  --workspace-radius-r: clamp(18px, 1.6vw, 34px);
  --control-gap-r: clamp(10px, 1.2vw, 28px);
}

#attract-layer header {
  padding: clamp(18px, 2.4vw, 42px) !important;
}
#attract-layer header img {
  width: clamp(34px, 2.8vw, 54px) !important;
  height: clamp(34px, 2.8vw, 54px) !important;
}
#attract-layer header span {
  font-size: clamp(20px, 1.7vw, 34px) !important;
}
.hero-stage {
  min-height: 100svh;
  padding-top: clamp(92px, 10svh, 172px) !important;
  padding-bottom: clamp(58px, 8svh, 140px) !important;
}
.hero-copy {
  width: min(92vw, 1500px) !important;
}
.hero-title-top,
.hero-title-bottom {
  font-size: clamp(50px, 5.7vw, 124px) !important;
}
.hero-title-ai {
  font-size: clamp(72px, 6.7vw, 148px) !important;
}
.hero-title-bottom {
  margin-top: clamp(24px, 4.2svh, 78px) !important;
}
.hero-cta {
  margin-top: clamp(72px, 10svh, 150px) !important;
  font-size: clamp(22px, 1.9vw, 34px) !important;
}

.cylinder-container {
  transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(clamp(8px, 2vh, 30px)) scale(clamp(1.55, 1.25 + 0.06vw, 3.1)) !important;
}
.perspective-scene {
  perspective: clamp(1200px, 90vw, 2500px) !important;
}
.panel {
  width: clamp(180px, 13vw, 280px) !important;
  height: clamp(300px, 22vw, 460px) !important;
  top: calc(clamp(300px, 22vw, 460px) / -2) !important;
  left: calc(clamp(180px, 13vw, 280px) / -2) !important;
}
.picture-card {
  width: clamp(155px, 11.5vw, 240px) !important;
  height: clamp(200px, 15.2vw, 300px) !important;
}

#app {
  padding: var(--page-pad) !important;
  min-width: 0;
  min-height: 100svh;
}
#workspace {
  width: min(97vw, 1780px) !important;
  height: min(95svh, 1120px) !important;
  border-radius: var(--workspace-radius-r) !important;
}
#canvas-area {
  left: clamp(10px, 1.6vw, 34px) !important;
  right: clamp(10px, 1.6vw, 34px) !important;
  top: clamp(10px, 1.6vw, 34px) !important;
  bottom: clamp(10px, 1.6vw, 34px) !important;
  border-radius: clamp(18px, 1.7vw, 34px) !important;
}
#canvas-area::after {
  border-radius: clamp(16px, 1.55vw, 32px) !important;
}
#side-toolbar {
  left: clamp(14px, 2.1vw, 58px) !important;
  top: clamp(118px, 17svh, 250px) !important;
  width: clamp(58px, 4.1vw, 92px) !important;
  padding: clamp(6px, 0.7vw, 12px) 0 !important;
  border-radius: clamp(13px, 1.05vw, 20px) !important;
}
.side-tool {
  width: clamp(50px, 3.7vw, 80px) !important;
  height: clamp(58px, 4.4vw, 92px) !important;
  font-size: clamp(10px, 0.72vw, 15px) !important;
  gap: clamp(4px, 0.4vw, 8px) !important;
}
.side-tool svg {
  width: clamp(17px, 1.25vw, 26px) !important;
  height: clamp(17px, 1.25vw, 26px) !important;
}
#bottom-controls {
  left: clamp(16px, 2.2vw, 58px) !important;
  right: clamp(16px, 2.2vw, 58px) !important;
  bottom: clamp(16px, 2.2svh, 54px) !important;
  display: grid !important;
  grid-template-columns: auto clamp(210px, 18vw, 340px) !important;
  justify-content: center !important;
  align-items: center !important;
  gap: var(--control-gap-r) !important;
}
#control-card {
  max-width: min(88vw, 1600px) !important;
  height: clamp(58px, 5.3vw, 88px) !important;
  padding: 0 clamp(14px, 1.7vw, 32px) !important;
  gap: clamp(12px, 1.3vw, 28px) !important;
  border-radius: clamp(13px, 1.1vw, 20px) !important;
}
#control-card::-webkit-scrollbar { display: none; }
.toolbar-section {
  gap: clamp(8px, 0.8vw, 15px) !important;
}
.toolbar-divider {
  height: clamp(28px, 2.3vw, 40px) !important;
}
.color-swatch {
  width: clamp(20px, 1.55vw, 34px) !important;
  height: clamp(20px, 1.55vw, 34px) !important;
}
.brush-group-title {
  font-size: clamp(12px, 0.95vw, 17px) !important;
}
.brush-btn {
  width: clamp(22px, 1.55vw, 32px) !important;
  height: clamp(22px, 1.55vw, 32px) !important;
}
#control-card .top-action {
  min-width: clamp(56px, 4.5vw, 86px) !important;
  height: clamp(36px, 3.2vw, 54px) !important;
  font-size: clamp(12px, 0.9vw, 17px) !important;
  border-radius: clamp(11px, 0.9vw, 16px) !important;
}
#control-card .top-action svg {
  width: clamp(14px, 1vw, 18px) !important;
  height: clamp(14px, 1vw, 18px) !important;
}
#btn-generate {
  height: clamp(58px, 5.3vw, 88px) !important;
  font-size: clamp(16px, 1.25vw, 24px) !important;
  border-radius: clamp(13px, 1.1vw, 20px) !important;
}

#loading-overlay {
  min-height: 100svh;
}
#loading-particles {
  width: min(86vmin, 1240px) !important;
  height: min(86vmin, 1240px) !important;
  top: 39% !important;
}
#loading-text {
  top: 66% !important;
  width: min(88vw, 980px) !important;
  white-space: normal !important;
  font-size: clamp(22px, 2.6vw, 38px) !important;
  line-height: 1.25 !important;
}
#loading-subtitle {
  top: calc(66% + clamp(44px, 5svh, 74px)) !important;
  width: min(88vw, 760px) !important;
  white-space: normal !important;
  font-size: clamp(13px, 1vw, 18px) !important;
}

#result-overlay {
  padding: clamp(12px, 2vw, 34px) !important;
}
#result-container {
  width: min(92vw, 1180px) !important;
  max-height: min(88svh, 920px) !important;
  padding: clamp(14px, 2vw, 30px) !important;
  gap: clamp(14px, 2svh, 24px) !important;
  border-radius: clamp(18px, 1.8vw, 28px) !important;
  overflow: hidden !important;
}
#comparison-slider {
  width: min(84vw, 980px) !important;
  height: min(58svh, 620px) !important;
  max-height: calc(88svh - 150px) !important;
}
#result-info {
  gap: clamp(8px, 1.2svh, 14px) !important;
}
#result-finish-text {
  font-size: clamp(13px, 1vw, 18px) !important;
}
.result-btn {
  min-width: min(78vw, 340px) !important;
  height: clamp(52px, 5.6svh, 68px) !important;
  padding: 0 clamp(24px, 3vw, 44px) !important;
  font-size: clamp(18px, 1.6vw, 24px) !important;
}
#result-label-before,
#result-label-after {
  font-size: clamp(11px, 0.9vw, 14px) !important;
  padding: clamp(6px, 0.7vw, 9px) clamp(10px, 1vw, 15px) !important;
}
#comparison-handle::after {
  width: clamp(42px, 4.4vw, 58px) !important;
  height: clamp(42px, 4.4vw, 58px) !important;
  font-size: clamp(20px, 1.9vw, 26px) !important;
}

@media (min-width: 1800px) {
  #workspace {
    width: min(94vw, 2160px) !important;
    height: min(92svh, 1280px) !important;
  }
  #control-card {
    max-width: min(86vw, 1600px) !important;
  }
  #comparison-slider {
    width: min(72vw, 1120px) !important;
    height: min(58svh, 700px) !important;
  }
}

@media (max-height: 760px) and (orientation: landscape) {
  .hero-stage {
    padding-top: 76px !important;
    padding-bottom: 34px !important;
  }
  .hero-title-top,
  .hero-title-bottom {
    font-size: clamp(42px, 7svh, 72px) !important;
  }
  .hero-title-ai {
    font-size: clamp(58px, 9svh, 92px) !important;
  }
  .hero-title-bottom {
    margin-top: clamp(12px, 2.6svh, 24px) !important;
  }
  .hero-cta {
    margin-top: clamp(30px, 5svh, 54px) !important;
    padding: 14px 34px !important;
    font-size: clamp(18px, 3svh, 24px) !important;
  }
  #workspace {
    width: 98vw !important;
    height: 96svh !important;
  }
  #side-toolbar {
    top: clamp(86px, 15svh, 130px) !important;
  }
  #bottom-controls {
    bottom: 10px !important;
  }
  #control-card,
  #btn-generate {
    height: clamp(52px, 8svh, 64px) !important;
  }
  #loading-particles {
    width: min(76vmin, 760px) !important;
    height: min(76vmin, 760px) !important;
    top: 36% !important;
  }
  #loading-text { top: 67% !important; }
  #comparison-slider {
    height: min(54svh, 420px) !important;
  }
}

@media (max-width: 1024px) {
  #app {
    padding: 0 !important;
  }
  #workspace {
    width: 100vw !important;
    height: 100svh !important;
    border-radius: 0 !important;
  }
  #side-toolbar {
    top: clamp(92px, 15svh, 150px) !important;
    left: 12px !important;
  }
  #bottom-controls {
    grid-template-columns: 1fr !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    gap: 10px !important;
  }
  #control-card {
    width: 100% !important;
    max-width: 100% !important;
    justify-content: flex-start !important;
  }
  #btn-generate {
    width: 100% !important;
  }
  #comparison-slider {
    width: min(90vw, 860px) !important;
    height: min(54svh, 560px) !important;
  }
}

@media (max-width: 640px) {
  #attract-layer header {
    padding: 16px !important;
  }
  .hero-title-bottom {
    white-space: normal !important;
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .hero-stage {
    padding-top: 96px !important;
  }
  .hero-cta {
    margin-top: 40px !important;
  }
  #side-toolbar {
    top: 86px !important;
    width: 52px !important;
  }
  .side-tool {
    width: 46px !important;
    height: 54px !important;
    font-size: 10px !important;
  }
  #canvas-area {
    left: 8px !important;
    right: 8px !important;
    top: 8px !important;
    bottom: 8px !important;
  }
  #control-card {
    height: 66px !important;
    padding: 0 12px !important;
    gap: 16px !important;
  }
  .brush-group-title {
    display: none !important;
  }
  #control-card .top-action {
    min-width: 52px !important;
    padding: 0 8px !important;
  }
  #loading-particles {
    width: min(104vw, 720px) !important;
    height: min(104vw, 720px) !important;
    top: 39% !important;
  }
  #loading-text {
    top: 66% !important;
    width: 86vw !important;
  }
  #result-container {
    width: 94vw !important;
    max-height: 90svh !important;
  }
  #comparison-slider {
    width: 88vw !important;
    height: min(48svh, 420px) !important;
  }
  .result-btn {
    min-width: 72vw !important;
  }
}

/* ============================================================
   EXTRA RESPONSIVE HARDENING
   ============================================================ */
html, body {
  min-width: 320px;
}

#result-container {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

#comparison-slider {
  aspect-ratio: 16 / 10;
}

@media (min-aspect-ratio: 21/9) {
  .hero-copy {
    width: min(76vw, 1560px) !important;
  }
  .hero-stage {
    padding-top: clamp(72px, 8vh, 120px) !important;
    padding-bottom: clamp(34px, 5vh, 72px) !important;
  }
  .hero-title-top,
  .hero-title-bottom {
    font-size: clamp(48px, 4.3vw, 108px) !important;
  }
  .hero-title-ai {
    font-size: clamp(68px, 5.3vw, 132px) !important;
  }
  .hero-title-bottom {
    margin-top: clamp(18px, 2.8vh, 44px) !important;
  }
  .hero-cta {
    margin-top: clamp(44px, 6vh, 82px) !important;
  }
  .cylinder-container {
    transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(10px) scale(clamp(1.8, 1.4 + 0.03vw, 2.6)) !important;
  }
  #workspace {
    width: min(96vw, 2360px) !important;
    height: min(94svh, 1240px) !important;
  }
  #bottom-controls {
    grid-template-columns: auto clamp(240px, 16vw, 360px) !important;
  }
  #comparison-slider {
    width: min(70vw, 1180px) !important;
    height: min(60svh, 720px) !important;
  }
}

@media (max-aspect-ratio: 9/16) {
  .hero-stage {
    padding-top: clamp(110px, 11vh, 170px) !important;
    padding-bottom: clamp(70px, 9vh, 140px) !important;
  }
  .hero-copy {
    width: min(90vw, 980px) !important;
  }
  .hero-title-top,
  .hero-title-bottom {
    font-size: clamp(46px, 7.3vw, 92px) !important;
  }
  .hero-title-ai {
    font-size: clamp(66px, 8.6vw, 116px) !important;
  }
  .hero-title-bottom {
    white-space: normal !important;
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .hero-cta {
    margin-top: clamp(48px, 6vh, 88px) !important;
  }
  #loading-particles {
    width: min(92vw, 900px) !important;
    height: min(92vw, 900px) !important;
    top: 37% !important;
  }
  #loading-text {
    top: 65% !important;
  }
  #comparison-slider {
    width: min(88vw, 760px) !important;
    height: min(44svh, 520px) !important;
  }
}

@media (max-height: 680px) {
  #workspace {
    height: 98svh !important;
  }
  #side-toolbar {
    top: 82px !important;
  }
  #bottom-controls {
    bottom: 8px !important;
  }
  #control-card,
  #btn-generate {
    height: clamp(50px, 7.6svh, 60px) !important;
  }
  #loading-particles {
    width: min(68vmin, 640px) !important;
    height: min(68vmin, 640px) !important;
    top: 35% !important;
  }
  #loading-text {
    top: 64% !important;
    font-size: clamp(18px, 3.2vh, 28px) !important;
  }
  #loading-subtitle {
    top: calc(64% + 38px) !important;
  }
  #result-container {
    max-height: 94svh !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    gap: 10px !important;
  }
  #comparison-slider {
    height: min(44svh, 340px) !important;
  }
  .result-btn {
    height: 50px !important;
  }
}

@media (min-width: 1025px) and (max-width: 1500px) {
  .hero-copy {
    width: min(90vw, 1320px) !important;
  }
  #workspace {
    width: min(97vw, 1540px) !important;
    height: min(94svh, 980px) !important;
  }
  #control-card {
    max-width: min(86vw, 1400px) !important;
  }
  #comparison-slider {
    width: min(82vw, 920px) !important;
  }
}

@media (max-width: 820px) and (max-height: 900px) {
  #result-container {
    width: 95vw !important;
    max-height: 92svh !important;
  }
  #comparison-slider {
    width: 90vw !important;
    height: min(46svh, 420px) !important;
  }
  .result-btn {
    min-width: 74vw !important;
  }
}

/* ============================================================
   55-INCH 4K LARGE SCREEN (3840x2160)
   ============================================================ */
@media (min-width: 3000px) {
  :root {
    --page-pad: 44px;
    --workspace-radius-r: 42px;
    --control-gap-r: 40px;
  }

  /* Attract hero */
  .hero-stage {
    padding-top: clamp(140px, 10svh, 240px) !important;
    padding-bottom: clamp(100px, 8svh, 200px) !important;
  }
  .hero-copy {
    width: min(76vw, 2400px) !important;
  }
  .hero-title-top,
  .hero-title-bottom {
    font-size: clamp(80px, 5.2vw, 180px) !important;
  }
  .hero-title-ai {
    font-size: clamp(110px, 6.4vw, 220px) !important;
  }
  .hero-title-bottom {
    margin-top: clamp(40px, 4svh, 100px) !important;
  }
  .hero-cta {
    margin-top: clamp(100px, 9svh, 180px) !important;
    padding: clamp(24px, 2svh, 36px) clamp(50px, 3vw, 80px) !important;
    font-size: clamp(28px, 1.6vw, 44px) !important;
  }

  /* Attract layer header */
  #attract-layer header {
    padding: clamp(28px, 2vw, 56px) !important;
  }
  #attract-layer header img {
    width: clamp(48px, 2.4vw, 72px) !important;
    height: clamp(48px, 2.4vw, 72px) !important;
  }
  #attract-layer header span {
    font-size: clamp(28px, 1.4vw, 48px) !important;
  }

  /* Carousel */
  .cylinder-container {
    transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(14px) scale(3.8) !important;
  }
  .perspective-scene {
    perspective: 3000px !important;
  }
  .panel {
    width: 340px !important;
    height: 540px !important;
    top: -270px !important;
    left: -170px !important;
  }
  .picture-card {
    width: 290px !important;
    height: 360px !important;
  }

  /* Workspace */
  #workspace {
    width: min(92vw, 3200px) !important;
    height: min(90svh, 1800px) !important;
  }
  #side-toolbar {
    top: 280px !important;
    left: 64px !important;
    width: 110px !important;
  }
  .side-tool {
    width: 96px !important;
    height: 108px !important;
    font-size: 17px !important;
    gap: 8px !important;
  }
  .side-tool svg {
    width: 30px !important;
    height: 30px !important;
  }

  #canvas-area {
    left: 42px !important;
    right: 42px !important;
    top: 42px !important;
    bottom: 42px !important;
    border-radius: 40px !important;
  }

  #bottom-controls {
    left: 64px !important;
    right: 64px !important;
    bottom: 52px !important;
    grid-template-columns: auto 380px !important;
    gap: 36px !important;
  }

  #control-card {
    height: 100px !important;
    padding: 0 36px !important;
    gap: 32px !important;
    border-radius: 22px !important;
  }
  .toolbar-section {
    gap: 18px !important;
  }
  .toolbar-divider {
    height: 48px !important;
  }
  .color-swatch {
    width: 36px !important;
    height: 36px !important;
  }
  .brush-group-title {
    font-size: 19px !important;
  }
  .brush-btn {
    width: 34px !important;
    height: 34px !important;
  }
  .brush-dot.small { width: 8px !important; height: 8px !important; }
  .brush-dot.medium { width: 14px !important; height: 14px !important; }
  .brush-dot.large { width: 20px !important; height: 20px !important; }
  #control-card .top-action {
    min-width: 90px !important;
    height: 58px !important;
    font-size: 18px !important;
    border-radius: 16px !important;
  }
  #control-card .top-action svg {
    width: 20px !important;
    height: 20px !important;
  }

  #btn-generate {
    height: 100px !important;
    font-size: 26px !important;
    border-radius: 22px !important;
  }

  /* Loading */
  #loading-particles {
    width: min(60vw, 1600px) !important;
    height: min(60vw, 1600px) !important;
  }
  #loading-text {
    font-size: clamp(28px, 2vw, 46px) !important;
  }
  #loading-subtitle {
    font-size: clamp(16px, 0.8vw, 22px) !important;
  }

  /* Result */
  #result-container {
    width: min(72vw, 1600px) !important;
    max-height: min(84svh, 1300px) !important;
    padding: 36px !important;
    gap: 28px !important;
  }
  #comparison-slider {
    width: min(62vw, 1300px) !important;
    height: min(58svh, 900px) !important;
  }
  #result-finish-text {
    font-size: 20px !important;
  }
  .result-btn {
    min-width: 380px !important;
    height: 80px !important;
    font-size: 28px !important;
  }
}

/* Extra large 4K+ (over 3800px) */
@media (min-width: 3800px) {
  .cylinder-container {
    transform: rotateZ(-22deg) rotateX(12deg) rotateY(-10deg) translateY(14px) scale(4.6) !important;
  }
  .perspective-scene {
    perspective: 3600px !important;
  }
  .panel {
    width: 400px !important;
    height: 640px !important;
    top: -320px !important;
    left: -200px !important;
  }
  .picture-card {
    width: 340px !important;
    height: 430px !important;
  }

  #workspace {
    width: min(90vw, 3600px) !important;
    height: min(88svh, 1900px) !important;
  }
  #side-toolbar {
    width: 130px !important;
  }
  .side-tool {
    width: 112px !important;
    height: 126px !important;
    font-size: 19px !important;
  }
  .side-tool svg {
    width: 34px !important;
    height: 34px !important;
  }
  #bottom-controls {
    grid-template-columns: auto 440px !important;
  }
  #control-card {
    height: 114px !important;
  }
  #control-card .top-action {
    min-width: 104px !important;
    height: 66px !important;
    font-size: 20px !important;
  }
  #btn-generate {
    height: 114px !important;
    font-size: 30px !important;
  }
}
