/* ═══════════════════════════════════════════════════════════════════
   My Words Quest — /games/my-words-quest
   Deep teal and violet: the player's own words, so a palette of its own
   rather than Chinese Quest's navy. Effects are the Grammar Gauntlet kit
   (mw- prefix): chrome only, clipped by the stage, off under reduced motion.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --mw-ink: #102a2c;
    --mw-teal: #0f766e;
    --mw-teal-light: #14b8a6;
    --mw-violet: #6d28d9;
    --mw-gold: #c9922e;
    --mw-surface: #ffffff;
    --mw-paper: #f4f8f8;
    --mw-line: #d4e0e0;
    --mw-muted: #5b6b6c;
}

[data-bs-theme="dark"] {
    --mw-ink: #e3f1f0;
    --mw-surface: #172526;
    --mw-paper: #101b1c;
    --mw-line: #2b3d3e;
    --mw-muted: #9fb3b3;
}

.mw-accent { color: var(--mw-teal); }

.mw-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 85% 20%, rgba(243, 210, 122, 0.22), transparent 40%),
        linear-gradient(135deg, #0b1b3f 0%, #13306b 55%, #1f4fbf 100%);
}
.mw-hero::after {
    content: ""; position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 18px 18px; pointer-events: none;
}
.mw-hero > .row { position: relative; z-index: 1; }
.mw-hero h1 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif; letter-spacing: 0.01em; }
.mw-eyebrow-light { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #f3d27a; }
.mw-hero-path { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.mw-hero-dot { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.mw-hero-dot:nth-child(2) { transform: translateX(-26px); }
.mw-hero-dot:nth-child(3) { transform: translateX(-40px); }
.mw-hero-dot:nth-child(4) { transform: translateX(-10px); }
.mw-hero-dot:nth-child(5) { transform: translateX(24px); }
.mw-hero-dot:nth-child(6) { transform: translateX(8px); }
.mw-hero-dot.is-done { background: #2f62d6; }
.mw-hero-dot.is-chest { background: linear-gradient(135deg, #c98a3a, #f3d27a); }
.mw-hero-dot.is-current { background: #5fb3f9; box-shadow: 0 0 0 4px rgba(95, 179, 249, 0.35), 0 3px 0 rgba(0, 0, 0, 0.25); }
.mw-hero-dot.is-nemesis { background: linear-gradient(135deg, #e11d48, #6d0f2a); }
.mw-hero-dot.is-trophy { background: linear-gradient(135deg, #fbe7a1, #c99a2e); }
.mw-eyebrow { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mw-muted); font-weight: 700; }

/* ── Top bar ──────────────────────────────────────────────────────── */
.mw-topbar { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.mw-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.mw-pick-btn {
    border: 1px solid var(--mw-line); background: var(--mw-surface); color: var(--mw-ink);
    border-radius: 0.55rem; padding: 0.35rem 0.7rem; font-size: 0.86rem; line-height: 1.15;
    display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0.05rem; min-width: 6.4rem;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.mw-pick-mult { font-size: 0.7rem; color: var(--mw-muted); }
.mw-pick-label { font-weight: 700; }
.mw-pick-btn.active, .mw-pick-btn[aria-pressed="true"] {
    background: linear-gradient(135deg, #13306b, #1f4fbf); border-color: #13306b; color: #fff;
}
.mw-pick-btn.active .mw-pick-mult, .mw-pick-btn[aria-pressed="true"] .mw-pick-mult { color: rgba(255, 255, 255, 0.85); }
.mw-pick-btn:active { transform: scale(0.97); }
.mw-pick-btn.mw-picked { animation: mw-pop 0.3s ease; }
@media (hover: hover) {
    .mw-pick-btn:hover { border-color: #1f4fbf; }
}
.mw-switches { display: flex; gap: 0.35rem; }
.mw-switch { border: 1px solid var(--mw-line); background: var(--mw-surface); color: var(--mw-ink); }
.mw-switch[aria-pressed="true"] { border-color: var(--mw-teal); color: var(--mw-teal); }
.mw-switch:disabled { opacity: 0.55; }
.mw-switches .mw-switch { min-width: 2.4rem; white-space: nowrap; }
.mw-switches .mw-switch[aria-pressed="true"] { border-color: #1f4fbf; color: #1f4fbf; }
@media (max-width: 575.98px) {
    .mw-topbar { flex-wrap: nowrap; align-items: stretch; }
    .mw-picker { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .mw-pick-btn { min-width: 0; padding: .35rem .4rem; font-size: .8rem; justify-content: center; }
    .mw-switches { flex-direction: column; }
    .mw-switches .mw-switch { min-height: 44px; }
}

/* ── The stage clips every effect ─────────────────────────────────── */
.mw-stage {
    position: relative; overflow: hidden; min-height: 300px; scroll-margin-top: 12px;
    background: var(--mw-paper); border: 1px solid var(--mw-line); border-radius: 0.9rem; padding: 1rem;
}
.mw-loading { text-align: center; color: var(--mw-muted); padding: 2.5rem 1rem; }
.mw-spinner {
    width: 2rem; height: 2rem; border-radius: 50%; margin: 0 auto 0.6rem;
    border: 3px solid var(--mw-line); border-top-color: var(--mw-teal); animation: mw-spin 0.9s linear infinite;
}
@keyframes mw-spin { to { transform: rotate(360deg); } }

/* ── Setup ────────────────────────────────────────────────────────── */
.mw-setup-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; margin-bottom: 0.6rem; }
.mw-count { font-size: 1.8rem; font-weight: 800; color: var(--mw-teal); line-height: 1; white-space: nowrap; }
.mw-count small { font-size: 0.9rem; color: var(--mw-muted); font-weight: 600; margin-left: 0.15rem; }
.mw-quick { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; align-items: center; }
.mw-quick-btn { border: 1px solid var(--mw-line); background: var(--mw-surface); color: var(--mw-ink); }
.mw-source { width: auto; max-width: 100%; flex: 1 1 12rem; }
.mw-list { list-style: none; padding: 0; margin: 0 0 0.5rem; max-height: 22rem; overflow-y: auto; border: 1px solid var(--mw-line); border-radius: 0.6rem; background: var(--mw-surface); }
.mw-list li + li { border-top: 1px solid var(--mw-line); }
.mw-item { display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.6rem; margin: 0; cursor: pointer; width: 100%; }
.mw-item.is-on { background: rgba(20, 184, 166, 0.1); }
.mw-item-hanzi { font-size: 1.15rem; font-weight: 700; min-width: 2.6rem; }
.mw-item-pinyin { color: var(--mw-teal); font-size: 0.85rem; min-width: 4rem; }
.mw-item-gloss { font-size: 0.85rem; color: var(--mw-muted); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mw-item-pic { color: var(--mw-violet); }
.mw-start-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.mw-start-btn {
    background: linear-gradient(135deg, var(--mw-teal), var(--mw-teal-light)); color: #fff; border: 0; font-weight: 700;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.mw-start-btn:disabled { opacity: 0.5; color: #fff; }
.mw-start-btn:active:not(:disabled) { transform: scale(0.98); }
@media (hover: hover) {
    .mw-start-btn:hover:not(:disabled) { color: #fff; filter: brightness(1.06); }
}
.mw-empty { padding: 0.5rem 0; }

/* ── Starter sets ─────────────────────────────────────────────────── */
.mw-starter { border: 1px solid var(--mw-line); border-radius: 0.6rem; background: var(--mw-surface); padding: 0.6rem; margin-bottom: 0.6rem; }
.mw-starter-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.4rem; }
.mw-starter-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 0.3rem; }
@media (min-width: 768px) { .mw-starter-list { grid-template-columns: 1fr 1fr; } }
.mw-starter-list li { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; min-width: 0; }
.mw-starter-picture { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.mw-starter-hanzi { font-weight: 700; font-size: 1.05rem; }
.mw-starter-pinyin { color: var(--mw-teal); }
.mw-starter-gloss { color: var(--mw-muted); flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ── Path ─────────────────────────────────────────────────────────── */
.mw-map-status { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .8rem; margin-bottom: .75rem; color: var(--mw-muted); }

/* ── The adventure map: a holographic star chart ───────────────────────
   Dark in both themes on purpose — it is a game board, like the stage
   HUD, and the neon trail and glowing orbs only read against night sky.
   The current stop wears Chinese Quest's call-out: a spinning gold ring
   and a bubble above it saying what pressing it does. */
.mw-map {
    position: relative; isolation: isolate; overflow: hidden; border-radius: 1.2rem;
    border: 1px solid #2dd4bf4d;
    background:
        radial-gradient(circle at 18% 8%, #2dd4bf38, transparent 38%),
        radial-gradient(circle at 88% 72%, #8b5cf64d, transparent 42%),
        radial-gradient(circle at 50% 120%, #0ea5e933, transparent 55%),
        linear-gradient(165deg, #06161f 0%, #0b2233 46%, #1a1142 100%);
    box-shadow: inset 0 0 48px #2dd4bf1f, 0 12px 30px #0b1b3f30;
}
/* Perspective-free holo grid, drifting slowly, faded at the edges. */
.mw-map::before {
    content: ''; position: absolute; inset: -40px 0 0; z-index: -2; pointer-events: none;
    background-image: linear-gradient(#5eead414 1px, transparent 1px), linear-gradient(90deg, #5eead414 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 35%, transparent 80%);
    mask-image: radial-gradient(ellipse at 50% 45%, #000 35%, transparent 80%);
    animation: mw-grid-drift 14s linear infinite;
}
/* Starfield: tiled layers of different sizes, so it stays dense at any width and height and
   never visibly repeats. A second layer (.mw-map-stars) twinkles out of phase with the first. */
.mw-map::after {
    content: ''; position: absolute; inset: 0; z-index: -2; pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 18% 22%, #fff, transparent),
        radial-gradient(1.2px 1.2px at 64% 58%, #e0f2fe, transparent),
        radial-gradient(1px 1px at 86% 12%, #ccfbf1, transparent),
        radial-gradient(1.4px 1.4px at 32% 78%, #fff, transparent),
        radial-gradient(1px 1px at 72% 34%, #ddd6fe, transparent),
        radial-gradient(1px 1px at 8% 52%, #fff, transparent),
        radial-gradient(1.6px 1.6px at 46% 16%, #fff, transparent),
        radial-gradient(1px 1px at 88% 70%, #ccfbf1, transparent),
        radial-gradient(1.2px 1.2px at 24% 92%, #e0f2fe, transparent);
    background-size: 120px 140px, 120px 140px, 120px 140px, 190px 170px, 190px 170px, 190px 170px, 260px 230px, 260px 230px, 260px 230px;
    animation: mw-twinkle 4.5s ease-in-out infinite alternate;
}
.mw-map-stars {
    position: absolute; inset: 0; z-index: -2; pointer-events: none;
    background-image:
        radial-gradient(2px 2px at 30% 40%, #fff, transparent),
        radial-gradient(1.6px 1.6px at 78% 82%, #fde68a, transparent),
        radial-gradient(1.8px 1.8px at 12% 76%, #a5f3fc, transparent),
        radial-gradient(2px 2px at 62% 14%, #f5d0fe, transparent),
        radial-gradient(1.4px 1.4px at 90% 46%, #fff, transparent);
    background-size: 170px 210px, 170px 210px, 240px 260px, 240px 260px, 310px 190px;
    animation: mw-twinkle 3.2s ease-in-out -1.6s infinite alternate;
}
/* Four-point sparkles: the bright stars. */
.mw-map-spark {
    position: absolute; z-index: -1; width: 16px; height: 16px; pointer-events: none;
    background:
        radial-gradient(circle, #fff 0 1.6px, transparent 2.6px),
        linear-gradient(90deg, transparent 46%, #ffffffd0 50%, transparent 54%),
        linear-gradient(transparent 46%, #ffffffd0 50%, transparent 54%);
    filter: drop-shadow(0 0 3px #a5f3fc);
    animation: mw-sparkle 3s ease-in-out infinite;
}
.mw-map-spark-a { top: 9%; left: 68%; }
.mw-map-spark-b { top: 41%; left: 7%; animation-delay: -1s; transform: scale(.75); }
.mw-map-spark-c { top: 63%; left: 88%; animation-delay: -2s; }
.mw-map-spark-d { top: 88%; left: 30%; animation-delay: -.5s; transform: scale(.6); }
/* A shooting star crosses the top of the chart now and then. */
.mw-map-comet {
    position: absolute; z-index: -1; top: 14%; left: -30%; width: 110px; height: 2px; border-radius: 2px; pointer-events: none;
    background: linear-gradient(90deg, transparent, #a5f3fc99, #fff);
    filter: drop-shadow(0 0 4px #a5f3fc);
    transform: rotate(14deg); opacity: 0;
    animation: mw-comet 9s linear 2s infinite;
}

/* Four planets. Each is pressable: the spacecraft flies to it. */
.mw-map-land { position: absolute; z-index: -1; border-radius: 50%; cursor: pointer; transition: filter .2s ease; }
@media (hover: hover) { .mw-map-land:hover { filter: brightness(1.25); } }
.mw-map-land-a {
    width: 150px; height: 150px; left: -62px; top: 34%;
    background: radial-gradient(circle at 35% 30%, #5eead4, #0f766e 55%, #042f2e 100%);
    box-shadow: 0 0 40px #2dd4bf55, inset -14px -10px 26px #0006; opacity: .55;
}
.mw-map-land-a::after {
    content: ''; position: absolute; left: -24%; right: -24%; top: 44%; height: 14%;
    border: 2px solid #99f6e4aa; border-radius: 50%; transform: rotate(-16deg);
}
.mw-map-land-b {
    width: 96px; height: 96px; right: -30px; bottom: 16%;
    background: radial-gradient(circle at 35% 30%, #c4b5fd, #7c3aed 55%, #2e1065 100%);
    box-shadow: 0 0 36px #8b5cf666, inset -10px -8px 20px #0006; opacity: .6;
    animation: mw-planet-bob 9s ease-in-out infinite;
}
/* A small banded gas giant, top right. */
.mw-map-land-c {
    width: 64px; height: 64px; right: 5%; top: 3%;
    background:
        repeating-linear-gradient(170deg, transparent 0 9px, #7c2d1240 9px 13px),
        radial-gradient(circle at 35% 30%, #fed7aa, #f97316 55%, #7c2d12 100%);
    box-shadow: 0 0 30px #fb923c55, inset -8px -6px 16px #0006; opacity: .7;
    animation: mw-planet-bob 11s ease-in-out -4s infinite;
}
.mw-map-land-c::after {
    content: ''; position: absolute; left: -30%; right: -30%; top: 42%; height: 16%;
    border: 2px solid #fdba74aa; border-radius: 50%; transform: rotate(18deg);
}
/* A little rose moon, bottom left. */
.mw-map-land-d {
    width: 42px; height: 42px; left: 7%; bottom: 4%;
    background: radial-gradient(circle at 35% 30%, #fecdd3, #f43f5e 60%, #881337 100%);
    box-shadow: 0 0 22px #fb718555, inset -6px -5px 10px #0006; opacity: .75;
    animation: mw-planet-bob 7s ease-in-out -2s infinite;
}

/* ── The spacecraft ── */
.mw-ship {
    position: absolute; left: 0; top: 0; z-index: 3; width: 28px; height: 40px; pointer-events: none;
    transition: transform .8s cubic-bezier(.45, .05, .25, 1), opacity .3s ease; will-change: transform;
}
.mw-ship:not(.is-ready) { opacity: 0; }
.mw-ship.no-move { transition: none; }
.mw-ship-tilt { width: 100%; height: 100%; transform: rotate(var(--mw-tilt, 0deg)); transition: transform .25s ease; }
.mw-ship-body { position: relative; width: 100%; height: 100%; filter: drop-shadow(0 0 6px #a5f3fc88); animation: mw-ship-hover 2.4s ease-in-out infinite; }
.mw-ship-body svg { display: block; position: relative; z-index: 1; }
.mw-ship-flame {
    position: absolute; left: 50%; top: 32px; width: 10px; height: 12px; margin-left: -5px; border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
    background: radial-gradient(ellipse at 50% 20%, #fff 0 18%, #fde68a 35%, #fb923c 65%, transparent 72%);
    transform-origin: 50% 0; animation: mw-flame .18s ease-in-out infinite alternate;
}
.mw-ship.is-flying .mw-ship-flame { height: 26px; background: radial-gradient(ellipse at 50% 15%, #fff 0 14%, #a5f3fc 30%, #fb923c 60%, transparent 72%); }
.mw-ship.is-flying .mw-ship-body { animation: none; }

.mw-map-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.mw-trail { fill: none; stroke: #7dd3fc59; stroke-width: 5; stroke-dasharray: 2 13; stroke-linecap: round; animation: mw-trail-flow 1.6s linear infinite; }
.mw-trail.is-walked { stroke: url(#mwTrailGlow); stroke-width: 6; stroke-dasharray: none; animation: none; filter: drop-shadow(0 0 5px #2dd4bfcc); }

/* A symmetric zig-zag down the middle of the chart: centre, left, centre, right. The labels sit
   under their stops, so the trail is centred and not pushed aside by text. Only the stops and their
   labels take presses; everything between them lets a press through to the planets. */
.mw-path { position: relative; list-style: none; padding: 30px 12px 30px; margin: 0; pointer-events: none; }
.mw-map-stop {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px;
    margin-bottom: 26px; transform: translateX(var(--mw-x, 0));
}
.mw-map-stop:last-child { margin-bottom: 0; }
.mw-map-stop > * { pointer-events: auto; }
.mw-map-stop.is-current { padding-top: 42px; }
.mw-stop-0 { --mw-x: 0%; }
.mw-stop-1 { --mw-x: -24%; }
.mw-stop-2 { --mw-x: 0%; }
.mw-stop-3 { --mw-x: 24%; }

/* Orbs. Locked ones are dark glass; cleared ones glow; the current one floats. */
.mw-node {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 68px; height: 68px; flex: 0 0 68px; border-radius: 50%; border: 0; padding: 0; margin: 0;
    background: radial-gradient(circle at 35% 28%, #475569, #1e293b 70%);
    color: #94a3b8; font-size: 1.5rem;
    box-shadow: 0 6px 0 #0b1220, inset 0 2px 0 #ffffff1f, inset 0 0 0 2px #64748b55;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent; cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}
.mw-node.is-locked { opacity: .85; }
.mw-node.is-done {
    color: #fff;
    background: radial-gradient(circle at 35% 28%, #5eead4, #0d9488 55%, #134e4a 100%);
    box-shadow: 0 6px 0 #053b37, 0 0 18px #2dd4bf66, inset 0 2px 0 #ffffff59;
}
.mw-node.is-current {
    color: #fff;
    background: radial-gradient(circle at 35% 28%, #a5f3fc, #14b8a6 45%, #0f766e 75%, #134e4a 100%);
    box-shadow: 0 7px 0 #053b37, 0 0 0 6px #2dd4bf2e, 0 0 34px #2dd4bfb3, inset 0 3px 0 #ffffff80;
    animation: mw-orb-in .55s cubic-bezier(.2, .9, .3, 1.4) backwards, mw-orb-float 2.6s ease-in-out .55s infinite;
}
.mw-node.is-current::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
    box-shadow: 0 0 0 0 #5eead4aa; animation: mw-orb-pulse 2s ease-out infinite;
}
@media (hover: hover) { .mw-node.is-current:hover { filter: brightness(1.12); } }
.mw-node.is-current:active { transform: translateY(5px); box-shadow: 0 2px 0 #053b37, 0 0 24px #2dd4bf99; }

.mw-node-bonus.is-locked, .mw-node-trophy.is-locked { color: #e7c378; }
.mw-node-nemesis.is-locked { color: #c4b5fd; }
.mw-node-bonus.is-done, .mw-node-bonus.is-current,
.mw-node-trophy.is-done, .mw-node-trophy.is-current {
    color: #5b3a06;
    background: radial-gradient(circle at 35% 28%, #fff7d1, #f3d27a 40%, #c99a2e 85%);
    box-shadow: 0 6px 0 #7a5208, 0 0 24px #facc1588, inset 0 2px 0 #ffffffa0;
}
.mw-node-nemesis.is-done, .mw-node-nemesis.is-current {
    color: #fff;
    background: radial-gradient(circle at 35% 28%, #f0abfc, #a855f7 45%, #5b21b6 100%);
    box-shadow: 0 6px 0 #2e1065, 0 0 26px #c084fcaa, inset 0 2px 0 #ffffff66;
}
.mw-node-bonus.is-current::after, .mw-node-trophy.is-current::after { animation-name: mw-orb-pulse-gold; }
.mw-node-nemesis.is-current::after { animation-name: mw-orb-pulse-violet; }

.mw-node-ring {
    position: absolute; inset: -10px; border-radius: 50%; border: 3px solid transparent; pointer-events: none;
    background: conic-gradient(from 0deg, #fff1bf, #f3d27a, #c99a2e, transparent 70%) border-box;
    -webkit-mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
    filter: drop-shadow(0 0 4px #facc15aa);
    animation: mw-ring-spin 2.4s linear infinite;
}

.mw-bubble {
    position: absolute; bottom: calc(100% + 16px); left: 50%; transform: translateX(-50%); z-index: 2;
    padding: .22rem .8rem; border-radius: .55rem; white-space: nowrap; pointer-events: none;
    background: #ecfeff; border: 2px solid #14b8a6; color: #0f5f58;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 800; font-size: .72rem;
    letter-spacing: .14em; text-transform: uppercase; line-height: 1.3;
    box-shadow: 0 0 0 3px #2dd4bf33, 0 0 18px #2dd4bf88;
    animation: mw-bubble-bob 1.8s ease-in-out infinite;
}
.mw-bubble::after {
    content: ''; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px;
    background: #ecfeff; border-right: 2px solid #14b8a6; border-bottom: 2px solid #14b8a6;
    transform: translateX(-50%) rotate(45deg);
}
.mw-node-trophy .mw-bubble, .mw-node-bonus .mw-bubble { border-color: #d4a017; color: #7a4d06; background: #fffbeb; box-shadow: 0 0 0 3px #facc1533, 0 0 18px #facc1588; }
.mw-node-trophy .mw-bubble::after, .mw-node-bonus .mw-bubble::after { border-color: #d4a017; background: #fffbeb; }
.mw-node-nemesis .mw-bubble { border-color: #a855f7; color: #5b21b6; background: #faf5ff; box-shadow: 0 0 0 3px #a855f733, 0 0 18px #c084fc88; }
.mw-node-nemesis .mw-bubble::after { border-color: #a855f7; background: #faf5ff; }

.mw-node-badge {
    position: absolute; right: -4px; bottom: -4px; width: 25px; height: 25px; border-radius: 50%;
    display: grid; place-items: center; font-size: .7rem;
    background: #334155; color: #cbd5e1; border: 2px solid #0b2233; box-shadow: 0 2px 6px #0008;
}
.mw-node.is-done .mw-node-badge { background: #f3d27a; color: #5b3a06; box-shadow: 0 0 10px #facc1599; }

.mw-map-label {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px;
    max-width: 150px; line-height: 1.25;
    padding: .35rem .6rem; border-radius: .6rem; font-size: .87rem;
    color: #e6fffb; background: #071c26cc; border: 1px solid #5eead433;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.mw-map-label > strong { display: inline-flex; align-items: baseline; justify-content: center; gap: .4rem; }
.mw-map-num { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; color: #f3d27a; font-weight: 700; }
.mw-map-label small { color: #99f6e4b3; font-size: .7rem; }
.mw-map-label .mw-star { font-size: .75rem; color: #f3d27a; }
.mw-map-label .mw-perfect-tag { display: block; color: #5eead4; font-size: .72rem; text-shadow: 0 0 8px #2dd4bf99; }
.mw-map-stop.is-current .mw-map-label { border-color: #5eead4aa; box-shadow: 0 0 14px #2dd4bf40; }
.mw-map-stop.is-locked .mw-map-label { color: #cbd5e1; }

.mw-map-goal { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; border-left: 3px solid var(--mw-teal); margin: .8rem 0; padding: .5rem .75rem; background: var(--mw-surface); font-size: .88rem; }
.mw-map-goal > span { color: var(--mw-muted); }

@keyframes mw-grid-drift { to { transform: translateY(32px); } }
@keyframes mw-twinkle { from { opacity: .45; } to { opacity: 1; } }
@keyframes mw-planet-bob { 50% { transform: translateY(-10px); } }
@keyframes mw-trail-flow { to { stroke-dashoffset: -30; } }
@keyframes mw-ring-spin { to { transform: rotate(360deg); } }
@keyframes mw-orb-in { 0% { transform: scale(.6); filter: grayscale(1); } 60% { transform: scale(1.12); } 100% { transform: scale(1); filter: none; } }
@keyframes mw-orb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes mw-orb-pulse { 0% { box-shadow: 0 0 0 0 #5eead4aa; } 100% { box-shadow: 0 0 0 20px #5eead400; } }
@keyframes mw-orb-pulse-gold { 0% { box-shadow: 0 0 0 0 #facc15aa; } 100% { box-shadow: 0 0 0 20px #facc1500; } }
@keyframes mw-orb-pulse-violet { 0% { box-shadow: 0 0 0 0 #c084fcaa; } 100% { box-shadow: 0 0 0 20px #c084fc00; } }
@keyframes mw-sparkle { 0%, 100% { opacity: .35; scale: .7; } 50% { opacity: 1; scale: 1.15; } }
@keyframes mw-comet { 0% { opacity: 0; translate: 0 0; } 3% { opacity: 1; } 12% { opacity: 0; translate: 520px 130px; } 100% { opacity: 0; translate: 520px 130px; } }
@keyframes mw-ship-hover { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes mw-flame { from { transform: scaleY(.8); opacity: .85; } to { transform: scaleY(1.15); opacity: 1; } }
@keyframes mw-bubble-bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }
.mw-node-dot {
    width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; background: var(--mw-line); color: var(--mw-muted); flex-shrink: 0;
}
.mw-node-text { display: flex; flex-direction: column; font-size: 0.9rem; min-width: 0; }
.mw-node-text span { color: var(--mw-muted); font-size: 0.82rem; }
.mw-node-text em { font-style: normal; font-size: 0.7rem; text-transform: uppercase; color: var(--mw-violet); margin-left: 0.25rem; }
.mw-node.is-done .mw-node-dot { background: #16a34a; color: #fff; }
.mw-node.is-current .mw-node-dot { background: var(--mw-teal); color: #fff; }
.mw-star { color: var(--mw-gold); }
.mw-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.75rem; }
.mw-chip { background: var(--mw-surface); border: 1px solid var(--mw-line); border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 1rem; }

/* ── Play ─────────────────────────────────────────────────────────── */
.mw-hud { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.mw-hud-stage { flex: 1; min-width: 0; }
.mw-hud-name { font-weight: 800; font-size: 1.05rem; color: var(--mw-ink); }
.mw-hud-item { display: flex; flex-direction: column; align-items: center; font-weight: 800; color: var(--mw-ink); min-width: 3.2rem; }
.mw-hud-item small { font-size: 0.66rem; font-weight: 600; color: var(--mw-muted); text-transform: uppercase; }
.mw-combo-badge { display: inline-block; background: var(--mw-teal); color: #fff; border-radius: 999px; padding: 0 0.5rem; font-size: 0.85rem; }
.mw-combo-badge.mw-combo-2 { background: #0284c7; }
.mw-combo-badge.mw-combo-3 { background: #7c3aed; }
.mw-combo-badge.mw-combo-4 { background: #ea580c; }
.mw-combo-badge.mw-combo-5 { background: linear-gradient(135deg, #dc2626, #f97316); animation: mw-glow 1.2s ease-in-out infinite; }
@keyframes mw-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.55); }
    50% { box-shadow: 0 0 0 6px rgba(249, 115, 22, 0); }
}
.mw-bar { height: 6px; background: var(--mw-line); border-radius: 999px; overflow: hidden; margin-bottom: 0.75rem; }
.mw-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--mw-teal), var(--mw-violet)); transition: width 0.3s ease; }

.mw-play-tools { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .7rem; }
.mw-hearts { color: #be185d; font-weight: 800; font-size: .83rem; }
.mw-hearts.is-low { color: #b91c1c; }
.mw-nemesis { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; border-radius: 1rem; padding: .9rem; background: linear-gradient(135deg, #281745, #512273); color: #f5eaff; }
.mw-nemesis > div:last-child { flex: 1; }
.mw-nemesis small { display: block; color: #e0c9fa; margin: .2rem 0; }
.mw-boss-face { width: 66px; height: 66px; flex-shrink: 0; border: 3px solid #c084fc; border-radius: 22px 22px 30px 30px; display: grid; place-items: center; color: #f0abfc; background: #160f2c; font-size: 2rem; box-shadow: 0 0 22px #c084fc44; }
.mw-boss-face.is-defeated { transform: rotate(15deg) scale(.8); opacity: .5; }
.mw-boss-bar { height: 9px; background: #160f2c; border-radius: 9px; overflow: hidden; }
.mw-timer { display: flex; align-items: center; gap: .6rem; color: var(--mw-muted); margin-bottom: .8rem; font-variant-numeric: tabular-nums; }
.mw-timer-track { height: 7px; flex: 1; overflow: hidden; background: var(--mw-line); border-radius: 9px; }
#mwTimerFill { height: 100%; background: var(--mw-teal); }
.mw-timer.is-urgent { color: var(--bs-danger); }
.mw-timer.is-urgent #mwTimerFill { background: var(--bs-danger); }
.mw-leaderboard-offer { margin: 1rem 0; padding: 1rem; border: 1px solid var(--mw-line); border-radius: .8rem; background: var(--mw-surface); }
.mw-leaderboard-offer .mw-start-btn { max-width: 100%; white-space: normal; }
.mw-leaderboard .tpl-lb-panel .tpl-lb-band { display: table; margin-top: .2rem; font-size: max(.75rem, 12px); line-height: 1.25; }
.mw-boss-bar span { display: block; height: 100%; background: linear-gradient(90deg, #a78bfa, #f0abfc); transition: width .45s ease; }
.mw-dials { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin: 1rem 0; }
.mw-dial { overflow: hidden; border: 2px solid var(--mw-line); border-radius: .7rem; width: calc((100% - 35px) / 6); min-width: 44px; max-width: 55px; background: var(--mw-surface); box-shadow: 0 4px 0 var(--mw-line); }
.mw-dial button { display: block; width: 100%; height: 44px; border: 0; background: var(--mw-paper); color: var(--mw-ink); font-size: .75rem; touch-action: manipulation; }
.mw-dial-value { display: flex; align-items: center; justify-content: center; height: 58px; font-size: 1.9rem; font-weight: 700; color: var(--mw-ink); background: linear-gradient(0deg, #0f766e0d, transparent 35%, transparent 65%, #0f766e0d); }
.mw-dial.is-locked { border-color: #16a34a; box-shadow: 0 4px 0 #15803d; }
.mw-dial.is-locked .mw-dial-value { color: #15803d; background: #dcfce7; }
.mw-dial.is-locked button { opacity: .4; }
.mw-bonus-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.mw-dial-turn { animation: mw-dial-turn .18s ease; }
@keyframes mw-dial-turn { from { transform: translateY(-8px) scale(.9); opacity: .4; } to { transform: none; opacity: 1; } }
.mw-perfect { display: flex; flex-direction: column; align-items: center; gap: .15rem; margin: .5rem 0; }
.mw-perfect > strong { color: #0f766e; font-size: clamp(2rem, 8vw, 3rem); font-weight: 900; letter-spacing: -.04em; }
.mw-oneup { background: #166534; border: 2px solid #86efac; border-radius: 999px; color: #fff; font-size: 1.4rem; font-weight: 900; padding: .1rem 1rem; animation: mw-bump .7s ease; }
.mw-perfect small { color: var(--mw-muted); }
.mw-perfect-tag { color: var(--mw-teal); font-size: .8rem; }
/* The failed-stage cost: a single figure that drops in, the opposite of the chest. */
.mw-penalty { display: flex; align-items: baseline; justify-content: center; gap: .4rem; margin: .4rem 0 .2rem; }
.mw-penalty > strong { color: #b91c1c; font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 900; letter-spacing: -.03em; animation: mw-penalty-drop .6s cubic-bezier(.2, .9, .3, 1.3); }
.mw-penalty > span { color: var(--mw-muted); font-weight: 700; }
.mw-trophy-stats .mw-penalty-stat { color: #b91c1c; border-color: #fca5a5; }
@keyframes mw-penalty-drop { from { opacity: 0; transform: translateY(-18px) scale(1.3); } to { opacity: 1; transform: none; } }
.mw-trophy { width: 120px; height: 120px; margin: .7rem auto; display: grid; place-items: center; position: relative; border-radius: 50%; background: radial-gradient(circle, #fff5c4, #facc1544 60%, transparent 70%); color: #d99512; font-size: 4.5rem; filter: drop-shadow(0 6px 0 #a5661330); animation: mw-trophy-land .65s cubic-bezier(.16, 1, .3, 1); }
.mw-trophy span { position: absolute; font-size: 1.6rem; left: -3px; top: 10px; }
.mw-trophy span:last-child { left: auto; top: auto; right: -3px; bottom: 12px; }
.mw-trophy-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; font-size: .75rem; }
.mw-trophy-stats span { border-radius: 999px; background: var(--mw-paper); border: 1px solid var(--mw-line); padding: .25rem .55rem; }
@keyframes mw-trophy-land { from { opacity: 0; transform: translateY(-35px) rotate(-15deg) scale(.6); } to { opacity: 1; transform: none; } }
.mw-node:focus-visible, .mw-dial-value:focus-visible, .mw-dial button:focus-visible { outline: 3px solid #7c3aed; outline-offset: 3px; }
.mw-map .mw-node:focus-visible { outline-color: #f3d27a; outline-offset: 6px; }
@media (max-width: 375px) {
    .mw-path { padding-inline: 5px; }
    .mw-node { width: 58px; height: 58px; flex-basis: 58px; font-size: 1.3rem; }
    .mw-map-stop { gap: 8px; }
    .mw-map-label { font-size: .8rem; padding: .2rem .4rem; max-width: 128px; }
    .mw-hud { flex-wrap: wrap; gap: .4rem; }
    .mw-hud-stage { flex-basis: 100%; }
    .mw-dials { gap: 6px; max-width: 210px; margin-inline: auto; }
    .mw-dial { width: 55px; }
}

.mw-prompt { text-align: center; margin-bottom: 0.75rem; position: relative; }
.mw-prompt-hanzi { font-size: clamp(2.2rem, 9vw, 3.2rem); font-weight: 700; color: var(--mw-ink); line-height: 1.2; }
.mw-prompt-pinyin { color: var(--mw-teal); font-size: 1.1rem; min-height: 1.5rem; }
.mw-prompt-gloss { font-size: 1.25rem; font-weight: 700; color: var(--mw-ink); }
.mw-prompt-gloss.small { font-size: 0.95rem; font-weight: 500; color: var(--mw-muted); }
.mw-prompt-ask { color: var(--mw-muted); font-size: 0.9rem; margin-top: 0.25rem; }
.mw-retry-tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; font-weight: 800; color: var(--mw-violet); letter-spacing: 0.06em; }
.mw-hint { color: var(--mw-violet); font-weight: 700; font-size: 0.9rem; min-height: 1.2rem; margin-top: 0.2rem; }
.mw-picture { width: 160px; height: 160px; object-fit: contain; }
.mw-stage .is-hidden { visibility: hidden; }

.mw-options { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
@media (min-width: 576px) { .mw-options { grid-template-columns: 1fr 1fr; } }
.mw-option {
    display: flex; align-items: center; gap: 0.55rem; text-align: left;
    background: var(--mw-surface); color: var(--mw-ink); border: 2px solid var(--mw-line); border-radius: 0.7rem;
    padding: 0.6rem 0.75rem; min-height: 3.2rem; font-size: 0.98rem;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    /* backwards, never both: a held end frame would out-rank :hover, :active and .faded. */
    animation: mw-deal-in 0.28s ease backwards;
}
@media (hover: hover) {
    /* Keep answer targets still: moving a button away from a pointer at its edge can flicker. */
    .mw-option:hover:not(:disabled) { border-color: var(--mw-teal); }
}
.mw-option:active:not(:disabled) { transform: scale(0.97); background: #f0fdfa; }
.mw-option.correct { border-color: #16a34a; background: #dcfce7; color: #14532d; animation: mw-pop 0.35s ease; }
.mw-option.wrong { border-color: #dc2626; background: #fee2e2; color: #7f1d1d; animation: mw-shake 0.35s ease; }
.mw-option.faded { opacity: 0.5; }
.mw-option:disabled { cursor: default; }
.mw-key { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 0.35rem; background: var(--mw-paper); color: var(--mw-muted); font-size: 0.75rem; font-weight: 800; flex-shrink: 0; }
.mw-option-hanzi { font-size: 1.4rem; font-weight: 700; }
.mw-option-pinyin { color: var(--mw-teal); font-size: 0.85rem; }

.mw-speaker { border: 1px solid var(--mw-line); background: var(--mw-surface); color: var(--mw-teal); border-radius: 50%; width: 2rem; height: 2rem; font-size: 0.9rem; vertical-align: middle; }
.mw-speaker.is-playing { background: var(--mw-teal); color: #fff; }

/* Memory Match */
.mw-match { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
@media (min-width: 576px) { .mw-match { grid-template-columns: repeat(4, 1fr); } }
.mw-tile {
    position: relative; min-height: 5.2rem; border-radius: 0.7rem; border: 2px solid var(--mw-teal);
    background: linear-gradient(135deg, #0f766e, #6d28d9); color: transparent; padding: 0.4rem;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.mw-tile::after { content: "?"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.7); font-size: 1.6rem; font-weight: 800; pointer-events: none; }
.mw-tile-face { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; visibility: hidden; }
.mw-tile.is-up { background: var(--mw-surface); color: var(--mw-ink); }
.mw-tile.is-up::after { content: none; }
.mw-tile.is-up .mw-tile-face { visibility: visible; }
.mw-tile.is-matched { border-color: #16a34a; background: #dcfce7; color: #14532d; animation: mw-pop 0.35s ease; }
.mw-tile-hanzi { font-size: 1.5rem; font-weight: 700; }
.mw-tile-pinyin { font-size: 0.78rem; color: var(--mw-teal); }
.mw-tile-gloss { font-size: 0.8rem; line-height: 1.2; overflow-wrap: anywhere; }
.mw-tile:active:not(:disabled) { transform: scale(0.97); }

/* Typing */
.mw-typing { max-width: 26rem; margin: 0 auto; }
.mw-type-input { font-size: 1.2rem; text-align: center; }
.mw-type-actions { display: flex; gap: 0.4rem; justify-content: center; margin-top: 0.5rem; }

.mw-feedback { text-align: center; min-height: 1.6rem; margin-top: 0.6rem; font-size: 0.95rem; color: var(--mw-ink); }
.mw-next-row { text-align: center; margin-top: 0.5rem; }

/* Stage cleared */
.mw-overlay {
    position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
    background: rgba(244, 248, 248, 0.94); padding: 1rem; text-align: center;
}
[data-bs-theme="dark"] .mw-overlay { background: rgba(16, 27, 28, 0.94); }
.mw-overlay[hidden] { display: none; }
.mw-stage [hidden] { display: none !important; }
.mw-stage:has(> .mw-overlay:not([hidden])) { min-height: 480px; }
.mw-clear-body { max-width: 100%; }
.mw-stars-big { font-size: 1.8rem; }
.mw-chest {
    display: inline-flex; align-items: center; gap: .35rem; padding: 0.4rem 0.9rem; border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #facc15); color: #422006; font-weight: 700;
}
/* The overlay's bottom row (chest + Back to the map, or Try again + Back to the map): one flex
   row whose items stretch to the same height, so their tops and bottoms line up; it wraps onto
   two centred lines when the card is too narrow. */
.mw-clear-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: .6rem; margin-top: .75rem; }
.mw-clear-actions > * { margin: 0; }
.mw-clear-actions > .btn { display: inline-flex; align-items: center; justify-content: center; }

/* Summary */
.mw-summary-head { text-align: center; margin-bottom: 0.5rem; }
.mw-final { font-size: 2.6rem; font-weight: 900; color: var(--mw-teal); line-height: 1.1; }
.mw-final small { font-size: 1rem; color: var(--mw-muted); margin-left: 0.3rem; font-weight: 600; }
.mw-newbest { display: inline-block; background: linear-gradient(135deg, #f59e0b, #facc15); color: #422006; border-radius: 999px; padding: 0.1rem 0.8rem; font-weight: 800; font-size: 0.85rem; margin: 0.2rem 0; }
.mw-stage-results { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.9rem; }
.mw-stage-results li { padding: 0.25rem 0; border-bottom: 1px dashed var(--mw-line); }
.mw-missed { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.mw-missed li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--mw-line); }
.mw-missed-hanzi { font-size: 1.2rem; font-weight: 700; }
.mw-missed-pinyin { color: var(--mw-teal); }
.mw-missed-gloss { color: var(--mw-muted); font-size: 0.88rem; flex: 1 1 8rem; min-width: 0; }
.mw-missed-link { font-size: 0.85rem; }
.mw-summary-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.mw-onward { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
@media (min-width: 576px) { .mw-onward { grid-template-columns: 1fr 1fr; } }
.mw-onward a { display: flex; gap: 0.6rem; align-items: center; padding: 0.6rem 0.75rem; border: 1px solid var(--mw-line); border-radius: 0.6rem; background: var(--mw-surface); color: var(--mw-ink); text-decoration: none; }
.mw-onward a span { display: flex; flex-direction: column; font-size: 0.82rem; color: var(--mw-muted); }
.mw-onward a strong { color: var(--mw-ink); font-size: 0.95rem; }
.mw-onward i { color: var(--mw-teal); font-size: 1.3rem; }

.mw-band-pill { display: inline-block; border-radius: 999px; padding: 0.05rem 0.55rem; font-size: 0.75rem; font-weight: 700; color: #fff; }
.mw-band-beginner { background: #16a34a; }
.mw-band-intermediate { background: #0284c7; }
.mw-band-advanced { background: #7c3aed; }
.mw-band-expert { background: #dc2626; }
.mw-how-list { padding-left: 1.2rem; }
.mw-how-list li { margin-bottom: 0.35rem; }

/* ── Effects kit ──────────────────────────────────────────────────── */
@keyframes mw-pop { 0% { transform: scale(1); } 45% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes mw-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.mw-float {
    position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
    font-weight: 800; font-size: 1.5rem; color: #15803d; text-shadow: 0 1px 0 #fff;
    pointer-events: none; z-index: 4;
    animation: mw-float-up 0.9s ease-out forwards;
}
@keyframes mw-float-up {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
    20% { transform: translate(-50%, -70%) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
.mw-particle, .mw-spark {
    position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
    pointer-events: none; z-index: 3;
    animation: mw-burst 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.mw-spark { width: 6px; height: 6px; z-index: 6; animation-duration: 1s; }
@keyframes mw-burst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}
/* Above the stage-cleared overlay (z-index 5) on purpose: that is where it falls. */
.mw-confetti {
    position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
    pointer-events: none; z-index: 6;
    animation: mw-confetti-fall 1.8s ease-in forwards;
}
@keyframes mw-confetti-fall {
    0% { opacity: 1; transform: translate(0, 0) rotate(0); }
    100% { opacity: 0; transform: translate(var(--drift), 460px) rotate(var(--spin)); }
}
.mw-combo-pop {
    position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
    font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 900; color: var(--mw-teal);
    text-shadow: 0 2px 0 #fff, 0 6px 18px rgba(20, 184, 166, 0.45);
    white-space: nowrap; pointer-events: none; z-index: 4;
    animation: mw-combo-pop 1.1s ease-out forwards;
}
.mw-combo-pop-3 { color: #7c3aed; }
.mw-combo-pop-4 { color: #ea580c; }
.mw-combo-pop-5 { color: #dc2626; }
@keyframes mw-combo-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
    45% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}
.mw-toast {
    position: absolute; top: 0.6rem; left: 50%; transform: translateX(-50%);
    padding: 0.35rem 0.9rem; border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #facc15); color: #422006;
    font-weight: 800; font-size: 0.9rem; white-space: nowrap;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    pointer-events: none; z-index: 7;
    animation: mw-toast 2.1s ease forwards;
}
@keyframes mw-toast {
    0% { opacity: 0; transform: translate(-50%, -12px); }
    12% { opacity: 1; transform: translate(-50%, 0); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}
.mw-prompt.mw-deal { animation: mw-deal-in 0.3s ease backwards; }
@keyframes mw-deal-in { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: translateY(0); } }
.mw-prompt.mw-shake, .mw-shake { animation: mw-shake 0.4s ease; }   /* declared after .mw-deal so it wins */
.mw-bump { display: inline-block; animation: mw-bump 0.35s ease; }
@keyframes mw-bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Dark theme: a selected button must out-rank the dark rule for the plain button. */
[data-bs-theme="dark"] .mw-pick-btn.active,
[data-bs-theme="dark"] .mw-pick-btn[aria-pressed="true"] {
    background: linear-gradient(135deg, #13306b, #1f4fbf); border-color: #5fb3f9; color: #fff;
}
[data-bs-theme="dark"] .mw-switches .mw-switch[aria-pressed="true"] { border-color: #5fb3f9; color: #5fb3f9; }
[data-bs-theme="dark"] .mw-option.correct { background: #14532d; color: #dcfce7; }
[data-bs-theme="dark"] .mw-option.wrong { background: #7f1d1d; color: #fee2e2; }
[data-bs-theme="dark"] .mw-tile.is-matched { background: #14532d; color: #dcfce7; }
[data-bs-theme="dark"] .mw-option:active:not(:disabled) { background: #134e4a; }
[data-bs-theme="dark"] .mw-float { text-shadow: none; }
[data-bs-theme="dark"] .mw-hearts { color: #f9a8d4; }
[data-bs-theme="dark"] .mw-perfect > strong, [data-bs-theme="dark"] .mw-perfect-tag { color: #5eead4; }
[data-bs-theme="dark"] .mw-penalty > strong, [data-bs-theme="dark"] .mw-trophy-stats .mw-penalty-stat { color: #fca5a5; }
[data-bs-theme="dark"] .mw-trophy-stats .mw-penalty-stat { border-color: #7f1d1d; }
[data-bs-theme="dark"] .mw-prompt-pinyin { color: #5eead4; }
[data-bs-theme="dark"] .mw-retry-tag, [data-bs-theme="dark"] .mw-hint { color: #c4b5fd; }
[data-bs-theme="dark"] .mw-dial.is-locked .mw-dial-value { background: #14532d; color: #bbf7d0; }

/* Last in the file: reduced motion turns every effect off, not just slower. */
@media (prefers-reduced-motion: reduce) {
    .mw-stage *, .mw-stage *::before, .mw-stage *::after, .mw-hud *, .mw-topbar * { animation: none !important; transition: none !important; }
    .mw-option:active:not(:disabled), .mw-pick-btn:active, .mw-tile:active, .mw-start-btn:active { transform: none; }
}

/* English text needs more room than the original character tiles. */
.mw-prompt-word { font-size: clamp(1.65rem, 6vw, 2.6rem); font-weight: 750; overflow-wrap: anywhere; color: var(--mw-ink); }
.mw-word-meaning { font-size: 1.1rem; font-weight: 600; }
.mw-item-hanzi, .mw-tile-hanzi { font-size: 1.05rem; overflow-wrap: anywhere; }
.mw-tile-gloss { font-size: .85rem; }
.mw-match { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 576px) { .mw-match { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mw-stage .mw-tile { min-height: 6.4rem; }
.mw-tile.is-matched .mw-tile-face { visibility: visible; }
.mw-tile.is-matched::after { content: none; }
.mw-study-entry { padding-block: .6rem; border-bottom: 1px solid var(--mw-line); }
.mw-study-entry dt { display: flex; align-items: center; gap: .5rem; }
.mw-study-entry dd { margin-bottom: .3rem; }
.mw-stage button, .mw-topbar button, .mw-quick-btn { min-height: 44px; }
.mw-start-btn { background: linear-gradient(135deg, #0f766e, #115e59); }
.mw-summary-score { font-size: clamp(2rem, 7vw, 3.5rem); font-weight: 800; color: var(--mw-ink); }
.mw-speaker { width: 44px; min-width: 44px; height: 44px; }
.mw-stage input[type="checkbox"] { width: 1.25rem; height: 1.25rem; flex-shrink: 0; accent-color: var(--mw-teal); }
.mw-option, .mw-item, .mw-map-label, .mw-chip { overflow-wrap: anywhere; }
.mw-empty { padding: 1.5rem .5rem; }
.mw-clear-body { width: 100%; }
.mw-overlay { position: relative; min-height: 350px; border-radius: .75rem; }
.mw-summary .mw-missed-list { max-height: none; }
.mw-summary .mw-missed-list li { padding-block: .6rem; }
#mwStudyWords { max-height: 32rem; overflow: auto; }
[data-bs-theme="dark"] .mw-speaker { color: #5eead4; }
[data-bs-theme="dark"] .mw-count { color: #5eead4; }
@media (prefers-reduced-motion: reduce) {
    .mw-stage *, .mw-stage *::before, .mw-stage *::after, .mw-hero *, .mw-topbar * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .mw-stage button:hover, .mw-stage button:active, .mw-topbar button:active { transform: none !important; }
}
