:root {
  --pink-bg: #e9d6d6;
  --blush: #f3dada;
  --rose: #d9a7a7;
  --mauve: #b48a8a;
  --cream: #f6ede4;
  --beige: #e8ddcf;
  --charcoal: #2a2222;
  --gold: #c9a96a;
  --glass: rgba(255, 245, 240, 0.55);
  --glass-border: rgba(255, 255, 255, 0.6);
  --shadow: 0 8px 30px rgba(80, 40, 50, 0.12);
  --radius: 18px;
  --serif: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  color: var(--charcoal);
  background: linear-gradient(180deg, #ead7d7 0%, #e2cbcb 100%);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; }
#scene { position: fixed; inset: 0; display: block; }

.zoom-controls {
  position: fixed;
  right: 16px;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 6px;
  z-index: 5;
}
.zoom-controls button {
  width: 38px; height: 38px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--charcoal);
  cursor: pointer;
  border-radius: 12px;
  font-weight: 300;
  line-height: 1;
}
.zoom-controls button:hover { background: rgba(255,255,255,0.35); }

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.hidden { display: none !important; }

.card { padding: 12px 16px; pointer-events: auto; }

/* Pearl pill (top-left) */
.pearl-pill {
  position: absolute; top: 16px; left: 16px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.pearl-pill .ico { font-size: 13px; }

/* Rings card — desktop: right side, mobile: top center */
.rings-card {
  position: absolute; top: 16px; right: 16px;
  width: 260px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.ring-row {
  display: grid; grid-template-columns: 50px 1fr 36px;
  align-items: center; gap: 10px; font-weight: 600; font-size: 12px;
}
.bar {
  height: 5px; background: rgba(120, 80, 90, 0.15);
  border-radius: 999px; overflow: hidden;
}
.fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--rose), var(--gold));
  border-radius: 999px;
  transition: width 0.6s ease;
}
.pct { text-align: right; font-size: 11px; color: #7a6262; font-weight: 600; }

/* Prompt pill */
.prompt {
  position: absolute; bottom: 110px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  border-radius: 999px;
}
@media (pointer: coarse), (max-width: 768px) {
  .prompt {
    pointer-events: auto;
    cursor: pointer;
    padding: 14px 26px;
    font-size: 14px;
    bottom: 40px;
  }
}

/* Toast */
.toast {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 24px; font-family: var(--serif);
  font-size: 18px; font-style: italic;
  color: var(--charcoal);
  opacity: 0; transition: opacity 0.5s ease;
  pointer-events: none;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; }

/* Unlock banner */
.unlock-banner {
  position: absolute; top: 80px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  padding: 12px 22px; text-align: center;
  opacity: 0; transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none; min-width: 220px;
}
.unlock-banner.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.unlock-count {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  color: #a8455a; text-transform: uppercase; margin-bottom: 4px;
}
.unlock-name {
  font-family: var(--serif); font-size: 18px; font-style: italic;
  color: var(--charcoal);
}

/* Unlock arrow */
.unlock-arrow {
  position: absolute; color: #a8455a;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(168, 69, 90, 0.4));
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity 0.6s ease;
  animation: arrow-bounce 1.2s ease-in-out infinite;
}
.unlock-arrow.show { opacity: 1; }
@keyframes arrow-bounce {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -8px; }
}

/* Modal */
.modal-wrap {
  position: absolute; inset: 0;
  background: rgba(40, 25, 30, 0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal {
  max-width: 380px; width: 100%; padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h2 {
  font-family: var(--serif); font-size: 28px; font-weight: 700;
  text-align: center; color: var(--charcoal);
}
.reflect strong {
  display: block; font-size: 11px; letter-spacing: 1.5px;
  color: #a8455a; margin-bottom: 4px;
}
.reflect p { font-size: 14px; line-height: 1.5; color: #4a3a3a; }
.btn-primary {
  margin-top: 8px; padding: 12px 24px;
  background: var(--charcoal); color: var(--cream);
  border: none; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: var(--sans);
}
.btn-primary:hover { background: #3d3030; }

/* Joystick */
.joystick {
  position: absolute; bottom: 100px; left: 24px;
  width: 110px; height: 110px;
  background: rgba(255, 245, 240, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
}
.stick {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 48px; height: 48px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.action-btn {
  position: absolute; bottom: 32px; right: 24px;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--charcoal); color: var(--cream);
  border: none; font-size: 22px; font-weight: 700;
  display: none; cursor: pointer;
  box-shadow: var(--shadow);
}

@media (pointer: coarse), (max-width: 768px) {
  .joystick { display: block; }
  .action-btn { display: none; }
  .rings-card {
    top: 60px; right: 50%; transform: translateX(50%);
    width: min(360px, calc(100% - 28px));
  }
  .music-toggle {
    top: 168px;
    right: 8px;
  }
}

/* Music toggle below rings card */
.music-toggle {
  position: absolute;
  top: 120px; right: 16px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  font-size: 16px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--charcoal);
  background: var(--glass);
  transition: opacity 0.3s ease, background 0.3s ease;
  z-index: 5;
}
.music-toggle.muted { opacity: 0.5; text-decoration: line-through; }
.music-toggle:hover { background: rgba(255,255,255,0.5); }

.help-toggle {
  position: absolute; top: 16px; right: 286px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: none;
}
@media (min-width: 769px) { .help-toggle { display: block; } }
.help {
  position: absolute; top: 60px; right: 14px;
  padding: 14px 18px; font-size: 12px;
  line-height: 1.8; max-width: 240px;
}

/* Tasks panel */
.tasks-card {
  position: absolute;
  top: 165px; right: 16px;
  width: 260px;
  padding: 14px 16px 12px;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: auto;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}
.tasks-card.collapsed {
  padding: 6px;
  width: auto;
  gap: 0;
  max-height: none;
  overflow: visible;
}
.tasks-card.collapsed .tasks-head h3,
.tasks-card.collapsed .tasks-tip,
.tasks-card.collapsed .tasks-list { display: none; }
.tasks-card.collapsed .tasks-head { justify-content: center; }
.tasks-head {
  display: flex; align-items: center; justify-content: space-between;
}
.tasks-head h3 {
  font-family: var(--serif);
  font-size: 18px; font-weight: 700;
  color: var(--charcoal); letter-spacing: 0.3px;
}
.tasks-collapse {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.4);
  font-size: 14px; line-height: 1; cursor: pointer;
  color: var(--charcoal);
}
.tasks-tip {
  font-size: 11.5px; line-height: 1.5; color: #6a5454;
  padding: 8px 10px;
  background: rgba(255, 220, 220, 0.35);
  border-radius: 10px;
  border: 1px solid rgba(168, 69, 90, 0.15);
}
.tasks-tip b { color: #a8455a; }
.tasks-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.task {
  display: grid; grid-template-columns: 16px 1fr auto;
  align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--charcoal);
  padding: 6px 4px;
  border-bottom: 1px solid rgba(120, 80, 90, 0.08);
}
.task:last-child { border-bottom: none; }
.task .tick {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid rgba(120, 80, 90, 0.35);
  display: inline-block;
}
.task.done .tick {
  background: #a8455a; border-color: #a8455a;
  box-shadow: 0 0 6px rgba(168, 69, 90, 0.4);
}
.task.done .tick::after {
  content: "✓"; color: #fff; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  height: 100%;
}
.task.done .label { color: #8a6a6a; text-decoration: line-through; opacity: 0.7; }
.task .label { line-height: 1.3; }
.task .count {
  font-size: 10px; font-weight: 700;
  color: #a8455a; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(255, 245, 240, 0.7);
  border: 1px solid rgba(168, 69, 90, 0.2);
}
.task.done .count {
  color: #6a8a6a;
  background: rgba(220, 240, 220, 0.6);
  border-color: rgba(100, 150, 100, 0.25);
}

@media (pointer: coarse), (max-width: 768px) {
  .tasks-card {
    top: 200px; bottom: auto;
    right: 50%; transform: translateX(50%);
    width: min(360px, calc(100% - 28px));
    left: auto;
    max-height: 35vh;
    padding: 10px 12px 8px;
    font-size: 11px;
  }
  .tasks-card .tasks-head h3 { font-size: 15px; }
  .tasks-card .tasks-tip { font-size: 10.5px; padding: 6px 8px; }
  .task { font-size: 11px; padding: 4px 2px; }
  .tasks-card.collapsed {
    top: 200px; left: auto;
    right: max(14px, calc(50% - 180px));
    transform: none;
  }
}

/* BeU link */
.beu-link {
  position: absolute;
  bottom: 16px;
  left: 16px;
  padding: 6px 14px;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  text-decoration: none;
  border-radius: 999px;
  opacity: 0.7;
  transition: opacity 0.3s ease, background 0.3s ease;
  z-index: 5;
}
.beu-link:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.5);
}

@media (pointer: coarse), (max-width: 768px) {
  .beu-link {
    bottom: auto;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ============ Splash / intro ============ */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.7s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 80% 20%, #f6e2d2 0%, transparent 55%),
    radial-gradient(100% 80% at 15% 90%, #e9c8c8 0%, transparent 60%),
    linear-gradient(160deg, #efd9c6 0%, #e8c4c0 55%, #c9a8a6 100%);
  filter: saturate(1.02);
}
.splash-bg::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 70% 60%, rgba(255,255,255,0.4), transparent 60%),
    radial-gradient(2px 2px at 40% 80%, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 85% 25%, rgba(255,255,255,0.4), transparent 60%);
  mix-blend-mode: screen;
  opacity: 0.7;
}
.splash-inner {
  position: relative;
  max-width: 640px;
  width: 100%;
  padding: 44px 44px 36px;
  background: rgba(255, 248, 242, 0.55);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(80, 40, 50, 0.18);
  text-align: left;
  animation: splashIn 0.9s ease both;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.splash-eyebrow {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mauve);
  margin-bottom: 18px;
}
.splash-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 5.2vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--charcoal);
  margin-bottom: 22px;
}
.splash-lede {
  font-size: 15.5px;
  line-height: 1.65;
  color: #4a3a3a;
  max-width: 520px;
}
.splash-lede em {
  font-style: italic;
  font-family: var(--serif);
  font-size: 1.05em;
  color: var(--charcoal);
}
.splash-divider {
  width: 36px; height: 1px;
  background: var(--mauve);
  opacity: 0.5;
  margin: 22px 0;
}
.splash-sub {
  font-size: 14px;
  line-height: 1.65;
  color: #5a4848;
  max-width: 520px;
}
.splash-keys {
  margin-top: 22px;
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 12px; color: #6a5555;
}
.splash-keys kbd {
  display: inline-block;
  padding: 2px 7px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(180,138,138,0.4);
  border-radius: 6px;
  margin-right: 4px;
  color: var(--charcoal);
}
.splash-start {
  margin-top: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 32px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--charcoal);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.25s ease;
}
.splash-start:hover {
  background: #3a2c2c;
  transform: translateY(-1px);
}
.splash-link {
  display: inline-block;
  margin-left: 18px;
  font-size: 13px;
  color: var(--mauve);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, color 0.25s ease;
}
.splash-link:hover { color: var(--charcoal); border-bottom-color: var(--mauve); }

@media (max-width: 540px) {
  .splash-inner { padding: 30px 24px 26px; border-radius: 22px; }
  .splash-title { font-size: 30px; }
  .splash-lede { font-size: 14px; }
  .splash-sub { font-size: 13px; }
  .splash-start { width: 100%; }
  .splash-link { display: block; margin: 14px 0 0; text-align: center; }
}
