* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --wood: #7a5230;
  --cream: #fef6e4;
  --ink: #3a2a1c;
  --accent: #ff8a3d;
  --leaf: #4b8a5a;
}
html, body { height: 100%; overflow: hidden; font-family: 'Bricolage Grotesque', sans-serif; }
#scene-container { position: fixed; inset: 0; }
canvas { display: block; touch-action: none; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* Frosted glass helper */
.glass {
  background: rgba(254, 246, 228, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Top bar */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: rgba(254, 246, 228, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--wood);
  box-shadow: 0 4px 18px rgba(90,60,20,0.15);
  flex-wrap: wrap;
}
.title {
  font-weight: 800; font-size: 22px; color: var(--ink);
  white-space: nowrap; letter-spacing: -0.5px;
}
#stepper { display: flex; gap: 4px; flex: 1; overflow-x: auto; padding-bottom: 2px; }
.step {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700; color: #9a7f5a;
  white-space: nowrap; opacity: 0.6; transition: all .25s;
  border: 2px solid transparent;
}
.step .dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: #e6d5b8; font-size: 12px;
}
.step.done { opacity: 1; color: var(--leaf); }
.step.done .dot { background: var(--leaf); color: #fff; }
.step.active {
  opacity: 1; color: var(--ink);
  background: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,138,61,0.25);
  animation: glow 1.4s ease-in-out infinite;
}
.step.active .dot { background: var(--accent); color: #fff; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(255,138,61,0.12); } }

/* Hint */
.hint {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  max-width: 92%; text-align: center;
  background: rgba(58,42,28,0.9); color: var(--cream);
  padding: 8px 18px; border-radius: 30px; font-size: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}
.hint b { color: #ffd24b; }

/* Inventory */
#inventory {
  position: absolute; top: 120px; left: 12px; width: 210px;
  background: rgba(254, 246, 228, 0.9);
  backdrop-filter: blur(10px);
  border: 2px solid var(--wood); border-radius: 14px;
  box-shadow: 0 6px 20px rgba(90,60,20,0.2);
  overflow: hidden; transition: width .25s;
}
#inventory.collapsed { width: 46px; }
#inventory.collapsed #invList { display: none; }
#inventory.collapsed .inv-head span:first-child { display: none; }
.inv-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; font-weight: 800; color: var(--ink); cursor: pointer;
  background: rgba(122,82,48,0.12);
}
#invChevron { font-weight: 800; color: var(--wood); }
#invList { padding: 6px 10px 10px; }
.inv-item { font-size: 13px; padding: 5px 4px; color: #9a7f5a; font-weight: 600; }
.inv-item.installed { color: var(--ink); }

/* Toolbar */
#toolbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
  background: rgba(254, 246, 228, 0.9);
  backdrop-filter: blur(10px);
  border-top: 3px solid var(--wood);
  box-shadow: 0 -4px 18px rgba(90,60,20,0.15);
}
.buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.btn {
  font-family: inherit; font-weight: 800; font-size: 15px;
  border: none; border-radius: 14px; cursor: pointer;
  padding: 12px 20px; transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: translateY(2px) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #ffa860, var(--accent));
  color: #fff; box-shadow: 0 4px 0 #c9591f, 0 6px 14px rgba(255,138,61,0.4);
}
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 #c9591f; }
.btn-ghost {
  background: #fff; color: var(--ink);
  box-shadow: 0 3px 0 #d8c4a0; border: 2px solid #e6d5b8;
}

/* Swatches */
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.sw-label { font-weight: 700; color: var(--ink); font-size: 13px; }
.swatch {
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.sel { border-color: var(--ink); transform: scale(1.15); }

/* Decor toggles */
.decorbtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.decor-toggle {
  font-family: inherit; font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: 20px; cursor: pointer;
  background: #fff; color: var(--ink); border: 2px solid #e6d5b8;
  box-shadow: 0 2px 0 #d8c4a0; transition: all .12s;
}
.decor-toggle.on {
  background: var(--leaf); color: #fff; border-color: var(--leaf);
  box-shadow: 0 2px 0 #326b40;
}

.hidden { display: none !important; }

/* Remix link */
#remixLink {
  position: absolute; bottom: 8px; right: 12px;
  font-size: 11px; color: rgba(58,42,28,0.6);
  text-decoration: none; font-weight: 700;
  background: rgba(254,246,228,0.7); padding: 4px 10px; border-radius: 12px;
  z-index: 5;
}
#remixLink:hover { color: var(--accent); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(58,42,28,0.55); backdrop-filter: blur(4px);
}
.modal-card {
  position: relative; overflow: hidden;
  background: var(--cream); border: 4px solid var(--wood);
  border-radius: 24px; padding: 28px 26px; max-width: 380px; width: 90%;
  text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  animation: pop .4s cubic-bezier(.2,1.3,.4,1);
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }
.modal-card h2 { font-size: 28px; color: var(--ink); margin-bottom: 8px; }
.modal-card p { color: #7a5f3a; font-size: 14px; margin-bottom: 16px; line-height: 1.4; }
#nameInput {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 2px solid #d8c4a0; font-family: inherit; font-size: 15px;
  margin-bottom: 16px; background: #fff; color: var(--ink);
}
#nameInput:focus { outline: none; border-color: var(--accent); }
.modal-btns { display: flex; gap: 10px; justify-content: center; }

/* Confetti */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -12px; width: 9px; height: 14px;
  border-radius: 2px; animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(360px) rotate(540deg); opacity: 0; }
}

@media (max-width: 560px) {
  .title { font-size: 17px; }
  .hint { top: 96px; font-size: 12px; }
  #inventory { top: 130px; }
  .btn { padding: 11px 16px; font-size: 14px; }
}