:root {
  --wood: #c9a36a;
  --wood-dark: #8a6238;
  --wood-deep: #5c3d22;
  --silk-shadow: rgba(70, 40, 20, 0.28);
  --ink: #3a2a32;
  --muted: #6e5a64;
  --gold: #e0b45a;
  --cell: 76px;
  --cube: 68px;
  --half: 34px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Assistant", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #23182a;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  width: min(430px, 100vw);
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, #ffe7c4 0%, transparent 42%),
    linear-gradient(180deg, #f3e6c8 0%, #e8d7b4 36%, #d5c9a4 68%, #c4b892 100%);
}

.sky-glow {
  pointer-events: none;
  position: absolute;
  inset: auto -20% 18% -20%;
  height: 40%;
  background: radial-gradient(ellipse at center, rgba(255, 220, 160, 0.35), transparent 70%);
}

.dust span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  animation: float 9s linear infinite;
}

@keyframes float {
  from { transform: translateY(110vh) scale(0.6); opacity: 0; }
  15% { opacity: 0.8; }
  to { transform: translateY(-10vh) scale(1); opacity: 0; }
}

.screen { position: absolute; inset: 0; }

.hidden { display: none !important; }

.mandala {
  width: 260px;
  height: 260px;
  margin: 8vh auto 0;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg, rgba(224, 180, 90, 0.28) 0 8deg, transparent 8deg 16deg),
    radial-gradient(circle at 50% 50%, #fff6e4 0 18%, transparent 19%),
    radial-gradient(circle at 50% 50%, transparent 42%, rgba(155, 90, 160, 0.18) 43% 48%, transparent 49%);
  box-shadow: 0 0 0 2px rgba(224, 180, 90, 0.25), 0 20px 50px rgba(90, 40, 80, 0.15);
  animation: spin 48s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow {
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 12px;
  color: var(--muted);
  margin-top: 22px;
}

.logo {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 64px;
  text-align: center;
  letter-spacing: 0.08em;
  color: #4a2f3a;
}

.tagline {
  text-align: center;
  line-height: 1.6;
  color: var(--muted);
  margin: 12px 32px 28px;
  font-size: 15px;
}

.hint-start {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 18px;
  opacity: 0.8;
}

.btn-primary, .btn-ghost {
  display: block;
  margin: 10px auto;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(180deg, #f0c36a, #d49a3c);
  color: #3a2610;
  padding: 14px 36px;
  border-radius: 999px;
  box-shadow: 0 8px 0 #a36d20, 0 12px 24px rgba(120, 60, 20, 0.25);
}

.btn-primary:active { transform: translateY(3px); box-shadow: 0 5px 0 #a36d20; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  color: #5a4450;
  cursor: pointer;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(80, 40, 60, 0.08);
}

.level-wrap { text-align: center; }
.level-label {
  display: block;
  font-family: "Cormorant Garamond", serif;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
#level-num {
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 15px;
}

.karma-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.6);
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  font-weight: 700;
  min-width: 72px;
  justify-content: flex-end;
}

.karma-sun {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3c4, #e0b45a 55%, #c48a28);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.bowls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px 4px;
  min-height: 86px;
}

.bowl {
  width: 78px;
  height: 72px;
  border-radius: 50% 50% 18px 18px;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255,255,255,0.55), transparent 46%),
    linear-gradient(180deg, #efe3d2, #c9a57a);
  box-shadow: 0 8px 0 rgba(140, 100, 60, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.7);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  gap: 3px;
}

.bowl.locked {
  background: linear-gradient(180deg, #ddd6e6, #c8bfd4);
  color: #7a7088;
}

.bowl-plus {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  color: #8a7c96;
}

.bowl .slot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 2px 3px rgba(80, 50, 30, 0.2);
}

.bowl .slot.filled {
  box-shadow: 0 0 8px color-mix(in srgb, var(--gem) 70%, white);
  background: var(--gem);
}

.bowl.flash { animation: bowl-sing 0.55s ease; }

@keyframes bowl-sing {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); filter: brightness(1.15); }
  100% { transform: scale(1); }
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  padding: 2px 0 4px;
}

.progress-row .stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.coin-icon, .lotus-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.coin-icon { background: radial-gradient(circle at 30% 30%, #ffe9a8, #d4a017); }
.lotus-icon {
  background: radial-gradient(circle at 50% 60%, #b7d48a, #5d8a3a);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.scene {
  height: min(52dvh, 420px);
  perspective: 1100px;
  display: grid;
  place-items: center;
  cursor: grab;
}

.scene.dragging { cursor: grabbing; }

.stage {
  position: relative;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(62deg) rotateZ(45deg);
}

.cube {
  position: absolute;
  width: var(--cube);
  height: var(--cube);
  left: 0;
  top: 0;
  transform: translate3d(
    calc(var(--x) * var(--cell) - var(--half)),
    calc(var(--y) * var(--cell) - var(--half)),
    calc(var(--z) * var(--cell))
  );
  transform-style: preserve-3d;
}

.cube.gone {
  animation: dissolve 0.45s ease forwards;
}

@keyframes dissolve {
  to {
    opacity: 0;
    transform: translate3d(
      calc(var(--x) * var(--cell) - var(--half)),
      calc(var(--y) * var(--cell) - var(--half)),
      calc(var(--z) * var(--cell) + 24px)
    ) scale(0.7);
  }
}

.face {
  position: absolute;
  width: var(--cube);
  height: var(--cube);
  transform-style: preserve-3d;
  background:
    repeating-linear-gradient(90deg, transparent, transparent 6px, rgba(90, 50, 20, 0.06) 6px, rgba(90, 50, 20, 0.06) 7px),
    linear-gradient(160deg, #e2c089, var(--wood) 40%, var(--wood-dark));
  box-shadow: inset 0 0 0 1px rgba(90, 50, 20, 0.18);
}

.face.top {
  background:
    repeating-linear-gradient(90deg, transparent, transparent 7px, rgba(90, 50, 20, 0.07) 7px, rgba(90, 50, 20, 0.07) 8px),
    linear-gradient(135deg, #edd6a6, #c9a36a);
}

.face.top.has-silk {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--silk) 72%, #fff), color-mix(in srgb, var(--silk) 88%, #6a3a20));
}

.face.front { transform: rotateY(0deg) translateZ(var(--half)); }
.face.back { transform: rotateY(180deg) translateZ(var(--half)); }
.face.east { transform: rotateY(90deg) translateZ(var(--half)); }
.face.west { transform: rotateY(-90deg) translateZ(var(--half)); }
.face.top { transform: rotateX(90deg) translateZ(var(--half)); }
.face.bottom { transform: rotateX(-90deg) translateZ(var(--half)); background: var(--wood-deep); }

.crystal, .fly {
  background-color: var(--gem);
  background-image:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.85) 0 18%, transparent 20%),
    radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--gem) 40%, white), var(--gem) 62%, #3a2010);
}

.crystal {
  position: absolute;
  width: 38px;
  height: 38px;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 50%;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0;
  box-shadow:
    0 0 0 2px rgba(90, 50, 20, 0.18),
    0 3px 8px rgba(40, 20, 20, 0.4);
  cursor: pointer;
  z-index: 8;
}

.nut.walnut {
  width: 42px;
  height: 32px;
  border-radius: 60% 40% 55% 45%;
  box-shadow: inset 0 -4px 0 rgba(60, 30, 10, 0.25), 0 3px 6px rgba(40,20,20,0.35);
}

.nut.pecan {
  width: 44px;
  height: 24px;
  border-radius: 50% / 45%;
}

.nut.almond {
  width: 28px;
  height: 40px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
}

.nut.brazil {
  width: 46px;
  height: 26px;
  border-radius: 40% 30% 45% 35%;
  box-shadow: inset 0 0 0 2px #c9a06a, 0 3px 6px rgba(40,20,20,0.3);
}

.nut.coconut {
  width: 40px;
  height: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 0 #e8d4b8, 0 3px 6px rgba(40,20,20,0.25);
}

.nut.raisin {
  width: 26px;
  height: 22px;
  border-radius: 45% 55% 50% 40%;
}

.crystal.blocked {
  filter: grayscale(0.25) brightness(0.78);
  cursor: default;
  box-shadow: 0 1px 3px rgba(40, 20, 20, 0.25);
}

.crystal.hint {
  animation: pulse 0.7s ease infinite;
}

@keyframes pulse {
  50% { filter: brightness(1.35); box-shadow: 0 0 0 6px rgba(255,255,255,0.55), 0 0 18px var(--gem); }
}

.crystal.taken { visibility: hidden; }

.fly {
  position: fixed;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 0 10px color-mix(in srgb, var(--gem) 60%, transparent);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  background: rgba(50, 30, 45, 0.86);
  color: #fff8ee;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.tools {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  direction: ltr;
}

.tool {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8ee, #f0e0d0);
  box-shadow: 0 6px 0 rgba(150, 110, 80, 0.2);
  cursor: pointer;
  position: relative;
  font-size: 26px;
}

.tool:disabled { opacity: 0.4; cursor: default; }

.tool .uses {
  position: absolute;
  top: -6px;
  left: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7d5ea8;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(40, 24, 38, 0.42);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 20;
}

.card {
  width: min(320px, 86%);
  background: #fff7ee;
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(40, 20, 40, 0.25);
}

.card h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 34px;
  margin-bottom: 8px;
}

.card p { color: var(--muted); margin-bottom: 16px; }
