:root {
    --ink: #1B1712;
    --ink-soft: #2A241C;
    --page: #f7f1e8;
    --page-line: #DED2B8;
    --text-main: #2C2416;
    --text-muted: #8A7E68;
    --danger: #B0472B;
    --danger-bg: #F3DCD2;
    --calm: #5C6E4E;
    --calm-bg: #E4E9DC;
    --gold: #C9A227;
    --gold-bg: #3A2E12;
    --radius-page: 22px;
    --radius-ctrl: 10px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    overscroll-behavior-y: none;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #1C1712;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

body.vk-desktop-app {
    background: #E8E4DC;
}

body.vk-desktop-app .book-frame {
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    border-radius: 12px;
    margin: 20px 0;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
}

body.vk-desktop-app .page {
    border-radius: 12px;
    overflow: hidden;
}

.book-frame {
    width: 100%;
    max-width: 620px;
    height: 100%;
}

.page {
    background: var(--page);
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    position: relative;
    display: flex;
    flex-direction: column;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--page-line);
}

.header-actions-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-back-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--page-line);
    color: var(--text-main);
    text-decoration: none;
    font-size: 15px;
    transition: .15s ease;
}

.header-back-btn:hover {
    background: rgba(0, 0, 0, .05);
}

.book-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.page-header button {
    border: none;
    background: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.world-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 24px 0;
    padding: 10px 14px;
    background: var(--danger-bg);
    border-radius: var(--radius-ctrl);
}

.world-banner .dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}

.world-banner .text {
    flex: 1;
    font-size: 12px;
    color: var(--danger);
}

.world-banner .percent {
    font-size: 15px;
    font-weight: 700;
    color: var(--danger);
}

.scene {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #111;
}

.scene-track {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: relative;
    z-index: 1;
    cursor: grab;
    user-select: none;
}

.scene-track.dragging {
    cursor: grabbing;
    scroll-snap-type: none;
}

.scene-track::-webkit-scrollbar {
    display: none;
}

.scene-slide {
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: start;
    position: relative;
}

.scene-slide img,
.scene-slide video,
.scene-slide canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity .4s ease;
    -webkit-user-drag: none;
    user-drag: none;
}

.scene-slide img.loaded,
.scene-slide video.loaded,
.scene-slide canvas.loaded {
    opacity: 1;
}

.scene::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--page-line), #e8ddc4, var(--page-line));
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    transition: opacity .3s;
}

.scene.loaded::before {
    opacity: 0;
    pointer-events: none;
}

.scene::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: repeating-linear-gradient(to right, var(--gold) 0, var(--gold) 8px, transparent 8px, transparent 16px);
    z-index: 10;
}

.scene-dots {
    display: none;
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    justify-content: center;
    gap: 5px;
    z-index: 6;
}

.scene-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.4);
    transition: background 0.2s ease, width 0.2s ease;
}

.scene-dot.active {
    background: #fff;
    width: 8px;
    height: 8px;
}

.scene-counter {
    display: none;
    position: absolute;
    top: 22px;
    right: 12px;
    z-index: 6;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.scene.vertical-video {
    aspect-ratio: 9 / 16;
    max-height: 78vh;
}

.cinematic-progress {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 3px;
    background: rgba(255, 255, 255, .35);
    border-radius: 3px;
    z-index: 7;
    overflow: hidden;
}

body.cinematic-active .cinematic-progress {
    display: block;
}

.cinematic-progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 0 4px rgba(255, 255, 255, .6);
}

.cinematic-progress-fill.image-timer {
    animation: cinematic-progress-fill-anim 5s linear forwards;
}

.cinematic-progress-fill.held-paused {
    animation-play-state: paused;
}

@keyframes cinematic-progress-fill-anim {
    from { width: 0%; }
    to { width: 100%; }
}

.video-mute-btn {
    position: absolute;
    top: 22px;
    right: 12px;
    z-index: 500;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .5);
    border: 1.5px solid rgba(255, 255, 255, .75);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.video-mute-btn svg {
    width: 17px;
    height: 17px;
    display: block;
}

.video-mute-btn:active {
    transform: scale(.92);
}

.scene.has-counter .video-mute-btn,
.scene.has-counter .scene-menu-btn {
    top: 56px;
}

.scene-menu-wrap {
    display: none;
    position: absolute;
    top: 22px;
    right: 54px;
    z-index: 500;
}

body.cinematic-active .scene-menu-wrap {
    display: block;
}

body.cinematic-active #footerHomeLink,
body.cinematic-active #moreMenuBtn {
    display: none;
}

.scene.has-counter .scene-menu-wrap {
    top: 56px;
}

.scene.has-mute .scene-menu-wrap {
    right: 54px;
}

.scene:not(.has-mute) .scene-menu-wrap {
    right: 12px;
}

.scene-menu-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .5);
    border: 1.5px solid rgba(255, 255, 255, .75);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.scene-menu-btn:active {
    transform: scale(.92);
}

.scene-menu-btn svg {
    width: 17px;
    height: 17px;
    display: block;
}

.more-menu-dropdown.scene-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    bottom: auto;
    z-index: 500;
}

body.cinematic-checking .page-header,
body.cinematic-checking .world-banner,
body.cinematic-checking .chapter-badge,
body.cinematic-checking .narrative,
body.cinematic-checking .sound-tag,
body.cinematic-checking .divider,
body.cinematic-checking .choices,
body.cinematic-checking #continueWrap,
body.cinematic-checking .footer-nav {
    display: none !important;
}

body.cinematic-active .page-header,
body.cinematic-active .world-banner {
    display: none;
}

body.cinematic-active #pageContent {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    z-index: 100;
    background: #000;
    display: block;
    animation: none;
}

body.cinematic-active .scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: unset;
    touch-action: none;
}

body.cinematic-active .chapter-badge {
    display: none;
}

body.cinematic-active .scene::after {
    display: none;
}

body.cinematic-image #revealSheetReplayBtn {
    display: none;
}

body.cinematic-image .reveal-sheet-bar {
    display: none;
}

body.cinematic-active .reveal-sheet {
    position: fixed;
    left: 0;
    right: 0;
    top: 44px;
    bottom: 0;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    z-index: 50;
    background: var(--page);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 34px rgba(0, 0, 0, .45);
    clip-path: inset(0 0 0 0 round 20px 20px 0 0);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    will-change: top;
    transition: top .32s cubic-bezier(.32, .72, 0, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--page-line) transparent;
}

body.cinematic-active .reveal-sheet::-webkit-scrollbar {
    width: 5px;
}

body.cinematic-active .reveal-sheet::-webkit-scrollbar-track {
    background: transparent;
}

body.cinematic-active .reveal-sheet::-webkit-scrollbar-thumb {
    background: var(--page-line);
    border-radius: 3px;
}

.reveal-sheet-handle {
    display: none;
}

body.cinematic-active .reveal-sheet-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px 10px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--page);
    border-radius: 20px 20px 0 0;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

body.cinematic-active .reveal-sheet-handle:active {
    cursor: grabbing;
}

.reveal-sheet-handle-bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--page-line);
}

.reveal-sheet-bar {
    display: none;
}

body.cinematic-active .reveal-sheet-bar {
    display: flex;
    gap: 8px;
    position: sticky;
    top: 52px;
    z-index: 2;
    padding: 14px 16px;
    background: var(--page);
    border-bottom: 1px solid var(--page-line);
}

.reveal-sheet-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border-radius: 10px;
    border: 1px solid var(--page-line);
    background: var(--page-white, #fff);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.reveal-sheet-action:active {
    transform: scale(.97);
}

.reveal-sheet-action-danger {
    color: var(--danger);
    border-color: var(--danger-bg);
}

.reveal-sheet-action-ico {
    font-size: 13px;
    line-height: 1;
}

body.cinematic-active .narrative {
    padding-top: 16px;
}

body.cinematic-active .choices,
body.cinematic-active #continueWrap {
    padding-bottom: calc(64px + 20px + env(safe-area-inset-bottom));
}

body.cinematic-active .footer-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    z-index: 101;
    background: var(--page);
    border-top: 1px solid var(--page-line);
    padding-bottom: env(safe-area-inset-bottom);
}

body.cinematic-active #panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0 !important;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    z-index: 101;
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--page);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .3);
}

.chapter-badge {
    display: inline-block;
    margin: -20px 24px 0;
    position: relative;
    z-index: 2;
    padding: 5px 13px;
    border-radius: 20px;
    background: var(--gold-bg);
    color: var(--gold);
    font-size: 11px;
    font-weight: 600;
}

.narrative {
    padding: 20px 24px 14px;
    font-family: 'Fraunces', serif;
    font-size: 18px;
    line-height: 1.85;
    color: var(--text-main);
}

.narrative p {
    margin: 0 0 16px;
}

.narrative p:last-child {
    margin-bottom: 0;
}

.narrative.mood-calm p:first-of-type::first-letter {
    color: var(--calm);
}

.sound-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 24px 16px;
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted);
}

.sound-toggle {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--page-line);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-toggle:active {
    transform: scale(.9);
}

.divider {
    height: 1px;
    background: var(--page-line);
    margin: 0 24px;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 26px 24px 24px;
}

.choice-btn {
    text-align: left;
    padding: 15px 18px;
    background: transparent;
    border: 1px solid #C9BC9E;
    border-radius: var(--radius-ctrl);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    transition: transform .08s ease, background .15s ease, border-color .15s ease,
        opacity .5s cubic-bezier(.34, 1.56, .64, 1),
        translate .5s cubic-bezier(.34, 1.56, .64, 1),
        scale .5s cubic-bezier(.34, 1.56, .64, 1);
}

.choice-btn.choice-hidden,
.continue-btn.choice-hidden {
    opacity: 0;
    translate: 0 22px;
    scale: 0.9;
    pointer-events: none;
}

.choice-btn:hover {
    background: rgba(0, 0, 0, .04);
    border-color: var(--text-muted);
}

.choice-btn:active {
    transform: scale(.98);
}

.choice-btn.item-choice {
    background: var(--danger);
    border-color: var(--danger);
    color: #FAECE7;
}

.choice-btn.item-choice:hover {
    background: #99401f;
}

.choice-btn.choice-locked {
    opacity: .5;
    cursor: not-allowed;
    border-style: dashed;
}

.continue-btn {
    width: calc(100% - 48px);
    margin: 18px 24px 24px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--ink);
    border: none;
    border-radius: var(--radius-ctrl);
    color: var(--page);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .2s ease, background .2s ease,
        opacity .5s cubic-bezier(.34, 1.56, .64, 1),
        translate .5s cubic-bezier(.34, 1.56, .64, 1),
        scale .5s cubic-bezier(.34, 1.56, .64, 1);
}

.continue-btn:hover {
    background: #332B22;
}

.continue-btn:active {
    transform: scale(.98);
}

.footer-nav {
    display: flex;
    border-top: 1px solid var(--page-line);
    padding: 8px 0 6px;
    margin-top: auto;
    background: rgba(242, 233, 216, .95);
    position: relative;
}

.nav-item {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    cursor: pointer;
    transition: .2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.nav-item:hover {
    opacity: .7;
}

.nav-item .ico {
    font-size: 18px;
    color: var(--text-muted);
}

.nav-item .ico svg,
.reveal-sheet-action-ico svg {
    width: 18px;
    height: 18px;
    display: block;
    margin: 0 auto;
}

.more-menu-dropdown {
    position: absolute;
    right: 8px;
    bottom: calc(100% + 8px);
    min-width: 190px;
    background: var(--page-white, #fff);
    border: 1px solid var(--page-line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    overflow: hidden;
    z-index: 5;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: background .15s ease;
}

.more-menu-item:hover {
    background: rgba(0, 0, 0, .04);
}

.more-menu-item + .more-menu-item {
    border-top: 1px solid var(--page-line);
}

.more-menu-item .ico {
    display: flex;
    color: var(--text-muted);
}

.more-menu-item .ico svg {
    width: 17px;
    height: 17px;
    display: block;
}

.nav-item .lbl {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    color: var(--text-muted);
}

.panel {
    padding: 0 24px;
    border-top: 0px solid var(--page-line);
    background: rgba(0, 0, 0, .01);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition:
        max-height 380ms cubic-bezier(.22, 1, .36, 1),
        opacity 260ms ease,
        padding 380ms cubic-bezier(.22, 1, .36, 1),
        border-top-width 380ms cubic-bezier(.22, 1, .36, 1);
}

.panel.open {
    max-height: 640px;
    opacity: 1;
    padding: 20px 24px calc(74px + env(safe-area-inset-bottom)) !important;
    border-top-width: 1px;
}

.panel h3 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 20px 10px;
    justify-items: center;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 88px;
}

.ring {
    position: relative;
    width: 84px;
    height: 84px;
}

.ring-disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%),
        var(--c);
    box-shadow:
        0 8px 18px color-mix(in srgb, var(--c) 45%, transparent),
        inset 0 1.5px 0 rgba(255, 255, 255, 0.45);
}

.ring-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, .32);
    stroke-width: 7;
}

.ring-progress {
    fill: none;
    stroke: #ffffffe6;
    stroke-width: 7;
    stroke-linecap: round;
    transition: stroke-dashoffset 1600ms cubic-bezier(.22, 1, .36, 1);
}

.ring-val {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ring-val small {
    font-size: 11px;
    font-weight: 700;
    opacity: .8;
    margin-left: 2px;
}

.ring-val b {
    font-size: 22px;
    line-height: 1;
}

.stat-card .stat-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    line-height: 1.25;
}

.inventory-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.inventory-item {
    padding: 6px 12px;
    background: var(--page-line);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-main);
}

.item-toast,
.stat-modal,
.story-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 999;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: .3s ease;
}

.item-toast.visible,
.stat-modal.visible,
.story-modal.visible {
    background: rgba(0, 0, 0, .5);
    pointer-events: auto;
}

.item-toast-sheet,
.stat-modal-sheet,
.story-modal-sheet {
    width: 100%;
    max-width: 480px;
    padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
    background: var(--page);
    border-radius: 20px 20px 0 0;
    text-align: center;
    transform: translateY(100%);
    transition: .32s cubic-bezier(.32, .72, 0, 1);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .25);
}

.item-toast.visible .item-toast-sheet,
.stat-modal.visible .stat-modal-sheet,
.story-modal.visible .story-modal-sheet {
    transform: translateY(0);
}

.item-toast-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--page-line);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.item-toast-icon {
    width: 88px;
    height: 88px;
    margin: 4px auto 18px;
    overflow: hidden;
    border-radius: 14px;
    background: var(--page-line);
}

.item-toast-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-toast-label,
.stat-modal-label,
.story-modal-label {
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--gold);
}

.item-toast-name,
.stat-modal-name {
    margin: 0 0 22px;
    font-family: 'Fraunces', serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
}

.item-toast-desc {
    margin: -14px 0 22px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
}

.item-toast-ok,
.stat-modal-ok,
.story-modal-ok {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: var(--ink);
    color: var(--page);
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
}

.item-toast-ok:hover,
.stat-modal-ok:hover,
.story-modal-ok:hover {
    background: #332B22;
}

.item-toast-ok:active,
.stat-modal-ok:active,
.story-modal-ok:active {
    transform: scale(.98);
}

.story-modal-icon {
    margin-bottom: 10px;
    font-size: 32px;
    color: var(--gold);
    animation: story-modal-pulse 1.1s infinite;
}

.story-modal-text {
    margin: 0 0 22px;
    font-family: 'Fraunces', serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

#minigameWrap {
    min-height: calc(100vh - 120px);
}

#minigameWrap iframe {
    width: 100%;
    height: 100% !important;
    min-height: calc(100vh - 120px);
}

.paywall-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 60px 32px 40px;
    min-height: calc(100vh - 200px);
}

.paywall-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gold-bg);
    color: var(--gold);
    font-size: 26px;
    margin-bottom: 22px;
}

.paywall-chapter-title {
    margin: 0 0 10px;
    font-family: 'Fraunces', serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
}

.paywall-chapter-description {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-soft);
    max-width: 340px;
}

.paywall-text {
    margin: 0 0 28px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 320px;
}

.paywall-buy-btn {
    width: 100%;
    max-width: 320px;
    padding: 15px 18px;
    margin-bottom: 10px;
    border: none;
    border-radius: var(--radius-ctrl);
    background: var(--ink);
    color: var(--page);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s ease, background .15s ease;
}

.paywall-buy-btn:hover {
    background: #332B22;
}

.paywall-buy-btn:active {
    transform: scale(.98);
}

.paywall-buy-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.paywall-buy-btn.paywall-buy-scenario {
    background: transparent;
    border: 1px solid var(--page-line);
    color: var(--text-main);
}

.paywall-buy-btn.paywall-buy-scenario:hover {
    background: rgba(0, 0, 0, .04);
}

.page-content {
    animation: page-turn-in .35s cubic-bezier(.22, 1, .36, 1);
}

.page-content.leaving {
    animation: page-turn-out .2s ease forwards;
}

@keyframes page-turn-in {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes page-turn-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-24px);
    }
}

@keyframes skeleton-shimmer {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

@keyframes story-modal-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

@media (min-width: 768px) {
    html {
        height: auto;
        overflow: auto;
    }
    body {
        padding: 30px 0;
        background-color: #16120E;
        background-image: radial-gradient(rgba(255, 255, 255, .03) 1px, transparent 0);
        background-size: 24px 24px;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: auto;
    }
    .book-frame {
        height: auto;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 20px 50px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .05);
    }
    .page {
        height: auto;
        min-height: auto;
        overflow: visible;
        border-radius: 16px;
    }
    .item-toast,
    .stat-modal,
    .story-modal {
        align-items: center;
    }
    .item-toast-sheet,
    .stat-modal-sheet,
    .story-modal-sheet {
        max-width: 440px;
        border-radius: 20px;
        opacity: 0;
        transform: scale(.95);
        box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
    }
    .item-toast.visible .item-toast-sheet,
    .stat-modal.visible .stat-modal-sheet,
    .story-modal.visible .story-modal-sheet {
        opacity: 1;
        transform: scale(1);
    }
}

.header-menu-wrap {
    position: relative;
    display: flex;
}

.more-menu-dropdown.header-menu-dropdown {
    top: calc(100% + 12px);
    bottom: auto;
    right: 0;
    z-index: 500;
}

.stat-toast {
    position: absolute;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 150;
    display: none;
    pointer-events: none;
    transform: translate(calc(-50% + 140%), 0);
    opacity: 0;
    transition: transform 480ms cubic-bezier(.22, 1, .36, 1), opacity 380ms ease;
}

body.cinematic-active .stat-toast {
    position: fixed;
}

.stat-toast.stat-toast-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.stat-toast.stat-toast-exit {
    transform: translate(calc(-50% - 140%), 0);
    opacity: 0;
}

.stat-toast-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.stat-toast-name-badge {
    background: var(--c);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .35), 0 0 0 1.5px rgba(255, 255, 255, .4);
    white-space: nowrap;
}

.stat-toast-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: var(--c);
    filter: blur(22px);
    opacity: .6;
    z-index: -1;
}

.stat-toast-delta {
    position: absolute;
    bottom: -4px;
    right: -8px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

.stat-toast-delta.up {
    background: var(--calm-bg);
    color: var(--calm);
}

.stat-toast-delta.down {
    background: var(--danger-bg);
    color: var(--danger);
}

.vk-native-app .scene-menu-wrap {
    right: auto !important;
    left: 12px !important;
}

.vk-native-app .scene-menu-dropdown {
    left: 0 !important;
    right: auto !important;
}

.vk-native-app .video-mute-btn {
    right: auto !important;
    left: 60px !important;
}

.recommended-books-wrap {
    margin: 24px 0 0;
    padding: 20px 20px 0;
    border-top: 1px solid rgba(0,0,0,0.08);
}

.recommended-books-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #8A7859);
    margin: 0 0 14px;
    padding: 0;
}

.recommended-books-grid {
    display: flex;
    margin: 0;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.recommended-book-card {
    flex: 0 0 130px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease;
}

.recommended-book-card:active {
    transform: scale(0.97);
}

.recommended-book-cover {
    width: 130px;
    height: 174px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    margin-bottom: 8px;
    background: #eee;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.recommended-book-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
    color: var(--text-main, #2C2416);
}

.video-ready-fab {
    position: fixed;
    right: 14px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ink, #2C2416);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.28);
    cursor: pointer;
    z-index: 160;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 280ms ease, transform 280ms cubic-bezier(.22,1,.36,1);
}

.video-ready-fab.visible {
    opacity: 1;
    transform: scale(1);
}

.video-ready-fab-ring {
    position: absolute;
    inset: -3px;
    width: auto;
    height: auto;
    pointer-events: none;
}

.video-ready-fab-ring .ring-track {
    stroke: rgba(255,255,255,0.18);
    stroke-width: 6;
}

.video-ready-fab-ring .ring-progress {
    stroke: #fff;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 220ms linear;
}

.video-ready-fab-play {
    width: 14px;
    height: 14px;
    color: #fff;
    margin-left: 1px;
    opacity: 0.55;
    transition: opacity 250ms ease;
}

.video-ready-fab.ready .video-ready-fab-play {
    opacity: 1;
}

.video-ready-fab.ready {
    animation: videoReadyFabPulse 1.7s ease-in-out infinite;
}

.video-ready-fab.ready .video-ready-fab-ring {
    opacity: 0;
    transition: opacity 300ms ease;
}

@keyframes videoReadyFabPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 0 0 rgba(255,255,255,0.35);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 10px 28px rgba(0,0,0,0.32), 0 0 0 10px rgba(255,255,255,0);
    }
}

.scene-deferred-hidden {
    display: none !important;
}

.checking-spinner {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    z-index: 140;
    pointer-events: none;
}

.checking-spinner-ring {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(44, 36, 22, 0.15);
    border-top-color: var(--ink, #2C2416);
    animation: checkingSpin 0.8s linear infinite;
}

@keyframes checkingSpin {
    to { transform: rotate(360deg); }
}

body.cinematic-checking .checking-spinner {
    display: flex;
}

body.cinematic-checking #scene {
    opacity: 0;
    pointer-events: none;
}

body.has-video-fab .narrative,
body.has-video-fab .choices,
body.has-video-fab #continueWrap {
    padding-right: 48px;
}