/* Dr. Glow Up: bright, bouncy kid-game UI over a Canvas 2D skin-clinic stage. */
:root {
  --ink: #3a2747;
  --paper: #ffffff;
  --gold: #ffc93c;
  --gold-deep: #f39a12;
  --pink: #ff6fae;
  --mint: #3fe0b5;
  --sky: #45c8ff;
  --coral: #ff7d9a;
  --muted: #7a6a8c;
  --pop: cubic-bezier(.34, 1.7, .5, 1);
  --soft: cubic-bezier(.2, .8, .2, 1);
  --font: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --safe-t: max(10px, env(safe-area-inset-top));
  --safe-b: max(10px, env(safe-area-inset-bottom));
  --burst: polygon(50.0% 0.0%, 58.4% 7.8%, 69.1% 3.8%, 73.9% 14.2%, 85.4% 14.6%, 85.8% 26.1%, 96.2% 30.9%, 92.2% 41.6%, 100.0% 50.0%, 92.2% 58.4%, 96.2% 69.1%, 85.8% 73.9%, 85.4% 85.4%, 73.9% 85.8%, 69.1% 96.2%, 58.4% 92.2%, 50.0% 100.0%, 41.6% 92.2%, 30.9% 96.2%, 26.1% 85.8%, 14.6% 85.4%, 14.2% 73.9%, 3.8% 69.1%, 7.8% 58.4%, 0.0% 50.0%, 7.8% 41.6%, 3.8% 30.9%, 14.2% 26.1%, 14.6% 14.6%, 26.1% 14.2%, 30.9% 3.8%, 41.6% 7.8%);
  --burst-sharp: polygon(50.0% 0.0%, 60.4% 11.4%, 75.0% 6.7%, 78.3% 21.7%, 93.3% 25.0%, 88.6% 39.6%, 100.0% 50.0%, 88.6% 60.4%, 93.3% 75.0%, 78.3% 78.3%, 75.0% 93.3%, 60.4% 88.6%, 50.0% 100.0%, 39.6% 88.6%, 25.0% 93.3%, 21.7% 78.3%, 6.7% 75.0%, 11.4% 60.4%, 0.0% 50.0%, 11.4% 39.6%, 6.7% 25.0%, 21.7% 21.7%, 25.0% 6.7%, 39.6% 11.4%);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #d6f3ec; color: var(--ink);
  font-family: var(--font); font-weight: 600;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; overflow: hidden; overflow: clip; }
#ui [data-ui] { pointer-events: auto; }
/* hidden controls must never catch a touch meant for the patient */
#ui .ba:not(.in) [data-ui], #ui .results:not(.in), #ui .results:not(.in) [data-ui],
#ui .tray:not(.on) [data-ui], #ui .kit:not(.on), #ui .kit.open, #ui.final .kit,
#ui .unlock:not(.on) [data-ui], #ui .card:not(.style) .styler [data-ui] { pointer-events: none; }
.ico { width: 22px; height: 22px; display: block; }
button { font: inherit; color: inherit; }

/* ---------- top HUD ---------- */
.hud-top {
  position: absolute; top: var(--safe-t); left: 12px; right: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.bar {
  width: 100%; max-width: 820px;
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'lvls aura mute';
  align-items: center; gap: 14px;
}
.lvls {
  grid-area: lvls; justify-self: start; display: flex; align-items: center; gap: 5px;
  height: 40px; padding: 0 14px 0 11px; border-radius: 22px;
  background: var(--gold); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  font-weight: 700; line-height: 1; color: var(--ink);
}
.lv-k { font-size: 13px; letter-spacing: .04em; opacity: .75; }
.lv-n { font-size: 24px; font-weight: 700; }
.lvls.pop { animation: lvpop .45s var(--pop); }
@keyframes lvpop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.mute {
  grid-area: mute; width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: transform .15s var(--soft), box-shadow .15s var(--soft);
}
.mute:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.mute:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.aura { grid-area: aura; display: flex; align-items: center; gap: 8px; min-width: 0; }
.aura-lbl {
  font-weight: 700; font-size: 13px; letter-spacing: .08em; color: #fff;
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
}
.aura-track {
  position: relative; flex: 1; min-width: 60px; height: 20px; border-radius: 999px;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); overflow: hidden;
}
.aura-fill {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--pink), var(--gold) 55%, var(--mint));
  transition: transform .7s var(--pop);
}
.aura-fill::after {
  content: ''; position: absolute; left: 6px; right: 6px; top: 3px; height: 4px; border-radius: 4px;
  background: rgba(255, 255, 255, .6);
}
.aura-track i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(58, 39, 71, .22); }
.aura-track i.pass { width: 4px; margin-left: -2px; background: var(--ink); transition: left .5s var(--soft); }
.aura-num {
  font-weight: 700; font-size: 22px; min-width: 2.2ch; text-align: right; color: #fff;
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
}
.aura.bump .aura-num { animation: bump .5s var(--pop); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.45); } 100% { transform: scale(1); } }

.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 7px; }
.steps li {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); color: var(--ink);
  transition: transform .3s var(--pop), background .2s;
}
.steps li .ico { width: 18px; height: 18px; }
.steps li.now { background: var(--gold); transform: translateY(-2px) scale(1.18); animation: hop 1.1s ease-in-out infinite; }
.steps li.ok { background: var(--mint); }
.steps li.bad { background: var(--coral); }
.steps li.ok.now, .steps li.bad.now { animation: none; }
.steps li { position: relative; }
.steps li.new::after {
  content: 'NEW'; position: absolute; top: -9px; right: -12px; padding: 1px 4px; border-radius: 6px;
  font-size: 9px; font-weight: 700; letter-spacing: .04em; line-height: 1.2; color: #fff;
  background: var(--pink); border: 2px solid var(--ink); transform: rotate(12deg);
}
@keyframes hop { 0%, 100% { transform: translateY(-2px) scale(1.18); } 50% { transform: translateY(-6px) scale(1.18); } }
/* the order: a number on every badge, a marching ring on the one to do next, and a
   red mark on any done out of order */
.steps li .sn {
  position: absolute; left: -6px; bottom: -6px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
  font-style: normal; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; color: #fff; background: var(--ink);
}
.steps li.next:not(.now) { outline: 3px dashed var(--ink); outline-offset: 3px; animation: nextring 1.1s ease-in-out infinite; }
.steps li.next .sn { background: var(--pink); }
@keyframes nextring { 0%, 100% { outline-color: var(--ink); } 50% { outline-color: rgba(58, 39, 71, .2); } }
.steps li.miss::before {
  content: '!'; position: absolute; right: -6px; bottom: -6px; width: 17px; height: 17px; border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 13px; text-align: center; color: #fff;
  background: #d9466d; border: 2px solid var(--ink);
}
#ui.final .steps { opacity: 0; transition: opacity .3s; }

/* ---------- title card ---------- */
.title-card {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 18px);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  opacity: 0; transform: translateY(30px); transition: opacity .35s, transform .5s var(--pop);
}
.title-card.on { opacity: 1; transform: none; }
.tc-logo { margin: 0; font-weight: 700; font-size: clamp(44px, 11vw, 92px); line-height: .95; letter-spacing: .01em; }
.tc-logo span span {
  display: inline-block; color: #fff; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill;
  filter: drop-shadow(0 6px 0 var(--ink));
  animation: wave 1.6s ease-in-out infinite; animation-delay: calc(var(--i) * .08s);
}
.tc-logo .w0 { display: block; font-size: .48em; margin-bottom: .1em; }
.tc-logo .w0 span { color: var(--mint); -webkit-text-stroke-width: 8px; filter: drop-shadow(0 4px 0 var(--ink)); }
.tc-logo .w2 { margin-left: .24em; }
.tc-logo .w2 span { color: var(--gold); }
@keyframes wave { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-10px) rotate(-3deg); } 60% { transform: translateY(0) rotate(2deg); } }
.tc-go {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: .04em; color: #fff;
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
}
.tc-go .ico { width: 30px; height: 30px; color: var(--ink); background: var(--gold); border-radius: 50%; padding: 3px; border: 3px solid var(--ink); animation: press 1.2s ease-in-out infinite; }
@keyframes press { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(3px) scale(.88); } }

/* ---------- level splash ---------- */
.splash { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; }
.sp-in {
  display: flex; flex-direction: column; align-items: center; line-height: .9;
  padding: 14px 30px 10px; background: var(--paper); border: 4px solid var(--ink); border-radius: 28px; box-shadow: 0 7px 0 var(--ink);
}
.sp-k { font-weight: 700; font-size: 18px; letter-spacing: .14em; color: var(--muted); }
.sp-n { font-weight: 700; font-size: 76px; color: var(--gold); -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; }
.splash.on { animation: slam 1.5s var(--soft) forwards; }
.splash.long.on { animation-duration: 2.3s; }
.sp-ch { font-weight: 700; font-size: 15px; letter-spacing: .12em; color: #fff; background: var(--sky); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px 3px; margin-bottom: 8px; line-height: 1; }
.splash.boss .sp-k { color: #d9466d; }
.splash.boss .sp-in { background: #fff4d1; }
.sp-new { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.sp-nw, .rs-nw {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 5px; border-radius: 999px;
  background: var(--pink); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: #fff;
}
.sp-nw b, .rs-nw b { font-weight: 700; font-size: 18px; letter-spacing: .04em; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.sp-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); border: 3px solid var(--ink); color: var(--ink); }
.sp-ico .ico { width: 22px; height: 22px; }
.splash.on .sp-nw { animation: wiggle 1s ease-in-out .35s 2; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg) scale(1.06); } 75% { transform: rotate(6deg) scale(1.06); } }
.rs-new { display: flex; justify-content: center; gap: 8px; }
.rs-nw { padding: 3px 5px 3px 12px; box-shadow: 0 3px 0 var(--ink); }
.rs-nw b { font-size: 15px; }
.rs-nw .sp-ico { width: 30px; height: 30px; }
.rs-nw .sp-ico .ico { width: 18px; height: 18px; }
.results.in .rs-nw { animation: badge .7s var(--pop) .9s both; }

/* ---------- hold prompt ---------- */
.dock { position: absolute; left: 0; right: 0; bottom: var(--safe-b); display: flex; justify-content: center; padding: 0 12px; }
.dock-in { position: relative; width: 100%; max-width: 420px; }
.card {
  width: 100%;
  transform: translateY(calc(100% + 30px)); transition: transform .45s var(--pop);
}
.card.in { transform: none; }
.card.in.holding { transform: translateY(3px); }
#ui.final .card { transform: translateY(calc(100% + 30px)); }
.prompt {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; padding: 9px 14px 13px;
  box-shadow: 0 6px 0 var(--ink);
  opacity: .5; transform: scale(.97); transition: opacity .2s, transform .3s var(--pop), background .2s, box-shadow .15s;
}
.prompt.in { opacity: 1; transform: none; }
.prompt.holding { background: #fff4d1; box-shadow: 0 3px 0 var(--ink); }
.prompt.in-zone { background: #d9fff2; }
.pr-row { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 34px; }
.pr-ico {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); border: 3px solid var(--ink);
}
.pr-ico .ico { width: 21px; height: 21px; }
.pr-text { font-size: 22px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.prompt.in-zone .pr-text { color: #12a37c; animation: wiggle .3s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.pr-ghost { display: none; }
.prompt.ghost .pr-ghost { display: block; }
.pr-ghost .ico { width: 28px; height: 28px; animation: press 1s ease-in-out infinite; }
.meter {
  position: relative; height: 16px; margin-top: 9px; border-radius: 999px;
  background: #eef6fb; border: 3px solid var(--ink);
}
.mt-fill {
  position: absolute; inset: 0; border-radius: inherit; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(180deg, #ffe27a, var(--gold) 55%, var(--gold-deep));
}
.mt-zone {
  position: absolute; top: -6px; bottom: -6px; border-radius: 6px;
  background: rgba(63, 224, 181, .55); border: 2px solid var(--ink); z-index: 1;
}
.mt-star { position: absolute; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); z-index: 2; transition: transform .2s var(--pop); }
.mt-star .star { width: 100%; height: 100%; display: block; }
.prompt.in-zone .mt-star { transform: translate(-50%, -50%) scale(1.35) rotate(18deg); }
.prompt.in-zone .mt-zone { background: rgba(63, 224, 181, .95); }

/* ---------- tool kit ---------- */
.kit {
  position: absolute; right: 4px; bottom: calc(100% + 16px);
  width: 62px; height: 62px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
  background: var(--gold); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  transform: scale(0); opacity: 0;
  transition: transform .4s var(--pop), opacity .2s, background .2s, color .2s, box-shadow .12s var(--soft);
}
.kit .ico { width: 32px; height: 32px; }
.kit.on { transform: none; opacity: 1; }
#ui.final .kit, .kit.open { transform: scale(0); opacity: 0; }
.kit.on:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.kit:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.kit.busy { background: #ece6f3; color: #9a8cad; }
.kit.call { animation: kitcall 1.3s ease-in-out infinite; }
@keyframes kitcall {
  0%, 55%, 100% { transform: scale(1) rotate(0); }
  12% { transform: scale(1.14) rotate(-9deg); }
  26% { transform: scale(1.14) rotate(8deg); }
  40% { transform: scale(1.06) rotate(-3deg); }
}
.kit.shake { animation: no .4s ease-in-out; }
@keyframes no { 0%, 100% { translate: 0; } 20% { translate: -6px; } 40% { translate: 6px; } 60% { translate: -4px; } 80% { translate: 3px; } }
.kit-n {
  position: absolute; top: -8px; right: -8px; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 13px;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; line-height: 1; color: #fff;
  background: var(--pink); border: 3px solid var(--ink);
}
.kit.busy .kit-n { background: #b9acc9; }

.tray { position: absolute; inset: 0; }
.tray-scrim { position: absolute; inset: 0; background: rgba(58, 39, 71, .2); opacity: 0; transition: opacity .25s; }
.tray.on .tray-scrim { opacity: 1; }
.tray-sheet {
  position: absolute; left: 50%; bottom: var(--safe-b); width: calc(100% - 24px); max-width: 460px;
  padding: 10px 14px 18px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--ink);
  transform: translate(-50%, calc(100% + 40px)); transition: transform .45s var(--pop);
}
.tray.on .tray-sheet { transform: translate(-50%, 0); }
.tray-head { display: flex; align-items: center; gap: 8px; }
.tray-ico {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); border: 3px solid var(--ink);
}
.tray-ico .ico { width: 19px; height: 19px; }
.tray-head b { flex: 1; font-size: 21px; font-weight: 700; letter-spacing: .06em; }
.tray-x {
  width: 40px; height: 40px; border-radius: 50%; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  transition: transform .12s var(--soft), box-shadow .12s var(--soft);
}
.tray-x:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.tray-x:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.slots {
  list-style: none; margin: 12px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 8px; justify-items: center;
}
.slot {
  position: relative; width: 62px; height: 62px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  transition: transform .12s var(--soft), box-shadow .12s var(--soft);
}
.slot .ico { width: 30px; height: 30px; }
.slot:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.slot:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
/* what this patient needs */
.slot.need { background: var(--gold); }
/* the treatment already under way */
.slot.now { background: var(--gold); outline: 3px dashed var(--ink); outline-offset: 4px; }
/* finished on this patient */
.slot.done { background: var(--mint); cursor: default; transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.slot .ok {
  position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--paper); border: 2px solid var(--ink);
}
.slot .ok .ico { width: 15px; height: 15px; stroke-width: 3; }
/* unlocked, but this patient has nothing for it */
.slot.none { background: #f4f0f8; color: #a597b6; border-color: #b4a8c4; box-shadow: 0 4px 0 #b4a8c4; }
/* not unlocked yet: an empty space */
.slot.locked { cursor: default; background: transparent; border: 3px dashed rgba(58, 39, 71, .28); box-shadow: none; }
.slot .lv { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: rgba(58, 39, 71, .42); }
.slot.shake { animation: no .4s ease-in-out; }
.tray.on .slots li { animation: slotin .4s var(--pop) both; animation-delay: calc(var(--i) * 22ms + 80ms); }
@keyframes slotin { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .tray-sheet { max-width: 520px; }
  .slots { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 360px) {
  .slot { width: 56px; height: 56px; }
  .slot .ico { width: 27px; height: 27px; }
}

/* ---------- toast ---------- */
.toast {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.6); opacity: 0;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .04em;
  padding: 9px 18px 8px; border-radius: 999px; white-space: nowrap;
}
.toast.on { animation: toast 1.4s var(--soft) forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  25%, 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* ---------- verdict sticker ---------- */
.stamp { position: absolute; left: 50%; top: 27%; transform: translate(-50%, -50%); opacity: 0; }
.st-in { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.st-burst {
  position: absolute; left: 50%; top: 42%; width: 230px; height: 230px; transform: translate(-50%, -50%);
  clip-path: var(--burst-sharp); background: rgba(255, 255, 255, .55); z-index: -1;
  animation: spin 6s linear infinite;
}
@keyframes spin { from { transform: translate(-50%, -50%) rotate(0); } to { transform: translate(-50%, -50%) rotate(360deg); } }
.st-verdict {
  font-weight: 700; font-size: clamp(38px, 10vw, 58px); line-height: 1; white-space: nowrap;
  color: var(--gold); -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; filter: drop-shadow(0 5px 0 var(--ink));
}
.stamp.good .st-verdict { color: var(--mint); }
.stamp.fail .st-verdict { color: var(--coral); }
.stamp.fail .st-burst { background: rgba(255, 255, 255, .35); }
.st-score { font-weight: 700; font-size: 26px; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.stamp.on { animation: slam 1.4s var(--soft) forwards; }
@keyframes slam {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-8deg); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(.92) rotate(3deg); }
  24% { transform: translate(-50%, -50%) scale(1.04) rotate(-1deg); }
  32%, 80% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(.9) rotate(0); }
}

/* ---------- before / after ---------- */
.ba { position: absolute; height: 48px; opacity: 0; pointer-events: none; transition: opacity .4s .9s; }
.ba.in { opacity: 1; }
.ba-range {
  -webkit-appearance: none; appearance: none; position: absolute; inset: 0; width: 100%; height: 48px;
  margin: 0; background: transparent; cursor: ew-resize; touch-action: pan-y;
}
.ba-range:focus-visible { outline: none; }
.ba-range::-webkit-slider-runnable-track { height: 48px; background: transparent; }
.ba-range::-moz-range-track { height: 48px; background: transparent; }
.ba-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 48px; height: 48px; border-radius: 50%;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233a2747' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 26px no-repeat;
  border: 4px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
}
.ba-range::-moz-range-thumb {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233a2747' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 24px no-repeat;
  border: 4px solid var(--ink);
}
.ba-range:focus-visible::-webkit-slider-thumb { background-color: #fff4d1; }

/* ---------- results ---------- */
.results {
  position: absolute; left: 12px; right: 12px; bottom: var(--safe-b);
  max-height: calc(100% - 150px); overflow: auto; overscroll-behavior: contain;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--ink);
  padding: 14px 16px 14px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  transform: translateY(calc(100% + 40px)); opacity: 0; transition: transform .6s var(--pop) .25s, opacity .2s .25s;
  touch-action: pan-y;
}
.results.in { transform: none; opacity: 1; }
.rs-badge { position: relative; width: 168px; height: 78px; flex: none; display: grid; place-items: center; }
.rs-badge::before, .rs-badge::after {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  clip-path: var(--burst);
}
.rs-badge::before { width: 168px; height: 78px; background: var(--ink); border-radius: 0; }
.rs-badge::after { width: 156px; height: 68px; background: var(--rk, var(--gold)); }
.results.in .rs-badge { animation: badge .8s var(--pop) .45s both; }
@keyframes badge { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }
.rs-badge[data-rank='NPC'] { --rk: #cbbfe0; }
.rs-badge[data-rank='NORMIE'] { --rk: var(--mint); }
.rs-badge[data-rank='CHADLITE'] { --rk: var(--sky); }
.rs-badge[data-rank='MOGGER'] { --rk: var(--pink); }
.rs-badge[data-rank='LEGENDARY'] { --rk: linear-gradient(90deg, var(--gold), var(--pink), var(--sky), var(--mint)); }
.rs-rank {
  position: relative; z-index: 1; font-weight: 700; font-size: 24px; letter-spacing: .02em; color: #fff;
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill;
}
.rs-aura { display: flex; align-items: center; gap: 10px; }
.rs-aura b { font-weight: 700; font-size: 48px; line-height: 1; color: var(--gold); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.rs-best { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 15px; padding: 3px 10px 3px 7px; border-radius: 999px; background: #efe9f5; }
.rs-best .ico { width: 17px; height: 17px; }
.rs-best.new { background: var(--pink); color: #fff; animation: bump .6s var(--pop) 1s both; }
.rs-near {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 14px; letter-spacing: .03em;
  color: #fff; background: #d9466d; border-radius: 999px; padding: 3px 12px 3px 8px;
}
.rs-near .ico { width: 16px; height: 16px; }
.rs-bars { list-style: none; margin: 4px 0 6px; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 5px; }
.rs-bars li {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; align-items: center; gap: 10px;
  padding: 3px 8px; border-radius: 12px; font-size: 15px; text-align: left;
}
.rs-bars li.worst { background: #ffe3ea; outline: 2px dashed #d9466d; outline-offset: -2px; }
.rs-bars li.worst .rb-ico { animation: hop 1.1s ease-in-out infinite; }
.rb-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #fff4d1; border: 2px solid var(--ink); }
.rb-ico .ico { width: 18px; height: 18px; }
.rb-bar { height: 13px; border-radius: 999px; background: #efe9f5; border: 2px solid var(--ink); overflow: hidden; }
.rb-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--gold)); transform-origin: left; transform: scaleX(0); }
.results.in .rb-bar i { animation: grow .7s var(--pop) both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(var(--s)); } }
.rs-bars li.worst .rb-bar i { background: var(--coral); }
.rb-sc { font-weight: 700; text-align: right; }
.rb-sc .ico { width: 20px; height: 20px; margin-left: auto; color: #12a37c; stroke-width: 3; }
.rs-bars li.order .rb-ico { background: #d9fff2; }
.rs-bars li.order .rb-bar i { background: linear-gradient(90deg, var(--mint), #12c493); }
.rs-bars li.order.miss { background: #ffe3ea; }
.rs-bars li.order.miss .rb-ico { background: #fff; }
.rs-bars li.order.miss .rb-bar i { background: var(--coral); }
.rs-bars li.order.miss .rb-sc { color: #d9466d; }
.rs-btns { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 6px; }
.rs-btns button {
  display: grid; place-items: center; cursor: pointer; padding: 0;
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 6px 0 var(--ink);
  transition: transform .12s var(--soft), box-shadow .12s var(--soft), background .2s;
}
.rs-btns button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.rs-btns button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.rs-btns button:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.again { width: 58px; height: 58px; background: var(--paper); }
.again .ico { width: 26px; height: 26px; }
.next { width: 104px; height: 64px; background: var(--gold); }
.next .ico { width: 34px; height: 34px; }
.next:disabled { width: 58px; height: 58px; background: #e3dcec; color: #8e7fa1; cursor: default; box-shadow: 0 4px 0 var(--ink); }
.next:disabled .ico { width: 24px; height: 24px; }
.results:not(.passed) .again { width: 104px; height: 64px; background: var(--gold); }
.results:not(.passed) .again .ico { width: 32px; height: 32px; }
.results.passed.in .next:not(:disabled) { animation: nudge 1.4s ease-in-out 1.6s infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

/* ---------- narrow screens ---------- */
@media (max-width: 639px) {
  .bar { grid-template-columns: 1fr auto; grid-template-areas: 'lvls mute' 'aura aura'; gap: 6px 10px; }
  .mute { width: 40px; height: 40px; }
  .steps li { width: 30px; height: 30px; }
  .steps { gap: 6px; }
  .steps li .ico { width: 16px; height: 16px; }
  .results { gap: 4px; }
}
@media (max-width: 380px) {
  .pr-text { font-size: 19px; }
}
@media (max-height: 560px) {
  .steps { display: none; }
}

/* ---------- wide screens: results card on the right ---------- */
@media (min-width: 760px) and (min-aspect-ratio: 21/20) {
  .results {
    left: auto; right: 24px; top: 50%; bottom: auto; width: 380px; max-height: calc(100% - 110px);
    transform: translate(calc(100% + 60px), -50%); padding: 18px 20px 16px;
  }
  .results.in { transform: translate(0, -50%); }
}

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

/* compact results on small phones so the patient keeps room above the card */
@media (max-width: 639px) {
  .results { padding: 10px 12px 12px; gap: 4px; max-height: calc(100% - 130px); }
  .rs-badge { width: 140px; height: 62px; }
  .rs-badge::before { width: 140px; height: 62px; }
  .rs-badge::after { width: 129px; height: 53px; }
  .rs-rank { font-size: 20px; }
  .rs-aura b { font-size: 38px; }
  .rs-bars { gap: 3px; margin: 2px 0 4px; }
  .rs-bars li { padding: 1px 8px; grid-template-columns: 26px minmax(0, 1fr) 28px; }
  .rb-ico { width: 26px; height: 26px; }
  .rb-ico .ico { width: 16px; height: 16px; }
  .rb-bar { height: 11px; }
  .next, .results:not(.passed) .again { width: 92px; height: 56px; }
  .again, .next:disabled { width: 52px; height: 52px; }
}

/* ---------- drawn tool art (toolart.js) ----------
   The treatments are little colour pictures of the tools, so they get more room than
   the line icons: they fill their round badges instead of sitting small inside them. */
.ico.art { overflow: visible; }
.steps { gap: 8px; }
.steps li { width: 40px; height: 40px; }
.steps li .art { width: 31px; height: 31px; }
.pr-ico { width: 40px; height: 40px; }
.pr-ico .art { width: 33px; height: 33px; }
.sp-ico .art { width: 31px; height: 31px; }
.rs-nw .sp-ico .art { width: 26px; height: 26px; }
.rb-ico .art { width: 26px; height: 26px; }
.slot .art { width: 48px; height: 48px; }
.slot.none .art { filter: grayscale(1); opacity: .45; }
.kit .art { width: 44px; height: 44px; }
.tray-ico { width: 40px; height: 40px; background: var(--gold); }
.tray-ico .art { width: 32px; height: 32px; }
.card.pick .pr-ico { background: var(--gold); }
@media (max-width: 639px) {
  .steps { gap: 6px; }
  .steps li { width: 36px; height: 36px; }
  .steps li .art { width: 28px; height: 28px; }
  .rb-ico .art { width: 23px; height: 23px; }
}
@media (max-width: 360px) {
  .steps li { width: 33px; height: 33px; }
  .steps li .art { width: 26px; height: 26px; }
  .slot .art { width: 44px; height: 44px; }
}

/* ---------- style tools: hair colour and piercing ---------- */
/* the kit's style row, under a little divider */
.tray-sub { display: flex; align-items: center; gap: 10px; margin: 14px 2px 0; font-size: 13px; font-weight: 700; letter-spacing: .14em; color: var(--muted); }
.tray-sub::before, .tray-sub::after { content: ''; flex: 1; height: 3px; border-radius: 2px; background: #ece6f3; }
.slots.styles { grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
.slot.style { background: #ffd6ea; }
.slot.style.now { background: #ffd6ea; outline: 3px dashed var(--ink); outline-offset: 4px; }
.slot .dot {
  position: absolute; bottom: -5px; right: -5px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); border: 3px solid var(--ink);
}
.slot .tag {
  position: absolute; top: -9px; right: -12px; min-width: 30px; height: 24px; padding: 0 6px; border-radius: 12px;
  display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 700; line-height: 1; color: #fff;
  background: #d9466d; border: 2px solid var(--ink);
}
@media (min-width: 640px) { .slots.styles { grid-template-columns: repeat(6, 1fr); } }

/* the card while a style tool is out: swatches (dye) or the running cost (piercing), and done */
.styler { display: none; }
.card.style .styler { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.card.style[data-style='pierce'] .meter { display: none; }
.card.style .pr-ico { background: #ffd6ea; }
.card.style .meter .mt-fill { background: linear-gradient(90deg, #ff6fb5, #b28cff, #45c8ff); }
.swatches { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sw {
  flex: none; width: 32px; height: 32px; border-radius: 50%; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 30%, var(--hi) 0 20%, var(--c) 23%);
  border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); color: #fff;
  transition: transform .15s var(--pop), box-shadow .12s var(--soft);
}
.sw .ico { width: 16px; height: 16px; stroke-width: 3; filter: drop-shadow(0 0 1.5px var(--ink)) drop-shadow(0 0 1px var(--ink)); }
.sw:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.sw.on { transform: translateY(-3px) scale(1.12); outline: 3px dashed var(--ink); outline-offset: 3px; }
.sw:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.sty-cost {
  flex: 1; display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 999px;
  font-size: 22px; font-weight: 700; background: #efe9f5; color: var(--muted);
}
.sty-cost.neg { background: #ffe3ea; color: #d9466d; }
.sty-done {
  flex: none; width: 46px; height: 46px; border-radius: 50%; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--mint); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: var(--ink);
  transition: transform .12s var(--soft), box-shadow .12s var(--soft);
}
.sty-done .ico { width: 24px; height: 24px; stroke-width: 3; }
.sty-done:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.sty-done:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
@media (max-width: 380px) {
  .sw { width: 28px; height: 28px; }
  .sw .ico { width: 14px; height: 14px; }
  .sty-done { width: 42px; height: 42px; }
}

/* results: one little stud per piercing */
.rs-bars li.pierce .rb-ico { background: #ffd6ea; }
.rb-studs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 13px; }
.rb-studs b { width: 11px; height: 11px; border-radius: 50%; background: #e3e8f4; border: 2px solid var(--ink); }

/* ---------- new tool pop-up ---------- */
.unlock { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; visibility: hidden; transition: visibility 0s .35s; }
.unlock.on { visibility: visible; transition: none; }
.ul-scrim { position: absolute; inset: 0; background: rgba(58, 39, 71, .45); opacity: 0; transition: opacity .3s; }
.unlock.on .ul-scrim { opacity: 1; }
.ul-card {
  position: relative; width: min(320px, 100%); padding: 22px 20px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 30px; box-shadow: 0 8px 0 var(--ink);
  transform: scale(.4); opacity: 0; transition: transform .45s var(--pop), opacity .2s;
}
.unlock.on .ul-card { transform: none; opacity: 1; }
.ul-x {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); color: var(--ink);
}
.ul-x:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.ul-x:focus-visible, .ul-play:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.ul-art { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-top: -4px; }
.ul-rays {
  position: absolute; inset: 0; clip-path: var(--burst-sharp);
  background: conic-gradient(from 0deg, var(--gold), #ffe27a, var(--gold), #ffe27a, var(--gold), #ffe27a, var(--gold), #ffe27a, var(--gold));
  animation: spin2 8s linear infinite;
}
@keyframes spin2 { to { transform: rotate(360deg); } }
.ul-ico {
  position: relative; width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
}
.unlock.on .ul-ico { animation: badge .7s var(--pop) .15s both; }
.ul-ico .art { width: 84px; height: 84px; }
.unlock.on .ul-ico .art { animation: ulhop 1.4s ease-in-out .9s infinite; }
@keyframes ulhop { 0%, 100% { transform: none; } 50% { transform: translateY(-5px) rotate(-5deg); } }
.ul-k {
  font-size: 34px; font-weight: 700; line-height: 1; color: var(--pink); letter-spacing: .02em;
  -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; filter: drop-shadow(0 4px 0 var(--ink));
}
.ul-name { font-size: 17px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.ul-play {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 62px; padding: 0 30px 0 24px; cursor: pointer;
  font: inherit; font-size: 26px; font-weight: 700; letter-spacing: .06em; color: var(--ink);
  background: var(--gold); border: 4px solid var(--ink); border-radius: 999px; box-shadow: 0 6px 0 var(--ink);
  transition: transform .12s var(--soft), box-shadow .12s var(--soft);
}
.ul-play .ico { width: 28px; height: 28px; fill: currentColor; }
.ul-play:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.unlock.on .ul-play { animation: nudge2 1.6s ease-in-out 1.2s infinite; }
@keyframes nudge2 { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---------- the patient's say (results) and the hurts row ---------- */
.rs-say {
  position: relative; margin: 0 0 8px; max-width: 100%; padding: 7px 16px;
  font-weight: 700; font-size: 17px; letter-spacing: .02em; line-height: 1.2;
  background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 3px 0 var(--ink);
}
.rs-say::before, .rs-say::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); border: solid transparent; }
/* the tail points up at the patient */
.rs-say::before { top: -16px; border-width: 0 11px 16px; border-bottom-color: var(--ink); }
.rs-say::after { top: -10px; border-width: 0 7px 11px; border-bottom-color: #fff; }
.rs-say[data-feel='upset'], .rs-say[data-feel='furious'] { background: #ffe3ea; color: #b8264f; }
.rs-say[data-feel='upset']::after, .rs-say[data-feel='furious']::after { border-bottom-color: #ffe3ea; }
.rs-say[data-feel='thrilled'] { background: #fff4d1; }
.rs-say[data-feel='thrilled']::after { border-bottom-color: #fff4d1; }
.results.in .rs-say { animation: badge .7s var(--pop) .3s both; }
.results.in .rs-say[data-feel='furious'] { animation: badge .7s var(--pop) .3s both, shout .5s ease-in-out 1s 3; }
@keyframes shout { 0%, 100% { translate: 0 0; } 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.rs-bars li.hurt .rb-ico { background: #ffd6de; }
.rb-studs b.skin { background: #ff8fa3; }
.rb-studs b.eye { width: 15px; height: 15px; background: #e8384f; }
