* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

:root {
    --bg-dark: #0d0f12;
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
    --text-white: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.65);
    --btn-back-active: rgba(255, 255, 255, 0.25);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Telegram's content insets are additional to the device's safe area. */
:root[data-telegram-fullscreen] {
    --app-safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
    --app-safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
    --app-safe-left: max(env(safe-area-inset-left, 0px), calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px)));
    --app-safe-right: max(env(safe-area-inset-right, 0px), calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px)));
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--app-backdrop, var(--bg-dark));
    font-family: var(--font-family);
    color: var(--text-white);
    position: fixed;
}

#snow-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    filter: blur(1px);
}

#app-container {
    width: 100%;
    height: var(--tg-viewport-stable-height, 100%);
    max-height: 100%;
    position: relative;
    overflow: hidden;
    container: mini-app / size;
}

/* Cover the whole WebView in fullscreen; pad the screen's content, not the artwork. */
:root[data-telegram-fullscreen] #app-container { height: 100%; }

/* Screens */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Snow-globe welcome */
#loading-screen {
    --theme-top: #080415;
    --theme-base: #100824;
    isolation: isolate;
    align-items: center;
    overflow: hidden;
    background: #080415;
    z-index: 100;
}

#loading-screen::before {
    position: absolute;
    inset: -24px;
    content: '';
    background: linear-gradient(#08041680, #13082d55), var(--intro-art) center top / cover;
    filter: blur(24px);
}

.intro-artboard {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(56.25cqh, 100cqw, 62cqh);
    aspect-ratio: 941 / 1672;
    transform: translate(-50%, -50%);
    background: var(--intro-art) center / 100% 100%;
    pointer-events: none;
}

@container mini-app (min-aspect-ratio: 31/50) {
    .intro-artboard {
        mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    }
}

.loader-content {
    position: relative;
    display: grid;
    grid-template-rows: 28cqh minmax(0, 1fr) auto;
    justify-items: center;
    width: min(100%, 498px);
    height: 100%;
    padding-block: var(--app-safe-top) max(clamp(8px, 7cqh, 64px), var(--app-safe-bottom));
    padding-inline: max(12px, var(--app-safe-left)) max(12px, var(--app-safe-right));
    gap: clamp(5px, 1.65cqh, 14px);
    text-align: center;
    text-shadow: 0 2px 8px #100524, 0 0 20px #100524;
}

.intro-copy {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: clamp(4px, 1.25cqh, 12px);
}

.intro-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: clamp(12px, 4vw, 16px);
    font-weight: 650;
    color: #f1e7ff;
}

.intro-brand > span:first-child {
    font-size: 1.26em;
    color: #bd85ff;
    text-shadow: 0 0 14px #9851ff;
}

.intro-brand-name:empty::before { content: 'Итоги года'; }

.loader-title {
    max-width: 12ch;
    margin-inline: auto;
    color: #faf5ff;
    font-size: clamp(19px, min(10vw, 6.5cqh), 51px);
    font-weight: 900;
    line-height: 0.97;
    letter-spacing: -0.055em;
    text-wrap: balance;
}

.loader-title em {
    color: #c08bff;
    font-style: normal;
}

.intro-heading p {
    margin-top: 8px;
    color: #d2bae9;
    font-size: clamp(12px, 4vw, 16px);
}

.globe-button {
    display: grid;
    align-items: end;
    justify-items: center;
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    touch-action: none;
    -webkit-touch-callout: none;
}

.globe-button:focus-visible { outline: none; }
.globe-button:focus-visible .globe-sensor { outline: 2px solid #f2e5ff; outline-offset: 5px; }
.globe-button:disabled { cursor: default; }

/* Live artwork reuses the background so only the masked globe region moves. */
.globe-visual {
    position: absolute;
    inset: 0;
    opacity: 0;
    mask-image: radial-gradient(ellipse 54% 27% at 50% 51%, #000 75%, transparent 100%);
    transition: opacity 180ms ease;
}

.globe-animated {
    position: absolute;
    inset: 0;
    background: var(--intro-art) center / 100% 100%;
    transform-origin: 50% 52%;
}

.globe-sensor {
    display: grid;
    place-items: center;
    width: clamp(42px, 11cqh, 76px);
    aspect-ratio: 1;
    border: 1px solid #e1c2ff;
    border-radius: 50%;
    color: #fbf6ff;
    background: radial-gradient(circle at 36% 25%, #d4a7ff, #7737d9 55%, #3a167e);
    box-shadow: 0 0 0 5px #9960e333, 0 0 0 11px #9960e31a, 0 0 22px #a467fb9e,
        inset 0 0 10px #f1deff7d;
}

.globe-sensor svg { width: 56%; height: auto; }

#loading-screen[data-hold="holding"] .globe-sensor,
#loading-screen[data-hold="lit"] .globe-sensor {
    box-shadow: 0 0 0 5px #bf85ff66, 0 0 0 11px #bf85ff33, 0 0 28px #c584ffd9,
        inset 0 0 14px #fff9;
}

#loading-screen[data-hold="lit"] .globe-visual { opacity: 1; }
#loading-screen[data-hold="lit"] .globe-animated { filter: brightness(1.16) saturate(1.1); }

@media (prefers-reduced-motion: no-preference) {
    #loading-screen[data-hold="holding"] .globe-visual { opacity: 1; }
    #loading-screen[data-hold="holding"] .globe-animated {
        animation: globe-shake 270ms ease-in-out infinite;
    }
}

@keyframes globe-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-3px) rotate(-1.8deg); }
    75% { transform: translateX(3px) rotate(1.8deg); }
}

.globe-flakes {
    position: absolute;
    inset: 36% 21% 32% 21%;
    overflow: clip;
    border-radius: 50%;
    pointer-events: none;
}

.globe-flakes i {
    position: absolute;
    top: 80%;
    left: var(--flake-left);
    width: var(--flake-size);
    height: var(--flake-size);
    border-radius: 50%;
    background: #f7efff;
    box-shadow: 0 0 6px #d3b1ff;
    animation: globe-snowfall 950ms var(--flake-delay) both ease-out;
}

@keyframes globe-snowfall {
    0% { opacity: 0; transform: translate(0, 0); }
    16% { opacity: 1; }
    48% { transform: translate(var(--flake-drift), var(--flake-rise)); }
    100% { opacity: 0; transform: translate(var(--flake-drift), 38px); }
}

.intro-controls {
    display: grid;
    justify-items: center;
    gap: 6px;
    color: #f6eaff;
}

.intro-hint {
    font-size: clamp(14px, 4vw, 18px);
    font-weight: 750;
}

.intro-hold-track {
    width: clamp(54px, 18vw, 92px);
    height: 4px;
    border-radius: 4px;
    overflow: hidden;
    background: #241044a6;
    box-shadow: 0 0 0 1px #e0c9ff66;
}

.intro-hold-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #e1b7ff;
}

#loading-screen[data-hold="holding"] .intro-hold-track span {
    animation: intro-hold-fill var(--hold-duration) linear both;
}

#loading-screen[data-hold="lit"] .intro-hold-track span { width: 100%; }
@keyframes intro-hold-fill { to { width: 100%; } }

.intro-confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.intro-confetti i {
    position: absolute;
    left: 50%;
    top: 55%;
    width: 5px;
    height: 9px;
    border-radius: 2px;
    background: var(--confetti-color);
    opacity: 0;
    animation: intro-confetti-pop 600ms var(--confetti-delay) ease-out both;
}

@keyframes intro-confetti-pop {
    10% { opacity: 1; }
    66% { opacity: 1; }
    100% { transform: translate(var(--confetti-x), var(--confetti-y)) rotate(var(--confetti-spin)); }
}

.loader-subtitle { font-size: 12px; color: #f0deff; }

.intro-retry {
    border: 1px solid #9062bc;
    border-radius: 999px;
    padding: 8px 14px;
    background: #281748;
    color: #fff;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

@container mini-app (max-height: 540px) {
    .intro-artboard { width: clamp(56.25cqh, 100cqw, 58cqh); }
    .loader-content { padding-bottom: max(8px, var(--app-safe-bottom)); }
    .loader-title { max-width: 20ch; }
    .intro-heading p { margin-top: 4px; }
    .intro-controls { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .globe-visual { transition: none; }
    .globe-flakes, .intro-confetti { display: none; }
    #loading-screen[data-hold="holding"] .intro-hold-track span { animation: none; width: 50%; }
}

/* Story Screen */
#story-screen {
    --theme-top: #170d39;
    --theme-base: #170d39;
    --story-width: min(100%, 408px);
    background:
        linear-gradient(180deg, #0b041f66, #0b041f18 46%, #0c042599 100%),
        var(--viewer-art, none) center 78% / cover var(--theme-base);
}

#summary-screen {
    --summary-width: min(336px, 78vw);
}

#summary-screen {
    background:
        radial-gradient(ellipse at 50% 44%, transparent, rgba(6, 4, 16, 0.93) 82%),
        linear-gradient(150deg, var(--theme-top, #3043b8), var(--theme-base, #111640) 70%, #080510);
}

#story-screen,
#summary-screen {
    --viewport-unit: 1vh;
    --card-gap: clamp(6px, calc(1.6 * var(--viewport-unit)), 14px);
    --card-padding: clamp(12px, calc(2.4 * var(--viewport-unit)), 20px);
    gap: var(--card-gap);
    padding-block: max(8px, var(--app-safe-top)) max(8px, var(--app-safe-bottom));
}

@supports (height: 1cqh) {
    #story-screen,
    #summary-screen {
        --viewport-unit: 1cqh;
    }
}

#story-screen.active,
#summary-screen.active {
    display: grid;
    justify-content: stretch;
    grid-template-columns: minmax(0, 1fr);
    margin-block: auto;
}

#story-screen.active {
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-block-start: max(
        var(--app-safe-top), clamp(12px, calc(3 * var(--viewport-unit)), 24px)
    );
    padding-inline: max(12px, var(--app-safe-left)) max(12px, var(--app-safe-right));
}

.story-progress-wrapper {
    display: flex;
    gap: 3px;
    width: var(--story-width);
    justify-self: center;
    z-index: 20;
}

.progress-track {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    position: relative;
    width: 0%;
    height: 100%;
    background: #ffffff;
    border-radius: 999px;
}

.progress-sparks { display: none; }

@media (prefers-reduced-motion: no-preference) {
    .progress-track.is-current {
        position: relative;
        z-index: 1;
        overflow: visible;
    }

    .is-current .progress-fill {
        box-shadow: 0 0 5px rgba(255, 217, 153, 0.42);
    }

    .is-current .progress-sparks {
        position: absolute;
        display: block;
        top: 50%;
        left: 100%;
        width: 0;
        height: 0;
        pointer-events: none;
    }

    .progress-sparks::before {
        content: '';
        position: absolute;
        inset: -2px;
        border-radius: 50%;
        background: #fff7dc;
        box-shadow: 0 0 5px 1px #fff1bd, 0 0 10px 2px rgba(255, 177, 73, 0.75);
    }

    .progress-sparks i {
        position: absolute;
        top: -1px;
        left: -1px;
        width: 2px;
        height: 2px;
        border-radius: 50%;
        background: #fff2c2;
        box-shadow: 0 0 4px #ffca74;
        animation: progress-spark-flight var(--flight-time, 620ms) var(--spark-delay, 0ms) infinite ease-out;
    }

    .progress-sparks i:nth-child(1) { --spark-x: -13px; --spark-y: -10px; }
    .progress-sparks i:nth-child(2) { --spark-x: 9px; --spark-y: -13px; --spark-delay: -280ms; }
    .progress-sparks i:nth-child(3) { --spark-x: 13px; --spark-y: 5px; --spark-delay: -190ms; --flight-time: 530ms; }
    .progress-sparks i:nth-child(4) { --spark-x: -8px; --spark-y: 9px; --spark-delay: -480ms; }
    .progress-sparks i:nth-child(5) { --spark-x: -3px; --spark-y: -15px; --spark-delay: -410ms; --flight-time: 710ms; }
    .progress-sparks i:nth-child(6) { --spark-x: 5px; --spark-y: 13px; --spark-delay: -90ms; --flight-time: 680ms; }

    .story-progress-wrapper.is-paused .progress-sparks i { animation-play-state: paused; }
}

@keyframes progress-spark-flight {
    0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
    15% { opacity: 1; }
    100% { transform: translate(var(--spark-x), var(--spark-y)) scale(0.25); opacity: 0; }
}

/* Viewer content sits directly on the themed screen, without a card surface. */
.story-card,
.frozen-card {
    display: grid;
    justify-self: center;
    align-self: center;
    width: var(--story-width);
    height: min(100%, 660px);
    min-height: 0;
    padding: clamp(4px, 2cqh, 16px) min(3vw, 12px);
    gap: var(--card-gap);
    text-align: center;
}

.story-card { grid-template-rows: minmax(0, 1fr) auto; }

.story-result {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: var(--card-gap);
    min-height: 0;
}

#viewer-brand {
    justify-self: center;
    color: #d9e3fb;
    font-size: clamp(11px, 3vw, 13px);
}

[data-theme="gradient-blue"], .gradient-blue {
    --theme-top: #3043b8;
    --theme-glow: #4d6df4;
    --theme-base: #111640;
}

[data-theme="gradient-deep-blue"], .gradient-deep-blue {
    --theme-top: #1962a6;
    --theme-glow: #4ca5e8;
    --theme-base: #0a2f62;
}

[data-theme="gradient-purple"], .gradient-purple {
    --theme-top: #6738a2;
    --theme-glow: #a673e5;
    --theme-base: #28133f;
}

[data-theme="gradient-premium"], .gradient-premium {
    --theme-top: #7150d2;
    --theme-base: #321878;
    --theme-glow: #a892ff;
}

[data-theme="gradient-gold"], .gradient-gold {
    --theme-top: #9b5518;
    --theme-glow: #d6983c;
    --theme-base: #3b210b;
}

[data-theme="gradient-teal"], .gradient-teal {
    --theme-top: #167b83;
    --theme-glow: #3bb4b5;
    --theme-base: #0c333c;
}

[data-theme="gradient-indigo"], .gradient-indigo {
    --theme-top: #4145a7;
    --theme-glow: #706aea;
    --theme-base: #21194d;
}

[data-theme="gradient-crimson"], .gradient-crimson {
    --theme-top: #8f3157;
    --theme-glow: #d96894;
    --theme-base: #41152f;
}

[data-theme="gradient-ruby"], .gradient-ruby {
    --theme-top: #96394a;
    --theme-glow: #dc6c78;
    --theme-base: #451a2b;
}

/* Animated Elements Transitions */
.story-header {
    text-align: center;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.45s ease;
}

.story-card.anim-active .story-header {
    transform: translateY(0);
    opacity: 1;
}

.story-title {
    font-size: clamp(20px, 6.1vw, 26px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.3px;
    color: #ffffff;
}

.story-subtitle {
    font-size: clamp(13px, 4vw, 16px);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.72);
    margin-top: 8px;
    line-height: 1.35;
    max-width: 290px;
}

/* Size every sticker against its available row. */
.story-character-wrapper {
    display: grid;
    place-items: center;
    min-height: 0;
    container-type: size;
}

.sticker-box {
    --sticker-size: min(50vw, 218px);
    width: var(--sticker-size);
    height: var(--sticker-size);
    display: grid;
    place-items: center;
    font-size: calc(var(--sticker-size) * 0.56);
    line-height: 1;
    visibility: hidden;
}

.sticker-box.is-ready {
    visibility: visible;
}

@media (prefers-reduced-motion: no-preference) {
    .story-card .sticker-box.is-ready,
    .frozen-card .sticker-box.is-ready,
    .swiper-slide-active .sticker-box.is-ready {
        animation: sticker-appear 420ms cubic-bezier(0.2, 0.75, 0.3, 1) both;
    }
}

@keyframes sticker-appear {
    0% { opacity: 0; transform: translateY(10px) scale(0.78); }
    72% { opacity: 1; transform: translateY(0) scale(1.04); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Metric Slot Machine Container */
.story-metric-wrapper {
    text-align: center;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) 0.1s, opacity 0.45s ease 0.1s;
}

.story-card.anim-active .story-metric-wrapper {
    transform: translateY(0);
    opacity: 1;
}

.metric-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 500;
    margin-bottom: 6px;
}

.story-metric-wrapper.is-message .metric-label {
    margin: 0;
    color: #fff;
    font-size: clamp(15px, min(5.5vw, 5cqh), 23px);
    font-weight: 800;
}

.drum-metric-container[hidden],
.summary-metric-value:empty { display: none; }

/* The reel and its translation share one responsive row height. */
.drum-metric-container {
    --drum-row: clamp(42px, calc(11 * var(--viewport-unit)), 72px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    font-weight: 900;
    font-size: clamp(36px, 11vw, 59px);
    color: #fff;
    text-shadow: 0 0 18px var(--theme-base, #28133f);
}

.drum-roller {
    display: inline-flex;
    align-items: center;
    height: var(--drum-row);
    overflow: hidden;
    letter-spacing: -0.045em;
}

.drum-digit-reel {
    display: inline-flex;
    flex-direction: column;
    height: var(--drum-row);
    line-height: var(--drum-row);
    transition: transform 1.2s cubic-bezier(0.12, 0.85, 0.2, 1);
}

.drum-digit {
    text-align: center;
    flex: 0 0 var(--drum-row);
    min-width: 0.6em;
}

.drum-char {
    display: inline-block;
    height: var(--drum-row);
    line-height: var(--drum-row);
    margin: 0 1px;
}

.story-result .story-subtitle { margin-inline: auto; }
.story-result .metric-suffix { color: #e2eaff; }

/* Story navigation (separate from the carousel controls). */
.story-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    transform: translateY(15px);
    opacity: 0;
    transition: transform 0.45s ease 0.15s, opacity 0.45s ease 0.15s;
}

.story-actions .btn {
    min-height: clamp(44px, calc(8 * var(--viewport-unit, 1vh)), 52px);
    height: auto;
    padding: 6px 10px;
    font-size: clamp(14px, 4vw, 16px);
}

.story-actions .btn[hidden] {
    display: none;
}

.story-card.anim-active .story-actions {
    transform: translateY(0);
    opacity: 1;
}

.btn {
    border: none;
    outline: none;
    border-radius: 999px;
    height: 50px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn-story-back {
    border: 1px solid rgba(222, 157, 255, 0.38);
    background: rgba(47, 21, 79, 0.48);
    color: #e2b9ff;
    font-weight: 600;
}

.btn-story-back:active {
    background: var(--btn-back-active);
}

.btn-story-next,
.btn-primary-gradient {
    border: 1px solid rgba(224, 191, 255, 0.66);
    background: linear-gradient(140deg, #f9efff, #cba5ff);
    color: #21103c;
}

/* Footer Tag */
.story-branding-footer {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
    letter-spacing: -0.1px;
}

/* Summary Screen & Carousel */
#summary-screen.active {
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    padding-inline: var(--app-safe-left) var(--app-safe-right);
    padding-block-start: max(
        var(--app-safe-top), clamp(12px, calc(4 * var(--viewport-unit)), 26px)
    );
}

.summary-top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 20;
}

.summary-arrow {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font: 22px/1 var(--font-family);
    cursor: pointer;
}

.summary-arrow:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.summary-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.summary-pill-badge {
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.4px;
}

/* Swiper styling */
.summary-swiper {
    width: min(100%, 464px);
    min-height: 0;
    justify-self: center;
}

.summary-slide {
    display: grid;
    align-items: center;
    width: var(--summary-width);
    height: 100%;
    min-height: 0;
    padding-block: 4px;
}

.result-card {
    --card-accent: var(--theme-glow, #a673e5);
    --card-highlight: #faf4ff;
    position: relative;
    isolation: isolate;
    width: 100%;
    min-height: 0;
    border: 1px solid rgba(222, 157, 255, 0.56);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(11, 4, 31, 0.16), transparent 49%, rgba(12, 4, 37, 0.55) 74%, rgba(12, 4, 37, 0.72)),
        var(--result-card-art, none) center / cover #170d39;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--card-gap);
    padding: var(--card-padding);
    overflow: clip;
    box-shadow: 0 16px 36px rgba(3, 1, 11, 0.72), inset 0 0 18px rgba(178, 100, 255, 0.22);
}

.summary-card-slide {
    height: min(100%, 488px);
    opacity: 0.55;
    transform: scale(0.95);
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.result-card-kicker,
.result-card-number {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    white-space: nowrap;
}

.result-card-kicker {
    font-size: 11px;
    font-weight: 650;
    color: #eadbfa;
}

.result-card-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.result-card-brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-card-brand-name:empty::before { content: 'Итоги года'; }

.result-card-spark {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #422381;
    color: #f3d6ff;
    box-shadow: 0 0 10px rgba(182, 105, 255, 0.42);
}

.result-card-number {
    font-size: 9px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: #d7bdf7;
}

.result-card-progress {
    width: clamp(18px, 10vw, 48px);
    height: 3px;
    border-radius: 10px;
    background: rgba(219, 193, 255, 0.22);
}

.result-card-progress::before {
    content: '';
    display: block;
    width: var(--card-progress, 0%);
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #9b4bfc, #f1a0ff);
}

.result-card > * {
    flex-shrink: 0;
    max-width: 100%;
}

.swiper-slide-prev .summary-card-slide,
.swiper-slide-next .summary-card-slide {
    opacity: 0.72;
    cursor: pointer;
}

.swiper-slide-active .summary-card-slide {
    opacity: 1;
    transform: none;
}

.result-card .story-header { text-align: left; }
.result-card .story-metric-wrapper { text-align: center; }

.summary-card-slide .story-header,
.summary-card-slide .story-metric-wrapper {
    opacity: 1;
    transform: none;
}

.result-card .story-title {
    max-width: 16ch;
    color: var(--card-highlight);
    font-size: clamp(22px, 7vw, 32px);
    font-weight: 900;
    line-height: 0.99;
    letter-spacing: -0.045em;
}

.result-title-accent { color: #da9bff; }

.result-card .story-subtitle,
.result-card .metric-label {
    color: #dbc7e9;
    font-size: clamp(11px, 3.4vw, 13px);
    line-height: 1.22;
}

.result-card .story-subtitle { margin-top: 6px; }

/* Measure the sticker against its own row, after text and controls are laid out. */
.result-card .story-character-wrapper {
    align-self: stretch;
    width: 100%;
    flex: 1 1 0;
}

#story-screen .sticker-box {
    --sticker-size: min(100cqh, 50vw, var(--story-sticker-limit, 218px));
}

.summary-slide .sticker-box {
    --sticker-size: min(100cqh, 50vw, var(--summary-sticker-limit, 191px));
}

.result-card-stage {
    position: relative;
    isolation: isolate;
}

.result-card-stage::after {
    content: '';
    position: absolute;
    z-index: -1;
    pointer-events: none;
    width: min(94%, 154cqh);
    height: 35%;
    border: 1px solid var(--card-accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--card-accent), inset 0 0 8px var(--card-accent);
    transform: rotate(-17deg);
    opacity: 0.8;
}

.result-card-stage-spark {
    position: absolute;
    right: 8%;
    top: 12%;
    color: #e8c9ff;
    font-size: 18px;
    text-shadow: 0 0 8px var(--card-accent);
}

.summary-metric-value {
    color: var(--card-highlight);
    font-size: clamp(36px, 11vw, 59px);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.06em;
    line-height: 0.96;
    text-shadow: 0 0 18px var(--theme-base, #28133f);
}

.metric-suffix,
.summary-metric-suffix {
    color: #e2a7ff;
    font-size: clamp(15px, 5.2vw, 23px);
    font-weight: 800;
    line-height: 1.08;
    overflow-wrap: anywhere;
}

.metric-suffix:empty,
.summary-metric-suffix:empty { display: none; }

.result-card .story-branding-footer {
    border-top: 1px solid rgba(225, 193, 255, 0.2);
    padding-top: 5px;
    min-height: 0;
    color: #d4bee6;
    text-align: center;
    font-size: 10px;
}

/* Keep the expanded layout from crowding short Telegram windows. */
@container mini-app (max-height: 460px) {
    #story-screen.active {
        --story-sticker-limit: 96px;
        --card-gap: 6px;
        padding-block-start: max(var(--app-safe-top), 12px);
        gap: 10px;
    }

    #summary-screen {
        --summary-sticker-limit: 72px;
        --card-gap: 5px;
        --card-padding: 8px;
    }

    .story-card .story-title,
    .swiper-slide .story-title { max-width: none; font-size: 19px; }

    .result-card-spark { width: 14px; height: 14px; }
    .result-card .metric-label { margin-bottom: 4px; }

    .story-card .story-subtitle,
    .swiper-slide .story-subtitle,
    .swiper-slide .metric-label { font-size: 12px; }

    .drum-metric-container { --drum-row: 36px; font-size: 32px; }
    .swiper-slide .summary-metric-value { font-size: 30px; }
    .swiper-slide .summary-metric-suffix { font-size: 14px; }
    .swiper-slide .result-card-kicker { font-size: 10px; }
}

@container mini-app (max-height: 350px) {
    .story-card .story-subtitle { margin-top: 4px; }
    .story-card .metric-label { font-size: 12px; }
    .story-card .metric-suffix { font-size: 16px; }
    .story-actions { gap: 6px; }
    .story-card, .frozen-card { padding-block: 2px; gap: 4px; }
    .story-result { gap: 4px; }

    .story-result .story-title { font-size: 17px; }
    .drum-metric-container { --drum-row: 29px; font-size: 26px; }

    #summary-screen.active {
        --card-gap: 4px;
        --card-padding: 8px;
        padding-block-start: max(var(--app-safe-top), 8px);
    }

    .summary-pill-badge { padding-block: 4px; }
    .summary-slide { padding-block: 2px; }
    .swiper-slide .story-title { font-size: 17px; }
    .swiper-slide .result-card-kicker { display: none; }
    .swiper-slide .summary-metric-value { font-size: 25px; }
    .swiper-slide .summary-metric-suffix { font-size: 13px; }
    .summary-action-panel { gap: 4px; }
    .summary-action-panel .btn { height: 44px; }
    .btn-restart-link { padding-block: 4px; }
}

/* Bottom Action Bar */
.summary-action-panel {
    width: var(--summary-width);
    justify-self: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

.btn-primary-gradient {
    flex-shrink: 0;
    gap: 8px;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.16), 0 4px 22px rgba(9, 2, 22, 0.54);
}

.share-plane { width: 19px; height: 19px; flex-shrink: 0; }

.btn-primary-gradient:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* Native modal gives the sheet an inert background and a keyboard focus trap. */
.share-sheet {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: transparent;
    color: #102039;
}

.share-sheet[open] { display: block; }

.share-sheet::backdrop {
    background: #080f2588;
    opacity: 0;
    transition: opacity 280ms ease;
}

.share-sheet.is-visible::backdrop { opacity: 1; }

.share-sheet-dismiss {
    position: absolute;
    inset: 0 auto auto 0;
    padding: 0;
    border: 0;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
}

.share-sheet-panel {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    margin-inline: auto;
    display: grid;
    gap: 13px;
    width: min(100%, 470px);
    max-height: calc(100% - max(8px, var(--app-safe-top)));
    padding: 10px max(14px, var(--app-safe-right)) max(12px, var(--app-safe-bottom)) max(14px, var(--app-safe-left));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 28px 28px 0 0;
    background: #fff;
    box-shadow: 0 -12px 40px #0b15352b;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.share-sheet.is-visible .share-sheet-panel { transform: translateY(var(--share-sheet-offset, 0px)); }
.share-sheet-panel.is-dragging { transition: none; }

.share-sheet-grabber {
    width: 45px;
    height: 5px;
    border-radius: 999px;
    background: #cfd7e3;
    margin: 0 auto 18px;
}

.share-sheet-heading {
    touch-action: none;
    text-align: center;
    margin-block: 0 5px;
    cursor: grab;
}

.share-sheet-panel.is-dragging .share-sheet-heading { cursor: grabbing; }
.share-sheet-heading h2 { font-size: clamp(20px, 5.8vw, 27px); letter-spacing: -0.035em; line-height: 1.13; }
.share-sheet-heading p { margin-top: 6px; color: #4c607b; font-size: clamp(13px, 3.65vw, 16px); }

.share-sheet-options { border-radius: 22px; background: #f0f5fa; overflow: hidden; }

.share-sheet-option {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 63px;
    padding: 8px 14px;
    border: 0;
    background: transparent;
    color: #102039;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.share-sheet-option + .share-sheet-option::before {
    content: '';
    position: absolute;
    top: 0;
    inset-inline: 68px 14px;
    border-top: 1px solid #dce5ef;
}

.share-sheet-option::after {
    content: '';
    width: 7px;
    height: 7px;
    margin-inline: 4px;
    border-top: 2px solid #8294a9;
    border-right: 2px solid #8294a9;
    transform: rotate(45deg);
}

.share-sheet-option:disabled { opacity: 0.55; cursor: wait; }
.share-sheet-option:active:not(:disabled) { background: #e5edf7; }
.share-sheet-option strong { display: block; font-size: clamp(13px, 3.7vw, 17px); font-weight: 700; }
.share-sheet-option small { display: block; margin-top: 3px; color: #4c607b; font-size: clamp(11px, 3.2vw, 14px); }

.share-sheet-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
}

.share-sheet-icon svg { width: 24px; height: 24px; }
.share-sheet-icon--story { color: #087ac9; background: #dfeefa; }
.share-sheet-icon--channel { color: #b66500; background: #fff0d6; }
.share-sheet-icon--chat { color: #138649; background: #d9f3e4; }

.share-sheet-status { text-align: center; font-size: 13px; color: #4c607b; }
.share-sheet-status:empty { display: none; }

.share-sheet-secondary {
    border: 0;
    background: none;
    color: #005fc7;
    font: inherit;
    font-size: 13px;
    font-weight: 630;
    text-align: center;
    cursor: pointer;
    padding: 6px 8px;
    justify-self: center;
    text-underline-offset: 3px;
}
.share-sheet :focus-visible { outline: 2px solid #0869ce; outline-offset: -3px; }

@media (max-height: 465px) {
    .share-sheet-panel { gap: 7px; }
    .share-sheet-grabber { margin-bottom: 10px; }
    .share-sheet-option { min-height: 49px; padding-block: 5px; }
    .share-sheet-icon { height: 34px; width: 34px; }
}

@media (prefers-reduced-motion: reduce) {
    .share-sheet::backdrop, .share-sheet-panel { transition: none; }
}

.btn-restart-link {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    padding: 6px 0;
}

.btn-restart-link:hover {
    color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
    .story-card .story-header,
    .story-card .story-metric-wrapper,
    .story-card .story-actions,
    .summary-card-slide {
        transition: none;
    }
}

/* The untimed interlude shares the viewer's progress row, not its timer. */
.story-card[hidden],
.frozen-card[hidden] { display: none; }

.progress-track.is-frozen {
    background: #80e6ff;
    box-shadow: 0 0 7px #77dcff, 0 0 14px #447cfa;
}

.progress-track.is-frozen.is-current .progress-fill { width: 100%; background: #e3fbff; }
.is-frozen .progress-fill .progress-sparks { display: none; }

.frozen-card { grid-template-rows: auto minmax(0, 1fr) auto; }

.frozen-kicker {
    color: #a1e5ff;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.frozen-card h1 { font-size: clamp(19px, 6vw, 30px); line-height: 1.05; }
.frozen-card h1:focus { outline: none; }
#frozen-description { color: #d0efff; font-size: clamp(12px, 3.5vw, 15px); margin-top: 6px; }

.frozen-actions { display: grid; gap: 6px; }
.frozen-actions .btn { height: clamp(40px, calc(8 * var(--viewport-unit)), 50px); font-size: clamp(13px, 4vw, 16px); }
#frozen-share { background: #86dbff26; border: 1px solid #a9e9ff; color: #edfaff; }
#frozen-next { background: #e6f8ff; color: #102948; }
#frozen-back { background: #86dbff15; border-color: #8bceff56; color: #d2efff; }
.frozen-actions .btn:disabled { opacity: 0.48; cursor: default; }
.frozen-actions .btn:focus-visible { outline: 2px solid #d4f6ff; outline-offset: 2px; }
#frozen-status { min-height: 2.4em; font-size: 11px; line-height: 1.2; color: #d0efff; }

@container mini-app (max-height: 350px) {
    .frozen-actions { gap: 4px; }
    .frozen-actions .btn { height: 36px; }
}

/* Sponsor gate uses the native-style bottom panel without a dismiss affordance. */
.sponsor-panel { gap: 12px; padding-block-end: max(18px, var(--app-safe-bottom)); }
.sponsor-heading { text-align: center; padding-bottom: 5px; }
.sponsor-star { color: #a4620b; }
.sponsor-heading p { max-width: 300px; margin-inline: auto; line-height: 1.4; }
.sponsor-list {
    --sponsor-row-height: 68px;
    --sponsor-gap: 5px;
    display: grid;
    grid-auto-rows: var(--sponsor-row-height);
    gap: var(--sponsor-gap);
    max-height: calc(3 * var(--sponsor-row-height) + 2 * var(--sponsor-gap));
    padding-inline-end: 1px;
    overflow: hidden auto;
    overscroll-behavior-y: contain;
    scroll-snap-type: y proximity;
    scrollbar-width: none;
}
.sponsor-list::-webkit-scrollbar { display: none; }
.sponsor-list[hidden], .sponsor-hint[hidden] { display: none; }
.sponsor-task {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(6.5rem, auto);
    align-items: center;
    gap: clamp(7px, 2.5vw, 13px);
    min-width: 0;
    padding: 8px clamp(8px, 3vw, 13px);
    border-radius: 17px;
    background: #f0f5fa;
    scroll-snap-align: start;
}
.sponsor-copy { display: grid; gap: 4px; min-width: 0; }
.sponsor-copy strong, .sponsor-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sponsor-copy strong { font-size: 15px; }
.sponsor-copy small, .sponsor-hint { font-size: 12px; line-height: 1.3; color: #526781; }
.sponsor-hint { text-align: center; }
.sponsor-avatar {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #dceaff;
    font-size: 22px;
    line-height: 1;
}
.sponsor-avatar[data-palette="1"] { background: #e8e2ff; }
.sponsor-avatar[data-palette="2"] { background: #d9f4f2; }
.sponsor-avatar[data-palette="3"] { background: #ffecda; }
.sponsor-avatar[data-palette="4"] { background: #f9e1ed; }
.sponsor-emoji-sprite { position: absolute; pointer-events: none; }
.sponsor-avatar svg { width: 25px; height: 25px; }
.sponsor-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sponsor-action, .sponsor-task button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
}
.sponsor-task button { background: #e1edfb; color: #085fca; padding: 9px 7px; font-size: 12px; }
.sponsor-task button.is-visited { background: #e7ecf5; color: #3b5578; }
.sponsor-task button:active { background: #d4e5fb; }
.sponsor-action { min-height: 49px; padding: 10px; }
.sponsor-check { background: #087bf1; color: white; }
.sponsor-check:disabled { background: #e8eef4; color: #61778b; cursor: default; }
.sponsor-vip { background: #f0f5fa; color: #085fca; }
.sponsor-vip:disabled { cursor: default; opacity: .65; }

/* The teaser only contains fixed masks; actual bonus values arrive after unlock. */
.bonus-card {
    container: bonus-card / size;
    position: relative;
    display: grid;
    justify-self: center;
    place-items: safe center;
    width: var(--story-width);
    min-height: 0;
    padding-inline: clamp(2px, 2vw, 10px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    color: #faf2ff;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}
.bonus-card::-webkit-scrollbar { display: none; }
.bonus-card[hidden] { display: none; }
.bonus-icon-defs { position: absolute; pointer-events: none; }

.bonus-layout {
    --bonus-gap: clamp(4px, 1.2cqh, 8px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(7px, 2.15cqh, 16px);
    width: 100%;
    height: min(100%, 570px);
    min-height: 254px;
    padding-block: 4px;
}

.bonus-layout h1 {
    justify-self: center;
    max-width: 100%;
    border: 1px solid #c276f597;
    border-radius: 999px;
    background: linear-gradient(115deg, #45237bdf, #241041ed);
    box-shadow: inset 0 0 12px #c769ff42, 0 2px 14px #a93dff33;
    padding: .38em .95em;
    font-size: clamp(15px, 4.8cqh, 22px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: .045em;
    text-transform: uppercase;
    text-align: center;
}
.bonus-layout h1 span { color: #ffd8a7; text-shadow: 0 0 8px #ffc2f3; }
.bonus-layout :focus-visible { outline: 2px solid #f8d3ff; outline-offset: 2px; }

.bonus-preview {
    display: grid;
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: var(--bonus-gap);
    list-style: none;
}
.bonus-preview li {
    display: grid;
    grid-template-columns: clamp(20px, 8cqh, 47px) minmax(0, 1fr) auto;
    align-items: center;
    min-height: 0;
    gap: clamp(5px, 2.5cqw, 12px);
    padding-inline: clamp(5px, 2.5cqw, 12px);
    border: 1px solid #c884ff84;
    border-radius: clamp(9px, 3.8cqw, 17px);
    background: linear-gradient(113deg, #522f8fe8, #241446f2 56%, #432476ea);
    box-shadow: inset 0 0 11px #ca78ff23, 0 2px 9px #a646fe40;
}
.bonus-preview img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: clamp(20px, 8cqh, 47px);
    min-height: 0;
    object-fit: contain;
    filter: drop-shadow(0 1px 4px #c18bf58c);
}
.bonus-preview-copy { display: grid; gap: clamp(0px, .5cqh, 3px); }
.bonus-preview strong { color: #fff7ff; font-size: clamp(11px, 3.15cqh, 15px); line-height: 1.14; }
.bonus-mask {
    width: max-content;
    filter: blur(3.75px);
    color: #e6caff;
    font-size: clamp(7px, 2cqh, 12px);
    font-weight: 700;
    letter-spacing: .08em;
    line-height: .8;
}
.bonus-lock {
    display: grid;
    place-items: center;
    width: clamp(18px, 5.8cqh, 34px);
    aspect-ratio: 1;
    border: 1px solid #c883ff68;
    border-radius: 50%;
    background: #a553ef25;
    color: #e8baff;
    box-shadow: inset 0 0 8px #9c4cdb59;
}
.bonus-lock svg { width: 58%; }

.bonus-actions { display: grid; gap: var(--bonus-gap); }
.bonus-actions .btn {
    height: clamp(27px, 8.1cqh, 47px);
    font-size: clamp(12px, 3.1cqh, 16px);
}
#bonus-open { gap: .5em; box-shadow: 0 0 18px #ad52ff5c, inset 0 1px 1px #fff; }
#bonus-open svg { width: 1em; height: 1em; }
#bonus-summary { border-color: #d59bfdb3; color: #f3ddff; }
#bonus-back {
    height: clamp(25px, 6.8cqh, 37px);
    justify-self: center;
    padding-inline: 20px;
    background: none;
    color: #e3c7fc;
    font-weight: 600;
}

@container bonus-card (max-height: 330px) {
    .bonus-layout { gap: 5px; padding-block: 2px; }
    .bonus-preview-copy { gap: 0; }
    .bonus-mask { filter: blur(2.6px); }
}

.drum-roller.is-word-metric,
.swiper-slide .summary-metric-value.is-word-metric {
    display: block;
    height: auto;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(19px, 6vw, 33px);
    line-height: 1.14;
    letter-spacing: -.035em;
}
.bonus-sheet-heading { text-align: center; }
.bonus-invite-progress {
    display: grid;
    gap: 9px;
    padding: 12px 14px;
    border: 1px solid #e3d0fa;
    border-radius: 16px;
    background: linear-gradient(115deg, #f0e6ff, #fcf1ff);
    color: #452368;
}
.bonus-invite-progress strong { font-variant-numeric: tabular-nums; }
.bonus-invite-progress progress {
    display: block;
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 12px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #e2d1f6;
    color: #8851e1;
}
.bonus-invite-progress progress::-webkit-progress-bar {
    border-radius: inherit;
    background: #e2d1f6;
    box-shadow: inset 0 1px 3px #5b338e2b;
}
.bonus-invite-progress progress::-webkit-progress-value {
    border-radius: inherit;
    background: linear-gradient(90deg, #773de0, #ad55ee, #ee92e8);
    box-shadow: inset 0 1px 1px #fff8;
    transition: width .25s ease;
}
.bonus-invite-progress progress::-moz-progress-bar {
    border-radius: inherit;
    background: linear-gradient(90deg, #773de0, #ad55ee, #ee92e8);
    box-shadow: inset 0 1px 1px #fff8;
}
@media (prefers-reduced-motion: reduce) {
    .bonus-invite-progress progress::-webkit-progress-value { transition: none; }
}
.bonus-sheet button:disabled { background: #e8eef4; color: #61778b; cursor: default; }
#bonus-copy.is-copied { background: #e5f7ed; color: #116344; }
.bonus-copy-fallback { width: 100%; padding: 8px; min-width: 0; user-select: text; -webkit-user-select: text; }
