:root {
  --ink: #1f2430;
  --muted: #7b8291;
  --accent: #5b6cff;
  --card: rgba(255, 255, 255, 0.96);
  --line: #e7e9ef;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Fredoka", system-ui, sans-serif;
  color: var(--ink);
  /* neutral studio backdrop — desaturated so the tee is the hero */
  background: radial-gradient(130% 100% at 50% 0%, #f2f3f6 0%, #e4e7ee 55%, #d3d7e0 100%);
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; }

.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
}
.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.brand .logo { display: inline-grid; place-items: center; width: 28px; height: 28px; background: var(--accent); color: #fff; border-radius: 9px; font-size: 14px; transform: rotate(-8deg); }
.link-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink); font-family: inherit;
  font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(30,36,48,.06);
}
.link-btn:hover { background: #fafbff; }

#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

.hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  background: rgba(255,255,255,.7); padding: 6px 13px; border-radius: 999px;
  pointer-events: none; transition: opacity .4s; z-index: 5;
}

/* bottom controls */
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 16px 20px;
}
.dock {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--card); backdrop-filter: blur(14px);
  padding: 12px 16px; border-radius: 20px;
  box-shadow: 0 12px 40px rgba(30, 36, 48, 0.14);
  max-width: 100%;
}
.dock-row { display: flex; align-items: center; gap: 12px; }
.dock-row .dock-label { min-width: 56px; }
.dock-label { font-weight: 600; font-size: 13px; color: var(--muted); flex: none; }
.sleeve-row { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); }
.sleeve-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.swatches {
  display: flex; gap: 9px; overflow-x: auto; padding: 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.swatches::-webkit-scrollbar { display: none; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; flex: none;
  border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(0,0,0,.14);
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { outline: 3px solid var(--accent); outline-offset: 2px; }

/* desktop order button, inline on the same row as the color swatches */
.btn-order-inline {
  border: none; background: var(--accent); color: #fff; font-family: inherit;
  font-weight: 700; font-size: 14px; padding: 10px 20px; border-radius: 12px; cursor: pointer;
  flex: none; margin-left: 14px;
  box-shadow: 0 6px 16px rgba(91, 108, 255, .32); transition: transform .12s, box-shadow .2s;
}
.btn-order-inline:hover { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(91,108,255,.45); }
.btn-order-inline:active { transform: translateY(0); }

/* order button (desktop-visible, and inside the sheet) */
.btn-order {
  border: none; background: var(--accent); color: #fff; font-family: inherit;
  font-weight: 700; font-size: 16px; padding: 14px 26px; border-radius: 14px; cursor: pointer;
  box-shadow: 0 10px 24px rgba(91, 108, 255, .38); transition: transform .12s, box-shadow .2s;
}
.btn-order:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(91,108,255,.5); }
.btn-order:active { transform: translateY(0); }

/* print size slider (inside the dock card) */
#sizeSlider {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 120px; max-width: 100%; height: 6px;
  border-radius: 999px; background: var(--line); outline: none; cursor: pointer;
}
#sizeSlider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); cursor: pointer;
}
#sizeSlider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); cursor: pointer;
}

/* mobile "scroll to buy" bar */
.buybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(30,36,48,.18);
  cursor: pointer; user-select: none;
}
.buybar .chev { animation: bounce 1.4s infinite; }
@keyframes bounce { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-4px);} }

/* bottom sheet (size + order) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 14; background: rgba(20,24,34,.4);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: #fff; border-radius: 22px 22px 0 0;
  padding: 14px 22px calc(26px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .34s cubic-bezier(.2,.8,.25,1);
  box-shadow: 0 -14px 50px rgba(20,24,34,.28);
  max-width: 520px; margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; background: #d7dae2; margin: 4px auto 14px; }
.sheet h2 { font-size: 19px; font-weight: 700; margin-bottom: 14px; text-align: center; }
.sizes { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 18px; }
.size {
  min-width: 54px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; font-family: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  color: var(--ink); transition: border .15s, background .15s;
}
.size.active { border-color: var(--accent); background: #eef0ff; color: var(--accent); }
.sheet .btn-order { width: 100%; }

/* desktop vs mobile visibility */
.desktop-only { display: none; }
@media (min-width: 641px) {
  .desktop-only { display: inline-flex; }
  .mobile-only { display: none !important; }
}

/* overlay / popup (pseudo) */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 20px;
  background: rgba(30, 34, 46, 0.34); backdrop-filter: blur(6px);
  transition: opacity .35s;
}
.overlay.hide { opacity: 0; pointer-events: none; }
.card {
  width: 100%; max-width: 400px; background: #fff;
  border-radius: 26px; padding: 32px 28px 28px; text-align: center;
  box-shadow: 0 30px 80px rgba(20, 24, 34, 0.34);
  animation: pop .4s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { transform: scale(.85) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.card-emoji { font-size: 44px; }
.card h1 { font-size: 23px; font-weight: 700; line-height: 1.15; margin: 8px 0 6px; letter-spacing: -0.5px; }
.card .sub { font-size: 14px; color: var(--muted); margin-bottom: 20px; font-weight: 500; }
#form { display: flex; flex-direction: column; gap: 12px; }
#username {
  font-family: inherit; font-size: 17px; font-weight: 500;
  padding: 15px 18px; border-radius: 14px; border: 2px solid var(--line);
  background: #f7f8fb; outline: none; transition: border .2s; text-align: center;
}
#username:focus { border-color: var(--accent); }
#go {
  font-family: inherit; font-weight: 700; font-size: 17px; color: #fff;
  padding: 15px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(91, 108, 255, .38);
  transition: transform .12s, box-shadow .2s;
}
#go:hover { transform: translateY(-2px); }
#go:active { transform: translateY(0); }
#go:disabled { opacity: .6; cursor: default; transform: none; }
.err { color: #e0245e; font-weight: 600; font-size: 14px; margin-top: 12px; min-height: 18px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; font-weight: 600; color: var(--muted); }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid #dfe2ec; border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .controls { bottom: 78px; } /* sit above the buy bar */
  .hint { bottom: 210px; }
}
