* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  overflow: hidden;
  color: #20252d;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 50% 28%, #f7fafc 0, #eef3f7 34%, #e9eef3 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.topbar {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 17px 38px 0;
  pointer-events: none;
}
.topbar h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  line-height: 1;
  letter-spacing: .02em;
}
.tabs {
  pointer-events: auto;
  display: flex;
  gap: 4px;
  min-width: 218px;
  padding: 5px;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(180,190,200,.25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 10px 24px rgba(94,108,122,.08);
  backdrop-filter: blur(16px);
}
.tab {
  min-width: 64px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  color: #9aa4af;
  background: transparent;
  font-size: 13px;
}
.tab.is-active {
  color: #56606c;
  background: rgba(255,255,255,.9);
  box-shadow: 0 6px 16px rgba(105,118,132,.14);
}
.hint {
  justify-self: end;
  margin: 0;
  color: #a6b0bb;
  font-size: 12px;
  letter-spacing: .02em;
}

main { min-height: 100vh; }
.view {
  display: none;
  width: 100vw;
  height: 100vh;
  position: relative;
}
.view.is-active { display: block; }
.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.make-view .maker-panel {
  position: absolute;
  z-index: 10;
  left: 7.4vw;
  top: 17vh;
  width: min(31vw, 370px);
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.make-view #imageInput { display: none; }
.paper-preview {
  position: relative;
  width: min(29vw, 355px);
  aspect-ratio: 1 / 1;
  margin: 0 0 24px 28px;
  overflow: hidden;
  border-radius: 16px;
  transform: rotate(7deg);
  background: rgba(255,255,255,.92);
  box-shadow: 0 28px 54px rgba(99,111,124,.12);
}
.paper-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translate(var(--paper-x, 0), var(--paper-y, 0)) scale(var(--paper-scale, 1));
}
.cut-ring {
  position: absolute;
  inset: 23%;
  border-radius: 50%;
  border: 2px solid rgba(120,130,142,.25);
  box-shadow: 0 0 0 999px rgba(255,255,255,.08);
}
.make-view .maker-panel label {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 14px;
  margin: 13px 0;
  color: #99a3ae;
  font-size: 13px;
}
.make-view select,
.make-view input[type="range"] { width: 100%; }
.make-view select {
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 3px;
  color: #68717d;
  background: rgba(255,255,255,.86);
  box-shadow: inset 0 0 0 1px rgba(178,187,198,.14);
}
input[type="range"] { accent-color: #1f242c; }
.secondary,
.make-next {
  height: 44px;
  border: 0;
  border-radius: 3px;
  color: #fff;
  background: rgba(94,103,114,.72);
}
.secondary {
  width: calc(100% - 46px);
  margin-left: 46px;
}
.make-next {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: 12vh;
  min-width: 128px;
  transform: translateX(-10%);
  opacity: .85;
}

.press-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.press-machine {
  width: min(43vw, 610px);
  transform: translate(18vw, 2vh);
  filter: drop-shadow(0 24px 38px rgba(94,103,114,.14));
}
.press-target {
  position: absolute;
  left: 64%;
  bottom: 25%;
  width: 150px;
  height: 150px;
  transform: translateX(-18%);
  border-radius: 50%;
}
.mini-badge {
  width: 68px;
  height: 68px;
  margin: 45px auto 0;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 12px 20px rgba(67,75,88,.2);
}
.mini-badge img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.press-copy {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translateX(-13%);
  margin: 0;
  color: #3c424c;
  font-size: 26px;
  font-weight: 600;
}

.badge-scene {
  width: min(52vw, 520px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  perspective: 1200px;
  filter: drop-shadow(0 30px 34px rgba(112,121,132,.18));
  touch-action: none;
}
.badge-scene canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.badge {
  --rotX: 10deg;
  --rotY: -12deg;
  --scale: 1;
  position: relative;
  width: min(21vw, 225px);
  aspect-ratio: 1 / 1;
  transform-style: preserve-3d;
  transform: rotateX(var(--rotX)) rotateY(var(--rotY)) scale(var(--scale));
  transition: transform 180ms ease, width 160ms ease;
}
.badge-face,
.badge-side {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.badge-side {
  transform: translateZ(-11px);
  background: linear-gradient(90deg, #717b86, #f5f7fa 48%, #69737f);
  box-shadow: inset 0 0 18px rgba(35,40,48,.25);
}
.badge-face {
  overflow: hidden;
  padding: 9%;
  background: radial-gradient(circle at 30% 22%, #fff, rgba(244,247,250,.95) 44%, rgba(207,215,224,.95));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.84), inset 0 -15px 24px rgba(61,70,82,.16);
}
.badge-face::before {
  content: "";
  position: absolute;
  inset: 6%;
  z-index: 2;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 20%, rgba(255,255,255,.82), rgba(255,255,255,.2) 24%, transparent 43%), linear-gradient(130deg, rgba(255,255,255,.38), transparent 46%);
  pointer-events: none;
}
.badge-face::after {
  content: "";
  position: absolute;
  inset: 8%;
  z-index: 3;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(88,99,112,.14);
  pointer-events: none;
}
.badge-face img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.badge-44 { width: min(17vw, 180px); }
.badge-58 { width: min(21vw, 225px); }
.badge-75 { width: min(25vw, 270px); }
.finish-matte .badge-face { filter: saturate(.82) contrast(.94); }
.finish-metal .badge-face { background: radial-gradient(circle at 28% 24%, #fff, #d9dee5 46%, #8e98a4); }
.finish-holo .badge-face { background: conic-gradient(from 20deg, rgba(255,238,107,.45), rgba(86,223,255,.4), rgba(134,109,255,.36), rgba(255,111,222,.36), rgba(255,149,82,.38), rgba(255,238,107,.45)); }
.finish-pearl .badge-face { background: linear-gradient(135deg, #fff, #eafaff 30%, #eee9ff 62%, #fff3fa); }

.finish-grid {
  position: absolute;
  left: 50%;
  bottom: 48px;
  z-index: 10;
  transform: translateX(-50%);
  display: flex;
  align-items: end;
  gap: 16px;
}
.finish {
  display: grid;
  justify-items: center;
  gap: 7px;
  width: 48px;
  padding: 0;
  border: 0;
  color: #8f99a5;
  background: transparent;
  font-size: 12px;
}
.finish span {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 1px solid rgba(150,160,172,.22);
  box-shadow: 0 9px 18px rgba(79,88,100,.09);
}
.finish.is-active span {
  outline: 2px solid rgba(133,142,154,.32);
  outline-offset: 3px;
}
.finish[data-finish="gloss"] span { background: linear-gradient(145deg, #fff, #e9edf1); }
.finish[data-finish="matte"] span { background: linear-gradient(145deg, #aeb5bd, #777f89); }
.finish[data-finish="metal"] span { background: radial-gradient(circle at 34% 34%, #fff, #b9c0ca 50%, #727c88); }
.finish[data-finish="holo"] span { background: conic-gradient(from 30deg, #ffef7a, #5fe4ff, #8677ff, #ff74df, #ff935b, #ffef7a); }
.finish[data-finish="pearl"] span { background: linear-gradient(135deg, #fff, #e5f8ff 33%, #efe8ff 64%, #fff4fa); }
.finish-next span {
  display: grid;
  place-items: center;
  background: rgba(92,101,112,.72);
}
.finish-next span::before {
  content: "";
  width: 12px;
  height: 12px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
  transform: rotate(45deg);
}

.arrow {
  position: absolute;
  top: 52%;
  z-index: 9;
  width: 160px;
  height: 60px;
  border: 0;
  background: transparent;
}
.arrow::before,
.arrow::after {
  content: "";
  position: absolute;
  top: 29px;
  background: #aeb6c1;
}
.arrow::before { width: 140px; height: 2px; left: 0; }
.arrow::after {
  width: 28px;
  height: 28px;
  border-top: 2px solid #aeb6c1;
  border-right: 2px solid #aeb6c1;
  background: transparent;
  right: 0;
  top: 15px;
  transform: rotate(45deg);
}
.arrow.left { left: 7vw; transform: scaleX(-1); }
.arrow.right { right: 7vw; }

.bag-stage {
  inset: 0;
  display: grid;
  place-items: center;
}
.bag-canvas {
  position: relative;
  width: min(35vw, 430px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 26px 34px rgba(101,110,121,.12));
}
.bag-canvas img { width: 100%; height: 100%; object-fit: contain; }
.bag-canvas::after {
  content: "";
  position: absolute;
  inset: 20% 14% 18%;
  z-index: 6;
  border-radius: 22% 22% 18% 18%;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255,255,255,.45), rgba(255,255,255,0) 34%),
    radial-gradient(circle at 76% 28%, rgba(255,255,255,.38), rgba(255,255,255,0) 22%),
    linear-gradient(0deg, rgba(255,255,255,.16), rgba(255,255,255,.04));
  mix-blend-mode: screen;
  filter: blur(.2px);
}
.placed-badge {
  position: absolute;
  z-index: 4;
  width: clamp(42px, 5vw, 66px);
  height: clamp(42px, 5vw, 66px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  overflow: hidden;
  transform: translate(-50%, -50%);
  background: #fff;
  box-shadow:
    inset 0 0 0 3px rgba(242,245,248,.92),
    inset 0 -8px 12px rgba(49,57,68,.2),
    0 2px 0 rgba(128,137,148,.62),
    0 12px 18px rgba(63,72,84,.18);
}
.placed-badge::before,
.tray-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 50%;
  background:
    radial-gradient(circle at 28% 18%, rgba(255,255,255,.9), rgba(255,255,255,.18) 25%, transparent 45%),
    linear-gradient(145deg, rgba(255,255,255,.28), transparent 45%);
  pointer-events: none;
}
.placed-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(78,88,100,.15), inset 0 -10px 12px rgba(54,62,74,.15);
}
.placed-badge img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.placed-badge.finish-holo::before,
.tray-badge.finish-holo::before {
  background:
    conic-gradient(from 20deg, rgba(255,235,85,.44), rgba(75,224,255,.34), rgba(135,106,255,.34), rgba(255,102,220,.34), rgba(255,150,75,.34), rgba(255,235,85,.44)),
    radial-gradient(circle at 28% 18%, rgba(255,255,255,.86), transparent 42%);
  mix-blend-mode: screen;
}
.placed-badge.finish-matte::before,
.tray-badge.finish-matte::before { opacity: .35; filter: grayscale(.35); }
.placed-badge.finish-metal,
.tray-badge.finish-metal {
  box-shadow:
    inset 0 0 0 3px rgba(235,239,244,.96),
    inset 0 -8px 12px rgba(49,57,68,.24),
    0 2px 0 rgba(160,169,180,.85),
    0 12px 18px rgba(63,72,84,.18);
}
.placed-badge.finish-pearl::before,
.tray-badge.finish-pearl::before {
  background:
    linear-gradient(135deg, rgba(255,255,255,.58), rgba(214,245,255,.24), rgba(246,220,255,.3)),
    radial-gradient(circle at 28% 18%, rgba(255,255,255,.86), transparent 42%);
}
.badge-tray {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  align-items: center;
}
.tray-badge {
  position: relative;
  width: 62px;
  height: 62px;
  margin-left: -8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: inset 0 0 0 3px rgba(244,247,250,.9), inset 0 -8px 12px rgba(49,57,68,.16), 0 12px 22px rgba(72,81,94,.14);
}
.tray-badge:first-child { margin-left: 0; }
.tray-badge img { width: 100%; height: 100%; object-fit: cover; }
.dots {
  position: absolute;
  left: 50%;
  bottom: 122px;
  z-index: 10;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}
.dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(128,139,151,.22);
}
.dots button.is-active { background: #68717d; }
.round-action {
  position: absolute;
  z-index: 12;
  bottom: 24px;
  width: 70px;
  height: 70px;
  border: 0;
  border-radius: 50%;
  color: #4d5560;
  background: rgba(255,255,255,.44);
  box-shadow: 0 16px 28px rgba(86,96,108,.08);
  font-size: 28px;
}
.trash { left: 34px; }
.camera { right: 34px; font-size: 22px; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .topbar { grid-template-columns: 1fr; gap: 12px; padding: 16px; background: rgba(235,240,245,.72); }
  .hint { justify-self: center; }
  .view { min-height: 100vh; height: auto; padding-top: 120px; }
  .make-view .maker-panel { position: relative; inset: auto; width: 86vw; margin: 0 auto 24px; }
  .paper-preview { width: 78vw; }
  .press-stage { position: relative; min-height: 520px; }
  .press-machine { width: min(96vw, 520px); transform: none; }
  .press-copy { top: 54%; left: 50%; transform: translateX(-50%); font-size: 20px; }
  .make-next { bottom: 7vh; transform: translateX(-50%); }
  .badge { width: min(54vw, 260px); }
  .arrow { display: none; }
  .bag-canvas { width: min(86vw, 430px); }
}
