:root {
  --bg: #fff4e4;
  --bg-2: #ffe9cc;
  --surface: #ffffff;
  --ink: #2a2140;
  --ink-2: #6b6180;
  --line: #eadfce;
  --accent: #ff6b3d;
  --accent-dark: #d9481c;
  --accent-ink: #ffffff;
  --mark: #ffd84d;
  --mark-ink: #2a2140;
  --good: #1fae7a;
  --shadow: 0 2px 0 rgba(42, 33, 64, .06), 0 10px 30px -12px rgba(42, 33, 64, .25);
  /* Difficulty scale: one hue family (easy teal → hard violet), deliberately not green/red,
     so no answer reads as "good" or "bad". */
  --s1: #2bb5a0; --s2: #3d95c9; --s3: #6b7bd6; --s4: #8b5fd0; --s5: #a2479e;
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1830;
    --bg-2: #241f3d;
    --surface: #2b2548;
    --ink: #f5efff;
    --ink-2: #b3a9cc;
    --line: #3d3560;
    --mark: #ffd84d;
    --mark-ink: #1c1830;
    --shadow: 0 2px 0 rgba(0, 0, 0, .2), 0 12px 30px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-2), var(--bg) 70%) fixed, var(--bg);
  color: var(--ink);
  font: 500 16px/1.45 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

#app { min-height: 100dvh; max-width: 560px; margin: 0 auto; }

.boot { height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.screen {
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 14px;
  animation: screen-in .35s ease both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.title {
  font: 700 clamp(28px, 8vw, 38px)/1.05 Fredoka, Nunito, sans-serif;
  margin: 0; letter-spacing: -.01em;
}
.eyebrow {
  margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}

/* ---------- buttons ---------- */
.btn {
  --b: var(--surface); --b-dark: var(--line); --b-ink: var(--ink);
  border: 0; border-radius: 16px; padding: 14px 18px;
  background: var(--b); color: var(--b-ink);
  font: 600 18px/1.1 Fredoka, Nunito, sans-serif;
  box-shadow: 0 5px 0 var(--b-dark);
  transform: translateY(0); transition: transform .08s, box-shadow .08s, opacity .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--b-dark); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { --b: var(--accent); --b-dark: var(--accent-dark); --b-ink: var(--accent-ink); }
.btn.big { width: 100%; min-height: 58px; font-size: 20px; }
.btn.ghost { background: none; box-shadow: none; color: var(--ink-2); font: 700 15px Nunito, sans-serif; }
.btn .spinner { width: 20px; height: 20px; border-width: 3px; border-color: rgba(255,255,255,.35); border-top-color: #fff; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; position: relative; flex: none;
}
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.3); } }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 14px; }
.tab {
  flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 11px;
  font-weight: 800; font-size: 14px; color: var(--ink-2);
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ---------- auth ---------- */
.auth { justify-content: center; }
.auth-hero { text-align: center; }
.auth-chests { display: flex; justify-content: center; align-items: end; gap: 6px; margin-bottom: 10px; }
.auth-chests .chest { width: 58px; animation: bob 2.4s ease-in-out infinite; }
.auth-chests .chest:nth-child(2) { width: 66px; animation-delay: -.6s; }
.auth-chests .chest:nth-child(3) { width: 74px; animation-delay: -1.2s; }
.auth-chests .chest:nth-child(4) { width: 84px; animation-delay: -1.8s; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.lede { margin: 8px 0 0; color: var(--ink-2); font-weight: 700; }
.auth-card { display: flex; flex-direction: column; gap: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; }
.field input {
  font-size: 17px; /* ≥16px so iOS doesn't zoom in on focus */
  padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg);
  outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.hint { margin: 0; font-size: 14px; color: var(--ink-2); }
.form-error { margin: 0; color: var(--accent-dark); font-weight: 800; min-height: 0; }
.form-error:empty { display: none; }
@media (prefers-color-scheme: dark) { .form-error { color: #ff9a78; } }

/* ---------- intro ---------- */
.intro { padding-bottom: calc(96px + var(--safe-b)); }
.intro-text p { margin: 0 0 10px; }
.intro-text p:first-child { font: 600 20px/1.3 Fredoka, sans-serif; }
.intro-chests { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; text-align: center; }
.intro-chests .chest { width: 100%; max-width: 72px; }
.intro-chests small { display: block; font-weight: 800; color: var(--ink-2); }
.scale-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.scale-list li { display: flex; align-items: center; gap: 10px; }
.scale-list b { display: block; }
.scale-list small { color: var(--ink-2); }
.consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; cursor: pointer; }
.consent input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; margin: 0; }
.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(transparent, var(--bg) 35%); max-width: 560px; margin: 0 auto;
}

/* ---------- profile & LexTALE ---------- */
.profile { justify-content: center; }
.profile-intro { margin: 0; font: 600 20px/1.3 Fredoka, sans-serif; }
.lextale section { display: flex; flex-direction: column; gap: 14px; }
.lextale section[hidden] { display: none; }
.lx-lead { margin: 0 0 12px; font-weight: 800; }
.lx-instructions p { margin: 0 0 10px; }
.lx-test { flex: 1; min-height: calc(100dvh - 48px); }
.lx-card { text-align: center; padding: 48px 16px; }
.lx-item { margin: 0; font: 600 clamp(30px, 9vw, 44px) Fredoka, sans-serif; overflow-wrap: anywhere; }
.lx-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lx-score { margin: 4px 0 10px; font: 700 44px Fredoka, sans-serif; }

/* ---------- closed (thank-you & lottery result) ---------- */
.closed { justify-content: center; }
.closed-hero { text-align: center; }
.closed-hero .big-emoji { font-size: 72px; line-height: 1; margin-bottom: 8px; animation: bob 1.6s ease-in-out infinite; }
.closed-result { display: flex; flex-direction: column; gap: 10px; }
.closed-result p { margin: 0; }
.closed-date { font: 600 20px/1.3 Fredoka, sans-serif; }
.closed-win { font: 700 26px/1.2 Fredoka, sans-serif; text-align: center; color: var(--accent); }
.phone {
  align-self: center; padding: 12px 18px; border-radius: 14px; border: 2px dashed var(--accent);
  font: 700 22px Fredoka, sans-serif; color: var(--accent); text-decoration: none;
}
.closed-treasure { display: flex; flex-direction: column; gap: 10px; }
.closed-chests { display: flex; flex-direction: column; gap: 10px; }
.closed-note { margin: 0; font-weight: 800; }

/* ---------- publish question: both answers look the same on purpose ---------- */
.publish { justify-content: center; }
.publish-text p { margin: 0 0 10px; }
.publish-text p:last-child { margin-bottom: 0; }
.publish-text .note { font-weight: 800; }
.publish-question { margin: 0; font: 600 20px/1.3 Fredoka, sans-serif; }
.publish-buttons { display: flex; flex-direction: column; gap: 12px; }
.publish-buttons .current { outline: 3px solid var(--ink-2); outline-offset: -3px; }

/* ---------- play ---------- */
.play { height: 100dvh; min-height: 0; gap: 12px; padding-bottom: calc(12px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 12px; }
.quest { flex: 1; min-width: 0; }
.quest-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 800; }
.count { white-space: nowrap; }
.count-num { font: 700 22px Fredoka, sans-serif; display: inline-block; }
.count-num.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--accent); } }
.quest-goal { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 4px; position: relative; }
.bar-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ffb03d);
  transition: width .45s cubic-bezier(.3, 1.4, .5, 1);
  position: relative; overflow: hidden;
}
.bar-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);
  transform: translateX(-100%); animation: shine 2.8s ease-in-out infinite;
}
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.next-chest { width: 48px; flex: none; }
.next-chest .chest { width: 100%; display: block; }
.next-chest.close .chest { animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-8deg); } 80% { transform: rotate(8deg); } 90% { transform: rotate(-4deg); } }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.sentence-card {
  max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 20px 20px 24px;
}
.sentence-card.out { animation: card-out .22s ease-in both; }
.sentence-card.in { animation: card-in .32s cubic-bezier(.2, 1.3, .5, 1) both; }
@keyframes card-out { to { opacity: 0; transform: translateX(-40px) rotate(-3deg); } }
@keyframes card-in { from { opacity: 0; transform: translateX(40px) rotate(3deg); } }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.question { text-transform: none; letter-spacing: 0; font-size: 14px; }
.undo {
  border: 0; background: var(--bg); color: var(--ink-2); border-radius: 99px; padding: 6px 12px;
  font-weight: 800; font-size: 13px; white-space: nowrap; flex: none;
}
.sentence { margin: 0; font-size: clamp(19px, 5.2vw, 23px); line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.sentence mark {
  color: var(--mark-ink); font-weight: 800; padding: 1px 5px; margin: 0 -2px; border-radius: 8px;
  background: var(--mark);
  box-shadow: 0 3px 0 #e8b400;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
/* Long sentences on small phones: fade the bottom edge so it's clear the card scrolls. */
.sentence-card.overflows { -webkit-mask-image: linear-gradient(#000 calc(100% - 44px), transparent); mask-image: linear-gradient(#000 calc(100% - 44px), transparent); }
.previous { margin: 0; font-size: 14px; color: var(--ink-2); font-weight: 700; }

.scale { display: flex; flex-direction: column; gap: 8px; }
.rate {
  --c: var(--s3);
  border: 0; border-radius: 16px; background: var(--surface); color: var(--ink);
  display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; min-height: 56px; text-align: left;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 55%, var(--line));
  border: 2px solid color-mix(in srgb, var(--c) 30%, transparent);
  transition: transform .08s, box-shadow .08s, background .15s;
  position: relative;
}
.rate:active:not(:disabled), .rate.pressed { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 55%, var(--line)); }
.rate.pressed { background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.rate:disabled { cursor: default; }
.num {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--c); color: #fff; font: 700 20px Fredoka, sans-serif;
}
.rate b { display: block; font-size: 17px; line-height: 1.15; }
.rate small { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.2; }
.rate.was { outline: 3px dashed var(--c); outline-offset: 2px; }
@media (max-height: 640px) {
  .rate { min-height: 48px; padding-block: 5px; }
  .rate .num { width: 36px; height: 36px; }
  .rate small { display: none; }
  .scale { gap: 6px; }
  .sentence { font-size: 18px; }
  .sentence-card { padding: 16px 18px 18px; gap: 8px; }
  .play { gap: 10px; }
}
@media (min-width: 700px) and (min-height: 700px) { .play { padding-top: 32px; } }
.plus-one {
  position: fixed; pointer-events: none; z-index: 60; font: 700 24px Fredoka, sans-serif; color: var(--accent);
  animation: plus-one .8s ease-out forwards;
}
@keyframes plus-one { to { transform: translateY(-60px) scale(1.2); opacity: 0; } }

/* ---------- chests ---------- */
.chest { overflow: visible; }
.chest .lid { transform-box: view-box; transform-origin: 14px 52px; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); }
.chest .lock { transform-box: fill-box; transform-origin: center; }
.chest.locked { filter: grayscale(1) opacity(.45); }
.look-wood    { --body: #c07f43; --dark: #7a4a22; --band: #56545f; --lock: #f2c14e; }
.look-silver  { --body: #d3dae3; --dark: #8592a4; --band: #6a7486; --lock: #4fc3f7; }
.look-gold    { --body: #f7c943; --dark: #c48a16; --band: #9a6a12; --lock: #ff6b6b; }
.look-diamond { --body: #8eeaf5; --dark: #3aa7c9; --band: #effcff; --lock: #b388ff; }
.chest .sparkle { fill: #fff; opacity: 0; }
.look-diamond .sparkle, .look-gold .sparkle { animation: sparkle 2s ease-in-out infinite; }
.chest .sparkle:nth-of-type(2) { animation-delay: -.7s; }
.chest .sparkle:nth-of-type(3) { animation-delay: -1.3s; }
@keyframes sparkle { 0%, 100% { opacity: 0; transform: scale(.4); } 50% { opacity: 1; transform: scale(1); } }
.chest .sparkle { transform-box: fill-box; transform-origin: center; }

/* chest opening modal */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b)); text-align: center;
  background: radial-gradient(circle at 50% 42%, rgba(60, 40, 110, .97), rgba(15, 10, 30, .99));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #fff; animation: fade-in .25s ease both; overflow-y: auto; overflow-x: hidden;
}
/* Centre vertically, but stay scrollable from the top when the content is taller than the screen. */
.modal > :first-child { margin-top: auto; }
.modal > :last-child { margin-bottom: auto; }
@keyframes fade-in { from { opacity: 0; } }
.modal h2 { font: 700 30px/1.1 Fredoka, sans-serif; margin: 0 0 4px; }
.modal .sub { margin: 0; opacity: .8; font-weight: 700; }
.chest-stage { position: relative; width: min(260px, 70vw); margin: 18px 0 8px; cursor: pointer; transition: width .5s ease; flex: none; }
.chest-stage.open { width: min(170px, 45vw); margin-top: 40px; }
.chest-stage .chest { width: 100%; position: relative; z-index: 1; filter: drop-shadow(0 18px 18px rgba(0,0,0,.4)); }
.chest-stage .rays {
  position: absolute; inset: -60%; z-index: 0; border-radius: 50%; opacity: .5;
  background: repeating-conic-gradient(from 0deg, rgba(255, 220, 120, .35) 0 10deg, transparent 10deg 24deg);
  mask: radial-gradient(circle, #000 20%, transparent 65%); -webkit-mask: radial-gradient(circle, #000 20%, transparent 65%);
  animation: rays 14s linear infinite;
}
@keyframes rays { to { transform: rotate(360deg); } }
.chest-stage.shake-1 .chest { animation: shake .35s ease; }
.chest-stage.shake-2 .chest { animation: shake .35s ease; animation-iteration-count: 2; }
@keyframes shake { 25% { transform: rotate(-6deg) scale(1.04); } 75% { transform: rotate(6deg) scale(1.04); } }
.chest-stage.open .lid { transform: translate(-2px, -14px) rotate(-16deg); }
.chest-stage.open .lock { animation: lock-drop .7s ease-in forwards; }
@keyframes lock-drop { to { transform: translate(40px, 120px) rotate(120deg); opacity: 0; } }
.chest-stage.open .rays { opacity: 1; inset: -90%; transition: all .6s; }
.chest-stage .burst {
  position: absolute; left: 50%; top: 45%; width: 20px; height: 20px; margin: -10px; border-radius: 50%;
  background: #fff6c9; box-shadow: 0 0 60px 30px #ffe27a; opacity: 0; z-index: 2; pointer-events: none;
}
.chest-stage.open .burst { animation: burst .7s ease-out; }
@keyframes burst { 20% { opacity: 1; transform: scale(8); } 100% { opacity: 0; transform: scale(14); } }
.tap-hint { font: 600 18px Fredoka, sans-serif; animation: bob 1.2s ease-in-out infinite; margin: 0; }
.rewards { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 420px; margin-top: 8px; }
.reward {
  background: #fff; color: #2a2140; border-radius: 20px; padding: 16px; text-align: left;
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center;
  animation: reward-in .5s cubic-bezier(.2, 1.5, .5, 1) both;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.reward:nth-child(2) { animation-delay: .15s; }
.reward:nth-child(3) { animation-delay: .3s; }
@keyframes reward-in { from { opacity: 0; transform: translateY(30px) scale(.8); } }
.reward .emoji { font-size: 42px; line-height: 1; grid-row: span 2; }
.reward h3 { margin: 0; font: 700 19px/1.2 Fredoka, sans-serif; }
.reward p { margin: 0; color: #6b6180; font-size: 15px; }
.reward .media { grid-column: 1 / -1; margin-top: 8px; }
.reward video, .reward img { width: 100%; border-radius: 14px; display: block; background: #000; max-height: 60vh; }
.ticket {
  grid-column: 1 / -1; margin-top: 8px; padding: 10px 14px; border-radius: 12px;
  border: 2px dashed #ff6b3d; background: #fff4e4; font: 700 22px Fredoka, sans-serif; text-align: center; color: #d9481c;
}
.modal .actions { margin-top: 18px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.modal .btn.ghost { color: rgba(255,255,255,.75); }

/* milestone / done modal */
.modal .big-emoji { font-size: 84px; line-height: 1; margin-bottom: 10px; animation: bob 1.6s ease-in-out infinite; }
.modal .body { max-width: 380px; font-weight: 700; opacity: .9; }

/* ---------- sheet (menu) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 14, 40, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade-in .2s ease both;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; background: var(--bg);
  border-radius: 26px 26px 0 0; padding: 8px 16px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 12px; animation: sheet-in .3s cubic-bezier(.2, 1.2, .5, 1) both;
}
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-handle { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-user { margin: 0; font: 600 20px Fredoka, sans-serif; }
.sheet-body { display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.chest-row {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 18px; padding: 12px;
  box-shadow: var(--shadow); border: 0; text-align: left; width: 100%;
}
.chest-row .chest { width: 64px; flex: none; }
.chest-row b { display: block; font: 600 18px Fredoka, sans-serif; }
.chest-row small { color: var(--ink-2); font-weight: 700; }
.chest-row.ready { outline: 3px solid var(--accent); animation: pulse-soft 1.6s ease-in-out infinite; }
@keyframes pulse-soft { 50% { outline-color: transparent; } }
.chest-row .mini-bar { height: 8px; background: var(--line); border-radius: 9px; overflow: hidden; margin-top: 6px; }
.chest-row .mini-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: flex; align-items: center; gap: 12px; background: var(--surface); padding: 10px 14px; border-radius: 14px; font-weight: 800; }
.board .rank { width: 28px; text-align: center; font: 700 18px Fredoka, sans-serif; }
.board .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li.me { outline: 3px solid var(--accent); }
.help p { margin: 0 0 10px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 70; transform: translate(-50%, 150%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 800;
  transition: transform .3s cubic-bezier(.2, 1.3, .5, 1), visibility .3s; max-width: calc(100% - 32px); text-align: center;
  visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- fun overlay (cheers) ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 45; overflow: hidden; }
.cheer-msg {
  position: absolute; left: 50%; top: calc(18% + var(--safe-t)); transform: translateX(-50%);
  font: 700 clamp(28px, 9vw, 44px)/1.1 Fredoka, sans-serif; color: #fff; text-align: center; width: 90%;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink), 0 10px 24px rgba(0,0,0,.25);
  animation: cheer-msg 2.6s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes cheer-msg {
  0% { opacity: 0; transform: translateX(-50%) scale(.3) rotate(-8deg); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.1) rotate(2deg); }
  25% { transform: translateX(-50%) scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}
.sprite { position: absolute; font-size: 64px; line-height: 1; will-change: transform; }
.flip { display: inline-block; transform: scaleX(-1); }

/* cowboy: rides right → left, galloping */
.fx-cowboy { bottom: 22%; left: 100%; animation: ride-left 3.4s linear forwards; font-size: 72px; }
.fx-cowboy .rider { position: absolute; left: 14px; top: -36px; font-size: 44px; animation: gallop .3s ease-in-out infinite alternate; }
.fx-cowboy .horse { display: inline-block; animation: gallop .3s ease-in-out infinite alternate-reverse; }
.fx-cowboy .lasso { position: absolute; left: -30px; top: -60px; font: 700 20px Fredoka; color: var(--ink); background: #fff; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.fx-dust { bottom: 22%; font-size: 30px; animation: dust 1s ease-out forwards; }
@keyframes ride-left { to { transform: translateX(calc(-100vw - 200px)); } }
@keyframes gallop { to { transform: translateY(-8px) rotate(-4deg); } }
@keyframes dust { from { opacity: .9; } to { opacity: 0; transform: translate(30px, -20px) scale(1.8); } }

.fx-rocket { bottom: -100px; left: 50%; font-size: 70px; animation: rocket 2.6s cubic-bezier(.6, 0, .9, .6) forwards; }
.fx-rocket .body { display: inline-block; transform: rotate(-45deg); }
@keyframes rocket { 0% { transform: translate(-50%, 0); } 15% { transform: translate(-50%, -10vh) rotate(-2deg); } 20% { transform: translate(-48%, -11vh) rotate(2deg); } 100% { transform: translate(-50%, -130vh); } }
.fx-smoke { font-size: 36px; animation: smoke 1.4s ease-out forwards; }
@keyframes smoke { from { opacity: .8; } to { opacity: 0; transform: scale(2.4) translateY(20px); } }

.fx-skier { top: -80px; left: -80px; animation: ski 3s ease-in-out forwards; }
@keyframes ski {
  0% { transform: translate(0, 0) rotate(10deg); }
  25% { transform: translate(55vw, 25vh) rotate(-10deg); }
  50% { transform: translate(20vw, 50vh) rotate(10deg); }
  75% { transform: translate(70vw, 75vh) rotate(-10deg); }
  100% { transform: translate(40vw, 110vh) rotate(10deg); }
}
.fx-snow { font-size: 22px; animation: dust 1.2s ease-out forwards; }

.fx-cat { bottom: 12%; left: 100%; animation: cat-walk 4.2s linear forwards; }
.fx-cat .meow { position: absolute; top: -34px; left: 10px; background: #fff; color: #2a2140; font: 700 16px Fredoka; padding: 3px 10px; border-radius: 12px; opacity: 0; animation: meow 4.2s linear forwards; }
@keyframes cat-walk { 0% { transform: translateX(0); } 40%, 60% { transform: translateX(calc(-50vw - 32px)); } 100% { transform: translateX(calc(-100vw - 140px)); } }
@keyframes meow { 0%, 40% { opacity: 0; } 45%, 58% { opacity: 1; } 62%, 100% { opacity: 0; } }

.fx-ufo { top: -90px; left: 50%; margin-left: -36px; animation: ufo 3.8s ease-in-out forwards; font-size: 72px; }
.fx-beam {
  position: absolute; top: calc(25vh + 40px); left: 50%; width: 140px; margin-left: -70px; height: 55vh;
  background: linear-gradient(rgba(170, 255, 160, .7), rgba(170, 255, 160, .1));
  clip-path: polygon(40% 0, 60% 0, 100% 100%, 0 100%); opacity: 0; animation: beam 3.8s ease-in-out forwards;
}
.fx-cow { top: calc(80vh - 50px); left: 50%; margin-left: -28px; font-size: 56px; animation: cow 3.8s ease-in-out forwards; }
@keyframes ufo { 0% { transform: translateY(0); } 20%, 70% { transform: translateY(calc(25vh + 90px)) rotate(-4deg); } 72% { transform: translateY(calc(25vh + 90px)) rotate(4deg); } 100% { transform: translate(80vw, -20vh) rotate(20deg); } }
@keyframes beam { 0%, 22% { opacity: 0; } 28%, 64% { opacity: 1; } 70%, 100% { opacity: 0; } }
@keyframes cow { 0%, 28% { transform: translateY(0) rotate(0); opacity: 1; } 66% { transform: translateY(-52vh) rotate(360deg) scale(.4); opacity: 1; } 67%, 100% { opacity: 0; } }

.fx-dino { bottom: 14%; left: 100%; animation: ride-left 3.4s linear forwards; font-size: 70px; }
.fx-dino .jump { display: inline-block; animation: dino-jump 3.4s linear forwards; }
@keyframes dino-jump { 0%, 22%, 38%, 58%, 74%, 100% { transform: translateY(0); } 30%, 66% { transform: translateY(-110px); } }
.fx-cactus { bottom: 14%; font-size: 48px; animation: fade-late 3.4s linear forwards; }
@keyframes fade-late { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

.fx-water { position: absolute; left: 0; right: 0; bottom: 0; height: 18vh; background: linear-gradient(#57c7ff, #1d6fd6); opacity: 0; animation: water 3.4s ease forwards; border-radius: 50% 50% 0 0 / 20px 20px 0 0; }
@keyframes water { 10%, 85% { opacity: .9; } 100% { opacity: 0; } }
.fx-whale { bottom: 6vh; left: 100%; font-size: 90px; animation: whale 3.4s ease-in-out forwards; }
@keyframes whale {
  0%, 12% { transform: translate(0, 0) rotate(0); }
  50% { transform: translate(calc(-50vw - 45px), -45vh) rotate(-10deg); }
  88%, 100% { transform: translate(calc(-100vw - 120px), 0) rotate(-40deg); }
}
.fx-splash { bottom: 12vh; font-size: 44px; animation: dust 1s ease-out forwards; }

.fx-snack { top: -60px; font-size: 44px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(calc(100vh + 120px)) rotate(var(--rot, 360deg)); } }

.fx-train { bottom: 8%; left: 100%; font-size: 60px; white-space: nowrap; animation: train 3.6s linear forwards; }
@keyframes train { to { transform: translateX(calc(-100vw - 100%)); } }
.fx-train .choo { position: absolute; left: 0; top: -44px; font: 700 22px Fredoka; background: #fff; color: #2a2140; padding: 2px 10px; border-radius: 12px; }

.fx-disco-light { position: absolute; inset: 0; animation: disco 2.8s steps(1) forwards; mix-blend-mode: soft-light; }
@keyframes disco {
  0% { background: rgba(255, 80, 180, .5); } 12% { background: rgba(80, 200, 255, .5); } 25% { background: rgba(255, 220, 60, .5); }
  37% { background: rgba(140, 90, 255, .5); } 50% { background: rgba(60, 255, 160, .5); } 62% { background: rgba(255, 80, 180, .5); }
  75% { background: rgba(80, 200, 255, .5); } 87% { background: rgba(255, 220, 60, .5); } 100% { background: transparent; }
}
.fx-ball { top: -80px; left: 50%; margin-left: -36px; font-size: 72px; animation: ball 2.8s ease forwards; }
@keyframes ball { 20%, 80% { transform: translateY(130px) rotate(20deg); } 50% { transform: translateY(130px) rotate(-20deg); } 100% { transform: translateY(-40px); } }
.fx-dancer { bottom: 10%; font-size: 70px; animation: dance 2.8s ease-in-out forwards; }
@keyframes dance {
  0% { opacity: 0; transform: scale(.3); } 10% { opacity: 1; transform: scale(1); }
  20%, 40%, 60% { transform: rotate(-12deg) translateY(-10px); } 30%, 50%, 70% { transform: rotate(12deg); }
  90% { opacity: 1; } 100% { opacity: 0; transform: scale(.6); }
}

.fx-balloon { bottom: -100px; font-size: 60px; animation: balloon ease-out forwards; }
@keyframes balloon { to { transform: translate(var(--dx, 0), calc(-100vh - 200px)) rotate(var(--rot, 0)); } }

@media (prefers-reduced-motion: reduce) {
  .sprite, .fx-beam, .fx-water, .fx-disco-light { display: none; }
  .bar-fill::after, .auth-chests .chest, .next-chest.close .chest { animation: none; }
}
