*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Nunito', system-ui, sans-serif;
  --ink: #3a3350;
  --ink-soft: #6b6383;
  --cream: #fdf6ec;
  --panel: rgba(255, 252, 246, 0.94);
  --gold: #f0c040;
  --gold-dim: #d4a830;
  --green: #5da345;
  --green-soft: #e8f4e0;
  --coral: #e2695a;
  --coral-soft: #fdeae6;
  --lav: #b9a5d8;
  --shadow: 0 10px 30px rgba(58, 51, 80, 0.18);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #efe3d5;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

button { font-family: var(--font); cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible {
  outline: 4px solid #4a90d9;
  outline-offset: 3px;
  border-radius: 12px;
}

/* ══ Top bar ══ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  background: var(--panel);
  border-bottom: 2px solid rgba(58, 51, 80, 0.08);
  backdrop-filter: blur(6px);
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-shop { height: 44px; width: auto; flex-shrink: 0; filter: drop-shadow(0 2px 3px rgba(58, 51, 80, 0.25)); }
.topbar-title-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar-build { font-size: 13px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; align-self: center; margin-left: 8px; }
.topbar-title strong { font-size: 17px; font-weight: 900; white-space: nowrap; }
.topbar-title span { font-size: 12px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.tb-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 46px; padding: 8px 14px;
  border: 2px solid rgba(58, 51, 80, 0.14);
  border-radius: 14px;
  background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 800;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.tb-btn:hover { transform: translateY(-1px); border-color: rgba(58, 51, 80, 0.3); }
.tb-btn svg { width: 20px; height: 20px; fill: var(--ink); stroke: var(--ink); flex-shrink: 0; }
.tb-btn.toggle[aria-pressed="false"] { opacity: 0.45; }
.tb-btn.toggle[aria-pressed="false"] span::after { content: " off"; font-weight: 700; }
.tb-btn.quick-exit {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.tb-btn.quick-exit svg { fill: var(--gold); stroke: none; }
.tb-btn.quick-exit:hover { background: #2a2440; }

/* ══ Stage ══ */
.stage {
  position: fixed; inset: 0;
  background: url('assets/bg-boutique.webp') center / cover no-repeat;
}

/* ══ Ambience: window light, mist, dust motes (decorative) ══ */
.ambience {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.light-beam {
  position: absolute;
  top: -20%; left: -6%;
  width: 24vw; height: 100vh;
  background: linear-gradient(to bottom,
    rgba(255, 243, 205, 0.75),
    rgba(255, 243, 205, 0.28) 55%,
    rgba(255, 243, 205, 0) 85%);
  border-radius: 0 0 50% 50%;
  transform: rotate(24deg);
  transform-origin: top left;
  filter: blur(16px);
  mix-blend-mode: screen;
  animation: beamBreathe 11s ease-in-out infinite;
}
.beam-2 {
  left: 5%; width: 11vw;
  opacity: 0.75;
  transform: rotate(29deg);
  animation-delay: -5s;
  animation-duration: 14s;
}
.window-glow {
  position: absolute;
  top: 8%; left: -6%;
  width: 34vw; height: 55vh;
  background: radial-gradient(ellipse at 30% 40%,
    rgba(255, 246, 208, 0.85), rgba(255, 246, 208, 0) 70%);
  filter: blur(10px);
  mix-blend-mode: screen;
  animation: beamBreathe 9s -3s ease-in-out infinite;
}
/* Star-like glints twinkling on the window panes */
.glint {
  position: absolute;
  left: var(--gx); top: var(--gy);
  width: 36px; height: 36px;
  background:
    radial-gradient(circle, rgba(255, 255, 240, 0.95) 0 8%, rgba(255, 255, 240, 0) 30%),
    linear-gradient(rgba(255, 255, 240, 0.9), rgba(255, 255, 240, 0)) 50% 0 / 2px 100% no-repeat,
    linear-gradient(90deg, rgba(255, 255, 240, 0.9), rgba(255, 255, 240, 0)) 0 50% / 100% 2px no-repeat;
  mix-blend-mode: screen;
  transform: scale(0);
  animation: glintTwinkle var(--gs) var(--gd) ease-in-out infinite;
}
@keyframes glintTwinkle {
  0%, 100% { transform: scale(0) rotate(0deg); opacity: 0; }
  12% { transform: scale(1) rotate(20deg); opacity: 1; }
  24% { transform: scale(0.25) rotate(40deg); opacity: 0.4; }
  32% { transform: scale(0) rotate(45deg); opacity: 0; }
}
@keyframes beamBreathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.mist {
  position: absolute;
  width: 70vw; height: 26vh;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(255, 250, 242, 0.16), rgba(255, 250, 242, 0) 70%);
  filter: blur(18px);
  mix-blend-mode: screen;
  will-change: transform;
}
.mist-1 {
  bottom: 6vh; left: -12vw;
  animation: mistDrift 46s ease-in-out infinite alternate;
}
.mist-2 {
  bottom: 20vh; right: -18vw;
  height: 20vh; opacity: 0.8;
  animation: mistDrift 62s ease-in-out infinite alternate-reverse;
}
@keyframes mistDrift {
  0% { transform: translateX(0); }
  100% { transform: translateX(16vw); }
}
.mote {
  position: absolute;
  left: var(--mx); top: var(--my);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 250, 225, 1), rgba(255, 250, 225, 0) 78%);
  box-shadow: 0 0 10px 2px rgba(255, 250, 225, 0.55);
  animation: moteFloat var(--ms) var(--md) ease-in-out infinite;
  opacity: 0;
  will-change: transform, opacity;
}
@keyframes moteFloat {
  0%   { transform: translate(0, 0) scale(0.7); opacity: 0; }
  20%  { opacity: 1; }
  50%  { transform: translate(18px, -26px) scale(1.1); opacity: 0.85; }
  80%  { opacity: 0.95; }
  100% { transform: translate(-10px, -48px) scale(0.6); opacity: 0; }
}
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(30, 24, 48, 0.12) 0%, rgba(30, 24, 48, 0) 22%, rgba(30, 24, 48, 0) 55%, rgba(30, 24, 48, 0.30) 100%);
}

/* Privacy meter */
:root { --topbar-h: 68px; }
.meter {
  position: absolute; top: calc(var(--topbar-h) + 14px); left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-radius: 18px;
  background: var(--panel); box-shadow: var(--shadow);
}
.meter-label { font-size: 14px; font-weight: 900; color: var(--ink-soft); }
.meter-locks { display: flex; gap: 8px; }
.meter-lock { width: 30px; height: 30px; position: relative; }
.meter-lock svg { width: 100%; height: 100%; }
.meter-lock .lock-body { fill: #ded5ea; }
.meter-lock .lock-shackle { fill: none; stroke: #ded5ea; stroke-width: 2.6; }
.meter-lock.locked .lock-body { fill: var(--gold); }
.meter-lock.locked .lock-shackle { stroke: var(--gold-dim); }
.meter-lock.locked { animation: lockPop 0.5s ease; }
@keyframes lockPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.45) rotate(-6deg); }
  100% { transform: scale(1); }
}

/* Progress dots */
.progress {
  position: absolute; top: calc(var(--topbar-h) + 72px); left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; gap: 7px;
}
.progress i {
  width: 11px; height: 11px; border-radius: 50%;
  background: rgba(255, 252, 246, 0.75);
  border: 2px solid rgba(58, 51, 80, 0.25);
}
.progress i.done { background: var(--green); border-color: var(--green); }
.progress i.now { background: var(--gold); border-color: var(--gold-dim); transform: scale(1.25); }

/* ══ Card ══ */
.card-zone {
  position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  z-index: 12;
}
.game-card {
  position: relative;
  width: 228px;
  background: #fff;
  border-radius: 26px;
  border: 3px solid rgba(58, 51, 80, 0.1);
  box-shadow: var(--shadow);
  padding: 16px 16px 18px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  animation: cardFloat 3.2s ease-in-out infinite;
  transition: box-shadow 0.2s;
  will-change: transform;
}
.game-card:active { cursor: grabbing; }
.game-card.dragging {
  animation: none;
  transition: none;
  box-shadow: 0 24px 48px rgba(58, 51, 80, 0.3);
  z-index: 30;
}
.game-card.entering { animation: cardEnter 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), cardFloat 3.2s 0.55s ease-in-out infinite; pointer-events: none; }
.game-card.flying { animation: none; transition: transform 0.55s cubic-bezier(0.5, 0, 0.75, 0.6), opacity 0.55s ease; pointer-events: none; }
.game-card.returning { animation: none; transition: transform 0.5s cubic-bezier(0.34, 1.3, 0.64, 1); }
/* Float via transform (GPU-composited); margin/top would jitter. */
@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
@keyframes cardEnter {
  0% { transform: scale(0.3) translateY(-120px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.card-art {
  position: relative;
  width: 100%; aspect-ratio: 1;
  border-radius: 18px; overflow: hidden;
  background: var(--cream);
}
.card-mystery {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  font-size: 130px; font-weight: 900; color: #2f9be8;
  opacity: 0.9;
}
.game-card.mystery .card-mystery { display: flex; }
.game-card.mystery img { visibility: hidden; }
.card-art img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.card-label {
  margin-top: 12px;
  font-size: 21px; font-weight: 900; line-height: 1.2;
  text-align: center;
  min-height: 50px;
  display: flex; align-items: center; justify-content: center;
}
.card-speak {
  position: absolute; top: -14px; right: -14px;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--gold); border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(58, 51, 80, 0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.card-speak:hover { transform: scale(1.12); }
.card-speak svg { width: 22px; height: 22px; fill: var(--ink); stroke: var(--ink); }
.card-hint {
  font-size: 14px; font-weight: 800; color: #fff;
  background: rgba(58, 51, 80, 0.55);
  padding: 6px 16px; border-radius: 999px;
  pointer-events: none;
}

/* ══ Baskets ══ */
.basket {
  position: absolute; bottom: 3.5vh; z-index: 11;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none;
  padding: 14px;
  border-radius: 30px;
  transition: transform 0.18s ease, background 0.18s ease;
}
#basketShare { left: 5vw; }
#basketPrivate { right: 5vw; }
.basket img {
  width: clamp(130px, 17vw, 200px);
  filter: drop-shadow(0 12px 14px rgba(58, 51, 80, 0.4));
  pointer-events: none;
  /* Only transform is transitioned; animating filter causes jittery repaints. */
  transition: transform 0.18s ease;
}
.basket:hover img, .basket:focus-visible img, .basket.armed img {
  filter: drop-shadow(0 12px 14px rgba(58, 51, 80, 0.4))
          drop-shadow(0 0 18px rgba(255, 232, 150, 0.95));
}
.basket-label {
  font-size: clamp(15px, 1.6vw, 19px); font-weight: 900; color: #fff;
  padding: 8px 20px; border-radius: 999px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  margin-top: -8px;
}
.share-label { background: var(--green); }
.private-label { background: var(--coral); }
.basket:hover img, .basket.armed img { transform: translateY(-6px) scale(1.06); }
.basket.armed { background: rgba(255, 252, 246, 0.35); }
.basket.armed::after {
  content: ""; position: absolute; inset: 0;
  border: 4px dashed rgba(255, 252, 246, 0.95);
  border-radius: 30px; pointer-events: none;
  animation: armedPulse 1s ease-in-out infinite;
}
@keyframes armedPulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}
.basket.received img { animation: basketBounce 0.5s ease; }
@keyframes basketBounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.14) translateY(-8px); }
  70% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ══ Sage ══ */
.sage {
  position: absolute; bottom: 3.5vh; left: 50%; transform: translateX(-50%);
  z-index: 13;
  display: flex; align-items: flex-end; gap: 12px;
  max-width: min(820px, 66vw);
}
.sage-face {
  width: 112px; height: 112px; border-radius: 50%;
  border: 4px solid #fff; object-fit: cover;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.sage-bubble {
  position: relative;
  background: var(--panel);
  border-radius: 20px 20px 20px 6px;
  padding: 22px 28px;
  box-shadow: var(--shadow);
  min-width: 300px;
}
.sage-bubble p { font-size: 26px; font-weight: 800; line-height: 1.45; }
.sage-bubble.tip-good { border: 3px solid var(--green); }
.sage-bubble.tip-gentle { border: 3px solid var(--gold); }
.sage-bubble .btn { margin-top: 10px; }
.sage-bubble.pop { animation: bubblePop 0.35s ease; }
@keyframes bubblePop {
  0% { transform: scale(0.85); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

/* ══ Demo hand ══ */
.demo-hand {
  position: fixed; z-index: 60; width: 64px; height: 64px;
  pointer-events: none;
  /* Moved with transform (GPU-composited), never top/left, to stay smooth. */
  will-change: transform;
  filter: drop-shadow(0 6px 10px rgba(58, 51, 80, 0.35));
}

/* ══ Overlays & panels ══ */
.overlay[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 84px 16px 24px;
  background: rgba(42, 34, 64, 0.45);
  backdrop-filter: blur(5px);
  overflow-y: auto;
}
.panel {
  background: var(--panel);
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(30, 24, 48, 0.4);
  padding: 34px 38px;
  width: min(560px, 94vw);
  text-align: center;
  margin: auto;
}
.panel h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 900; line-height: 1.1; margin-bottom: 4px; }
.panel h2 { font-size: 30px; font-weight: 900; margin-bottom: 8px; }
.panel-shop {
  font-size: 13px; font-weight: 900; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--lav); margin-bottom: 6px;
}
.entry-sage {
  width: 130px; height: 130px; border-radius: 50%;
  border: 5px solid var(--gold); object-fit: cover;
  margin: 18px auto 14px; display: block;
  box-shadow: var(--shadow);
}
.entry-welcome { font-size: 18px; font-weight: 700; line-height: 1.55; margin-bottom: 12px; }
.entry-note {
  font-size: 15px; font-weight: 800; color: var(--ink-soft);
  background: var(--green-soft); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 22px;
}
.entry-quick-note { margin-top: 18px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.pause-text { font-size: 17px; font-weight: 700; color: var(--ink-soft); margin-bottom: 22px; }

.panel-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

.btn {
  border: none; border-radius: 16px;
  background: #fff; color: var(--ink);
  border: 2px solid rgba(58, 51, 80, 0.16);
  font-weight: 900;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn-big { font-size: 19px; padding: 15px 26px; min-height: 58px; }
.btn-small { font-size: 15px; padding: 8px 18px; min-height: 42px; }
.btn-primary {
  background: var(--gold); border-color: var(--gold);
  box-shadow: 0 5px 0 var(--gold-dim);
}
.btn-primary:hover { box-shadow: 0 7px 0 var(--gold-dim), 0 8px 18px rgba(58, 51, 80, 0.2); }
.btn-primary:active { box-shadow: 0 2px 0 var(--gold-dim); }

/* ══ Completion ══ */
.done-panel h2 { margin-top: 14px; }
.badge {
  width: 148px; height: 148px; margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff8e2, #ffe9a8);
  border: 6px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(240, 192, 64, 0.3), var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 16px; overflow: hidden;
  animation: badgeSpin 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgeSpin {
  0% { transform: scale(0.2) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.badge img { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; }
.badge span {
  font-size: 12px; font-weight: 900; color: var(--gold-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
  text-align: center; line-height: 1.15; max-width: 104px;
}
.done-text { font-size: 18px; font-weight: 700; line-height: 1.5; margin: 10px 0 22px; }

.help-box {
  margin-top: 24px; text-align: left;
  background: var(--cream); border-radius: 16px; padding: 16px 20px;
}
.help-title { font-size: 14px; font-weight: 900; margin-bottom: 10px; }
.help-box ul { list-style: none; }
.help-box li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; font-size: 15px; font-weight: 700;
  border-bottom: 1px solid rgba(58, 51, 80, 0.08);
}
.help-box li:last-child { border-bottom: none; }
.help-box li span:last-child { color: var(--ink-soft); text-align: right; }

/* ══ Sparkles ══ */
.spark {
  position: fixed; z-index: 90; pointer-events: none;
  width: 12px; height: 12px;
  clip-path: polygon(50% 0%, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0% 50%, 37% 37%);
  animation: sparkFly 0.9s ease-out forwards;
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.1) rotate(180deg); opacity: 0; }
}

/* ══ Responsive ══ */
@media (max-width: 900px) {
  .tb-btn span { display: none; }
  .tb-btn.quick-exit span { display: inline; }
  .game-card { width: 190px; }
  .card-label { font-size: 18px; min-height: 44px; }
  .sage { max-width: 74vw; }
  .sage-face { width: 78px; height: 78px; }
  .sage-bubble p { font-size: 20px; }
}
@media (max-width: 640px) {
  .meter { padding: 8px 12px; }
  .meter-lock { width: 24px; height: 24px; }
  .progress { top: calc(var(--topbar-h) + 62px); }
  .card-zone { top: 42%; }
  .basket { bottom: 2vh; padding: 8px; }
  #basketShare { left: 1vw; }
  #basketPrivate { right: 1vw; }
  .sage { position: absolute; bottom: 2vh; max-width: 46vw; }
  .sage-face { display: none; }
}

/* ══ Reduced motion ══ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
