* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html {
            touch-action: pan-x pan-y;
        }

        body {
            background-color: var(--bg);
            color: var(--fg);
            font-family: 'Univia Pro', 'Merriweather', Georgia, sans-serif;
            font-size: 19px;
            padding: 20px;
            padding-top: 20px;
            min-height: 100vh;
            overflow-x: hidden;
            scroll-behavior: smooth;
            -webkit-font-smoothing: antialiased;
            text-rendering: optimizeLegibility;
            touch-action: pan-x pan-y;
        }

        #app {
            max-width: 600px;
            margin: 0 auto;
            position: relative;
        }

        #scene {
            opacity: 0;
            transform: translateY(15px);
            transition: opacity 0.45s ease, transform 0.45s ease;
            text-align: left;
        }

        #scene.active {
            opacity: 1;
            transform: translateY(0);
        }

        .illustration-wrap {
            position: sticky;
            top: 0;
            z-index: 2;
            margin: 0 0 1em 0;
        }

        .illustration {
            width: 100%;
            aspect-ratio: 16 / 9;
            height: auto;
            overflow: hidden;
            background: #141224;
            box-shadow: var(--shadow-md);
            cursor: pointer;
        }

        .illustration img,
        .illustration video {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            pointer-events: auto;
        }

        .illustration.illustration-video {
            cursor: default;
            pointer-events: none;
            position: relative;
        }

        .illustration.illustration-video video {
            pointer-events: none;
        }

        .illustration.illustration-video .video-to-image-fade {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            opacity: 0;
            transition: opacity 1s ease;
        }

        .illustration-fade {
            height: 40px;
            pointer-events: none;
            background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%);
        }

        .illustration .fallback {
            color: #777;
            font-style: italic;
            text-align: center;
            padding: 24px;
            font-family: system-ui, sans-serif;
            aspect-ratio: 16 / 9;
            min-height: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            box-sizing: border-box;
        }

        .text-wrap {
            overflow-x: hidden;
        }

        .text {
            line-height: 1.78;
            margin: 0 0 26px 0;
            text-align: justify;
            hyphens: auto;
        }

        .text p {
            margin-bottom: 22px;
            text-indent: 24px;
        }

        .choices {
            display: flex;
            flex-direction: column;
            gap: 16px;
            margin: 30px 0 24px;
        }

        /* === ЗАКРЕПЛЁННАЯ ПАНЕЛЬ КНОПОК СВЕРХУ === */
        #top-nav-bar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 999;
            background: rgba(12, 11, 20, 0.25);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-bottom: 1px solid rgba(106, 90, 205, 0.2);
            padding: 10px 0;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        }

        .top-nav-buttons {
            display: flex;
            justify-content: center;
            gap: 8px;
            flex-wrap: wrap;
            max-width: 600px;
            margin: 0 auto;
            padding: 0 20px;
        }

        .top-nav-btn {
            flex: 1;
            min-width: 80px;
            max-width: 120px;
            padding: 10px 8px;
            background: rgba(106, 90, 205, 0.2);
            border: 2px solid rgba(106, 90, 205, 0.4);
            border-radius: var(--radius-md);
            color: white;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
            text-decoration: none;
            box-shadow: var(--shadow-sm);
        }

        .top-nav-btn:hover {
            background: rgba(106, 90, 205, 0.4);
            border-color: rgba(106, 90, 205, 0.7);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(106, 90, 205, 0.4);
        }

        .top-nav-btn:active {
            transform: translateY(0);
        }

        .top-nav-btn-icon {
            font-size: 24px;
            line-height: 1;
        }

        .top-nav-btn-text {
            font-size: 11px;
            font-weight: 500;
            text-align: center;
            line-height: 1.2;
        }

        .top-nav-btn.inventory {
            background: rgba(85, 85, 85, 0.2);
            border-color: rgba(85, 85, 85, 0.4);
        }

        .top-nav-btn.inventory:hover {
            background: rgba(85, 85, 85, 0.4);
            border-color: rgba(85, 85, 85, 0.7);
            box-shadow: 0 4px 12px rgba(85, 85, 85, 0.4);
        }

        .top-nav-btn.shop {
            background: rgba(139, 69, 19, 0.2);
            border-color: rgba(139, 69, 19, 0.4);
        }

        .top-nav-btn.shop:hover {
            background: rgba(139, 69, 19, 0.4);
            border-color: rgba(139, 69, 19, 0.7);
            box-shadow: 0 4px 12px rgba(139, 69, 19, 0.4);
        }

        .top-nav-btn.map {
            background: rgba(58, 60, 109, 0.2);
            border-color: rgba(58, 60, 109, 0.4);
        }

        .top-nav-btn.map:hover {
            background: rgba(58, 60, 109, 0.4);
            border-color: rgba(58, 60, 109, 0.7);
            box-shadow: 0 4px 12px rgba(58, 60, 109, 0.4);
        }

        .choice-btn {
            padding: 16px 20px;
            background: rgba(106, 90, 205, 0.25);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            color: white;
            border: 1px solid rgba(106, 90, 205, 0.4);
            border-radius: var(--radius-lg);
            font-family: 'Noto Sans', sans-serif;
            font-size: 17px;
            text-align: left;
            cursor: pointer;
            transition: background 0.2s, transform 0.12s, border-color 0.2s;
            box-shadow: var(--shadow-sm);
        }
        
        /* ✅ ИСПРАВЛЕНО: Анимация 4 мигания с плавным затуханием */
        @keyframes choiceBlink {
            /* 1-е мигание (0-25%) */
            0% {
                box-shadow: 0 0 15px var(--blink-color, hsl(0, 100%, 60%)), 0 0 30px var(--blink-color, hsl(0, 100%, 60%));
                border: 2px solid var(--blink-color, hsl(0, 100%, 60%));
            }
            12.5% {
                box-shadow: 0 0 25px var(--blink-color, hsl(0, 100%, 60%)), 0 0 50px var(--blink-color, hsl(0, 100%, 60%)), 0 0 70px var(--blink-color, hsl(0, 100%, 60%));
                border: 3px solid var(--blink-color, hsl(0, 100%, 60%));
            }
            25% {
                box-shadow: 0 0 8px var(--blink-color, hsl(0, 100%, 60%)), 0 0 15px var(--blink-color, hsl(0, 100%, 60%));
                border: 2px solid color-mix(in srgb, var(--blink-color, hsl(0, 100%, 60%)) 20%, transparent);
            }
            /* 2-е мигание (25-50%) */
            37.5% {
                box-shadow: 0 0 25px var(--blink-color, hsl(0, 100%, 60%)), 0 0 50px var(--blink-color, hsl(0, 100%, 60%)), 0 0 70px var(--blink-color, hsl(0, 100%, 60%));
                border: 3px solid var(--blink-color, hsl(0, 100%, 60%));
            }
            50% {
                box-shadow: 0 0 8px var(--blink-color, hsl(0, 100%, 60%)), 0 0 15px var(--blink-color, hsl(0, 100%, 60%));
                border: 2px solid color-mix(in srgb, var(--blink-color, hsl(0, 100%, 60%)) 20%, transparent);
            }
            /* 3-е мигание (50-75%) */
            62.5% {
                box-shadow: 0 0 25px var(--blink-color, hsl(0, 100%, 60%)), 0 0 50px var(--blink-color, hsl(0, 100%, 60%)), 0 0 70px var(--blink-color, hsl(0, 100%, 60%));
                border: 3px solid var(--blink-color, hsl(0, 100%, 60%));
            }
            75% {
                box-shadow: 0 0 8px var(--blink-color, hsl(0, 100%, 60%)), 0 0 15px var(--blink-color, hsl(0, 100%, 60%));
                border: 2px solid color-mix(in srgb, var(--blink-color, hsl(0, 100%, 60%)) 20%, transparent);
            }
            /* 4-е мигание (75-100%) - последнее, затухает до 0 */
            87.5% {
                box-shadow: 0 0 25px var(--blink-color, hsl(0, 100%, 60%)), 0 0 50px var(--blink-color, hsl(0, 100%, 60%)), 0 0 70px var(--blink-color, hsl(0, 100%, 60%));
                border: 3px solid var(--blink-color, hsl(0, 100%, 60%));
            }
            100% {
                box-shadow: var(--shadow-sm);
                border: 2px solid transparent;
            }
        }
        
        .choice-btn.checkpoint-btn {
            background: rgba(255, 215, 0, 0.25);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            color: #fef3c7;
            font-weight: bold;
            border: 1px solid rgba(255, 215, 0, 0.5);
            box-shadow: var(--shadow-sm);
        }
        
        .choice-btn.checkpoint-btn:hover {
            background: rgba(255, 165, 0, 0.35);
            border-color: rgba(255, 215, 0, 0.6);
            box-shadow: 0 4px 12px rgba(255, 215, 0, 0.25);
            transform: translateY(-2px);
        }
        
        .choice-btn.newly-unlocked {
            animation: choiceBlink 4s ease-in-out 1; /* 1 цикл = 4 мигания */
            animation-fill-mode: forwards;
            border: 2px solid transparent;
        }

        .choice-btn:hover {
            background: rgba(106, 90, 205, 0.4);
            border-color: rgba(106, 90, 205, 0.6);
        }

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

        .deadend .choice-btn {
            background: rgba(244, 67, 54, 0.25);
            border-color: rgba(244, 67, 54, 0.4);
        }

        .deadend .choice-btn:hover {
            background: rgba(211, 47, 47, 0.35);
            border-color: rgba(244, 67, 54, 0.6);
        }
        
        .ending-success {
            border-left: 4px solid var(--success);
            padding-left: 16px;
        }

        .loading {
            padding: 40px;
            color: #777;
            text-align: center;
            font-family: system-ui, sans-serif;
        }

        .restart-btn {
            background: #ff9800;
        }

        .restart-btn:hover {
            background: #f57c00;
        }

        #audio-control {
            position: fixed;
            bottom: 16px;
            right: 16px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: rgba(var(--accent-rgb), 0.15);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            border: 1px solid rgba(var(--frame-rgb), 0.35);
            color: var(--fg);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            z-index: 100;
            box-shadow: 0 0 8px rgba(var(--frame-rgb), 0.15), var(--shadow-sm);
            transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
        }
        #audio-control:active {
            transform: scale(0.92);
        }
        #audio-control:hover {
            background: rgba(var(--accent-rgb), 0.25);
            border-color: rgba(var(--frame-rgb), 0.55);
            box-shadow: 0 0 12px rgba(var(--frame-rgb), 0.25), var(--shadow-sm);
        }
        #audio-control.muted {
            background: rgba(239, 68, 68, 0.12);
            border-color: rgba(239, 68, 68, 0.35);
            box-shadow: var(--shadow-sm);
            color: rgba(239, 68, 68, 0.7);
        }
        #audio-control.muted:hover {
            background: rgba(239, 68, 68, 0.2);
            border-color: rgba(239, 68, 68, 0.5);
        }
        #audio-control svg {
            width: 18px;
            height: 18px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        /* === ВЫДВИЖНОЕ МЕНЮ СПРАВА === */
        body.right-menu-drag {
            user-select: none;
            -webkit-user-select: none;
        }
        #right-menu-overlay {
            position: fixed;
            left: 0;
            top: 0;
            bottom: 0;
            width: calc(100% - 320px);
            z-index: 9500;
            pointer-events: none;
            transition: opacity 0.2s;
        }
        #right-menu-overlay.active {
            pointer-events: auto;
        }
        #right-menu-strip-wrap {
            position: fixed;
            top: 50%;
            right: 0;
            transform: translateY(-50%);
            z-index: 9510;
            display: flex;
            align-items: center;
            height: 224px;
            transition: right 0.25s ease;
        }
        #right-menu-strip {
            height: 112px;
            min-width: 14px;
            border-radius: 14px 0 0 14px;
            display: flex;
            align-items: center;
            padding-left: 0;
            transition: min-width 0.25s ease, height 0.25s ease;
            cursor: pointer;
            flex-shrink: 0;
        }
        #right-menu-strip.wide {
            min-width: 40px;
            height: 110px;
            padding-left: 12px;
        }
        #right-menu-hamburger {
            display: none;
            flex-direction: column;
            justify-content: center;
            gap: 6px;
            width: 24px;
            height: 30px;
        }
        #right-menu-strip.wide #right-menu-hamburger {
            display: flex;
        }
        #right-menu-strip.right-menu-strip-new-location-blink {
            animation: rightMenuStripNewLocationBlink 3s ease-in-out;
        }
        @keyframes rightMenuStripNewLocationBlink {
            0%, 25%, 50%, 75%, 100% { box-shadow: inherit; }
            12%, 62% { box-shadow: 0 0 16px 2px rgba(76, 201, 240, 0.7), inset 0 0 20px rgba(76, 201, 240, 0.2); }
        }
        #right-menu-hamburger span {
            display: block;
            width: 100%;
            height: 3px;
            background: rgba(255,255,255,0.9);
            border-radius: 2px;
        }
        #right-menu-buttons {
            position: fixed;
            top: 50%;
            z-index: 9505;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            overflow: visible;
            transition: opacity 0.3s ease, visibility 0s linear 0.3s;
        }
        #right-menu-buttons.open {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transition: opacity 0.3s ease, visibility 0s;
        }

        /* Стиль для экрана броска кубиков */
        #dice-screen {
            display: none;
            text-align: center;
            padding: 40px;
        }

        #dice-screen .dice {
            font-size: 100px;
            margin-bottom: 30px;
        }

        #dice-screen .result {
            font-size: 24px;
            margin: 20px 0;
        }

        #dice-screen button {
            width: 200px;
            margin: 0 auto;
        }

        /* === ИНВЕНТАРЬ === */
        #inventory-screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg);
            z-index: 1000;
            overflow-y: auto;
            padding: 20px 15px;
            text-align: center;
        }

        /* === ЭКРАН СТАТУСОВ === */
        #statuses-screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg);
            z-index: 1000;
            overflow-y: auto;
        }
        
        /* === ПАНЕЛЬ РАЗРАБОТЧИКА === */
        #dev-screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg);
            z-index: 10000;
            overflow-y: auto;
            padding: 20px 15px;
        }
        
        .dev-section {
            background: rgba(106, 90, 205, 0.1);
            border: 2px solid rgba(106, 90, 205, 0.3);
            border-radius: var(--radius-lg);
            padding: 15px;
            margin-bottom: 15px;
        }
        
        .dev-section-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 10px;
            color: var(--accent);
        }
        
        .dev-item {
            background: rgba(255, 255, 255, 0.05);
            padding: 8px 12px;
            margin: 5px 0;
            border-radius: 6px;
            font-size: 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .dev-btn {
            background: var(--accent);
            color: white;
            border: none;
            border-radius: 8px;
            padding: 8px 16px;
            margin: 5px;
            cursor: pointer;
            font-size: 14px;
        }
        
        .dev-btn:hover {
            background: #5a4ab0;
        }
        
        .dev-input {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(106, 90, 205, 0.3);
            border-radius: 6px;
            padding: 6px 10px;
            color: white;
            font-size: 14px;
            width: 150px;
            margin: 5px;
            padding: 20px 15px;
            text-align: center;
        }

        #statuses-screen h2 {
            margin-bottom: 16px;
            font-size: 24px;
        }

        /* Модальное окно пользовательского соглашения */
        #terms-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            z-index: 12000;
            justify-content: center;
            align-items: center;
            padding: 20px;
            box-sizing: border-box;
        }
        #terms-modal-overlay.terms-modal-open {
            display: flex;
        }
        .terms-modal-box {
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            max-width: 500px;
            width: 100%;
            max-height: 85vh;
            display: flex;
            flex-direction: column;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
        }
        .terms-modal-title {
            padding: 16px 20px;
            font-size: 18px;
            font-weight: 600;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }
        .terms-modal-content {
            padding: 16px 20px;
            overflow-y: auto;
            flex: 1;
            white-space: pre-wrap;
            font-size: 14px;
            line-height: 1.5;
            color: var(--fg);
        }
        .terms-modal-footer {
            padding: 12px 20px;
            border-top: 1px solid var(--border);
            flex-shrink: 0;
        }
        .terms-modal-ok {
            width: 100%;
            padding: 10px 20px;
            background: var(--accent);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
        }
        .terms-modal-ok:hover {
            opacity: 0.9;
        }
        
        .registration-error {
            background: rgba(244, 67, 54, 0.2);
            border: 1px solid rgba(244, 67, 54, 0.5);
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 15px;
            color: #ff6b6b;
            font-size: 14px;
        }
        
        .registration-loading {
            text-align: center;
            color: #4cc9f0;
            font-size: 16px;
            margin-bottom: 15px;
            padding: 10px;
        }
        
        .registration-buttons {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: 25px;
        }
        
        .registration-submit-btn {
            width: 100%;
            padding: 15px 25px;
            background: linear-gradient(135deg, var(--accent) 0%, #5a4ab0 100%);
            color: white;
            border: none;
            border-radius: var(--radius-md);
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 4px 15px rgba(106, 90, 205, 0.4);
        }
        
        .registration-submit-btn:hover:not(:disabled) {
            background: linear-gradient(135deg, #5a4ab0 0%, var(--accent) 100%);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(106, 90, 205, 0.6);
        }
        
        .registration-submit-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }
        
        .registration-skip-btn {
            width: 100%;
            padding: 12px 25px;
            background: rgba(255, 255, 255, 0.1);
            color: #aaa;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: var(--radius-md);
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .registration-skip-btn:hover {
            background: rgba(255, 255, 255, 0.15);
            color: var(--fg);
        }

        /* === МАГАЗИН === */
        #shop-screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(5px);
            -webkit-backdrop-filter: blur(5px);
            z-index: 1001;
            overflow-y: auto;
            padding: 30px 20px;
            text-align: center;
        }

        #shop-screen.active {
            display: block;
        }

        .shop-container {
            max-width: 600px;
            margin: 0 auto;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
            border: 3px solid #FFD700;
            box-shadow: 
                0 0 20px rgba(255, 215, 0, 0.6),
                0 0 40px rgba(255, 215, 0, 0.4),
                0 0 60px rgba(255, 215, 0, 0.2),
                inset 0 0 20px rgba(255, 215, 0, 0.1);
            animation: shopGlow 2s ease-in-out infinite alternate;
        }

        @keyframes shopGlow {
            0% {
                box-shadow: 
                    0 0 20px rgba(255, 215, 0, 0.6),
                    0 0 40px rgba(255, 215, 0, 0.4),
                    0 0 60px rgba(255, 215, 0, 0.2),
                    inset 0 0 20px rgba(255, 215, 0, 0.1);
            }
            100% {
                box-shadow: 
                    0 0 30px rgba(255, 215, 0, 0.8),
                    0 0 60px rgba(255, 215, 0, 0.6),
                    0 0 90px rgba(255, 215, 0, 0.4),
                    inset 0 0 30px rgba(255, 215, 0, 0.2);
            }
        }

        .shop-title {
            color: #FFD700;
            font-size: 32px;
            margin-bottom: 30px;
            text-shadow: 
                0 0 10px rgba(255, 215, 0, 0.8),
                0 0 20px rgba(255, 215, 0, 0.6),
                0 2px 4px rgba(0, 0, 0, 0.5);
            font-weight: bold;
        }

        .shop-content {
            width: 100%;
            margin: 0 auto;
        }

        .shop-item {
            background: rgba(139, 69, 19, 0.3);
            border: 2px solid rgba(255, 215, 0, 0.5);
            border-radius: 15px;
            padding: 25px;
            margin-bottom: 20px;
            text-align: left;
            transition: all 0.3s;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        }

        .shop-item:hover {
            transform: translateY(-3px);
            border-color: rgba(255, 215, 0, 0.8);
            box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
            background: rgba(139, 69, 19, 0.4);
        }

        .shop-item-owned {
            background: rgba(76, 175, 80, 0.2);
            border-color: rgba(76, 175, 80, 0.6);
        }

        .shop-item-owned:hover {
            border-color: rgba(76, 175, 80, 0.8);
            box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
        }

        .shop-item-title {
            font-size: 22px;
            color: #FFD700;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 10px;
            font-weight: bold;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        .shop-item-description {
            color: rgba(255, 255, 255, 0.8);
            font-size: 15px;
            margin-bottom: 18px;
            line-height: 1.6;
        }

        .shop-item-price {
            font-size: 20px;
            color: #FFD700;
            font-weight: bold;
            margin-bottom: 18px;
            text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
        }

        .shop-item-button {
            background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
            color: white;
            border: 2px solid rgba(255, 215, 0, 0.5);
            padding: 14px 28px;
            border-radius: var(--radius-md);
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            width: 100%;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        }

        .shop-item-button:hover {
            background: linear-gradient(135deg, #a0522d 0%, #cd853f 100%);
            transform: translateY(-2px);
            box-shadow: 
                0 6px 20px rgba(255, 215, 0, 0.5),
                0 0 15px rgba(255, 215, 0, 0.3);
            border-color: rgba(255, 215, 0, 0.8);
        }

        .shop-item-button:active {
            transform: translateY(0);
        }

        .shop-item-button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
            background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
            border-color: rgba(76, 175, 80, 0.6);
        }

        .shop-close {
            margin-top: 25px;
            background: rgba(255, 215, 0, 0.2);
            border: 2px solid rgba(255, 215, 0, 0.5);
            color: #FFD700;
            padding: 12px 24px;
            border-radius: var(--radius-md);
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
        }

        .shop-close:hover {
            background: rgba(255, 215, 0, 0.3);
            border-color: rgba(255, 215, 0, 0.8);
            box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
            transform: translateY(-2px);
        }

        #inventory-screen h2 {
            margin-bottom: 16px;
            font-size: 24px;
        }

        /* Аккордеон для инвентаря */
        .inventory-accordion {
            width: 100%;
            max-width: 500px;
            margin: 0 auto;
            padding: 0 10px;
            box-sizing: border-box;
        }

        .inventory-group {
            margin: 0;
        }

        .inventory-item {
            width: 100%;
            border: none;
            border-radius: var(--radius-md);
            padding: 8px 12px;
            margin: 4px 0;
            text-align: left;
            background: rgba(86, 78, 132, 0.55);
            color: #fff;
            font-size: 16px;
            cursor: pointer;
        }

        .inventory-item:hover {
            filter: brightness(1.05);
        }

        .inventory-item.level-0 {
            padding-left: 12px;
            background: rgba(86, 78, 132, 0.55);
            font-weight: 600;
        }

        .inventory-item.level-1 {
            padding-left: 24px;
            background: rgba(70, 95, 145, 0.48);
            font-size: 15px;
        }

        .inventory-row {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .inventory-icon {
            width: 20px;
            text-align: center;
            font-size: 18px;
        }

        .inventory-label {
            flex: 1;
            line-height: 1.2;
        }

        .inventory-arrow {
            width: 18px;
            text-align: right;
            opacity: 0.95;
            font-size: 16px;
        }

        .inventory-children {
            display: none;
            margin: 0;
        }

        .inventory-group.open > .inventory-children {
            display: block;
        }

        .inventory-empty {
            text-align: center;
            color: #aaa;
            padding: 20px;
            font-size: 15px;
        }

        #code-screen {
            display: none;
            text-align: center;
            padding: 40px 20px;
            max-width: 500px;
            margin: 0 auto;
        }

        #code-screen h2 {
            font-size: 28px;
            margin-bottom: 24px;
            text-align: center;
        }

        .code-input-container {
            background: white;
            color: black;
            border-radius: 16px;
            padding: 32px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
            margin: 20px 0;
        }

        #code-input {
            width: 100%;
            padding: 18px;
            font-size: 32px;
            font-weight: bold;
            text-align: center;
            border: 3px solid #333;
            border-radius: var(--radius-lg);
            margin: 20px 0;
            background: #f8f8f8;
            box-sizing: border-box;
            letter-spacing: 4px;
        }

        #code-input:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(106, 90, 205, 0.3);
        }

        #submit-code {
            background: var(--accent);
            color: white;
            border: none;
            border-radius: var(--radius-lg);
            padding: 16px 32px;
            font-size: 20px;
            font-weight: bold;
            cursor: pointer;
            margin-top: 10px;
            transition: all 0.2s;
            width: 100%;
        }

        #submit-code:hover {
            background: #5a4ab0;
            transform: translateY(-2px);
        }

        #code-error {
            color: var(--deadend);
            min-height: 24px;
            margin-top: 12px;
            font-weight: bold;
            font-size: 18px;
        }

        .code-hint {
            color: #666;
            margin-top: 15px;
            font-style: italic;
            font-size: 18px;
        }

        .keys-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
            gap: 16px;
            max-width: 450px;
            margin: 0 auto;
        }

        .key-item {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .key-icon {
            font-size: 48px;
            margin-bottom: 6px;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
        }

        .key-label {
            background: white;
            color: black;
            font-size: 12px;
            font-family: 'Merriweather', sans-serif;
            padding: 4px 6px;
            border-radius: 4px;
            width: 100%;
            box-sizing: border-box;
            text-align: center;
            line-height: 1.2;
        }

        .inventory-close {
            display: block;
            width: calc(100% - 24px);
            max-width: 540px;
            margin: 28px auto 0 auto;
            background: var(--accent);
            color: white;
            border: none;
            border-radius: var(--radius-lg);
            padding: 12px 24px;
            font-size: 17px;
            cursor: pointer;
            text-align: center;
        }

        .inventory-close:hover {
            background: #5a4ab0;
        }

        /* === АНИМАЦИЯ ПОЛУЧЕНИЯ КЛЮЧА === */
        #key-animation {
            display: none;
            text-align: center;
            padding: 40px 20px;
        }

        #key-animation .icon {
            font-size: 120px;
            margin-bottom: 20px;
            opacity: 0;
            animation: keyPop 1.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        #key-animation .label {
            font-size: 22px;
            margin-bottom: 30px;
            opacity: 0;
            animation: fadeIn 0.8s 0.4s forwards;
        }

        @keyframes keyPop {
            0% {
                transform: scale(0.2) rotate(-30deg);
                opacity: 0;
            }

            70% {
                transform: scale(1.2) rotate(5deg);
                opacity: 1;
            }

            100% {
                transform: scale(1) rotate(0);
                opacity: 1;
            }
        }

        @keyframes fadeIn {
            to {
                opacity: 1;
            }
        }

        /* === КАРТА МИРА === */
        #map-screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg);
            z-index: 1000;
            overflow-y: auto;
            padding: 30px 20px;
            text-align: center;
        }

        .locations-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 20px;
            max-width: 500px;
            margin: 20px auto;
        }

        .location-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            background: rgba(106, 90, 205, 0.1);
            border-radius: var(--radius-lg);
            padding: 15px;
            cursor: pointer;
            transition: all 0.2s;
            border: 2px solid transparent;
            box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
            -webkit-tap-highlight-color: rgba(106, 90, 205, 0.3);
            user-select: none;
            -webkit-user-select: none;
        }

        .location-item:hover {
            transform: translateY(-3px);
            border-color: var(--accent);
            background: rgba(106, 90, 205, 0.2);
            box-shadow: var(--shadow-md);
        }

        .location-item:active {
            transform: translateY(1px);
        }

        .location-icon {
            font-size: 48px;
            margin-bottom: 10px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
        }

        .location-name {
            font-family: 'Merriweather', sans-serif;
            font-size: 16px;
            text-align: center;
            color: white;
            font-weight: 600;
        }

        /* Стили для форматированного текста */
        .text strong,
        .text b {
            font-weight: bold;
        }

        .text em,
        .text i {
            font-style: italic;
        }

        .text code {
            font-family: 'Courier New', monospace;
            background-color: rgba(255, 255, 255, 0.1);
            padding: 2px 4px;
            border-radius: 3px;
            font-size: 0.9em;
        }

        .text a {
            color: #4cc9f0;
            text-decoration: underline;
        }

        .text a:hover {
            color: #6dd5fa;
        }

        .location-description {
            font-size: 12px;
            color: #aaa;
            margin-top: 4px;
        }

        .current-location {
            border-color: var(--success);
            background: rgba(76, 175, 80, 0.2);
            box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4), 0 3px 8px rgba(0, 0, 0, 0.2);
        }

        .location-unvisited {
            opacity: 0.6;
            filter: grayscale(0.5);
        }

        .location-unvisited:hover {
            opacity: 1;
            filter: grayscale(0);
        }

        .map-info {
            color: #aaa;
            font-size: 15px;
            margin-top: 15px;
            max-width: 450px;
            margin-left: auto;
            margin-right: auto;
        }

        .map-title {
            text-align: center;
            margin: 12px 0 10px;
            font-size: 28px;
            letter-spacing: 0.2px;
        }

        .category-title {
            margin: 30px 0 15px;
            color: #aaa;
            text-align: left;
            font-size: 20px;
            font-weight: 600;
        }

        /* Адаптация для мобильных устройств */
        @media (max-width: 480px) {
            .locations-grid {
                grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
                gap: 15px;
            }

            .location-item {
                padding: 12px;
            }

            .location-icon {
                font-size: 40px;
            }

            .location-name {
                font-size: 15px;
            }
        }

        .ios-only-warning {
            background: rgba(255, 235, 59, 0.15);
            border-left: 3px solid #ffc107;
            padding: 14px 16px;
            border-radius: 0 8px 8px 0;
            margin: 12px 0 18px 15px;
            font-size: 15px;
            display: none;
        }

        @media (max-width: 480px) {
            .ios-only-warning {
                display: block;
                margin: 12px 10px !important;
                border-radius: 12px !important;
                border-left: none !important;
                border-top: 3px solid #ffc107 !important;
            }
        }

        /* END NOTIFICATION SYSTEM */
        /* ============================================
ПОЛНОЭКРАННЫЙ ПОКАЗ NPC (тап для продолжения)
============================================ */
        #npc-screen {
            pointer-events: none;
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #000;
            z-index: 9999;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }

        #npc-screen.active {
            pointer-events: auto;
            display: flex;
            animation: npcFadeIn 0.25s ease-out;
        }

        @keyframes npcFadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        #npc-screen.fade-out {
            animation: npcFadeOut 0.25s ease-out forwards;
        }

        @keyframes npcFadeOut {
            from {
                opacity: 1;
            }

            to {
                opacity: 0;
            }
        }

        #npc-image {
            max-width: calc(100% - 80px);
            max-height: calc(100% - 80px);
            width: calc(100% - 80px);
            height: calc(100% - 80px);
            object-fit: cover;
            object-position: center;
            opacity: 0;
            transition: opacity 0.3s ease-in;
            border: 4px solid #4ade80;
            border-radius: var(--radius-lg);
            box-shadow: 0 8px 32px rgba(74, 222, 128, 0.3), 0 0 0 2px rgba(74, 222, 128, 0.1);
        }
        
        #npc-screen.ready #npc-image {
            opacity: 1;
        }

        /* UI поверх картинки */
        #npc-overlay-ui {
            position: absolute;
            inset: 0;
            pointer-events: none;
            /* кликается весь экран */
        }

        /* Облачко текста (комикс) */
        #npc-speech {
            position: absolute;
            left: 50%;
            top: 56%;
            transform: translate(-50%, -50%);
            width: min(680px, 75vw);
            background: rgba(255, 255, 255, 0.95);
            color: #0b0f14;
            border: 3px solid rgba(15, 23, 36, 0.95);
            border-radius: 22px;
            padding: 14px 16px;
            font-size: 15px;
            line-height: 1.3;
            text-align: left;
            box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
            white-space: pre-wrap;
        }

        #npc-speech:empty {
            display: none;
        }

        #npc-speech::after {
            content: "";
            position: absolute;
            left: 50%;
            bottom: -18px;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 16px solid transparent;
            border-right: 16px solid transparent;
            border-top: 18px solid rgba(255, 255, 255, 0.95);
        }

        #npc-speech::before {
            content: "";
            position: absolute;
            left: 50%;
            bottom: -24px;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 19px solid transparent;
            border-right: 19px solid transparent;
            border-top: 22px solid rgba(15, 23, 36, 0.95);
        }

        /* Подсказка "Продолжить" */
        #npc-continue {
            position: absolute;
            left: 50%;
            bottom: 52px;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            color: rgba(255, 255, 255, 0.92);
            text-shadow: 0 8px 18px rgba(0, 0, 0, 0.55);
            font-size: 28px;
            letter-spacing: 0.2px;
        }

        /* Пока картинка грузится — прячем подсказку продолжения */
        #npc-screen:not(.ready) #npc-continue {
            opacity: 0;
        }

        .npc-continue-arrow {
            font-size: 34px;
            line-height: 1;
            animation: npcArrowBlink 1.05s ease-in-out infinite;
        }

        @keyframes npcArrowBlink {
            0% {
                opacity: 0.25;
                transform: translateY(6px);
            }

            50% {
                opacity: 1;
                transform: translateY(0);
            }

            100% {
                opacity: 0.25;
                transform: translateY(6px);
            }
        }

        /* Для телефонов - картинка на весь экран */
        @media (max-width: 768px) {
            #npc-image {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }

            #npc-speech {
                top: 60%;
                font-size: 21px;
                width: 92vw;
            }

            #npc-continue {
                bottom: 64px;
                font-size: 30px;
            }
        }

        /* Стили модальных окон уведомлений — в css/popup-modals.css */

        /* === WORD WARP ЭФФЕКТ (hint-stage) === */
        #hint-stage {
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            pointer-events: none !important;
            z-index: 100000 !important;
            overflow: hidden !important;
        }

        #hint-stage .warp-word {
            position: absolute;
            left: 50%;
            top: 50%;
            font: 600 28px/1.0 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
            color: #eef3ff;
            white-space: nowrap;
            pointer-events: none;
            will-change: transform, opacity, filter;
            text-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 20px rgba(155, 89, 182, 0.5);
        }

        /* === FAST TEST MODE: choices only on white, no animations === */
        body.fast-test { background: #fff !important; scroll-behavior: auto !important; }
        body.fast-test * { animation: none !important; transition: none !important; }
        body.fast-test #app { max-width: 100%; }
        body.fast-test #scene {
            opacity: 1 !important;
            transform: none !important;
            transition: none !important;
        }
        body.fast-test .illustration-wrap,
        body.fast-test .text-wrap,
        body.fast-test .location-bar,
        body.fast-test .notification-banner,
        body.fast-test .scene-content-frame,
        body.fast-test .matrix-bg-inside,
        body.fast-test .states-display { display: none !important; }
        body.fast-test #npc-screen,
        body.fast-test #dust-effect { display: none !important; }
        body.fast-test .choices {
            margin: 20px;
            gap: 12px;
        }
        body.fast-test .choice-btn-frame,
        body.fast-test .choice-btn-frame * {
            animation: none !important;
            opacity: 1 !important;
            transition: none !important;
        }
        body.fast-test .choice-btn-frame {
            background: transparent !important;
            border: 1px solid #ccc !important;
        }
        body.fast-test .choice-btn-frame .frame-background,
        body.fast-test .choice-btn-frame .corner-group,
        body.fast-test .choice-btn-frame .line { display: none !important; }
        body.fast-test .choice-btn-frame .choice-btn {
            color: #222 !important;
            padding: 12px 16px !important;
        }