/* Nexon Maplestory Bold (free for commercial use; see assets/fonts/README.md). */
/* Japanese and Traditional Chinese (v351): their own rounded fonts, subsets of
   just the characters the game uses (tools/cjk_fonts.py rebuilds them). Digits
   and Latin letters stay in Maplestory in every language ('OSD Latin' is the
   same file limited to ASCII). Japanese: Mochiy Pop One for large text,
   M PLUS Rounded 1c ExtraBold for small text and the settings title. */
@font-face{font-family:'OSD Latin';src:url('assets/fonts/Maplestory-Bold.woff2') format('woff2');unicode-range:U+0020-007E,U+00D7;font-display:block}
@font-face{font-family:'OSD Ja Pop';src:url('assets/fonts/ja-pop.woff2?v=402') format('woff2');font-display:block}
@font-face{font-family:'OSD Ja Round';src:url('assets/fonts/ja-round.woff2?v=402') format('woff2');font-weight:100 900;font-display:block}
@font-face{font-family:'OSD Zh';src:url('assets/fonts/zh-round.woff2?v=402') format('woff2');font-display:block}
html:lang(ja) body,html:lang(ja) body *{font-family:'OSD Latin','OSD Ja Pop','Maplestory',sans-serif!important}
html:lang(ja) :is(.settings-head h1,.lang-head h1,[data-toggle] span,.result-stats dt,.settings-links button,.settings-version,.result-record-line,.message,.stage-mix),html:lang(ja) :is(.settings-head h1,.lang-head h1,.result-record-line,.message,.stage-mix) *{font-family:'OSD Latin','OSD Ja Round','Maplestory',sans-serif!important;font-weight:800}
html:lang(ja) .settings-toggles .toggle span,html:lang(zh) .settings-toggles .toggle span{font-size:12.5px}
html:lang(ja) .result-ribbon{font-size:clamp(22px,6.2vw,34px)}
html:lang(zh) body,html:lang(zh) body *{font-family:'OSD Latin','OSD Zh','Maplestory',sans-serif!important}
/* Spanish, Portuguese, German, French (v358): Nunito Black, which has the
   accented letters Maplestory lacks. Digits and the praise words stay Maplestory. */
@font-face{font-family:'OSD Digits';src:url('assets/fonts/Maplestory-Bold.woff2') format('woff2');unicode-range:U+0030-0039,U+003A,U+0025,U+00D7;font-display:block}
@font-face{font-family:'OSD Nunito';src:url('assets/fonts/eu-nunito.woff2') format('woff2');font-weight:900;font-display:block}
html:is(:lang(es),:lang(pt),:lang(de),:lang(fr)) body,html:is(:lang(es),:lang(pt),:lang(de),:lang(fr)) body *{font-family:'OSD Digits','OSD Nunito','Maplestory',sans-serif!important;font-weight:900!important}
html:is(:lang(es),:lang(pt),:lang(de),:lang(fr)) :is(.complete-good,.complete-good *){font-family:'Maplestory',sans-serif!important}
/* Language picker (v353): every language name in its own font, whatever the current language. */
.lang-list .lang-option{font-family:'Maplestory',system-ui,sans-serif!important}
.lang-list .lang-option:is(:lang(es),:lang(pt),:lang(de),:lang(fr)){font-family:'OSD Nunito','Maplestory',sans-serif!important;font-weight:900}
.lang-list .lang-option:lang(ja){font-family:'OSD Latin','OSD Ja Round',sans-serif!important;font-weight:800;font-size:18px}
.lang-list .lang-option:lang(zh){font-family:'OSD Latin','OSD Zh',sans-serif!important;font-size:18px;-webkit-text-stroke:.6px currentColor} /* Huninn has one weight: a thin stroke thickens it (v356) */
html:lang(zh) .result-stats dt{font-size:clamp(13px,3.7vw,19px)}
@font-face{font-family:'Maplestory';src:url('assets/fonts/Maplestory-Bold.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:block}
:root{--card-radius:7px;--css-version:"v412"}*{box-sizing:border-box}html,body{height:100%;margin:0;overflow:hidden;overscroll-behavior:none;font-family:'Maplestory',system-ui,-apple-system,sans-serif}body{background:#078be8}.game{width:min(100%,560px);height:100dvh;margin:auto;background:linear-gradient(180deg,#0aa9ef,#0560e8);position:relative;overflow:hidden}.top{height:clamp(108px,15.4dvh,150px);background:linear-gradient(#87e2f8,#28d0ef);border-bottom:7px solid #05a8dc;box-shadow:0 4px 6px #004d9d80;display:flex;align-items:flex-end;justify-content:space-around;padding:0 12px 15px;position:relative;z-index:2}.level{text-align:center;color:#1983d4;font-weight:900;line-height:1.05;font-size:clamp(17px,4.5vw,24px);text-shadow:0 1px #9bf5ff}.level strong{display:block;color:#fff;font-size:clamp(28px,7vw,38px);-webkit-text-stroke:1px #328dc8;text-shadow:0 2px #3188bc}.tool{border:0;background:transparent;color:white;text-shadow:0 2px 0 #2686ca,2px 0 #2686ca,-2px 0 #2686ca,0 -2px #2686ca;font-size:40px;font-weight:800;width:48px;height:48px;cursor:pointer}.table{padding:0 7px;position:relative}.decks{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;height:clamp(52px,10dvh,85px);overflow:hidden;align-items:end;margin-bottom:clamp(10px,2.2dvh,20px)}.deck{height:100%;position:relative}.deck-card{position:absolute;left:var(--inset,1.5px);right:var(--inset,1.5px);height:var(--card-height,calc((100% - 3px)/.69));bottom:calc(2% + var(--position)*60%/var(--stack-steps));box-shadow:0 1px 1px #073f8090}.board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:repeat(4,1fr);gap:0;touch-action:none;user-select:none}.slot{aspect-ratio:0.69;position:relative}.tile{position:absolute;inset:0;border:2px solid #fff;border-radius:var(--card-radius);box-shadow:0 0 0 1px #453d2e,0 2px 2px #06428a;cursor:grab;touch-action:none;background-repeat:no-repeat;background-origin:border-box;background-clip:border-box;transition:filter .15s,transform .15s}.message{text-align:center;color:#ddf8ff;font-weight:700;font-size:13px;margin-top:11px;min-height:20px;text-shadow:0 1px 2px #0570a8}.modal{position:absolute;inset:0;z-index:10;background:#002b59a8;display:grid;place-items:center;padding:24px}.modal[hidden]{display:none}.win-card{background:#fffaf0;border:4px solid #fff;border-radius:24px;box-shadow:0 8px 25px #003a7a88;padding:30px;text-align:center;color:#7c4b18;width:min(100%,320px)}.win-card span{font-size:56px;color:#f2aa0c}.win-card h1{font-size:26px}.win-card p{font-size:15px}.win-card button{background:#ffab13;border:0;border-bottom:4px solid #db7600;border-radius:16px;padding:12px 35px;font-size:18px;color:white;font-weight:800}
@media(max-height:670px){.game{width:min(100%,calc((100dvh - 165px)*.69));}.top{height:82px;padding-bottom:8px}.decks{height:46px;margin-bottom:7px}.message{margin-top:4px}}

.tile.connected { box-shadow:none }

.status{text-align:center;color:#ddf8ff;font-size:12px;min-height:16px}.tile.drag-source{visibility:hidden}.drag-ghost{position:fixed!important;right:auto!important;bottom:auto!important;margin:0;pointer-events:none;z-index:100;transition:none!important;will-change:transform}.board.busy{pointer-events:none}

.tile.drag-source{visibility:hidden}

.game,.game *,.drag-ghost{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}

/* Separate unrelated cards; connected edges meet without a gap. */
.slot .tile{inset:var(--inset,1.5px)}
.group-fx{position:fixed;z-index:110;pointer-events:none;transform-origin:center;will-change:transform,opacity}
.group-fx-tile{position:absolute!important;inset:auto;margin:0;pointer-events:none;transition:none!important}
.complete-fx{overflow:visible}
.complete-shine{position:absolute;inset:0;border-radius:7px;overflow:hidden;pointer-events:none}
.complete-shine::after{content:'';position:absolute;left:0;top:0;width:300%;height:300%;background:linear-gradient(45deg,transparent 41%,rgba(255,255,255,.06) 46%,rgba(255,255,255,.8) 49%,rgba(255,255,255,.15) 52%,transparent 57%) no-repeat;animation:shine-wipe 700ms ease-in-out 100ms both}
.complete-good{position:absolute;left:50%;top:-8px;transform:translate(-50%,-100%);transform-origin:center bottom;line-height:1;white-space:nowrap;color:#fff8d8;font-size:clamp(26px,8vw,42px);font-weight:900;letter-spacing:1px;-webkit-text-stroke:1.5px #c76c02;paint-order:stroke fill;text-shadow:0 2px 0 #b55400,0 3px 6px #4e340b88;animation:good-pop 1000ms ease-out both}
/* The light band is part of a background three times the picture's size, so it
   always covers the whole picture and only the band itself crosses it. */
@keyframes shine-wipe{from{transform:translateX(-66.66666667%)}to{transform:translateY(-66.66666667%)}}
@keyframes good-pop{0%{opacity:0;transform:translate(-50%,-100%) scale(.45)}25%{opacity:1;transform:translate(-50%,-100%) scale(1.15)}50%{opacity:1;transform:translate(-50%,-100%) scale(1)}100%{opacity:0;transform:translate(-50%,-100%) scale(1.03)}}

/* Smooth inward corners where three connected pieces meet. */
.inner-corner{position:absolute;width:8px;height:8px;z-index:5;pointer-events:none;background-repeat:no-repeat}
.inner-corner::after{content:'';position:absolute;inset:0;pointer-events:none}
.inner-br{left:100%;top:100%;--corner:100% 100%}
.inner-bl{right:100%;top:100%;--corner:0% 100%}
.inner-tr{left:100%;bottom:100%;--corner:100% 0%}
.inner-tl{right:100%;bottom:100%;--corner:0% 0%}
.inner-corner{mask-image:radial-gradient(circle at var(--corner),transparent 0 6px,#000 6.3px);-webkit-mask-image:radial-gradient(circle at var(--corner),transparent 0 6px,#000 6.3px)}
.inner-corner::after{background:radial-gradient(circle at var(--corner),transparent 0 5.8px,white 6px 7.6px,transparent 8px)}

.edge-bridge{position:absolute;background:#fff;pointer-events:none;z-index:3}
.edge-h-top,.edge-h-bottom{right:-2px;width:4px;height:2px}
.edge-h-top{top:-2px}.edge-h-bottom{bottom:-2px}
.edge-v-left,.edge-v-right{bottom:-2px;height:4px;width:2px}
.edge-v-left{left:-2px}.edge-v-right{right:-2px}

/* One continuous vector outline surrounds each connected picture. */
.tile.connected{border-color:transparent!important}
.group-outline{position:absolute;overflow:visible;pointer-events:none;z-index:7}
.inner-corner::after{display:none}

/* Connected pictures are rendered once, including curved inner corners. */
.tile.connected{background-image:none!important}
.tile.selected.connected{filter:none}

.board.busy{pointer-events:auto}

/* Keep the header just tall enough for its controls. */
.top{height:calc(env(safe-area-inset-top, 0px) + 68px);padding:env(safe-area-inset-top, 0px) 12px 6px;align-items:center;border-bottom-width:4px}
@media(max-height:670px){.top{height:calc(env(safe-area-inset-top, 0px) + 68px);padding-bottom:6px}}

/* The held card stays above moving cards and completion effects. */
.drag-ghost.user-moving,.tile.user-moving-tile{z-index:120}
.drag-ghost.user-held{z-index:130}


.joining-card{background:none!important;box-shadow:none!important;border-color:transparent!important;outline:0;overflow:visible}
.join-slice{position:absolute;overflow:visible;pointer-events:none}

.tile.dealing{background-image:none!important;border-color:transparent;box-shadow:none;perspective:700px}
.deal-rotor{position:absolute;inset:-2px;transform-style:preserve-3d;pointer-events:none}
.deal-face{position:absolute;inset:0;border-radius:var(--card-radius);backface-visibility:hidden;-webkit-backface-visibility:hidden;box-shadow:0 0 0 1px #453d2e,0 2px 2px #06428a}
/* Show only the fabric inside the artwork's baked-in rim. The single
   CSS edge then has exactly the silhouette of a board card. */
.deck-card,.deal-back{border:2px solid #fff4dc;border-radius:var(--card-radius);background:var(--fabric-base) var(--card-back) center/var(--back-size,120% 120%) no-repeat;box-shadow:0 0 0 1px var(--fabric-edge),0 2px 2px #26140d66}
.deal-front{transform:rotateY(180deg);border:2px solid white;background-repeat:no-repeat;background-origin:border-box}

/* Keep the stage number centred while the navigation sits at the right. */
.top{justify-content:initial}
/* The restart button sits under the board where the status text used to be. */
.table-actions{position:absolute;left:10px;right:10px;bottom:calc(env(safe-area-inset-bottom, 0px) + 6px);z-index:5;display:grid;grid-template-columns:minmax(0,.8fr) 48px minmax(0,1.2fr);grid-template-rows:44px;align-items:center;pointer-events:none}
.table-actions button{pointer-events:auto}
.footer-info{display:flex;align-items:center;justify-content:space-between;gap:4px;padding-right:6px}
.table-actions #reset{font-size:40px;width:48px;height:44px;padding:0;line-height:1}
.version{text-align:right;word-break:keep-all;overflow-wrap:anywhere;line-height:1.1;font-size:11px;color:#ddf8ff;opacity:.7;pointer-events:none}
.message[hidden],.status[hidden]{display:none}
.top > .level{position:absolute;left:50%;transform:translateX(-50%)}
/* Stage navigation sits at the bottom right: ‹ number ›. */
.stage-nav{justify-self:end;display:flex;align-items:center;gap:0;flex:none}
.stage-nav #stage-prev,.stage-nav #stage-next{width:26px}
.stage-nav #stage-number{min-width:38px;padding:0 8px}
/* Right of restart: the stage's style mix, three lines centred vertically. */
.footer-right{display:flex;align-items:center;justify-content:space-between;gap:4px;min-width:0;height:44px}
.stage-mix{display:flex;flex-direction:column;justify-content:center;min-width:0;padding-left:6px;font-size:11px;line-height:1.2;color:#ddf8ff;opacity:.85;pointer-events:none}
.stage-mix span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#stage-number{width:auto;min-width:44px;height:34px;padding:0 10px;border:2px solid #ffffffb0;border-radius:14px;background:#0b4fae99;color:#fff;font-size:16px;font-weight:800;text-shadow:none;cursor:pointer}
.stage-card h1{margin:0 0 6px;font-size:22px}.stage-card p{margin:0 0 14px}
#stage-input{width:100%;font-size:24px;font-weight:800;text-align:center;padding:10px;border:3px solid #ffd27a;border-radius:14px;color:#7c4b18;background:#fff;outline:none}
#stage-input:focus{border-color:#ffab13}
#stage-input::-webkit-inner-spin-button,#stage-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}#stage-input{-moz-appearance:textfield;appearance:textfield}
/* Sit above the on-screen keyboard. */
#stage-picker{place-items:start center;padding-top:max(18dvh,calc(env(safe-area-inset-top, 0px) + 80px))}
.stage-buttons{display:flex;gap:10px;margin-top:16px}.stage-buttons button{flex:1;padding:12px 0}
#stage-cancel{background:#c9b79a;border-bottom-color:#a08c6c}
.stage-nav button{width:34px;height:44px;padding:0;border:0;background:transparent;color:white;font-size:30px;font-weight:800;line-height:1;text-shadow:0 2px 0 #2686ca,2px 0 #2686ca,-2px 0 #2686ca,0 -2px #2686ca;cursor:pointer}

/* Empty card frames are painted as the board background by drawCellFrames(). */
.board{background-repeat:repeat}

/* A dealt card leaves from under the deck cards stacked above it. */
.decks{position:relative;z-index:10}

/* Effect speed toggle at the bottom left. */
.effect-speed{flex:none;white-space:nowrap;border:2px solid #ffffffb0;border-radius:14px;background:#0b4fae99;color:#fff;font-size:12px;font-weight:800;padding:6px 10px;cursor:pointer}
.effect-speed.active{background:#ffab13;border-color:#fff;color:#fff;box-shadow:0 0 0 2px #db7600}
.slow-effects .complete-shine::after{animation-duration:7000ms;animation-delay:1000ms}
.slow-effects .complete-good{animation-duration:10000ms}

/* Single-card pictures are SVG layers like group pictures (see drawSinglePicture). */
.tile.svg-picture{background-image:none}
.tile-picture{position:absolute;overflow:visible;pointer-events:none}
.tile.dealing .tile-picture{visibility:hidden}

/* A board card in motion stays above resting cards and group pictures (z 7). */
.tile.moving-tile{z-index:8}
/* Layer order: board cards < decks (10) < header (12) < win modal (30) < moving/held copies (99+). */
.top{z-index:12}
.modal{z-index:30}
#win{grid-template-rows:auto auto;align-content:center;gap:14px}
.clear-time{margin:0;color:#fff;font-size:15px;line-height:1.5;text-align:center;white-space:pre-line;text-shadow:0 1px 2px #0008}
.clear-time:empty{display:none}
.dev-times{width:100%;max-width:100%;box-sizing:border-box;max-height:55vh;overflow:auto;margin:0;padding:8px;border-radius:8px;background:#f3e6d2;color:#5a3714;font:11px/1.5 ui-monospace,Menlo,monospace;text-align:left;white-space:pre;-webkit-user-select:text;user-select:text}
.dev-card{width:min(100%,360px);max-width:calc(100vw - 32px);min-width:0;padding:22px}#dev-times-view{min-width:0}
.dev-card h1{margin:0 0 14px}
.dev-card .stage-buttons{gap:8px}.dev-card .stage-buttons button{padding:12px 0;font-size:16px}.dev-card h2{font-size:18px;margin:0 0 10px}
.dev-home{display:flex;flex-direction:column;gap:10px}.dev-home[hidden]{display:none}
.dev-info{margin:0 0 4px;padding:8px;border-radius:8px;background:#f3e6d2;color:#6b4a2a;font:11px/1.4 ui-monospace,Menlo,monospace;text-align:left;white-space:pre-wrap;word-break:break-all;-webkit-user-select:text;user-select:text}
.win-card button.dev-secondary{background:#c9b49a;border-bottom-color:#9c8467}
.dev-params{max-height:55vh;overflow-y:auto;text-align:left;display:flex;flex-direction:column;gap:6px;padding-right:4px}
.dev-row{display:grid;grid-template-columns:1fr 84px 24px;align-items:center;gap:6px;font-size:14px}
.dev-row input{width:100%;padding:6px 8px;border:2px solid #e2cba8;border-radius:8px;font:inherit;font-size:15px;color:#5a3714;background:#fff;-webkit-user-select:text;user-select:text}
.dev-row span{font-size:14px;color:#7c4b18;line-height:1.25}
.dev-row em{font-style:normal;font-size:12px;opacity:.7}
/* With snapLayout() the grid rows set each cell's height on whole device pixels. */
.board.snapped .slot{aspect-ratio:auto}

/* Group pictures: dark rim, CSS-background picture clipped to the outline, white rim. */
.group-picture{position:absolute;overflow:visible;pointer-events:none}
.group-picture>svg,.group-picture-art{position:absolute;left:0;top:0;width:100%;height:100%;overflow:visible}
.group-picture-art{background-repeat:no-repeat}

/* The header fabric and deck share a palette. Portaled cards inherit it from html. */
:root{--card-back:url('assets/themes/apricot-back.webp');--thread-img:url('assets/themes/apricot-thread.webp');--thread-vertical:url('assets/themes/apricot-thread-vertical.webp');--ground:url('assets/themes/apricot-ground.webp');--ground-base:#492b1c;--thread:#a36435;--header-cloth:url('assets/themes/apricot-header.webp');--fabric-base:#f5e0bd;--fabric-edge:#b98459;--fabric-ink:#693817}
:root[data-theme="rose"]{--thread-img:url('assets/themes/rose-thread.webp');--thread-vertical:url('assets/themes/rose-thread-vertical.webp');--ground:url('assets/themes/rose-ground.webp');--ground-base:#44232e;--thread:#ffe8d8;--header-cloth:url('assets/themes/rose-header.webp');--fabric-base:#f3d5d0;--fabric-edge:#b37b80;--fabric-ink:#71364a}
:root[data-theme="sage"]{--thread-img:url('assets/themes/sage-thread.webp');--thread-vertical:url('assets/themes/sage-thread-vertical.webp');--ground:url('assets/themes/sage-ground.webp');--ground-base:#353820;--thread:#ede8bc;--header-cloth:url('assets/themes/sage-header.webp');--fabric-base:#dedfc5;--fabric-edge:#90946c;--fabric-ink:#394728}
:root[data-theme="cocoa"]{--thread-img:url('assets/themes/cocoa-thread.webp');--thread-vertical:url('assets/themes/cocoa-thread-vertical.webp');--ground:url('assets/themes/cocoa-ground.webp');--ground-base:#322219;--thread:#855528;--header-cloth:url('assets/themes/cocoa-header.webp');--fabric-base:#ffe3a6;--fabric-edge:#bf9051;--fabric-ink:#633e25}
:root[data-theme="indigo"]{--ground:url('assets/themes/indigo-ground.webp');--ground-base:#152537;--header-cloth:url('assets/themes/indigo-header.webp');--fabric-base:#e4ded2;--fabric-edge:#8598a4;--fabric-ink:#213552;--stitch-filter:saturate(.05) brightness(1.38)}
:root[data-theme="honey"]{--ground:url('assets/themes/honey-ground.webp');--ground-base:#353516;--header-cloth:url('assets/themes/honey-header.webp');--fabric-base:#f2dfa5;--fabric-edge:#9d9865;--fabric-ink:#404828;--stitch-filter:hue-rotate(14deg) saturate(.72)}
:root[data-theme="book"]{--ground:url('assets/themes/book-ground.webp');--ground-base:#39261d;--header-cloth:url('assets/themes/book-header.webp');--fabric-base:#ead1ae;--fabric-edge:#885530;--fabric-ink:#fff0c9;--stitch-filter:brightness(1.55) saturate(.6)}
:root[data-theme="corduroy"]{--ground:url('assets/themes/corduroy-ground.webp');--header-cloth:url('assets/themes/corduroy-header.webp');--ground-base:#382418;--fabric-ink:#48270d;--fabric-edge:#aa713e;--fabric-base:#ffd59c;--stitch-filter:saturate(.65) brightness(.86);--ground-size:185px auto;--cloth-size:auto 98px;--back-size:100% 100%}
:root[data-theme="suede"]{--ground:url('assets/themes/suede-ground.webp');--header-cloth:url('assets/themes/suede-header.webp');--ground-base:#371c2a;--fabric-ink:#422136;--fabric-edge:#744755;--fabric-base:#ecd5de;--stitch-filter:hue-rotate(337deg) saturate(.8);--ground-size:185px auto;--cloth-size:auto 98px;--back-size:100% 100%}
:root[data-theme="lace"]{--ground:url('assets/themes/lace-ground.webp');--header-cloth:url('assets/themes/lace-header.webp');--ground-base:#153e3a;--fabric-ink:#343c1a;--fabric-edge:#858657;--fabric-base:#fff3d3;--stitch-filter:saturate(.05) brightness(1.38);--ground-size:185px auto;--cloth-size:auto 111px;--back-size:100% 100%}
:root[data-theme="fur"]{--ground:url('assets/themes/fur-ground.webp');--header-cloth:url('assets/themes/fur-header.webp');--ground-base:#412d25;--fabric-ink:#533a29;--fabric-edge:#967654;--fabric-base:#f2d6ae;--stitch-filter:brightness(1.55) saturate(.6);--ground-size:185px auto;--cloth-size:auto 98px;--back-size:100% 100%}
:root[data-theme="flannel"]{--ground:url('assets/themes/flannel-ground.webp');--header-cloth:url('assets/themes/flannel-header.webp');--ground-base:#253326;--fabric-ink:#382f31;--fabric-edge:#825052;--fabric-base:#decfc1;--stitch-filter:saturate(.6);--ground-size:185px auto;--cloth-size:auto 98px;--back-size:100% 100%}
:root:is([data-theme="indigo"],[data-theme="honey"],[data-theme="book"]){--ground-size:185px auto;--cloth-size:auto 98px;--back-size:100% 100%}
body,.game{background:var(--ground-base) var(--ground) center/var(--ground-size,150px 150px) repeat}
.top{--frame-height:98px;height:var(--frame-height);margin:calc(env(safe-area-inset-top,0px) + 4px) 7px 3px;padding:0 16px;background:linear-gradient(#fff2,transparent 32%,#54301712),var(--header-cloth) center/var(--cloth-size,105px 105px) repeat,var(--fabric-base);border:1px solid var(--fabric-edge);border-radius:24px;box-shadow:inset 0 2px 3px #fffa,inset 0 -3px 5px #643e272f,0 3px 5px #1d100b65}
/* Maplestory glyphs sit high in their line box: nudge the label down so the
   inked text is centred between the top and bottom stitch rows. */
.top .level{font-size:clamp(18px,4.8vw,22px);transform:translate(-50%,.165em)}
.top .level strong{font-size:clamp(31px,8.5vw,40px)}
/* Put individual photographed stitches along one rounded perimeter. */
.frame-stitch{position:absolute;inset:10px;pointer-events:none}
.frame-stitch-canvas{filter:var(--stitch-filter,none);position:absolute;left:-8px;top:-8px}
:root[data-theme="rose"] .deck-card,:root[data-theme="rose"] .deal-back{background-size:140% 140%}
@media(max-height:670px){.top{--frame-height:82px}}
.level,.level strong{color:var(--fabric-ink);text-shadow:0 1px 0 #fff9;-webkit-text-stroke:0}
/* The first card sits lowest and leaves from behind its own pile. */
.deck{isolation:isolate}
.deck-card{z-index:var(--position);border-color:var(--fabric-base);box-shadow:0 0 0 1px var(--fabric-edge),0 1px 1px #26140d55}

/* Clip both dealt tiles and reserve cards at the same height behind the panel. */
.table{margin-top:-37px;clip-path:inset(0 -100vmax -100vmax)}
.top{isolation:isolate}

.game[data-opening]{visibility:hidden}
.game:not([data-opening]){animation:game-in .35s ease-out}@keyframes game-in{from{opacity:0}}
/* Until the first stage is painted the page is a plain field in stage 1's ground colour (set on <html>), not the default set's rust-brown ground. */
html[data-booting] body{background:var(--ground-base)}

/* Buttons and inputs use the game font too. */
button,input{font-family:inherit}
@media(max-height:670px) and (max-width:380px){
 .footer-info{gap:3px;padding-right:2px}
 .footer-info .effect-speed{font-size:10px;padding-inline:5px}
 .footer-info .version{font-size:10px}
}

/* Auto-merge item (top-right of the header) and the stage 1 tutorial */
.top .item-button{--s:1;position:absolute;right:27px;top:50%;transform:translateY(-50%);width:calc(48px*var(--s));height:calc(48px*var(--s));padding:0;border:0;border-radius:50%;background:var(--item-base,#b3774b);cursor:pointer;z-index:3;transition:transform .1s,opacity .35s ease;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.top .settings-button{--s:1;position:absolute;left:27px;top:50%;transform:translateY(-50%);width:calc(48px*var(--s));height:calc(48px*var(--s));padding:0;border:0;border-radius:50%;background:var(--item-base,#b3774b);cursor:pointer;z-index:3;transition:transform .1s;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.top .settings-button:active{transform:translateY(-50%) scale(.88)}
.settings-icon{position:absolute;inset:11%;background:var(--item-mark,#ffe3a6);-webkit-mask:url('assets/ui/gear.svg?v=v412') center/contain no-repeat;mask:url('assets/ui/gear.svg?v=v412') center/contain no-repeat}
/* The circle is pressed into the cloth; the icon and the count dot stand up
   from it (shadow below, a thin light rim on top). */
.top .item-button,.top .settings-button{box-shadow:0 1px 0 #fff6,inset 0 2px 4px #0007,inset 0 -1px 1px #fff5}
.icon-wrap{position:absolute;inset:0;pointer-events:none;filter:drop-shadow(0 -.8px 0 #fff7) drop-shadow(0 1.5px 1.2px #0009)}
.item-count{box-shadow:0 1.5px 1.5px #0009}
.top .item-button.is-disabled{opacity:.45;pointer-events:none}
.top .item-button.pressed{transform:translateY(-50%) scale(.86)}
.merge-layer{position:fixed;inset:0;pointer-events:none;z-index:60;filter:drop-shadow(2px 0 0 #ffd34d) drop-shadow(-2px 0 0 #ffd34d) drop-shadow(0 2px 0 #ffd34d) drop-shadow(0 -2px 0 #ffd34d) drop-shadow(0 0 8px #ffd34dcc) drop-shadow(0 6px 8px #0006)}
.merge-flyer{position:absolute}
.merge-piece{position:absolute;box-sizing:border-box;border:2px solid #fff;background-repeat:no-repeat;background-origin:border-box;background-clip:border-box}
.merge-halo{position:absolute;inset:0;pointer-events:none;opacity:0}.merge-halo-layer{position:absolute;inset:0}.merge-halo-layer>div{position:absolute}
.merge-flash{position:absolute;inset:0;border-radius:var(--card-radius,7px);background:#fff;pointer-events:none}
.item-burst{position:absolute;inset:0;border-radius:50%;pointer-events:none;box-shadow:0 0 0 3px #fff8,0 0 14px 6px var(--item-base,#b3774b),0 0 22px 10px #fff6}
.item-icon{position:absolute;left:50%;top:calc(1px*var(--s));width:calc(43px*var(--s));height:calc(41px*var(--s));transform:translateX(-50%);background:var(--item-mark,#ffe3a6);-webkit-mask:url('assets/ui/wand-cat.svg?v=v412') center/contain no-repeat;mask:url('assets/ui/wand-cat.svg?v=v412') center/contain no-repeat}
.item-count{position:absolute;left:50%;bottom:calc(2px*var(--s));transform:translateX(-50%);display:flex;align-items:center;justify-content:center;box-sizing:border-box;min-width:calc(15px*var(--s));height:calc(15px*var(--s));padding:0 calc(3px*var(--s));border:0;border-radius:calc(8px*var(--s));background:var(--badge-bg,#fff3dc);color:var(--badge-ink,#3d2414);font-size:calc(11px*var(--s));font-weight:700;line-height:1;font-variant-numeric:tabular-nums}
.item-count-digits{display:block;line-height:1}
.item-refill{position:absolute;left:50%;bottom:-4px;transform:translateX(-50%);white-space:nowrap;display:flex;align-items:center;gap:2px;box-sizing:border-box;height:19px;padding:0 5px 0 2px;border-radius:6px;background:#9e9fa2;color:#fff;font-size:11px;font-weight:700;line-height:1;text-shadow:0 1px 0 #6f7073}
.item-refill[hidden],.item-count[hidden]{display:none}
.item-refill-play{display:block;width:20px;height:auto}
@media(max-height:670px){.top .item-button{--s:.86;right:22px}.top .settings-button{--s:.86;left:22px}}
.reward-note{font-size:12px;opacity:.7}
.tutorial{position:absolute;inset:0;z-index:20;pointer-events:none;opacity:0;transition:opacity .3s ease}
.tutorial.shown{opacity:1}
.tutorial[hidden]{display:none}
.tutorial-dim{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.tutorial-dim path{fill:rgba(12,8,5,.6)}
.tutorial-spot{position:absolute;border-radius:12px;box-shadow:0 0 0 3px #ffe27a,0 0 14px 4px #ffd34d}
.tutorial-bubble{position:absolute;left:50%;transform:translateX(-50%);max-width:92%;padding:10px 16px;border-radius:16px;background:#fffaf0;color:#4a2f1a;font-size:17px;line-height:1.35;text-align:center;box-shadow:0 4px 14px #0007;white-space:nowrap}
.tutorial-hand{position:absolute;left:0;top:0;width:64px;height:64px;filter:drop-shadow(0 3px 3px #0006)}
.tutorial-hand img{position:absolute;left:0;top:0;width:64px;height:auto;opacity:0}
.tutorial-hand .hand-grab{width:49.5px;left:4.7px;top:11.3px} /* the closed hand's yellow cuff matches the open hand's in size and place */
.tutorial-hand .hand-point{transform:scaleX(-1)} /* points up-right, toward the header button */

/* Chain words: DOUBLE! and up glow warmer; long words shrink a little to fit. */
.complete-good.chain{color:#fff3b0;-webkit-text-stroke-color:#d0461b}
.complete-good.chain-big{font-size:clamp(24px,7vw,38px);color:#ffe9f4;-webkit-text-stroke-color:#b0306a}
#stage-fade{position:absolute;inset:0;background:#000;opacity:0;pointer-events:none;z-index:70}

/* Settings panel (v281): the stage's own header cloth around a cream sheet. */
#settings-panel{z-index:40}
.settings-card{width:min(100%,330px);border-radius:26px;padding:10px 12px 14px;background:linear-gradient(#fff3,transparent 30%,#5430171a),var(--settings-cloth,var(--header-cloth)) center top/var(--settings-cloth-size,var(--cloth-size,105px 105px)) repeat,var(--fabric-base);border:1px solid var(--fabric-edge);box-shadow:inset 0 2px 3px #fffa,inset 0 -3px 5px #643e272f,0 8px 22px #0007;position:relative}
.settings-card::before{content:"";position:absolute;inset:6px;border:2px dashed var(--thread,#fff4dc);border-radius:21px;opacity:.85;pointer-events:none}
.settings-head{position:relative;display:flex;align-items:center;justify-content:center;height:52px}
.settings-head h1{margin:0;font-size:26px;color:var(--fabric-ink);text-shadow:0 1px 0 #fff8;transform:translateY(.1em)}
.settings-close{position:absolute;right:4px;top:50%;transform:translateY(-50%);width:40px;height:40px;border:0;border-radius:50%;background:var(--fabric-ink);color:var(--fabric-base);display:grid;place-items:center;box-shadow:0 2px 0 #0003;cursor:pointer}
.settings-close svg{width:22px;height:22px}
.settings-body{background:#fffaf0;border-radius:18px;padding:20px 16px 12px;box-shadow:inset 0 1px 3px #6b4a2a33;text-align:center;position:relative}
.settings-toggles{display:flex;justify-content:space-between;gap:10px;margin-bottom:20px}
.settings-toggles .toggle{--icon-face:#fffaf0;flex:1;aspect-ratio:1;max-width:84px;border:0;border-radius:20px;background:var(--toggle-bg,var(--fabric-ink));color:#fffaf0;position:relative;display:grid;place-items:center;padding:12px 12px 22px;box-shadow:0 4px 0 #0003,inset 0 2px 0 #fff4;cursor:pointer;transition:transform .12s,background .2s}
.settings-toggles .toggle:active{transform:scale(.92)}
.settings-toggles .toggle svg{width:100%;height:100%;grid-area:1/1}
.settings-toggles .toggle span{position:absolute;bottom:6px;left:0;right:0;font-size:11px;color:#fffaf0cc}
.settings-toggles .toggle .slash{opacity:0;transition:opacity .2s}
.settings-toggles .toggle.off{background:#a89e93;color:#f1ece6;--icon-face:#a89e93}
.settings-toggles .toggle.off .slash{opacity:1;color:#f1ece6}
.settings-toggles .toggle.off .waves{opacity:.35}
.settings-contact{width:100%;border:0;border-bottom:4px solid #db7600;border-radius:16px;background:linear-gradient(#ffc230,#ffa012);color:#fff;font:800 19px 'Maplestory',sans-serif;padding:13px 0 11px;text-shadow:0 1px 1px #b55a0099;cursor:pointer}
.settings-contact:active{border-bottom-width:2px;margin-top:2px} /* v358: same total height while pressed, so the card does not jump */
.settings-language{width:100%;margin-top:10px;display:flex;align-items:center;justify-content:center;gap:8px;border:2px solid #e6d7c2;border-bottom-width:4px;border-radius:16px;background:#fff;color:#6b4a2a;font:800 17px 'Maplestory',sans-serif;padding:10px 0 8px;cursor:pointer}
.settings-language svg{width:22px;height:22px;flex:none;transform:translateY(-1px)}
.settings-language:active{border-bottom-width:2px;margin-top:12px}
#lang-panel{z-index:45}
.lang-list{display:flex;flex-direction:column;gap:8px;padding:14px;max-height:min(62dvh,470px);overflow-y:auto}
.lang-option{position:relative;width:100%;border:2px solid #eadfcf;border-radius:14px;background:#fff;color:#6b4a2a;font:700 17px 'Maplestory',system-ui,sans-serif;padding:11px 0 9px;cursor:pointer}
.lang-option:active{transform:scale(.97)}
.lang-option.current{background:var(--toggle-bg,var(--fabric-ink));border-color:transparent;color:#fffaf0}
.lang-option.current::after{content:'✓';position:absolute;right:16px;top:50%;transform:translateY(-50%);font-weight:900}
.settings-links{display:flex;justify-content:space-around;margin-top:18px}
.settings-links button{border:0;background:none;color:#8a7a6a;font:15px 'Maplestory',sans-serif;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:4px}
.settings-version{margin:12px 0 0;color:#a5998c;font-size:13px}
.toast{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);z-index:60;padding:13px 24px 11px;border-radius:16px;background:#2b1c14e6;color:#fff;font-size:16px;pointer-events:none;white-space:nowrap;box-shadow:0 6px 16px #0006}

/* Results: separate fabric resources, live artwork and live text (v284). */
#win.result-screen{display:block;overflow:hidden;overscroll-behavior:none;touch-action:none;padding:0;background:linear-gradient(#45261b22,#24110e55),url('assets/themes/apricot-ground.webp') center/240px;color:#fff1d8;z-index:50;scrollbar-width:thin}
#win.result-screen[hidden],.result-viewer[hidden]{display:none}
.result-content{width:100%;max-width:560px;height:100%;display:flex;flex-direction:column;justify-content:center;margin:auto;padding:calc(env(safe-area-inset-top,0px) + 15px) 16px calc(env(safe-area-inset-bottom,0px) + 18px);text-align:center;isolation:isolate}
.result-linen{position:relative;background:linear-gradient(#fff4,#eecaa433),url('assets/themes/apricot-header.webp') center/130px;color:#562c18;border:1px solid #c9a57e;border-radius:22px;box-shadow:inset 0 1px 2px #fff9,0 4px 5px #1f110c55}
/* Stitches on result panels are drawn from the real thread image by sewOutline() (v303). */
.result-linen>.sew{position:absolute;inset:0;pointer-events:none}
.result-stage{display:inline-flex;align-items:center;justify-content:center;align-self:center;gap:7px;width:max-content;max-width:100%;flex-shrink:0;margin:0 auto 15px;padding:12px 24px 11px;font-size:clamp(17px,4.6vw,25px);line-height:1;white-space:nowrap}
.result-stage>span[aria-hidden]{color:#af7962;font-size:.8em;margin:0}.result-stage>span{flex-shrink:0}#result-stage{font-variant-numeric:tabular-nums}
.result-hero{position:relative;height:clamp(155px,28dvh,285px);margin:0 0 37px;perspective:850px}
.result-fan{position:absolute;inset:0 5%;filter:drop-shadow(0 5px 4px #1d0c0a66)}
.result-art-card{padding:5px;border:1px solid #ddc6a5;border-radius:13px;background:url('assets/themes/apricot-header.webp') center/90px;position:relative;box-shadow:0 3px 5px #23100b55}
.result-art-card:after{content:'';position:absolute;inset:2px;border:1px dashed #ae8562;border-radius:10px;pointer-events:none}
.result-art-card img{display:block;width:100%;height:100%;object-fit:cover;border-radius:8px;background:#c2aa8e}
.result-fan-card{position:absolute;bottom:0;left:50%;width:auto;height:95%;aspect-ratio:328/476;margin:0;transform:translateX(calc(-50% + var(--fan-x))) translateY(var(--fan-y)) rotate(var(--fan-angle));transform-origin:50% 100%;will-change:transform}
.result-fan-card:nth-child(1){--fan-x:-66%;--fan-y:10px;--fan-angle:-15deg;z-index:1;--fan-delay:140ms}
.result-fan-card:nth-child(2){--fan-x:66%;--fan-y:10px;--fan-angle:15deg;z-index:2;--fan-delay:280ms}
.result-fan-card:nth-child(3){--fan-x:0%;--fan-y:-3px;--fan-angle:0deg;z-index:3;--fan-delay:0ms}
.result-fan-card{z-index:auto}
@keyframes result-fan-open{0%{opacity:0;transform:translateX(-50%) translateY(35px) rotate(-3deg) scale(.72)}25%{opacity:1}100%{opacity:1;transform:translateX(calc(-50% + var(--fan-x))) translateY(var(--fan-y)) rotate(var(--fan-angle))}}
.result-ribbon{position:absolute;z-index:4;bottom:-30px;left:-8px;right:-8px;height:clamp(63px,11dvh,95px);margin:0;display:grid;place-items:center;padding:0 12px 6px;background:url('assets/ui/results/ribbon.webp') center/100% 100% no-repeat;color:#542912;font-size:clamp(27px,7.6vw,43px);line-height:1.15;text-shadow:0 1px #fff8}
/* The ribbon, stats, message and next button are shown in order by playResultSequence() (v300). */
.result-screen:not(.playing) .result-ribbon,.result-screen:not(.playing) .result-stats,.result-screen:not(.playing) .result-message,.result-screen:not(.playing) #again{opacity:0}
.result-stats dd{display:inline-block}
.result-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin:0;padding:15px 8px 13px}
.result-stats>div{min-width:0;padding:0 3px}.result-stats>div+div{border-left:1px dashed #b58d68}
.result-stats dt{display:flex;flex-direction:column;align-items:center;gap:5px;font-size:clamp(12px,3.4vw,18px);white-space:nowrap}
.result-stats svg{display:block;width:25px;height:25px;fill:none;stroke:#ae7753;stroke-width:2.7;stroke-linecap:round;stroke-linejoin:round}
.result-stats svg.result-paw{fill:#ae7753;stroke-width:0}
.result-stats dd{text-shadow:0 1px #fff8;margin:7px 0 0;font-size:clamp(25px,7.3vw,40px);font-variant-numeric:tabular-nums;line-height:1;white-space:nowrap;letter-spacing:-1px}
.result-message{font-size:clamp(12px,3.5vw,18px);margin:13px 0 14px;line-height:1.5;color:#ffe8cc}
.result-actions{display:flex;flex-direction:column;align-items:center;gap:7px}
.result-next{display:flex;align-items:center;justify-content:center;gap:14px;width:100%;height:clamp(63px,10dvh,88px);border:0;background:url('assets/ui/results/next-button.webp') center/100% 100% no-repeat;color:#fff3d9;font-size:clamp(25px,7vw,38px);padding:0 20px 5px;cursor:pointer;text-shadow:0 2px 1px #7c392b88;transition:transform 120ms}
.result-next-arrow{font-size:1.4em;line-height:.8}.result-next:active{transform:translateY(2px) scale(.98)}.result-next:disabled,.result-replay:disabled{opacity:.55;cursor:wait}
.result-replay{border:0;background:none;color:#ffe7c6;padding:7px 20px;font-size:clamp(16px,4.5vw,23px);cursor:pointer}.result-replay span{font-size:1.35em;vertical-align:-1px;margin-right:5px}
.result-collection{margin-top:15px}.result-collection h2{margin:0;font-size:clamp(18px,5vw,27px);line-height:1.2}.result-collection>p{font-size:clamp(12px,3.3vw,17px);margin:7px 0 12px;color:#e9c8a6}
.result-gallery{display:flex;gap:10px;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x proximity;padding:2px 1px 10px;scrollbar-width:thin;scrollbar-color:#bd8d66 transparent}
.result-gallery button{flex:0 0 auto;aspect-ratio:328/476;height:clamp(120px,19dvh,185px);cursor:pointer;scroll-snap-align:start;color:inherit}
.result-gallery button:active{transform:scale(.97)}.result-screen button:focus,.result-viewer button:focus{outline:none}
.result-viewer{z-index:60;background:#20110bf7;padding:calc(52px + env(safe-area-inset-top,0px)) 0 calc(16px + env(safe-area-inset-bottom,0px));cursor:zoom-out}
.result-viewer-close,.album-arrow{position:absolute;display:grid;place-items:center;padding:0;width:44px;height:44px;border:1px solid #f6dcb977;border-radius:50%;background:#fff0da;color:#5a321d;line-height:1;cursor:pointer;z-index:2}
.result-viewer-close{right:14px;top:calc(env(safe-area-inset-top,0px) + 9px);width:48px;height:48px;border:0;border-radius:0;background:transparent;color:#fff0da;font-size:44px}
.album{width:100%;min-width:0}
.album-page{position:relative}
.album-rail{--gap:clamp(7px,2vw,14px);--card:min(78%,calc((100dvh - 150px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) * .689));position:relative;display:flex;align-items:center;gap:var(--gap);overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory;overscroll-behavior-x:contain;touch-action:pan-x;scrollbar-width:none;padding-block:9px;cursor:grab}
.album-rail::-webkit-scrollbar{display:none}
.album-rail::before,.album-rail::after{content:"";flex:0 0 calc((100% - var(--card)) / 2 - var(--gap))}
.album-slide{flex:0 0 var(--card);min-width:0;aspect-ratio:328/476;scroll-snap-align:center;scroll-snap-stop:always}
.album-rail.dragging{scroll-snap-type:none;cursor:grabbing}
.album-arrow{top:50%;transform:translateY(-50%);font:32px/1 system-ui;background:#392117d9;color:#fff1dd;box-shadow:0 2px 5px #1e10084d}
.album-prev{left:4px}.album-next{right:4px}
.album-arrow[aria-disabled="true"]{visibility:hidden}
.album-count{display:grid;place-items:center;height:36px;margin:6px 0 0;color:#fff0db;font-size:24px;font-variant-numeric:tabular-nums;line-height:1;pointer-events:none}
.result-viewer button:focus-visible{outline:2px solid #ffce85;outline-offset:2px}
.album-flight{position:absolute;pointer-events:none;z-index:1;transform-origin:center}
@keyframes result-rise{from{opacity:0;transform:translateY(12px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(max-height:700px){.result-content{padding-top:calc(env(safe-area-inset-top,0px) + 9px)}.result-stage{margin-bottom:9px;padding:10px 22px}.result-hero{height:clamp(135px,25dvh,180px);margin-bottom:33px}.result-stats{padding:12px 6px}.result-stats svg{width:21px;height:21px}.result-message{margin:10px 0}.result-collection{margin-top:8px}}
@media(prefers-reduced-motion:reduce){.result-screen.playing .result-ribbon{animation:none;opacity:1}.result-fan-card{will-change:auto}}

/* Result dial cards are placed by script (startResultDial); bottom tools (v285). */
.result-fan{overflow:visible}
.result-fan-card{transform:translateX(-50%) scale(.6);opacity:0;will-change:transform,opacity}
.result-tools{position:absolute;left:12px;right:12px;bottom:calc(env(safe-area-inset-bottom,0px) + 10px);display:flex;justify-content:space-between;align-items:center;gap:10px;z-index:5}
#win.result-screen{position:absolute}
.result-tools .result-speed{background:#0000004d;border-color:#ffffff99}
.result-tools .result-speed.active{background:#ffab13;border-color:#fff}
.result-again-show{border:2px solid #ffffff99;border-radius:14px;background:#0000004d;color:#fff;font-size:12px;font-weight:800;padding:6px 10px;cursor:pointer}

#result-fx-panel{z-index:80}

/* Transparent result-only additive fireworks; all buttons remain tappable. */
.result-fireworks{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:2}
@media(prefers-reduced-motion:reduce){.result-fireworks{display:none}}

.result-version{color:#ffe7c6b3;font-size:12px;letter-spacing:.3px}

/* No focus or tap boxes on the result screen buttons (v294). */
.result-screen button,.result-screen button:focus,.result-screen button:focus-visible,.result-screen button:active{outline:none!important;-webkit-tap-highlight-color:transparent;box-shadow:none}

/* Move only the ribbon label; the fabric and stamp animation stay anchored. */
.result-ribbon-label{display:block;transform:translateY(-10px)}
.result-fan-card{appearance:none;-webkit-appearance:none;min-width:0;cursor:zoom-in;touch-action:manipulation}

.result-ribbon .bend{display:inline-block;transform-origin:50% 60%}

/* v308: stage label, pictures and stats spread evenly from near the top; the
   message and next button keep about where they were (bottom gap ~16dvh). */
.result-content{justify-content:flex-start;padding-top:calc(env(safe-area-inset-top,0px) + 2dvh);padding-bottom:calc(env(safe-area-inset-bottom,0px) + 16dvh)}
.result-top{flex:1;min-height:0;display:flex;flex-direction:column;justify-content:space-evenly}
.result-top .result-stage{margin-bottom:0}
.result-top .result-stats{margin-bottom:2dvh}
.result-stats>div+div{border-left:0;position:relative}

/* v312 combo praise: two gradient lines (word, "Combo xN"); colours by combo level */
.complete-good{display:flex;flex-direction:column;align-items:center;gap:0;color:transparent;-webkit-text-stroke:0;text-shadow:none;font-style:italic;letter-spacing:.5px;filter:drop-shadow(0 3px 2px #0b1e4f66)}
.complete-good>span{position:relative;display:block;line-height:1.02;white-space:nowrap;padding:0 .18em;margin:0 -.18em}
.complete-good>span::before{content:attr(data-text);position:absolute;inset:0;padding:inherit;z-index:-1;color:var(--stroke);-webkit-text-stroke:.2em var(--stroke);text-shadow:0 .09em 0 var(--stroke)}
.complete-good>span{background:linear-gradient(180deg,var(--top) 18%,var(--bottom) 82%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}
.complete-good .praise-word{font-size:1em}
.complete-good .praise-combo{font-size:.58em;margin-top:.12em;--top:#fff7a8;--bottom:#ffad1f;--stroke:var(--combo-stroke,#7a3300)}
.complete-good.long .praise-word{font-size:.78em}
.complete-good.lv-1{--top:#f0ffe6;--bottom:#7fe05a;--stroke:#1f7a1f;--combo-stroke:#1f7a1f}
.complete-good.lv-2{--top:#e6fff9;--bottom:#4fe0c0;--stroke:#0b7468;--combo-stroke:#0b7468}
.complete-good.lv-3{--top:#eefaff;--bottom:#7fd2ff;--stroke:#1677b8;--combo-stroke:#1677b8}
.complete-good.lv-4{--top:#eef3ff;--bottom:#6fa4ff;--stroke:#1f3fb3;--combo-stroke:#1f3fb3}
.complete-good.lv-5{--top:#f1edff;--bottom:#9a8cff;--stroke:#3a2aa8;--combo-stroke:#3a2aa8}
.complete-good.lv-6{--top:#f8ecff;--bottom:#c27bff;--stroke:#5f1fa3;--combo-stroke:#5f1fa3}
.complete-good.lv-7{--top:#ffecfa;--bottom:#ff6fd0;--stroke:#9a1477;--combo-stroke:#9a1477}
.complete-good.lv-8{--top:#ffeaea;--bottom:#ff5a5a;--stroke:#a50f24;--combo-stroke:#a50f24}
.complete-good.lv-9{--top:#fff2e0;--bottom:#ff9a2e;--stroke:#a94300;--combo-stroke:#a94300}
.complete-good.lv-10{--top:#fff8cc;--bottom:#ffc72e;--stroke:#8f5200;--combo-stroke:#8f5200}
.complete-good.lv-11{--top:#ffffff;--bottom:#ffe066;--stroke:#7a4300;--combo-stroke:#7a4300}
.complete-good.lv-12{--top:#fff;--bottom:#ffd84a;--stroke:#3b1a7a;--combo-stroke:#3b1a7a}
.complete-good.lv-12 .praise-word{background:linear-gradient(90deg,#ff7b7b,#ffd84a,#7dff9c,#7ad7ff,#c58cff);-webkit-background-clip:text;background-clip:text}
/* v317 record line under the result numbers, and a "신기록" tag on record cells */
.result-message>span{display:block}
.result-record{color:#fff4dc;font-size:1.05em;font-weight:800;text-shadow:0 1px 2px #3a1a0c99}
.result-record b{color:#ffd54a;font-weight:900}
.result-hint{opacity:.8;font-size:.85em;margin-top:2px}
.result-stats>div{position:relative}
.result-stats>div.rec::after{content:var(--rec-label,'신기록');position:absolute;top:-10px;right:2px;padding:2px 7px 1px;border-radius:9px;background:linear-gradient(#ff8a5c,#e5484d);color:#fff;font-size:11px;font-weight:900;line-height:1.3;box-shadow:0 2px 3px #5a1a0e55;transform:rotate(6deg)}

/* Keep moving cards interactive while other result elements animate. */
.result-hero{pointer-events:none;z-index:3}
.result-fan-card{pointer-events:auto}
.result-ribbon{pointer-events:none}
.album-slide{will-change:transform}
.album-arrow{top:auto;bottom:-42px;width:42px;height:36px;transform:none;background:transparent;border:0;box-shadow:none;color:#f5d9b5;font:600 0/1 system-ui}
.album-arrow::after{content:'';display:block;width:12px;height:12px;border-top:3px solid currentColor;border-right:3px solid currentColor;border-radius:1px}
.album-prev{left:calc(50% - 80px)}.album-prev::after{transform:rotate(-135deg)}
.album-next{right:calc(50% - 80px)}.album-next::after{transform:rotate(45deg)}
/* v322 grade badge (S, A) at a result cell's bottom-right; no badge below A */
.result-grade{position:absolute;right:-2px;bottom:-22px;width:30px;height:33px;display:grid;place-items:center;clip-path:polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%);font:900 20px/1 'Maplestory',system-ui;font-style:italic;color:#fff;-webkit-text-stroke:1px #0004;filter:drop-shadow(0 2px 2px #0005);pointer-events:none}
.result-grade.grade-S{background:linear-gradient(160deg,#ffd6fb,#b46cff 45%,#5a7cff)}
.result-grade.grade-A{background:linear-gradient(160deg,#ffe6a8,#ff9f2e 50%,#e2562a)}
.result-grade::before{content:'';position:absolute;inset:3px;clip-path:inherit;border:0;background:#fff3;z-index:-1}
/* v324 record line right under the number board (hint stays above the next button) */
.result-record-line{margin:calc(-2dvh - 10px) 0 0;min-height:1.5em;font-size:clamp(12px,3.5vw,18px);line-height:1.5;text-align:center}
.result-record-line:empty{min-height:0}
.result-screen:not(.playing) .result-record-line{opacity:0}
.result-record-line+.result-message{margin-top:30px}
/* v325 album page number and arrows: bigger, on one centre line, arrows shrink while pressed */
.album-count{height:56px;margin:8px 0 0;font-size:34px;transform:translateY(9px)}
.album-count>*{display:block}
.album-arrow{bottom:-64px;width:60px;height:56px;transition:transform .12s ease-out;touch-action:manipulation}
.album-arrow::after{width:17px;height:17px;border-top-width:4px;border-right-width:4px}
.album-prev{left:calc(50% - 116px)}
.album-next{right:calc(50% - 116px)}
.album-prev::after{transform:translateX(3px) rotate(-135deg)}
.album-next::after{transform:translateX(-3px) rotate(45deg)}
.album-arrow:active{transform:scale(.82)}
/* v325 badges stamp in when their number stops: start big, shrink into place */
.result-stats>div.pending .result-grade,.result-stats>div.pending.rec::after{opacity:0}
.result-stats>div.stamped .result-grade{animation:grade-stamp .42s cubic-bezier(.25,1.35,.5,1) both}
.result-stats>div.stamped.rec::after{animation:tag-stamp .42s cubic-bezier(.25,1.35,.5,1) both}
@keyframes grade-stamp{0%{opacity:0;transform:scale(2.6)}55%{opacity:1;transform:scale(.88)}100%{opacity:1;transform:scale(1)}}
@keyframes tag-stamp{0%{opacity:0;transform:rotate(6deg) scale(2.4)}55%{opacity:1;transform:rotate(6deg) scale(.9)}100%{opacity:1;transform:rotate(6deg) scale(1)}}
/* v326 badges above the stitch overlay; record line a little lower when grade badges hang under the board; hint removed */
.result-stats>div.rec::after{z-index:3}
.result-record-line.below-grade{margin-top:calc(-2dvh - 21px)}
.result-record-line{margin-bottom:18px}
.result-record-line:not(.below-grade){margin-top:calc(-2dvh - 26px)}
.result-message:empty{display:none}
/* v328 grade patches (cat-head felt badges) centred under each number */
.result-grade{left:50%;right:auto;top:auto;bottom:-48px;width:38px;height:42px;margin-left:-19px;clip-path:none;font-size:0;color:transparent;-webkit-text-stroke:0;filter:none;z-index:-1}
.result-grade::before{display:none}
.result-grade.grade-S{background:url('assets/ui/results/grade-s.webp?v=v334') center/contain no-repeat}
.result-grade.grade-A{background:url('assets/ui/results/grade-a.webp?v=v334') center/contain no-repeat}
.result-record-line.below-grade{margin-top:calc(-2dvh + 24px)}
/* v330 round grade badge right of each cell's top icon */
.result-stats>div{overflow:visible}
/* v331 grade tabs: cloth tags hanging from the board's bottom edge, behind it, centred under each value */
.result-grade.grade-S,.result-grade.grade-A{background-size:100% 100%}
.result-grade::before{display:none}
.result-stats>div.stamped .result-grade{animation:tab-drop .5s cubic-bezier(.3,1.5,.55,1) both}
@keyframes tab-drop{0%{transform:translateY(-36px)}60%{transform:translateY(4px)}100%{transform:translateY(0)}}

/* Keep the splash artwork in one coordinate system, including its moving layers. */
.title-screen{
 position:fixed;inset:0;z-index:1000;overflow:hidden;display:grid;place-items:center;
 padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);
 background:radial-gradient(ellipse at 50% 48%,#ffe2d2 10%,#f9c9c2 76%,#f1b7b8);
 touch-action:manipulation;cursor:pointer;contain:layout paint;
}
.title-scene{
 position:relative;isolation:isolate;width:min(100%,64dvh);height:min(100%,180vw);opacity:0;will-change:transform,opacity;
}
.title-screen.title-rising .title-scene{animation:title-spring var(--title-duration,900ms) linear both}
.title-screen.title-suspended .title-scene,.title-screen.title-suspended .title-scene *{animation-play-state:paused!important}
.title-screen.title-risen .title-scene{opacity:1;transform:translate3d(0,0,0)}
@media(prefers-reduced-motion:reduce){
 .title-screen.title-rising .title-scene{animation:title-appear 140ms ease-out both}
 @keyframes title-appear{from{opacity:0}to{opacity:1}}
}
/* Restart the loops for each entrance, and begin the logo delay after landing. */
.title-screen:not(.title-rising):not(.title-risen) .title-scene *{animation-name:none}
.title-screen.title-rising .title-scene *{animation-play-state:paused}
.title-fade{position:fixed;inset:0;background:#000;opacity:0;pointer-events:none;z-index:1001}
.title-ragdoll{
 position:absolute;height:75%;width:auto;max-width:none;aspect-ratio:1;left:45%;bottom:-1%;translate:-50% 0;
 --edge-x:linear-gradient(90deg,transparent,#000 14% 86%,transparent);
 --edge-y:linear-gradient(180deg,transparent,#000 18% 94%,transparent);
 -webkit-mask-image:var(--edge-x),var(--edge-y);-webkit-mask-composite:source-in;
 mask-image:var(--edge-x),var(--edge-y);mask-composite:intersect;
}
.title-logo{
 position:absolute;z-index:2;width:81%;height:32%;object-fit:contain;
 left:50%;top:1%;translate:-50% 0;animation:title-knead var(--title-knead-cycle,3s) ease-in-out var(--title-kneadFirst,2100ms) infinite;
}
.title-cards{position:absolute;inset:0;pointer-events:none}
.title-cards img{position:absolute;display:block;height:auto;translate:-50% -50%;pointer-events:none}
.title-swirl{width:96%;left:50%;top:47%;opacity:.8;animation:title-swirl var(--title-swirl,4s) ease-in-out infinite alternate}
.title-card{
 --pitch:0deg;--yaw:0deg;
 transform:perspective(650px) rotateY(var(--yaw)) rotateX(var(--pitch));
 box-shadow:0 2px 0 #ae785ba6,0 4px 3px #9c5d4448;animation:title-float var(--title-float,2s) ease-in-out infinite alternate}
.title-fragment{position:absolute;translate:-50% -50%;width:19%;border:2px solid #f5e4c7;border-radius:8%;overflow:hidden;aspect-ratio:1}
.title-fragment.f2{aspect-ratio:438/437}
.title-fragment.f3{aspect-ratio:437/460}
.title-fragment.f4{aspect-ratio:438/460}
.title-cards .title-fragment img{position:absolute;left:50%;top:50%;width:112%;height:112%;object-fit:fill}
.title-fragment.f1{left:22%;top:39%;--pitch:26deg;--yaw:-21deg;rotate:-13deg}
.title-fragment.f2{left:84%;top:42%;--pitch:21deg;--yaw:29deg;rotate:17deg;animation-delay:-1s}
.title-fragment.f3{left:22%;top:54%;--pitch:31deg;--yaw:-16deg;rotate:10deg;animation-delay:-.7s}
.title-fragment.f4{left:86%;top:56%;--pitch:27deg;--yaw:20deg;rotate:-15deg;animation-delay:-1.6s}
.title-back{width:12%;box-shadow:none}
.title-back.b1{left:8%;top:49%;--pitch:14deg;--yaw:-41deg;rotate:-20deg;animation-delay:-.4s}
.title-back.b2{left:62%;top:37%;width:14%;--pitch:17deg;--yaw:39deg;rotate:105deg;animation-delay:-1.3s}
.title-back.b3{left:86%;top:75%;width:15%;--pitch:-24deg;--yaw:34deg;rotate:-25deg;animation-delay:-1.7s}
.title-complete{box-shadow:none;position:absolute;translate:-50% -50%;width:49%;aspect-ratio:3/2;left:52%;top:47.5%;rotate:4deg;animation-delay:-.8s}
.title-complete img{width:100%;left:50%;top:50%}
.title-photo{clip-path:inset(16.8% 18% 14.7% 18% round 6%)}
.title-rays-left{clip-path:inset(32% 82% 36% 8%);animation:title-ray-left 1.4s ease-in-out infinite alternate}
.title-rays-right{clip-path:inset(32% 8% 36% 82%);animation:title-ray-right 1.4s ease-in-out infinite alternate}
@keyframes title-ray-left{from{transform:translateX(1%)}to{transform:translateX(-3%)}}
@keyframes title-ray-right{from{transform:translateX(-1%)}to{transform:translateX(3%)}}
@media(prefers-reduced-motion:reduce){.title-rays{animation:none}}
@keyframes title-knead{0%,70%,100%{transform:scale(1)}78%{transform:scale(.94,.91)}86%{transform:scale(1.035,1.045)}93%{transform:scale(.99)}}
@keyframes title-float{from{transform:translate(-3%,-3%) perspective(650px) rotateY(calc(var(--yaw) - 5deg)) rotateX(calc(var(--pitch) - 3deg))}to{transform:translate(3%,4%) perspective(650px) rotateY(calc(var(--yaw) + 5deg)) rotateX(calc(var(--pitch) + 3deg))}}
@keyframes title-swirl{from{transform:rotate(-5deg)}to{transform:rotate(8deg)}}
@media(prefers-reduced-motion:reduce){.title-logo,.title-cards,.title-card,.title-swirl{animation:none}}

.title-screen,.title-screen *{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
.title-screen img{-webkit-user-drag:none}
.title-start{position:absolute;inset:0;width:100%;height:100%;background:transparent;border:0;cursor:pointer}
.title-scene{pointer-events:none}
.title-tools{position:absolute;bottom:max(8px,env(safe-area-inset-bottom));left:max(10px,env(safe-area-inset-left));right:max(10px,env(safe-area-inset-right));display:flex;justify-content:space-between;pointer-events:none}
.title-tools[hidden]{display:none}
.title-tools button,.title-editor-actions button{pointer-events:auto;min-height:44px;padding:6px 13px;color:#fff5e8;background:#754a42;border:1px solid #ffe5d4;border-radius:16px;font-size:13px;line-height:1.2;font-family:inherit;font-weight:700;cursor:pointer}
.title-tools .title-speed[aria-pressed=true]{background:#9a453d}
.title-editor{width:min(360px,calc(100vw - 32px));max-height:85dvh;overflow:auto;padding:18px;color:#603e36;background:#fff2e5;border:2px solid #b78773;border-radius:20px;cursor:auto}
.title-editor::backdrop{background:#38201c80}
.title-editor h2{margin:0 0 14px;font-size:20px}
.title-editor .dev-row input{user-select:text;-webkit-user-select:text}
.title-editor-actions{display:flex;gap:4px;justify-content:space-between;margin-top:10px}
.title-editor-actions button{padding-inline:8px}

.title-prompt{position:absolute;left:0;right:0;bottom:calc(max(8px,env(safe-area-inset-bottom)) + 55px);text-align:center;pointer-events:none;opacity:0}
.title-screen.title-rising .title-prompt,.title-screen.title-risen .title-prompt{opacity:1}
.title-prompt span{display:inline-block;color:#fff4dc;-webkit-text-stroke:3px #663329;paint-order:stroke fill;font-size:clamp(18px,4.5vw,25px);font-weight:900;line-height:1.35;animation:title-knead var(--title-knead-cycle,3s) ease-in-out var(--title-kneadFirst,2100ms) infinite}
.title-screen:not(.title-rising):not(.title-risen) .title-prompt span{animation-name:none}
.title-screen.title-rising .title-prompt span,.title-screen.title-suspended .title-prompt span{animation-play-state:paused}
@media(prefers-reduced-motion:reduce){.title-prompt span{animation:none}}
/* v386: Traditional Chinese (Huninn, thin and only five characters) reads larger on the title */
html:lang(zh) .title-prompt span{font-size:clamp(23px,6vw,32px);letter-spacing:.06em}
