/* Matsuri, the match-3 (/matsuri): the level map, the board with its pieces and effects, and the result. */

.mt-art { position: absolute; width: 0; height: 0; overflow: hidden; }

.mt-page { --mt-gold: #f5b82e; --mt-night: #231c3d; --mt-night-2: #18132b; }

.mt-note { display: flex; align-items: center; gap: 8px; color: var(--ink-muted); font-size: 0.9rem; }

/* ---------- Map: three worlds along a winding path ---------- */

.mt-world {
    position: relative;
    margin: 0 0 16px;
    border-radius: 18px;
    overflow: hidden;
    color: #f4ecff;
    background: var(--mt-world-bg);
    box-shadow: 0 8px 24px rgba(20, 10, 40, .25);
}
.mt-world--grove { --mt-world-bg: radial-gradient(circle at 80% 0%, rgba(255, 150, 190, .35), transparent 45%), linear-gradient(180deg, #4a2448, #2a1a3e); }
.mt-world--harbour { --mt-world-bg: radial-gradient(circle at 15% 10%, rgba(255, 190, 90, .3), transparent 45%), linear-gradient(180deg, #1d3157, #141c33); }
.mt-world--shrine { --mt-world-bg: radial-gradient(circle at 80% 8%, rgba(255, 244, 204, .22), transparent 35%), linear-gradient(180deg, #1c1a3c, #0e0e22); }
.mt-world.is-locked { filter: saturate(.55) brightness(.8); }
.mt-world--mystery {
    --mt-world-bg: repeating-linear-gradient(135deg, rgba(255, 255, 255, .03) 0 12px, transparent 12px 24px), linear-gradient(180deg, #2a2440, #17142a);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 18px;
    text-align: center;
}
.mt-world--mystery h2 { margin: 0; font-size: 1.6rem; letter-spacing: .3em; color: #fff; }
.mt-world--mystery p { margin: 0; opacity: .8; }
.mt-mystery__lock { font-size: 2rem; color: var(--mt-gold); animation: mt-beat 3s ease-in-out infinite; }
.mt-mystery__ahead { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); }

.mt-world__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 18px 0; }
.mt-world__head h2 { margin: 0; font-size: 1.15rem; color: #fff; }
.mt-world__stars { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; opacity: .85; }
.mt-world__stars .icon { color: var(--mt-gold); }

.mt-world__path { position: relative; margin: 0 8px; }
.mt-world__line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.mt-line { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: 6; stroke-dasharray: 2 12; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mt-line--done { stroke: var(--mt-gold); stroke-dasharray: none; stroke-width: 5; filter: drop-shadow(0 0 4px rgba(255, 200, 90, .7)); }

.mt-decor { position: absolute; width: 58px; height: 58px; transform: translate(-50%, -50%); opacity: .4; pointer-events: none; animation: mt-idle-sway 6s ease-in-out infinite; }
.mt-world--shrine .mt-decor { opacity: .55; }

.mt-stop { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 3px; z-index: 1; }
.mt-stop__button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid #ffe2a8;
    background: radial-gradient(circle at 35% 30%, #ff9a7a, #d8323f 70%);
    color: #fff;
    font: inherit;
    font-weight: 700;
    font-size: 1.15rem;
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(255, 210, 120, .15), 0 6px 14px rgba(0, 0, 0, .35);
    transition: transform .15s ease;
}
.mt-stop__button:hover:not(:disabled) { transform: translateY(-2px) scale(1.06); }
.mt-stop.is-done .mt-stop__button { background: radial-gradient(circle at 35% 30%, #ffe08a, #e39a12 70%); color: #4a2a00; }
.mt-stop.is-current .mt-stop__button { animation: mt-glow 1.8s ease-in-out infinite; }
.mt-stop.is-locked .mt-stop__button { background: #3b3456; border-color: #5b5378; color: #a69cc6; cursor: default; box-shadow: none; }
.mt-stop__stars { display: flex; gap: 1px; font-size: var(--text-sm); color: rgba(255, 255, 255, .25); }
.mt-stop__stars .is-won { color: var(--mt-gold); }

@keyframes mt-glow {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 210, 120, .2), 0 6px 14px rgba(0, 0, 0, .35); }
    50% { box-shadow: 0 0 0 10px rgba(255, 210, 120, .35), 0 6px 18px rgba(255, 150, 80, .5); }
}

/* You stand above your level, the others beside theirs. */
.mt-me {
    position: absolute;
    bottom: calc(100% - 4px);
    left: 50%;
    transform: translateX(-50%);
    padding: 3px;
    border-radius: 50%;
    background: #fff6d6;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .4);
    animation: mt-hop 1.6s ease-in-out infinite;
    z-index: 2;
}
.mt-me::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fff6d6;
    border-bottom: 0;
}
.mt-me .avatar { display: block; }
@keyframes mt-hop { 50% { transform: translateX(-50%) translateY(-5px); } }
.mt-others { position: absolute; left: calc(100% + 4px); top: 8px; display: flex; flex-direction: column; gap: 2px; }
.mt-others--left { left: auto; right: calc(100% + 4px); }
.mt-others .avatar { box-shadow: 0 0 0 2px #fff, 0 3px 8px rgba(0, 0, 0, .4); border-radius: 50%; animation: mt-hop-side 2.2s ease-in-out infinite; }
@keyframes mt-hop-side { 50% { transform: translateY(-3px); } }

/* The household: how far everyone is, and a life to send. */
.mt-household, .mt-help, .mt-result__card, .mt-sheet__card { padding: 16px 18px; }
.mt-household { margin-bottom: 16px; }
.mt-household h2 { margin: 0 0 12px; font-size: 1.05rem; }
.mt-household ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mt-household li {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 8px 8px;
    border-radius: 14px;
    background: var(--surface-2);
}
.mt-household__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mt-household__who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-household__who span { color: var(--ink-muted); font-size: var(--text-sm); display: inline-flex; align-items: center; gap: 4px; }
.mt-household__who .icon { color: var(--mt-gold); }
.mt-household__race {
    font-size: 0.8rem;
    color: var(--ink-muted);
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    white-space: nowrap;
}
.mt-household .secondary-button { white-space: nowrap; }
.mt-household .secondary-button .icon { color: #e5484d; }
@media (max-width: 560px) {
    .mt-household li { grid-template-columns: auto 1fr; }
    .mt-household__race { justify-self: start; grid-column: 2; }
    .mt-household .secondary-button { grid-column: 1 / -1; justify-content: center; }
}

/* Lives. */
.mt-lives { display: inline-flex; align-items: center; gap: 2px; color: var(--ink-muted); }
.mt-lives .icon { width: 1.05em; height: 1.05em; color: var(--line); }
.mt-lives .icon.is-full { color: #e5484d; fill: #e5484d; animation: mt-beat 2.4s ease-in-out infinite; }
.mt-lives small { margin-left: 6px; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
@keyframes mt-beat { 0%, 70%, 100% { transform: scale(1); } 78% { transform: scale(1.18); } 86% { transform: scale(1); } 92% { transform: scale(1.1); } }
.mt-note--warn { color: var(--danger); font-weight: 600; }

/* The level card before playing. */
.mt-sheet {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    /* One column no wider than the screen: a long word inside can't push the card off it. */
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
    background: rgba(12, 8, 24, .55);
    backdrop-filter: blur(3px);
    animation: mt-flash-in .2s ease;
}
.mt-sheet__card { width: min(100%, 380px); min-width: 0; max-width: 100%; max-height: calc(100dvh - 32px); overflow-y: auto; justify-self: center; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; animation: mt-born calc(.3s * var(--mt-speed, 1)) cubic-bezier(.3, 1.4, .6, 1); }
.mt-sheet__card h2 { margin: 0; }
.mt-sheet__card h3 { margin: 4px 0 0; font-size: var(--text-md); align-self: flex-start; }
.mt-sheet__world { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.mt-sheet__stars { font-size: 2rem; }
.mt-sheet__goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; align-self: stretch; text-align: left; }
.mt-sheet__goals li { display: flex; align-items: center; gap: 8px; }
.mt-board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; align-self: stretch; }
.mt-board-list li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--radius-md); background: var(--surface-2); }
.mt-board-list li.is-me { box-shadow: inset 0 0 0 2px var(--accent); }
.mt-board-list li > span:nth-child(2) { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-board-list__stars { color: var(--mt-gold); font-size: 0.8rem; display: inline-flex; }
.mt-board-list strong { font-variant-numeric: tabular-nums; }

.mt-help summary { cursor: pointer; font-weight: 600; }
.mt-help[open] summary { margin-bottom: 4px; }
.mt-help ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; }
.mt-help__pieces { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.mt-help__pieces span { display: inline-flex; align-items: center; gap: 6px; }
.mt-help__pieces svg { width: 30px; height: 30px; }

/* ---------- Playing ---------- */

.mt-play { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 560px; margin: 0 auto; position: relative; }

.mt-hud { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.mt-hud__level { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--ink-muted); font-size: var(--text-sm); }
.mt-hud__score { color: var(--ink); font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mt-hud__moves {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 64px;
    padding: 6px 10px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--mt-night), var(--mt-night-2));
    color: #fff;
}
.mt-hud__moves strong { font-size: 1.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.mt-hud__moves span { font-size: 0.72rem; opacity: .75; }

.mt-meter { position: relative; height: 8px; margin: 6px 10px 6px 0; border-radius: 4px; background: var(--surface-2); }
.mt-meter__fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: linear-gradient(90deg, #ff7ab6, var(--mt-gold)); transition: width .4s ease; }
.mt-meter__star { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: var(--text-md); color: var(--ink-muted); line-height: 0; }
.mt-meter__star.is-won { color: var(--mt-gold); animation: mt-bump .4s ease; }

.mt-goals { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mt-goal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font-variant-numeric: tabular-nums;
}
.mt-goal.is-done { border-color: #3fb27f; color: #2e9b6a; }
.mt-goal__text { font-size: 0.8rem; color: var(--ink-muted); }
.mt-goals--small .mt-goal { padding: 2px 8px 2px 4px; }
.mt-goal-icon { width: 26px; height: 26px; flex: none; }
.mt-goal-icon--score { color: var(--mt-gold); width: 22px; height: 22px; }
.mt-goal-icon--frost {
    display: inline-block;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(225, 245, 255, .95), rgba(140, 200, 240, .9));
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8), 0 0 0 1px #7fb5d9;
    width: 22px;
    height: 22px;
}
@media (max-width: 520px) {
    .mt-goal__text { display: none; }
}

.mt-actions { display: flex; justify-content: center; }

/* ---------- The board ---------- */

.mt-board {
    position: relative;
    width: 100%;
    aspect-ratio: var(--w) / var(--h);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 20% 0%, rgba(255, 170, 80, .22), transparent 45%),
        radial-gradient(circle at 80% 100%, rgba(255, 110, 170, .18), transparent 45%),
        linear-gradient(180deg, var(--mt-night), var(--mt-night-2));
    box-shadow: 0 10px 30px rgba(20, 10, 40, .35);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.mt-cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--w), 1fr); grid-template-rows: repeat(var(--h), 1fr); }
.mt-cell { position: relative; background: rgba(255, 255, 255, .07); margin: 1px; border-radius: var(--radius-sm); }
.mt-cell--even { background: rgba(255, 255, 255, .11); }
.mt-cell--none { background: none; }
.mt-cell--frost { background: linear-gradient(135deg, rgba(220, 244, 255, .55), rgba(120, 190, 235, .45)); box-shadow: inset 0 0 0 2px rgba(220, 245, 255, .55); }
.mt-cell--frost2 { background: linear-gradient(135deg, rgba(235, 250, 255, .85), rgba(140, 205, 245, .7)); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .85); }
.mt-cell--frost::after {
    content: "";
    position: absolute;
    inset: 18% 55% 55% 18%;
    border-radius: 50%;
    background: rgba(255, 255, 255, .7);
    filter: blur(1px);
}
.mt-stone { position: absolute; inset: 4%; width: 92%; height: 92%; animation: mt-born calc(.3s * var(--mt-speed, 1)) ease; }

.mt-piece {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(100% / var(--w));
    height: calc(100% / var(--h));
    transition: transform calc(.3s * var(--mt-speed, 1)) cubic-bezier(.45, .05, .55, .95);
    cursor: pointer;
    z-index: 1;
}
.is-busy .mt-piece { cursor: default; }
.mt-piece__body {
    position: absolute;
    inset: 7%;
    /* A soft shadow under each piece, painted once (a filter per piece is slow on phones). */
    background: radial-gradient(ellipse 36% 9% at 50% 96%, rgba(0, 0, 0, .32), transparent 72%);
}
.mt-piece__body > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.mt-piece--drop .mt-piece__body {
    animation: mt-drop var(--fall, .4s) cubic-bezier(.3, .05, .7, .95) both, mt-land0 calc(.36s * var(--mt-speed, 1)) ease-out var(--fall, .4s);
}
.mt-piece--pop { z-index: 2; pointer-events: none; }
.mt-piece--pop .mt-piece__body { animation: mt-pop calc(.34s * var(--mt-speed, 1)) ease-in var(--pop-delay, 0s) forwards; }
.mt-piece--born .mt-piece__body { animation: mt-born calc(.5s * var(--mt-speed, 1)) cubic-bezier(.3, 1.6, .6, 1); }
.mt-piece.is-selected .mt-piece__body { animation: mt-pulse .8s ease-in-out infinite; }
.mt-piece.is-selected::before {
    content: "";
    position: absolute;
    inset: 3%;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 3px #fff6d6, 0 0 14px rgba(255, 230, 150, .8);
}
.mt-piece.is-hint .mt-piece__body { animation: mt-wiggle 1.2s ease-in-out infinite; }

@keyframes mt-drop { from { transform: translateY(calc(var(--drop, 1) * -114%)); } }
@keyframes mt-pop {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.3); opacity: 1; filter: brightness(2) saturate(.6); }
    100% { transform: scale(.1) rotate(25deg); opacity: 0; filter: brightness(2.4); }
}
@keyframes mt-born { from { transform: scale(0) rotate(-120deg); filter: brightness(3); } 60% { filter: brightness(1.6); } }
@keyframes mt-pulse { 50% { transform: scale(1.1); } }
@keyframes mt-wiggle {
    0%, 60%, 100% { transform: rotate(0); }
    70% { transform: rotate(-12deg) scale(1.08); }
    85% { transform: rotate(12deg) scale(1.08); }
}
@keyframes mt-bump { 50% { transform: translate(-50%, -50%) scale(1.5); } }

/* Specials: stripes for lines, sparks for fireworks, an aura for the kitsune. */
.mt-stripes, .mt-spark { position: absolute; inset: -6%; width: 112%; height: 112%; overflow: visible; pointer-events: none; }
.mt-stripes path { stroke: #fff; stroke-width: 6; fill: none; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3px #ffe58a) drop-shadow(0 0 1px #000); opacity: .92; }
.mt-stripes .mt-stripes__tip { stroke-width: 5; }
.mt-piece--column .mt-stripes { transform: rotate(90deg); }
.mt-piece--row .mt-piece__body, .mt-piece--column .mt-piece__body { animation: mt-shine 1.6s ease-in-out infinite; }
.mt-spark circle { fill: none; stroke: #ffe58a; stroke-width: 5; stroke-dasharray: 10 8; }
.mt-spark path { stroke: #fff2b8; stroke-width: 5; stroke-linecap: round; }
.mt-spark { animation: mt-spin 4s linear infinite; filter: drop-shadow(0 0 4px #ffb347); }
.mt-piece--kitsune .mt-piece__body > svg { animation: mt-float 2.4s ease-in-out infinite; filter: drop-shadow(0 0 6px #ffd36e); }
.mt-piece--drop.mt-piece--kitsune .mt-piece__body > svg, .mt-piece--pop .mt-piece__body > svg { animation: none; }

@keyframes mt-shine { 50% { filter: brightness(1.25); } }
@keyframes mt-spin { to { transform: rotate(360deg); } }
@keyframes mt-float { 50% { transform: translateY(-5%) rotate(4deg); } }

/* ---------- Effects ---------- */

.mt-fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.mt-blast { position: absolute; display: block; }
.mt-blast--row, .mt-blast--column {
    background: linear-gradient(90deg, transparent, #fff8d6 15%, #fff 50%, #fff8d6 85%, transparent);
    box-shadow: 0 0 18px 6px rgba(255, 220, 120, .7);
    border-radius: var(--radius-pill);
}
.mt-blast--row { left: 0; right: 0; height: calc(100% / var(--h) * .36); transform: translateY(-50%); animation: mt-beam-row calc(.5s * var(--mt-speed, 1)) ease-out forwards; }
.mt-blast--column {
    top: 0;
    bottom: 0;
    width: calc(100% / var(--w) * .36);
    transform: translateX(-50%);
    background: linear-gradient(180deg, transparent, #fff8d6 15%, #fff 50%, #fff8d6 85%, transparent);
    animation: mt-beam-column calc(.5s * var(--mt-speed, 1)) ease-out forwards;
}
.mt-blast--firework {
    width: calc(100% / var(--w) * var(--size));
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(.2);
    background: radial-gradient(circle, #fff 0 12%, rgba(255, 220, 120, .9) 22%, rgba(255, 120, 170, .55) 45%, transparent 68%);
    animation: mt-burst calc(.58s * var(--mt-speed, 1)) ease-out forwards;
}
.mt-blast--kitsune {
    inset: 0;
    background: radial-gradient(circle, rgba(255, 245, 210, .85), rgba(255, 170, 90, .35) 50%, transparent 75%);
    animation: mt-flash calc(.62s * var(--mt-speed, 1)) ease-out forwards;
}
/* The paper crane: a badge on its piece, and its flight to where it lands (a little arc, then a puff of petals). */
.mt-piece__body > .mt-crane-badge {
    inset: auto -10% -8% auto;
    width: 62%;
    height: 62%;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
    animation: mt-crane-bob 1.6s ease-in-out infinite;
}
.mt-flight {
    position: absolute;
    width: calc(100% / var(--w));
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    animation: mt-flight calc(.48s * var(--mt-speed, 1)) cubic-bezier(.45, .05, .55, .95) both;
}
.mt-flight__bird { position: absolute; inset: 0; animation: mt-flight-arc calc(.48s * var(--mt-speed, 1)) ease-in-out both, mt-fade calc(.18s * var(--mt-speed, 1)) ease-in calc(.46s * var(--mt-speed, 1)) forwards; }
.mt-flight__bird svg { width: 100%; height: 100%; transform: scaleX(var(--face, 1)); filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .4)); }
.mt-flight__burst {
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0 14%, rgba(255, 190, 220, .85) 30%, rgba(255, 143, 191, .4) 50%, transparent 70%);
    opacity: 0;
    transform: scale(.2);
    animation: mt-flight-burst calc(.4s * var(--mt-speed, 1)) ease-out calc(.42s * var(--mt-speed, 1)) forwards;
}
@keyframes mt-flight { from { left: var(--x0); top: var(--y0); } to { left: var(--x1); top: var(--y1); } }
@keyframes mt-flight-arc { from { transform: scale(.8); } 50% { transform: translateY(-55%) scale(1.35) rotate(-8deg); } to { transform: scale(.9); } }
@keyframes mt-flight-burst { 0% { opacity: 1; transform: scale(.2); } to { opacity: 0; transform: scale(1.2); } }
@keyframes mt-fade { to { opacity: 0; } }
@keyframes mt-crane-bob { 50% { transform: translateY(-6%) rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) {
    .mt-piece__body > .mt-crane-badge { animation: none; }
}

@keyframes mt-beam-row { from { transform: translateY(-50%) scaleX(.1); opacity: 1; } 60% { opacity: 1; } to { transform: translateY(-50%) scaleX(1); opacity: 0; } }
@keyframes mt-beam-column { from { transform: translateX(-50%) scaleY(.1); opacity: 1; } 60% { opacity: 1; } to { transform: translateX(-50%) scaleY(1); opacity: 0; } }
@keyframes mt-burst { 60% { opacity: 1; } to { transform: translate(-50%, -50%) scale(1.1); opacity: 0; } }
@keyframes mt-flash { from { opacity: 0; } 30% { opacity: 1; } to { opacity: 0; } }

.mt-points {
    position: absolute;
    transform: translate(-50%, -50%);
    font-weight: 800;
    font-size: clamp(0.9rem, 3.6vw, 1.2rem);
    color: #fff;
    text-shadow: 0 2px 0 #b8325c, 0 0 8px rgba(0, 0, 0, .5);
    animation: mt-rise calc(1.2s * var(--mt-speed, 1)) ease-out forwards;
    white-space: nowrap;
}
.mt-cheer {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display, inherit);
    font-weight: 800;
    font-size: clamp(1.8rem, 9vw, 3rem);
    color: #fff3c4;
    text-shadow: 0 3px 0 #d8323f, 0 0 18px rgba(255, 150, 80, .8);
    animation: mt-cheer calc(1.8s * var(--mt-speed, 1)) cubic-bezier(.3, 1.6, .6, 1) forwards;
    white-space: nowrap;
}
.mt-cheer--small { font-size: clamp(1rem, 5vw, 1.5rem); }
@keyframes mt-rise { from { opacity: 1; } to { transform: translate(-50%, -160%); opacity: 0; } }
@keyframes mt-cheer {
    from { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
    15% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    25% { transform: translate(-50%, -50%) scale(1); }
    80% { transform: translate(-50%, -56%) scale(1); opacity: 1; }
    to { transform: translate(-50%, -70%) scale(1); opacity: 0; }
}

/* ---------- Result ---------- */

.mt-result {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(20, 12, 36, .45);
    backdrop-filter: blur(2px);
    border-radius: var(--radius-lg);
    animation: mt-flash-in .3s ease;
}
.mt-result__card { width: min(100%, 360px); text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.mt-result__card { gap: 12px; padding: 22px 20px 18px; }
.mt-result__card h2 { margin: 0; }
.mt-result__card p { margin: 0; }
.mt-result__card .mt-goals { flex-direction: column; align-items: center; }
.mt-result__card .mt-goal { padding: 4px 12px 4px 6px; }
.mt-result__actions { margin-top: 4px; }
.mt-result__stars { display: flex; gap: 6px; font-size: 2.6rem; color: var(--surface-2); }
.mt-result__stars .is-won { color: var(--mt-gold); animation: mt-born calc(.5s * var(--mt-speed, 1)) cubic-bezier(.3, 1.6, .6, 1) both; }
.mt-result__stars .is-won:nth-child(2) { animation-delay: .2s; }
.mt-result__stars .is-won:nth-child(3) { animation-delay: .4s; }
.mt-result__score { margin: 0; color: var(--ink-muted); }
.mt-result__score strong { color: var(--ink); font-size: 1.3rem; margin-left: 6px; }
.mt-result__note { margin: 0; font-size: 0.88rem; color: var(--ink-muted); }
.mt-result__note.is-best { color: var(--accent); font-weight: 600; }
.mt-result__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
@keyframes mt-flash-in { from { opacity: 0; } }

/* ---------- Intro: a quick card when a level starts ---------- */

.mt-intro {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(20, 12, 36, .35);
    border-radius: var(--radius-lg);
    cursor: pointer;
    animation: mt-flash-in .2s ease;
    transition: opacity .25s ease;
}
.mt-intro.is-leaving { opacity: 0; }
.mt-intro__card {
    width: min(100%, 340px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
    text-align: center;
    animation: mt-intro-in .35s cubic-bezier(.3, 1.4, .6, 1) both;
}
.mt-intro.is-leaving .mt-intro__card { transform: scale(.96); transition: transform .25s ease; }
.mt-intro__card h2 { margin: 0; }
.mt-intro__goals, .mt-intro__rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mt-intro__goals li { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; }
.mt-intro__rules { gap: 4px; padding-top: 8px; border-top: 1px solid var(--surface-2); width: 100%; }
.mt-intro__rules li { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: var(--text-sm); color: var(--ink-muted); }
.mt-intro__rules .icon { flex: none; color: var(--accent); }
.mt-intro__tap { font-size: var(--text-xs); color: var(--ink-muted); opacity: .8; }
@keyframes mt-intro-in { from { opacity: 0; transform: translateY(10px) scale(.92); } }
@media (prefers-reduced-motion: reduce) {
    .mt-intro, .mt-intro__card { animation: none; }
}

/* ---------- Motion: landing, swapping, idling, bits, rings, shaking ---------- */

/* Falling speeds up like gravity; where it lands it squashes and springs back. */
.mt-piece--land0, .mt-piece--land1 { transition-timing-function: cubic-bezier(.3, .05, .7, .95); }
.mt-piece--land0 .mt-piece__body { animation: mt-land0 calc(.36s * var(--mt-speed, 1)) ease-out var(--fall, .3s); }
.mt-piece--land1 .mt-piece__body { animation: mt-land1 calc(.36s * var(--mt-speed, 1)) ease-out var(--fall, .3s); }
@keyframes mt-land0 {
    0% { transform: translateY(0) scale(1, 1); }
    30% { transform: translateY(6%) scale(1.14, .8); }
    65% { transform: translateY(-5%) scale(.95, 1.06); }
    100% { transform: translateY(0) scale(1, 1); }
}
@keyframes mt-land1 {
    0% { transform: translateY(0) scale(1, 1); }
    30% { transform: translateY(6%) scale(1.14, .8); }
    65% { transform: translateY(-5%) scale(.95, 1.06); }
    100% { transform: translateY(0) scale(1, 1); }
}
.mt-piece__body { transform-origin: 50% 85%; }

/* A swap lifts both pieces as they cross; one that doesn't work shakes its head. */
.mt-piece--swap { z-index: 3; }
.mt-piece--swap { transition-duration: calc(.36s * var(--mt-speed, 1)); }
.mt-piece--swap .mt-piece__body { animation: mt-swap calc(.36s * var(--mt-speed, 1)) ease-in-out; }
.mt-piece--nope { z-index: 3; transition-duration: calc(.34s * var(--mt-speed, 1)); transition-delay: calc(.1s * var(--mt-speed, 1)); }
.mt-piece--nope .mt-piece__body { animation: mt-nope calc(.52s * var(--mt-speed, 1)) ease-in-out; }
@keyframes mt-swap { 50% { transform: scale(1.18); filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35)); } }
@keyframes mt-nope {
    20% { transform: translateX(-9%) rotate(-8deg); }
    45% { transform: translateX(8%) rotate(7deg); }
    70% { transform: translateX(-4%) rotate(-3deg); }
}

/* Each kind has its own little life while it waits. */
.mt-piece__art { transform-box: fill-box; }
.mt-piece--k0 .mt-piece__art { animation: mt-idle-spin 5s ease-in-out var(--idle, 0s) infinite; }
.mt-piece--k1 .mt-piece__art { animation: mt-idle-bob 3.4s ease-in-out var(--idle, 0s) infinite; }
.mt-piece--k2 .mt-piece__art { animation: mt-idle-wobble 4.2s ease-in-out var(--idle, 0s) infinite; transform-origin: 50% 95%; }
.mt-piece--k3 .mt-piece__art { animation: mt-idle-sway 3.2s ease-in-out var(--idle, 0s) infinite; transform-origin: 50% 5%; }
.mt-piece--k4 .mt-piece__art { animation: mt-idle-sway 3.8s ease-in-out var(--idle, 0s) infinite; transform-origin: 50% 8%; }
.mt-piece--k5 .mt-piece__art { animation: mt-idle-flicker 2.4s ease-in-out var(--idle, 0s) infinite; transform-origin: 50% 95%; }
@keyframes mt-idle-spin { 50% { transform: rotate(10deg); } }
@keyframes mt-idle-bob { 50% { transform: translateY(-4%); } }
@keyframes mt-idle-wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-7deg); } 86% { transform: rotate(6deg); } 93% { transform: rotate(-3deg); } }
@keyframes mt-idle-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes mt-idle-flicker {
    0%, 100% { transform: scale(1, 1); filter: drop-shadow(0 0 2px #c69bff); }
    40% { transform: scale(.96, 1.07) translateY(-2%); filter: drop-shadow(0 0 7px #c69bff); }
    70% { transform: scale(1.03, .97); }
}
.mt-piece--pop .mt-piece__art, .mt-piece--drop .mt-piece__art { animation: none; }

/* Cleared pieces burst into bits in their own colour. */
.mt-bit {
    position: absolute;
    width: calc(100% / var(--w) * .2);
    aspect-ratio: 1;
    border-radius: 70% 0 70% 0;
    background: var(--c, #fff);
    box-shadow: 0 0 6px var(--c, #fff);
    transform: translate(-50%, -50%) rotate(var(--a)) translateY(0) scale(1);
    animation: mt-bit calc(.78s * var(--mt-speed, 1)) cubic-bezier(.2, .7, .4, 1) forwards;
}
.mt-bit--k0 { --c: #ff9cc6; }
.mt-bit--k1 { --c: #ffffff; border-radius: 50%; }
.mt-bit--k2 { --c: #ff5b4f; border-radius: 50%; }
.mt-bit--k3 { --c: #ffd84d; }
.mt-bit--k4 { --c: #6f9bff; border-radius: 2px; }
.mt-bit--k5 { --c: #c08bff; border-radius: 50% 50% 50% 0; }
.mt-bit--kfox { --c: #ffd36e; }
@keyframes mt-bit {
    70% { opacity: 1; }
    to { transform: translate(-50%, -50%) rotate(calc(var(--a) + 160deg)) translateY(calc(var(--d) * -5%)) scale(.3); opacity: 0; }
}

/* A new special arrives with a ring of light. */
.mt-ring {
    position: absolute;
    width: calc(100% / var(--w) * 1.1);
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid #ffe7a0;
    box-shadow: 0 0 14px #ffc24d, inset 0 0 10px #ffc24d;
    transform: translate(-50%, -50%) scale(.2);
    animation: mt-ring calc(.68s * var(--mt-speed, 1)) ease-out forwards;
}
@keyframes mt-ring { 60% { opacity: 1; } to { transform: translate(-50%, -50%) scale(1.7); opacity: 0; } }

/* The firework's sparks fly out. */
.mt-blast__spark {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5%;
    height: 22%;
    border-radius: var(--radius-pill);
    background: linear-gradient(#fff, #ffcf5a 60%, transparent);
    transform: translate(-50%, -100%) rotate(var(--a)) translateY(0);
    transform-origin: 50% 100%;
    animation: mt-spark calc(.62s * var(--mt-speed, 1)) ease-out forwards;
}
@keyframes mt-spark { to { transform: translate(-50%, -100%) rotate(var(--a)) translateY(-130%); opacity: 0; } }

/* Big blasts shake the board. */
.mt-board--shake0 { animation: mt-shake0 calc(.45s * var(--mt-speed, 1)) ease-out; }
.mt-board--shake1 { animation: mt-shake1 calc(.45s * var(--mt-speed, 1)) ease-out; }
@keyframes mt-shake0 { 15% { transform: translate(-4px, 2px); } 35% { transform: translate(4px, -3px); } 55% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, -1px); } }
@keyframes mt-shake1 { 15% { transform: translate(-4px, 2px); } 35% { transform: translate(4px, -3px); } 55% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, -1px); } }

/* Festival lights drift behind the board. */
.mt-board::before {
    content: "";
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 190, 90, .22) 0 6%, transparent 14%),
        radial-gradient(circle at 75% 20%, rgba(255, 120, 170, .18) 0 5%, transparent 12%),
        radial-gradient(circle at 60% 75%, rgba(160, 120, 255, .18) 0 7%, transparent 15%),
        radial-gradient(circle at 30% 85%, rgba(255, 210, 120, .16) 0 4%, transparent 10%);
    animation: mt-lights 18s ease-in-out infinite alternate;
    pointer-events: none;
}
@keyframes mt-lights { to { transform: translate(6%, -5%) rotate(8deg); } }

/* Live numbers bump when they change. */
.mt-bump { display: inline-block; animation: mt-number .35s cubic-bezier(.3, 1.6, .6, 1); }
@keyframes mt-number { from { transform: scale(1.35); color: var(--mt-gold); } }

/* Won: petals rain over the result. */
.mt-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: var(--radius-lg); }
.mt-confetti i {
    position: absolute;
    top: -8%;
    left: var(--x);
    width: 12px;
    height: 12px;
    border-radius: 70% 0 70% 0;
    background: var(--c);
    animation: mt-petal var(--t) linear var(--delay) infinite;
    opacity: .9;
}
@keyframes mt-petal {
    0% { transform: translate(0, 0) rotate(0); }
    50% { transform: translate(30px, 55vh) rotate(260deg); }
    100% { transform: translate(-10px, 110vh) rotate(520deg); }
}

@media (prefers-reduced-motion: reduce) {
    .mt-piece__art, .mt-board::before, .mt-confetti, .mt-board--shake0, .mt-board--shake1, .mt-bit { animation: none !important; }
    .mt-bit, .mt-confetti { display: none; }
    .mt-piece { transition-duration: .05s; }
    .mt-spark, .mt-piece--kitsune .mt-piece__body > svg, .mt-stop.is-current .mt-stop__button, .mt-piece.is-hint .mt-piece__body,
    .mt-piece--row .mt-piece__body, .mt-piece--column .mt-piece__body { animation: none; }
}

/* ---------- Boosters: the tool bar under the board, the shop, taking one into a level ---------- */

.mt-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mt-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.mt-tool:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.mt-tool:disabled { opacity: .45; cursor: default; }
.mt-tool.is-active { border-color: var(--mt-gold); box-shadow: 0 0 0 3px rgba(245, 184, 46, .35); }
.mt-tool__count {
    min-width: 1.4em;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--on-accent, #fff);
    font-size: 0.8rem;
    text-align: center;
}
.mt-tool__price { display: inline-flex; align-items: center; gap: 3px; font-size: 0.8rem; color: var(--ink-muted); font-weight: 600; }
.mt-tool--quiet { background: none; }
.mt-aim-note { justify-content: center; color: var(--mt-gold); font-weight: 600; }
.mt-board.is-aiming .mt-piece, .mt-board.is-aiming .mt-cell { cursor: crosshair; }
.mt-board.is-aiming .mt-piece__body { animation: mt-aim 1s ease-in-out infinite; }
.mt-board.is-aiming .mt-stone { animation: mt-aim 1s ease-in-out infinite; }
@keyframes mt-aim { 50% { transform: scale(.92); filter: brightness(1.2); } }

.mt-result__more { flex-direction: column; gap: 2px; align-self: stretch; }
.mt-result__more small { font-weight: 400; opacity: .85; }

.mt-sheet__boost {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: stretch;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}
.mt-sheet__boost-text .mt-sheet__boost-count { font-weight: 600; }
.mt-sheet__boost-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.mt-sheet__boost-text small { font-size: var(--text-xs); color: var(--ink-muted); font-weight: 400; }
.mt-sheet__boost .icon { color: var(--mt-gold); }
.mt-sheet__boost.is-empty { opacity: .6; cursor: default; }

.mt-shop { padding: 16px 18px; margin-bottom: 16px; }
.mt-shop__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mt-shop__head h2 { margin: 0; font-size: 1.05rem; }
.mt-shop__coins { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--mt-gold); }
.mt-shop__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mt-shop__list li {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 14px;
    background: var(--surface-2);
}
.mt-shop__icon { font-size: var(--text-xl); color: var(--mt-gold); }
.mt-shop__what { display: flex; flex-direction: column; min-width: 0; }
.mt-shop__what span { font-size: 0.82rem; color: var(--ink-muted); }
.mt-shop__have { font-size: 0.8rem; color: var(--ink-muted); white-space: nowrap; }
.mt-shop .secondary-button { white-space: nowrap; }
@media (max-width: 560px) {
    .mt-shop__list li { grid-template-columns: auto 1fr; }
    .mt-shop__have { grid-column: 2; }
    .mt-shop .secondary-button { grid-column: 1 / -1; justify-content: center; }
}

/* ---------- The challenge of the day ---------- */

.mt-daily {
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: 18px;
    color: #fff7ea;
    background: linear-gradient(135deg, #b8324a, #e2703a 55%, #f5b82e);
    box-shadow: 0 10px 26px rgba(184, 50, 74, .35);
}
.mt-daily__glow {
    position: absolute;
    inset: -40% -20% auto auto;
    width: 60%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .35), transparent 65%);
    animation: mt-lights 9s ease-in-out infinite alternate;
    pointer-events: none;
}
.mt-daily__head { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mt-daily__label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: .02em; }
.mt-daily__streak {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, .22);
    font-weight: 800;
}
.mt-daily__streak .icon { color: #ffe08a; animation: mt-beat 2s ease-in-out infinite; }
.mt-daily__body { position: relative; display: grid; gap: 8px; margin: 10px 0 12px; }
.mt-daily__goals { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.mt-daily__goals li {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 4px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .2);
    font-weight: 700;
}
.mt-daily__goals .mt-goal-icon { width: 24px; height: 24px; }
.mt-daily__goals .mt-daily__moves { padding-left: 10px; font-weight: 600; }
.mt-daily__status, .mt-daily__reward { margin: 0; display: flex; align-items: center; gap: 6px; }
.mt-daily__reward { font-size: 0.9rem; opacity: .9; }
.mt-daily__ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mt-daily__ranking li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--radius-md); background: rgba(0, 0, 0, .16); }
.mt-daily__ranking li.is-me { background: rgba(255, 255, 255, .22); }
.mt-daily__ranking li > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-daily__won { color: #c7ffd8; }
.mt-daily__foot { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-daily__foot .primary-button { background: #fff7ea; color: #b8324a; border-color: transparent; }
.mt-daily__foot small { opacity: .85; font-variant-numeric: tabular-nums; }

/* ---------- The wheel of the day ---------- */

.mt-wheel { display: flex; align-items: center; gap: var(--space-5); padding: 16px 18px; margin-bottom: 16px; }
.mt-wheel__stage { position: relative; flex: none; width: 168px; aspect-ratio: 1; }
.mt-wheel__disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 5px solid #fff7ea;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28), inset 0 0 0 2px rgba(0, 0, 0, .08);
    will-change: transform;
}
/* Thin lines between the slices, and each slice's prize near the rim. */
.mt-wheel__slice { position: absolute; inset: 0; transform: rotate(calc((var(--i) + .5) * 45deg)); }
.mt-wheel__slice::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 50%;
    background: rgba(255, 255, 255, .7);
    transform: translateX(-50%) rotate(-22.5deg);
    transform-origin: bottom center;
}
.mt-wheel__prize {
    position: absolute;
    left: 50%;
    top: 9%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #3a1f3d;
    line-height: 1;
}
.mt-wheel__prize .icon { width: 22px; height: 22px; }
.mt-wheel__prize b { font-size: var(--text-xs); margin-top: 1px; }
.mt-wheel.is-won .mt-wheel__slice.is-picked .mt-wheel__prize { animation: mt-pulse .9s ease-in-out 3; }
.mt-wheel__pointer {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: -8px;
    width: 22px;
    height: 26px;
    transform: translateX(-50%);
    background: #b8324a;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
}
.mt-wheel__hub {
    position: absolute;
    z-index: 1;
    left: 50%;
    top: 50%;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #fff7ea;
    color: #b8324a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.mt-wheel__text { flex: 1; min-width: 0; display: grid; gap: var(--space-2); justify-items: start; }
.mt-wheel__text h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.mt-wheel__text p { margin: 0; }
.mt-wheel__prize-note { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.mt-wheel.is-won .mt-wheel__prize-note { animation: mt-born .5s cubic-bezier(.3, 1.6, .6, 1); }
@media (max-width: 480px) {
    .mt-wheel { flex-direction: column; text-align: center; }
    .mt-wheel__text { justify-items: center; }
    .mt-wheel__stage { width: min(220px, 70vw); }
}
@media (prefers-reduced-motion: reduce) {
    .mt-wheel.is-won .mt-wheel__slice.is-picked .mt-wheel__prize, .mt-wheel.is-won .mt-wheel__prize-note { animation: none; }
}

/* ---------- The household's goal of the week ---------- */

.mt-week { padding: 16px 18px; margin-bottom: 16px; display: grid; gap: 10px; }
.mt-week__head { display: flex; align-items: center; gap: 12px; }
.mt-week__head h2 { margin: 0; font-size: 1.05rem; }
.mt-week__head p { margin: 2px 0 0; color: var(--ink-muted); font-size: 0.9rem; }
.mt-week__head > div { flex: 1; min-width: 0; }
.mt-week__piece { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3)); animation: mt-idle-bob 3s ease-in-out infinite; }
.mt-week__left { font-size: 0.8rem; color: var(--ink-muted); white-space: nowrap; }
.mt-week__bar { display: flex; height: 14px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-2); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .15); }
.mt-week__bar span { height: 100%; transition: width .6s ease; }
.mt-week__bar span + span { box-shadow: inset 2px 0 0 rgba(255, 255, 255, .5); }
.mt-week.is-reached .mt-week__bar { box-shadow: 0 0 0 2px var(--mt-gold), 0 0 12px rgba(245, 184, 46, .5); }
.mt-week__parts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.88rem; }
.mt-week__parts li { display: inline-flex; align-items: center; gap: 6px; }
.mt-week__total { margin-left: auto; color: var(--ink-muted); }
.mt-week__claim { justify-self: start; animation: mt-glow 1.8s ease-in-out infinite; }

/* ---------- Chains, boulders, the later worlds ---------- */

.mt-chain {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(100% / var(--w));
    height: calc(100% / var(--h));
    z-index: 2;
    pointer-events: none;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45));
    animation: mt-born calc(.35s * var(--mt-speed, 1)) ease;
}
.mt-stone--boulder { filter: brightness(.82) contrast(1.15) drop-shadow(0 0 3px rgba(150, 200, 255, .6)); transform: scale(1.04); }

.mt-world--bamboo { --mt-world-bg: radial-gradient(circle at 20% 5%, rgba(170, 230, 140, .25), transparent 45%), linear-gradient(180deg, #1f3d2c, #12241a); }
.mt-world--snow { --mt-world-bg: radial-gradient(circle at 75% 0%, rgba(220, 240, 255, .3), transparent 45%), linear-gradient(180deg, #3a4f72, #1b2740); }
.mt-world--dragon { --mt-world-bg: radial-gradient(circle at 50% 0%, rgba(255, 120, 60, .35), transparent 50%), linear-gradient(180deg, #4a1620, #1f0b14); }
.mt-world--snow::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 255, 255, .7) 0 1.5px, transparent 2px), radial-gradient(circle, rgba(255, 255, 255, .5) 0 1px, transparent 1.5px);
    background-size: 90px 90px, 60px 60px;
    background-position: 10px 0, 40px 30px;
    animation: mt-snowfall 14s linear infinite;
}
@keyframes mt-snowfall { to { background-position: 10px 900px, 40px 630px; } }
@media (prefers-reduced-motion: reduce) { .mt-world--snow::after { animation: none; } }

/* ---------- Kiko, the festival's fox ---------- */

.mt-kiko { display: flex; align-items: flex-end; gap: 6px; animation: mt-kiko-in .45s cubic-bezier(.3, 1.4, .6, 1); }
.mt-kiko--floating {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 40;
    width: min(420px, calc(100vw - 32px));
}
.mt-kiko__face { width: 76px; height: 76px; flex: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); animation: mt-kiko-bob 2.6s ease-in-out infinite; }
.mt-kiko__bubble {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 16px 16px 16px 4px;
    background: #fff8ec;
    color: #3b2414;
    box-shadow: 0 8px 22px rgba(30, 15, 5, .25);
}
.mt-kiko__bubble strong { color: #d0602a; font-size: var(--text-sm); }
.mt-kiko__bubble p { margin: 0; line-height: 1.4; }
.mt-kiko__bubble .secondary-button { align-self: flex-end; background: #fff; color: #3b2414; border-color: #f0c9a0; }
@keyframes mt-kiko-in { from { transform: translateY(20px) scale(.9); opacity: 0; } }
@keyframes mt-kiko-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(3deg); } }

.mt-scene {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(12, 8, 24, .6);
    backdrop-filter: blur(4px);
    animation: mt-flash-in .25s ease;
}
.mt-scene__card {
    position: relative;
    overflow: hidden;
    width: min(100%, 400px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 22px 20px;
    border-radius: 22px;
    text-align: center;
    color: #fff7ea;
    background: var(--mt-scene-bg, linear-gradient(180deg, #4a2448, #2a1a3e));
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
    animation: mt-born calc(.45s * var(--mt-speed, 1)) cubic-bezier(.3, 1.4, .6, 1);
}
.mt-scene--grove { --mt-scene-bg: linear-gradient(180deg, #6a2d5e, #2a1a3e); }
.mt-scene--harbour { --mt-scene-bg: linear-gradient(180deg, #24406e, #141c33); }
.mt-scene--shrine { --mt-scene-bg: linear-gradient(180deg, #2c2958, #0e0e22); }
.mt-scene--bamboo { --mt-scene-bg: linear-gradient(180deg, #2d5a3d, #12241a); }
.mt-scene--snow { --mt-scene-bg: linear-gradient(180deg, #4d6a95, #1b2740); }
.mt-scene--dragon { --mt-scene-bg: linear-gradient(180deg, #7a2430, #1f0b14); }
.mt-scene__kiko { width: 130px; height: 130px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .4)); animation: mt-kiko-hop 1.4s ease-in-out infinite; }
@keyframes mt-kiko-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px) rotate(-4deg); } 60% { transform: translateY(0) scale(1.04, .96); } }
.mt-scene__kicker { font-size: 0.78rem; letter-spacing: .14em; text-transform: uppercase; color: #f5b82e; }
.mt-scene__card h2 { margin: 0; font-size: 1.5rem; }
.mt-scene__card p { margin: 0; line-height: 1.45; opacity: .92; }
.mt-scene__reward { list-style: none; margin: 4px 0; padding: 0; display: flex; gap: 8px; }
.mt-scene__reward li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--radius-pill); background: rgba(255, 255, 255, .16); font-weight: 600; }
.mt-scene__reward .icon { color: #f5b82e; }
.mt-scene .primary-button { margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .mt-kiko__face, .mt-scene__kiko { animation: none; } }

/* Sound and vibration switches in the playing header. */
.mt-hud__toggles { display: flex; flex-direction: column; gap: 2px; }
.mt-hud__toggles .icon-button { width: 32px; height: 32px; }
.mt-hud__toggles .icon-button.is-off { opacity: .45; }

/* Matsuri in the statistics. */
.mt-stats { margin-top: 16px; }
.mt-stats__part h3 { margin: 12px 0 8px; font-size: var(--text-md); }
.mt-stats__art { width: 20px; height: 20px; vertical-align: -5px; margin-right: 4px; }
.mt-stats .stats-rows__value .icon { color: var(--mt-gold, #f5b82e); }
/* Phones: above the menu button in the corner. */
@media (max-width: 760px) {
    .mt-kiko--floating { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px); }
}

/* Phones and tablets: the board moves on its own layer, and the effects that run all the time are left out. */
.mt-piece { will-change: transform; }
.mt-board { contain: paint; }
@media (pointer: coarse) {
    .mt-piece__art, .mt-board::before, .mt-decor, .mt-piece--row .mt-piece__body, .mt-piece--column .mt-piece__body, .mt-crane-badge { animation: none !important; }
    .mt-stripes path, .mt-spark { filter: none; }
}
.mt-tool--speed { margin-left: auto; }
.mt-tool--speed span { font-size: var(--text-sm); }

/* ---------- Playing header: moves, score, goals as rings ---------- */

.mt-hud { display: grid; gap: 10px; padding: 10px 12px 12px; align-items: stretch; }
.mt-hud__top { display: flex; align-items: center; gap: 8px; }
.mt-hud__title { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 700; line-height: 1.15; }
.mt-hud__title small { font-weight: 500; font-size: 0.78rem; color: var(--ink-muted); }
.mt-hud__toggles { flex-direction: row; gap: 4px; }
.mt-hud__main { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.mt-hud__moves {
    min-width: 72px;
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    transition: background-color .3s ease;
}
.mt-hud__moves strong { font-size: 2rem; }
.mt-hud__moves.is-low { background: linear-gradient(180deg, #b8324a, #7a1c30); animation: mt-low 1.6s ease-in-out infinite; }
@keyframes mt-low { 50% { box-shadow: 0 0 0 4px rgba(229, 72, 77, .35); } }
.mt-hud__score { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mt-hud__score > strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mt-hud__score .mt-meter { margin: 4px 8px 4px 0; height: 10px; }

.mt-rings { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.mt-ring-goal { position: relative; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mt-ring-goal__ring { width: 50px; height: 50px; transform: rotate(-90deg); }
.mt-ring-goal__track { fill: var(--surface-2); stroke: var(--line); stroke-width: 4; }
.mt-ring-goal__fill {
    fill: none;
    stroke: var(--mt-gold, #f5b82e);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 119.38;
    transition: stroke-dashoffset .45s ease, stroke .3s ease;
}
.mt-ring-goal.is-done .mt-ring-goal__fill { stroke: #3fb27f; }
.mt-ring-goal__icon { position: absolute; top: 9px; left: 50%; transform: translateX(-50%); width: 32px; height: 32px; display: grid; place-items: center; }
.mt-ring-goal__icon .mt-goal-icon { width: 28px; height: 28px; }
.mt-ring-goal__left { font-weight: 800; font-size: var(--text-sm); font-variant-numeric: tabular-nums; line-height: 1; }
.mt-ring-goal.is-done .mt-ring-goal__left { color: #2e9b6a; }
.mt-ring-goal__delta {
    position: absolute;
    top: -4px;
    right: -6px;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    background: var(--mt-gold, #f5b82e);
    color: #3b2414;
    font-size: var(--text-xs);
    font-weight: 800;
    pointer-events: none;
    animation: mt-delta calc(1.1s * var(--mt-speed, 1)) ease-out forwards;
}
@keyframes mt-delta { from { transform: translateY(6px) scale(.6); opacity: 0; } 20% { transform: translateY(0) scale(1.1); opacity: 1; } 75% { opacity: 1; } to { transform: translateY(-14px); opacity: 0; } }
.mt-ring-goal.is-just-done .mt-ring-goal__ring { animation: mt-goal-done .7s cubic-bezier(.3, 1.6, .6, 1); }
.mt-ring-goal.is-just-done::after {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(255, 230, 140, .7), transparent 65%);
    animation: mt-flash .8s ease-out forwards;
    pointer-events: none;
}
@keyframes mt-goal-done { 40% { transform: rotate(-90deg) scale(1.2); } }

/* ---------- On the board: the cascade counter, a word when a swap doesn't work ---------- */

.mt-combo {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 4;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: rgba(20, 12, 36, .72);
    color: #ffe08a;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: 0 0 0 2px rgba(255, 224, 138, .5);
    animation: mt-born calc(.35s * var(--mt-speed, 1)) cubic-bezier(.3, 1.6, .6, 1);
    pointer-events: none;
}
.mt-nope-note {
    position: absolute;
    left: 50%;
    bottom: 10%;
    transform: translateX(-50%);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: rgba(20, 12, 36, .82);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    animation: mt-note 1.4s ease forwards;
}
@keyframes mt-note { from { opacity: 0; transform: translate(-50%, 8px); } 15% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } to { opacity: 0; } }

/* Paper boats float off at the bottom; moss grows in. */
.mt-piece--landed { z-index: 2; pointer-events: none; }
.mt-piece--landed .mt-piece__body { animation: mt-landed calc(.6s * var(--mt-speed, 1)) ease-in forwards; }
@keyframes mt-landed { 30% { transform: translateY(8%) scale(1.1); filter: brightness(1.4); } to { transform: translateY(60%) scale(.6); opacity: 0; } }
.mt-moss { position: absolute; inset: 3%; width: 94%; height: 94%; animation: mt-born calc(.45s * var(--mt-speed, 1)) ease; }

/* ---------- Map page: carry on, tabs, worlds that fold ---------- */

.mt-continue { width: 100%; justify-content: center; margin-bottom: 12px; padding: 12px 16px; font-size: 1.05rem; }
.mt-tabs { margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.mt-tabs .tab { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.mt-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 2px var(--surface); }
.mt-panel { margin-bottom: 16px; }
.mt-panel > .mt-daily, .mt-panel > .mt-week, .mt-panel > .mt-shop, .mt-panel > .mt-household { margin-bottom: 0; }

.mt-world__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.mt-world__toggle h2 { flex: 1; min-width: 0; }
.mt-world__head { padding: 14px 16px; }
.mt-world__done { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: #c7ffd8; }
.mt-world__chevron { transition: transform .25s ease; opacity: .8; }
.mt-world__chevron.is-open { transform: rotate(180deg); }

.mt-world--river { --mt-world-bg: radial-gradient(circle at 30% 10%, rgba(255, 240, 140, .22), transparent 40%), linear-gradient(180deg, #123a4a, #0b1e2c); }
.mt-world--autumn { --mt-world-bg: radial-gradient(circle at 80% 5%, rgba(255, 150, 70, .3), transparent 45%), linear-gradient(180deg, #5a2a16, #2a140c); }
.mt-scene--river { --mt-scene-bg: linear-gradient(180deg, #1c4f63, #0b1e2c); }
.mt-scene--autumn { --mt-scene-bg: linear-gradient(180deg, #7a3a1c, #2a140c); }
.mt-world--summit { --mt-world-bg: radial-gradient(circle at 70% 8%, rgba(200, 225, 255, .28), transparent 42%), linear-gradient(180deg, #24305e, #0e1230); }
.mt-scene--summit { --mt-scene-bg: linear-gradient(180deg, #34477e, #0e1230); }

/* ---------- Narrow phones ---------- */

@media (max-width: 400px) {
    .mt-play { gap: 8px; }
    .mt-hud { padding: 8px 10px 10px; gap: 8px; }
    .mt-hud__moves { min-width: 60px; padding: 6px 10px; }
    .mt-hud__moves strong { font-size: 1.6rem; }
    .mt-hud__score > strong { font-size: 1.2rem; }
    .mt-rings { gap: 6px; }
    .mt-ring-goal { width: 50px; }
    .mt-ring-goal__ring { width: 44px; height: 44px; }
    .mt-ring-goal__icon { top: 8px; width: 28px; height: 28px; }
    .mt-ring-goal__icon .mt-goal-icon { width: 24px; height: 24px; }
    .mt-tool { padding: 7px 10px; }
    .mt-tabs .tab span { display: none; }
    .mt-tabs .tab { padding-inline: 14px; }
    .mt-stop__button { width: 50px; height: 50px; }
}

/* ---------- Phones while playing: header, board and tools on one screen ---------- */

@media (max-width: 480px) {
    .mt-page--playing { padding-top: var(--space-2); }
    .mt-play { gap: 6px; }
    /* Two rows: moves next to the goals, then the score as a thin bar. */
    .mt-hud {
        grid-template-columns: auto 1fr;
        grid-template-areas: "top top" "moves rings" "score score";
        gap: 6px 10px;
        padding: 6px 10px 8px;
    }
    .mt-hud__top { grid-area: top; }
    .mt-hud__title { flex-direction: row; align-items: baseline; gap: 6px; font-size: var(--text-sm); }
    .mt-hud__title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mt-hud__top .icon-button, .mt-hud__toggles .icon-button { width: 30px; height: 30px; }
    .mt-hud__main { display: contents; }
    .mt-hud__moves { grid-area: moves; align-self: center; min-width: 54px; padding: 4px 8px; }
    .mt-hud__moves strong { font-size: 1.5rem; }
    .mt-hud__score { grid-area: score; flex-direction: row; align-items: center; gap: 10px; }
    .mt-hud__score > strong { font-size: 1.05rem; min-width: 4.5ch; }
    .mt-hud__score .mt-meter { flex: 1; margin: 0 8px 0 0; height: 8px; }
    .mt-rings { grid-area: rings; flex-wrap: nowrap; justify-content: flex-start; align-items: center; gap: 4px; min-width: 0; }
    .mt-ring-goal { width: 46px; }
    .mt-ring-goal__ring { width: 40px; height: 40px; }
    .mt-ring-goal__icon { top: 6px; width: 28px; height: 28px; }
    .mt-ring-goal__icon .mt-goal-icon { width: 22px; height: 22px; }
    .mt-tools { gap: 6px; }
    .mt-tool { padding: 6px 10px; }
}

/* ---------- Less motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .mt-board { --mt-speed: .5 !important; }
    .mt-bit, .mt-blast__spark, .mt-ring, .mt-confetti, .mt-ring-goal.is-just-done::after { display: none !important; }
    .mt-board--shake0, .mt-board--shake1, .mt-hud__moves.is-low, .mt-stop.is-current .mt-stop__button, .mt-me, .mt-others .avatar,
    .mt-lives .icon.is-full, .mt-week__claim, .mt-daily__glow, .mt-daily__streak .icon, .mt-mystery__lock, .mt-week__piece { animation: none !important; }
    .mt-piece--land0 .mt-piece__body, .mt-piece--land1 .mt-piece__body, .mt-piece--swap .mt-piece__body, .mt-piece--nope .mt-piece__body,
    .mt-piece.is-hint .mt-piece__body, .mt-piece.is-selected .mt-piece__body { animation: none !important; }
    .mt-cheer { animation: mt-flash 1.2s ease forwards !important; }
    .mt-world__chevron { transition: none; }
}
.wrapped__card--puzzle { --w1: #3a1530; --w2: #e2703a; --w3: #ffd36e; }
