body {
            margin: 0;
            padding: 0;
            background-color: #000;
            font-family: Arial, sans-serif;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            user-select: none;
            overflow: hidden;
        }
        
        .game-container {
            width: 100vw;
            height: 100vh;
            margin: 0;
            background-color: #111;
            padding: 0;
            overflow: hidden;
            position: relative;
            touch-action: none;
            -webkit-overflow-scrolling: touch;
            -webkit-transform: translate3d(0,0,0);
            transform: translate3d(0,0,0);
        }
        
        .viewport {
            position: absolute;
            transform-origin: 0 0;
            will-change: transform;
            width: 100%;
            height: 100%;
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            -webkit-transform: translateZ(0);
            transform: translateZ(0);
            -webkit-perspective: 1000;
            perspective: 1000;
            -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d;
        }
        
        .tile-map {
            position: absolute;
            background-color: #222;
            border: 0px;
            overflow: visible;
            transform: translateZ(0);
            -webkit-transform: translateZ(0);
            /* Size set dynamically in JavaScript */
        }
        
        .tile-layer {
            position: absolute;
            width: 100%;
            height: 100%;
            pointer-events: none; /* Let events pass through to individual tiles */
        }
        
        
        .tile {
            width: 64px;
            height: 64px;
            position: absolute; /* Changed from relative to absolute */
            background-image: url('../images/moon_soil.png');
            background-size: 64px 64px;
            background-repeat: no-repeat;
            touch-action: none;
            -webkit-tap-highlight-color: transparent;
            overflow: visible;
            pointer-events: auto; /* Ensure tiles can receive events */
        }
        
        .building {
            position: absolute;
            z-index: 20;
            pointer-events: auto;
            transform: translateZ(0);
            will-change: transform;
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden;
            border-radius: 4px;
            transition: none;
            cursor: pointer;
        }
        
        .building-rocket {
            width: 128px;
            height: 128px;
            background-image: url('../images/building_2.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
        }
        
        h1 {
            color: #fff;
            text-align: center;
            margin-bottom: 20px;
        }
        
        .info {
            color: #ccc;
            text-align: center;
            margin-top: 20px;
            font-size: 14px;
        }
        
        /* Road overlay styles */
        .road-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 64px;
            height: 64px;
            background-size: 64px 64px;
            background-repeat: no-repeat;
            pointer-events: none;
            z-index: 10;
        }
        
        .road-overlay.road-vertical {
            background-image: url('../images/roads/road_vertical.svg');
        }
        
        .road-overlay.road-horizontal {
            background-image: url('../images/roads/road_horizontal.svg');
        }
        
        .road-overlay.road-curve-top-left {
            background-image: url('../images/roads/road_curve_top_left.svg');
        }
        
        .road-overlay.road-curve-top-right {
            background-image: url('../images/roads/road_curve_top_right.svg');
        }
        
        .road-overlay.road-curve-left-bottom {
            background-image: url('../images/roads/road_curve_left_bottom.svg');
        }
        
        .road-overlay.road-curve-right-bottom {
            background-image: url('../images/roads/road_curve_right_bottom.svg');
        }
        
        .road-overlay.road-t-top-left-bottom {
            background-image: url('../images/roads/road_t_top_left_bottom.svg');
        }
        
        .road-overlay.road-t-top-right-bottom {
            background-image: url('../images/roads/road_t_top_right_bottom.svg');
        }
        
        .road-overlay.road-t-left-top-right {
            background-image: url('../images/roads/road_t_left_top_right.svg');
        }
        
        .road-overlay.road-t-left-bottom-right {
            background-image: url('../images/roads/road_t_left_bottom_right.svg');
        }
        
        .road-overlay.road-cross {
            background-image: url('../images/roads/road_cross.svg');
        }
        
        /* Bridge overlay styles */
        .road-overlay.road-bridge-vertical {
            background-image: url('../images/roads/bridges/bridge_vertical.svg');
        }
        
        .road-overlay.road-bridge-horizontal {
            background-image: url('../images/roads/bridges/bridge_horizontal.svg');
        }
        
        .road-overlay.road-bridge-curve-top-left {
            background-image: url('../images/roads/bridges/bridge_curve_top_left.svg');
        }
        
        .road-overlay.road-bridge-curve-top-right {
            background-image: url('../images/roads/bridges/bridge_curve_top_right.svg');
        }
        
        .road-overlay.road-bridge-curve-left-bottom {
            background-image: url('../images/roads/bridges/bridge_curve_left_bottom.svg');
        }
        
        .road-overlay.road-bridge-curve-right-bottom {
            background-image: url('../images/roads/bridges/bridge_curve_right_bottom.svg');
        }
        
        .road-overlay.road-bridge-t-top-left-bottom {
            background-image: url('../images/roads/bridges/bridge_t_top_left_bottom.svg');
        }
        
        .road-overlay.road-bridge-t-top-right-bottom {
            background-image: url('../images/roads/bridges/bridge_t_top_right_bottom.svg');
        }
        
        .road-overlay.road-bridge-t-left-top-right {
            background-image: url('../images/roads/bridges/bridge_t_left_top_right.svg');
        }
        
        .road-overlay.road-bridge-t-left-bottom-right {
            background-image: url('../images/roads/bridges/bridge_t_left_bottom_right.svg');
        }
        
        .road-overlay.road-bridge-cross {
            background-image: url('../images/roads/bridges/bridge_cross.svg');
        }
        
        /* Keep tiles with roads clickable */
        .tile.has-road {
            cursor: pointer;
        }
        
        .tile:hover {
            opacity: 0.8;
            cursor: pointer;
        }
        
        .astronaut {
            position: absolute;
            width: 128px;
            height: 128px;
            background-image: url('../images/astronout.png');
            background-size: 512px 256px;
            z-index: 25;
            pointer-events: none;
            animation: astronaut-jump 0.8s steps(1) infinite;
        }
        
        @keyframes astronaut-jump {
            0%    { background-position: 0 0; }
            12.5% { background-position: -128px 0; }
            25%   { background-position: -256px 0; }
            37.5% { background-position: -384px 0; }
            50%   { background-position: 0 -128px; }
            62.5% { background-position: -128px -128px; }
            75%   { background-position: -256px -128px; }
            87.5% { background-position: -384px -128px; }
            100%  { background-position: 0 0; }
        }
        
        /* Build button - old positioning removed, now uses toolbar-button class */
        
        .modal {
            display: none;
            position: fixed;
            z-index: 200;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.95);
        }
        
        .modal-content {
            background-color: #222;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #444;
            border-radius: 10px;
            width: 90%;
            max-width: 500px;
            text-align: center;
        }
        
        .modal-content.modern-modal {
            background: linear-gradient(145deg, rgba(10, 25, 47, 0.98), rgba(0, 15, 30, 0.98));
            border: 1px solid rgba(0, 212, 255, 0.3);
            box-shadow: 0 8px 32px rgba(0, 212, 255, 0.4), 
                        0 2px 20px rgba(0, 0, 0, 0.8),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
            margin: 5% auto;
            max-width: 900px;
            padding: 0;
            border-radius: 20px;
            overflow: hidden;
        }
        
        .modal-header-section {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 20px 12px;
            background: linear-gradient(to right, rgba(0, 212, 255, 0.2), rgba(0, 150, 200, 0.2));
            border-bottom: 1px solid rgba(0, 212, 255, 0.2);
        }
        
        .modal-header {
            color: #fff;
            margin: 0;
            font-size: 20px;
            font-weight: 600;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            letter-spacing: -0.5px;
        }
        
        .modal-content.modern-modal .close {
            color: rgba(255, 255, 255, 0.8);
            font-size: 32px;
            font-weight: 300;
            cursor: pointer;
            transition: all 0.2s ease;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
        }
        
        .modal-content.modern-modal .close:hover {
            color: #fff;
            background: rgba(255, 255, 255, 0.2);
            transform: rotate(90deg);
        }
        
        .category-tabs-container {
            width: 100%;
            padding: 20px 30px 0;
            overflow: hidden;
            position: relative;
        }
        
        .category-tabs {
            display: flex;
            gap: 8px;
            overflow-x: auto;
            overflow-y: hidden;
            scroll-behavior: smooth;
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* Internet Explorer 10+ */
            padding-bottom: 10px;
        }
        
        .category-tabs::-webkit-scrollbar {
            display: none; /* WebKit */
        }
        
        .category-tab {
            flex: 0 0 auto;
            width: 50px;
            height: 50px;
            padding: 0;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(0, 212, 255, 0.3);
            border-radius: 50%;
            color: rgba(255, 255, 255, 0.7);
            cursor: pointer;
            font-size: 24px;
            transition: all 0.3s ease;
            background: rgba(255, 255, 255, 0.08);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }
        
        .category-tab:hover {
            background: rgba(0, 212, 255, 0.2);
            border-color: rgba(0, 212, 255, 0.5);
            transform: scale(1.1);
        }
        
        /* Tooltip on hover */
        .category-tab:hover::after {
            content: attr(title);
            position: absolute;
            bottom: -30px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 5px 10px;
            border-radius: 5px;
            font-size: 12px;
            white-space: nowrap;
            z-index: 1000;
            pointer-events: none;
        }
        
        .category-tab.active {
            background: linear-gradient(135deg, #00d4ff, #0096c7);
            border-color: transparent;
            box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
            transform: scale(1.15);
        }
        
        .building-options {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 20px;
            padding: 30px;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        /* Custom scrollbar for building options */
        .building-options::-webkit-scrollbar {
            width: 8px;
        }
        
        .building-options::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
        }
        
        .building-options::-webkit-scrollbar-thumb {
            background: rgba(0, 212, 255, 0.5);
            border-radius: 4px;
        }
        
        .building-options::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 212, 255, 0.7);
        }
        
        .building-option {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(0, 212, 255, 0.2);
            border-radius: 15px;
            padding: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            background: rgba(255, 255, 255, 0.08);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
            overflow: hidden;
        }
        
        .building-option::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, transparent, rgba(0, 212, 255, 0.1));
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .building-option:hover {
            border-color: rgba(0, 212, 255, 0.5);
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
        }
        
        .building-option:hover::before {
            opacity: 1;
        }
        
        /* Locked building/decoration state */
        .building-option.locked {
            opacity: 0.5;
            cursor: not-allowed;
            border-color: rgba(255, 0, 0, 0.2);
        }
        
        .building-option.locked:hover {
            transform: none;
            box-shadow: none;
            border-color: rgba(255, 0, 0, 0.3);
        }
        
        .building-option.locked::before {
            background: linear-gradient(135deg, transparent, rgba(255, 0, 0, 0.1));
        }
        
        .building-image {
            width: 100px;
            height: 100px;
            margin: 0 auto 15px;
            object-fit: contain;
            display: block;
        }
        
        .building-name {
            color: #fff;
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 10px;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        }
        
        .building-details {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        
        .building-detail-row {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            font-size: 14px;
            color: rgba(255, 255, 255, 0.8);
        }
        
        .coin-icon {
            width: 20px;
            height: 20px;
            object-fit: contain;
        }
        
        /* Decoration options specific styling */
        .decoration-options {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 20px;
            padding: 30px;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        /* Custom scrollbar for decoration options */
        .decoration-options::-webkit-scrollbar {
            width: 8px;
        }
        
        .decoration-options::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
        }
        
        .decoration-options::-webkit-scrollbar-thumb {
            background: rgba(0, 212, 255, 0.5);
            border-radius: 4px;
        }
        
        .decoration-options::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 212, 255, 0.7);
        }
        
        /* Road options styling */
        .road-options {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 20px;
            padding: 30px;
            max-height: 60vh;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        /* Custom scrollbar for road options */
        .road-options::-webkit-scrollbar {
            width: 8px;
        }
        
        .road-options::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
        }
        
        .road-options::-webkit-scrollbar-thumb {
            background: rgba(0, 212, 255, 0.5);
            border-radius: 4px;
        }
        
        .road-options::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 212, 255, 0.7);
        }
        
        /* Landscape/terrain options styling */
        .landscape-options {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 20px;
            padding: 30px;
            max-height: 60vh;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        /* Custom scrollbar for landscape options */
        .landscape-options::-webkit-scrollbar {
            width: 8px;
        }
        
        .landscape-options::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
        }
        
        .landscape-options::-webkit-scrollbar-thumb {
            background: rgba(0, 212, 255, 0.5);
            border-radius: 4px;
        }
        
        .landscape-options::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 212, 255, 0.7);
        }
        
        .building-cost {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, 0.8);
            color: #FFD700;
            text-align: center;
            padding: 4px;
            font-size: 14px;
            font-weight: bold;
            border-radius: 0 0 6px 6px;
        }
        
        @media (max-width: 768px) {
            .modal-content {
                margin: 10% auto;
                width: 95%;
            }
            
            .modal-content.modern-modal {
                margin: 0;
                width: 100%;
                height: 100%;
                max-width: 100%;
                border-radius: 0;
            }
            
            .modal-header-section {
                padding: 12px 15px;
            }
            
            .modal-header {
                font-size: 18px;
            }
            
            .category-tabs-container {
                padding: 15px 20px 0;
            }
            
            .category-tabs {
                gap: 6px;
            }
            
            .category-tab {
                width: 45px;
                height: 45px;
                font-size: 20px;
            }
            
            .building-options {
                grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
                gap: 15px;
                padding: 20px;
            }
            
            .building-option {
                padding: 12px;
            }
            
            .building-image {
                width: 80px;
                height: 80px;
                margin-bottom: 10px;
            }
            
            .building-name {
                font-size: 14px;
            }
            
            .building-detail-row {
                font-size: 12px;
            }
            
            .coin-icon {
                width: 16px;
                height: 16px;
            }
            
            .decoration-options {
                grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
                gap: 15px;
                padding: 20px;
            }
            
            .road-options {
                grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
                gap: 15px;
                padding: 20px;
            }
            
            .landscape-options {
                grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
                gap: 15px;
                padding: 20px;
            }
        }
        
        /* Landscape mode for mobile and tablets */
        @media (max-width: 1024px) and (orientation: landscape) {
            .modal-content.modern-modal {
                margin: 0 !important;
                width: 100vw !important;
                max-width: 100vw !important;
                height: 100vh !important;
                max-height: 100vh !important;
                border-radius: 0 !important;
                /* Add safe area padding for notch and ensure close button is visible */
                padding-left: env(safe-area-inset-left) !important;
                padding-right: max(env(safe-area-inset-right), 15px) !important;
                box-sizing: border-box !important;
            }
            
            .unified-modal-content {
                margin: 0 !important;
                width: 100vw !important;
                max-width: 100vw !important;
                height: 100vh !important;
                max-height: 100vh !important;
                /* Remove border for fullscreen landscape to prevent edge visibility */
                border: none !important;
                border-radius: 0 !important;
                /* Very transparent with strong blur for landscape */
                background: linear-gradient(145deg, rgba(10, 25, 47, 0.2), rgba(0, 15, 30, 0.2)) !important;
                backdrop-filter: blur(30px) !important;
                -webkit-backdrop-filter: blur(30px) !important;
                /* Enable scrolling */
                overflow-y: auto !important;
                overflow-x: hidden !important;
                -webkit-overflow-scrolling: touch !important;
                /* Remove cyan glow on landscape mobile */
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
                /* Add safe area padding for notch with fallback values */
                padding-top: env(safe-area-inset-top, 0px) !important;
                padding-bottom: env(safe-area-inset-bottom, 0px) !important;
                padding-left: env(safe-area-inset-left, 0px) !important;
                padding-right: env(safe-area-inset-right, 0px) !important;
                box-sizing: border-box !important;
            }
            
            .modal-header-section {
                padding: 8px 12px 6px 20px !important; /* top right bottom left - asymmetric for notch */
            }
            
            .modal-header {
                font-size: 14px !important;
            }
            
            .modal-content.modern-modal .close {
                width: 44px !important;
                height: 44px !important;
                font-size: 32px !important;
            }
            
            .category-tabs-container {
                padding: 8px 12px 0 20px !important; /* top right bottom left - asymmetric for notch */
            }
            
            .category-tab {
                width: 36px !important;
                height: 36px !important;
                font-size: 16px !important;
            }
            
            .building-options {
                grid-template-columns: repeat(3, 1fr) !important;
                gap: 12px !important;
                padding: 12px 12px 12px 20px !important; /* top right bottom left - more padding on left for notch */
            }
            
            .decoration-options {
                grid-template-columns: repeat(3, 1fr) !important;
                gap: 12px !important;
                padding: 12px 12px 12px 20px !important; /* top right bottom left - more padding on left for notch */
            }
            
            .road-options {
                max-height: calc(100vh - 120px) !important;
                padding: 12px 12px 12px 20px !important; /* top right bottom left - more padding on left for notch */
            }
            
            .landscape-options {
                max-height: calc(100vh - 120px) !important;
                padding: 12px 12px 12px 20px !important; /* top right bottom left - more padding on left for notch */
            }
            
            .building-option {
                padding: 10px !important;
            }
            
            .building-image {
                width: 80px !important;
                height: 80px !important;
                margin-bottom: 8px !important;
            }
            
            .building-name {
                font-size: 13px !important;
                margin-bottom: 6px !important;
            }
            
            .building-info,
            .decoration-info {
                font-size: 11px !important;
            }
            
            .building-cost,
            .decoration-cost {
                font-size: 13px !important;
            }
        }
        
        
        /* Portrait mode for mobile - terrain 2x2 grid */
        @media (max-width: 768px) and (orientation: portrait) {
            .landscape-options {
                grid-template-columns: repeat(2, 1fr);
                gap: 12px;
                padding: 15px;
            }
        }
        
        
        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }
        
        .close:hover {
            color: #fff;
        }
        
        .building-preview {
            position: fixed;
            width: 128px;
            height: 128px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            pointer-events: none;
            z-index: 50;
            opacity: 0.7;
            display: none;
        }
        
        /* Road button - old positioning removed, now uses toolbar-button class */

        
        /* Landscape button - old positioning removed, now uses toolbar-button class */        
        /* Terrain overlay base styles */
        .terrain-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 64px;
            height: 64px;
            background-size: 64px 64px;
            background-repeat: no-repeat;
            pointer-events: none;
            z-index: 5;
            overflow: hidden;
        }
        
        /* Specific terrain types */
        .terrain-overlay.terrain-water {
            background-image: url('../images/water_1.png');
        }
        
        .terrain-overlay.terrain-grass {
            background-image: url('../images/grass_1.png');
        }
        
        .terrain-overlay.terrain-dirt {
            background-image: url('../images/dirt_1.png');
        }
        
        .terrain-overlay.terrain-sand {
            background-image: url('../images/sand_1.png');
        }
        
        /* Terrain corner styles with border-radius */
        .terrain-overlay.corner-top-left {
            border-top-left-radius: 32px;
        }
        
        .terrain-overlay.corner-top-right {
            border-top-right-radius: 32px;
        }
        
        .terrain-overlay.corner-bottom-left {
            border-bottom-left-radius: 32px;
        }
        
        .terrain-overlay.corner-bottom-right {
            border-bottom-right-radius: 32px;
        }
        
        .terrain-overlay.corner-all {
            border-radius: 32px;
        }
        
        /* Keep tiles with terrain clickable */
        .tile.has-terrain {
            cursor: pointer;
        }
        
        /* Terrain/landscape emoji styles */
        .landscape-water,
        .landscape-grass,
        .landscape-dirt,
        .landscape-sand,
        .landscape-lava {
            background-image: none;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 50px;
        }
        
        .landscape-water::before {
            content: "💧";
        }
        
        .landscape-grass::before {
            content: "🌿";
        }
        
        .landscape-dirt::before {
            content: "🟫";
        }
        
        .landscape-sand::before {
            content: "🏖️";
        }
        
        .landscape-snow {
            background-image: none;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 50px;
        }
        
        .landscape-snow::before {
            content: "❄️";
        }
        
        .landscape-lava {
            background-image: none;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 50px;
        }
        
        .landscape-lava::before {
            content: "🌋";
        }
        
        
        /* Drawing indicator */
        .drawing-indicator {
            position: fixed;
            bottom: max(env(safe-area-inset-bottom) + 16px, 30px);
            left: 50%;
            transform: translateX(-50%);
            background: rgba(30, 30, 30, 0.85);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            display: none;
            align-items: center;
            gap: 12px;
            z-index: 150;
            font-size: 14px;
            font-weight: 500;
            box-shadow: 
                0 8px 32px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
            min-height: 44px;
            max-width: calc(100vw - 32px);
            white-space: nowrap;
        }
        
        .drawing-indicator.active {
            display: flex;
        }
        
        .drawing-indicator .drawing-icon {
            width: 44px;
            height: 44px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.15);
            flex-shrink: 0;
            font-size: 26px;
        }
        
        .drawing-indicator .drawing-info {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 14px;
            font-weight: 500;
        }
        
        .drawing-indicator .drawing-size {
            background: rgba(255, 255, 255, 0.15);
            padding: 2px 8px;
            border-radius: 10px;
            font-weight: 600;
            min-width: 20px;
            text-align: center;
        }
        
        .drawing-indicator .drawing-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-left: auto;
        }
        
        .drawing-indicator .close-drawing {
            width: 44px;
            height: 44px;
            background: rgba(244, 67, 54, 0.9);
            border: none;
            border-radius: 22px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: 600;
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .drawing-indicator .close-drawing:hover {
            transform: scale(1.1);
            background: rgba(244, 67, 54, 1);
        }
        
        /* Brush settings button */
        .drawing-indicator .brush-settings-btn {
            width: 44px;
            height: 44px;
            background: rgba(66, 133, 244, 0.9);
            border: none;
            border-radius: 22px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .drawing-indicator .brush-settings-btn:hover {
            transform: scale(1.1);
            background: rgba(66, 133, 244, 1);
        }
        
        /* Terrain quick change button */
        .drawing-indicator .terrain-quick-change-btn {
            width: 44px;
            height: 44px;
            background: rgba(156, 39, 176, 0.9);
            border: none;
            border-radius: 22px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .drawing-indicator .terrain-quick-change-btn:hover {
            transform: scale(1.1);
            background: rgba(156, 39, 176, 1);
        }

        /* Terrain undo button */
        .drawing-indicator .terrain-undo-btn {
            width: 44px;
            height: 44px;
            background: rgba(76, 175, 80, 0.9);
            border: none;
            border-radius: 22px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .drawing-indicator .terrain-undo-btn:hover {
            transform: scale(1.1);
            background: rgba(76, 175, 80, 1);
        }
        
        .drawing-indicator .terrain-undo-btn:active {
            transform: scale(0.95);
        }
        
        /* Mobile optimizations for drawing indicator */
        @media (max-width: 768px) {
            .drawing-indicator {
                bottom: max(env(safe-area-inset-bottom) + 12px, 20px);
                padding: 8px 12px;
                gap: 10px;
                border-radius: 24px;
                font-size: 13px;
                min-height: 60px;
            }
            
            .drawing-indicator .drawing-icon {
                width: 44px;
                height: 44px;
                font-size: 24px;
                border-radius: 12px;
            }
            
            .drawing-indicator .drawing-info {
                gap: 4px;
                font-size: 13px;
            }
            
            .drawing-indicator .drawing-size {
                padding: 1px 6px;
                font-size: 13px;
                min-width: 18px;
            }
            
            .drawing-indicator .drawing-actions {
                gap: 6px;
            }
            
            .drawing-indicator .brush-settings-btn,
            .drawing-indicator .terrain-quick-change-btn,
            .drawing-indicator .terrain-undo-btn,
            .drawing-indicator .close-drawing {
                width: 44px;
                height: 44px;
                border-radius: 22px;
                font-size: 16px;
            }
        }
        
        /* Road Builder Indicator */
        .road-builder-indicator {
            position: fixed;
            bottom: max(env(safe-area-inset-bottom) + 16px, 30px);
            left: 50%;
            transform: translateX(-50%);
            background: rgba(30, 30, 30, 0.85);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            display: none;
            align-items: center;
            gap: 12px;
            z-index: 1000;
            font-size: 14px;
            font-weight: 500;
            box-shadow: 
                0 8px 32px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
            min-height: 44px;
            max-width: calc(100vw - 32px);
            white-space: nowrap;
            animation: slideUpFade 0.3s ease-out;
        }
        
        .road-builder-indicator.active {
            display: flex;
        }
        
        .road-builder-indicator .road-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 165, 0, 0.15);
            border: 1px solid rgba(255, 165, 0, 0.25);
            flex-shrink: 0;
            font-size: 20px;
        }
        
        .road-builder-indicator .road-info {
            display: flex;
            align-items: center;
            font-size: 14px;
            font-weight: 500;
        }
        
        .road-builder-indicator .road-type {
            color: rgba(255, 255, 255, 0.9);
        }
        
        .road-builder-indicator .road-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-left: auto;
        }
        
        .road-builder-indicator .road-quick-change-btn {
            width: 28px;
            height: 28px;
            background: rgba(255, 165, 0, 0.9);
            border: none;
            border-radius: 14px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .road-builder-indicator .road-quick-change-btn:hover {
            transform: scale(1.1);
            background: rgba(255, 165, 0, 1);
        }
        
        /* Road undo button */
        .road-builder-indicator .road-undo-btn {
            width: 28px;
            height: 28px;
            background: rgba(76, 175, 80, 0.9);
            border: none;
            border-radius: 14px;
            color: white;
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s, background 0.2s;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        .road-builder-indicator .road-undo-btn:hover {
            transform: scale(1.1);
            background: rgba(76, 175, 80, 1);
        }
        
        .road-builder-indicator .road-undo-btn:active {
            transform: scale(0.95);
        }
        
        .road-builder-indicator .close-road-builder {
            width: 28px;
            height: 28px;
            background: rgba(244, 67, 54, 0.9);
            border: none;
            border-radius: 14px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            font-weight: 600;
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .road-builder-indicator .close-road-builder:hover {
            transform: scale(1.1);
            background: rgba(244, 67, 54, 1);
        }
        
        /* Mobile optimizations for road builder indicator */
        @media (max-width: 768px) {
            .road-builder-indicator {
                bottom: max(env(safe-area-inset-bottom) + 12px, 20px);
                padding: 6px 12px;
                gap: 10px;
                border-radius: 18px;
                font-size: 13px;
                min-height: 40px;
            }
            
            .road-builder-indicator .road-icon {
                width: 28px;
                height: 28px;
                font-size: 18px;
            }
            
            .road-builder-indicator .road-info {
                font-size: 13px;
            }
            
            .road-builder-indicator .road-actions {
                gap: 6px;
            }
            
            .road-builder-indicator .road-quick-change-btn,
            .road-builder-indicator .road-undo-btn,
            .road-builder-indicator .close-road-builder {
                width: 24px;
                height: 24px;
                border-radius: 12px;
                font-size: 12px;
            }
        }
        
        @keyframes slideUpFade {
            from {
                transform: translateX(-50%) translateY(20px);
                opacity: 0;
            }
            to {
                transform: translateX(-50%) translateY(0);
                opacity: 1;
            }
        }
        
        /* Brush Settings Modal */
        .brush-modal .modal-content {
            max-width: 400px;
            width: 90%;
        }
        
        .brush-settings-content {
            background: linear-gradient(135deg, rgba(29, 36, 51, 1) 0%, rgba(44, 55, 78, 1) 100%);
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                        0 0 100px rgba(66, 133, 244, 0.15),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }
        
        .brush-settings-body {
            padding: 30px;
        }
        
        .brush-size-control {
            text-align: center;
        }
        
        .brush-size-control label {
            display: block;
            margin-bottom: 20px;
            font-size: 18px;
            font-weight: 500;
            color: white;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .brush-size-slider-container {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-bottom: 30px;
            padding: 20px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        .brush-slider {
            flex: 1;
            -webkit-appearance: none;
            appearance: none;
            height: 8px;
            background: rgba(255, 255, 255, 0.1);
            outline: none;
            border-radius: 4px;
            position: relative;
        }
        
        .brush-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 24px;
            height: 24px;
            background: linear-gradient(135deg, #4285f4 0%, #1976d2 100%);
            cursor: pointer;
            border-radius: 50%;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3),
                        0 0 20px rgba(66, 133, 244, 0.5);
            transition: all 0.2s ease;
        }
        
        .brush-slider::-webkit-slider-thumb:hover {
            transform: scale(1.2);
            box-shadow: 0 4px 12px rgba(0,0,0,0.4),
                        0 0 30px rgba(66, 133, 244, 0.7);
        }
        
        .brush-slider::-moz-range-thumb {
            width: 24px;
            height: 24px;
            background: linear-gradient(135deg, #4285f4 0%, #1976d2 100%);
            cursor: pointer;
            border-radius: 50%;
            border: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3),
                        0 0 20px rgba(66, 133, 244, 0.5);
            transition: all 0.2s ease;
        }
        
        .brush-size-value {
            font-size: 32px;
            font-weight: 700;
            color: #4285f4;
            min-width: 50px;
            text-shadow: 0 0 20px rgba(66, 133, 244, 0.5);
        }
        
        .brush-preview-container {
            background: rgba(0, 0, 0, 0.5);
            border-radius: 16px;
            padding: 20px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 20px;
        }
        
        #brushPreviewCanvas {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 8px;
            display: block;
            margin: 0 auto;
        }
        
        .brush-preview-label {
            text-align: center;
            margin-top: 10px;
            font-size: 14px;
            color: rgba(255, 255, 255, 0.6);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .brush-actions {
            display: flex;
            justify-content: center;
            margin-top: 30px;
        }
        
        .brush-action-btn {
            padding: 12px 32px;
            border: none;
            border-radius: 24px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .brush-action-btn.apply-btn {
            background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
            color: white;
            box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3),
                        inset 0 1px 0 rgba(255, 255, 255, 0.2);
        }
        
        .brush-action-btn.apply-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4),
                        inset 0 1px 0 rgba(255, 255, 255, 0.3);
        }
        
        .brush-action-btn.apply-btn:active {
            transform: translateY(0);
        }

        .space-car {
            position: absolute;
            width: 64px;
            height: 64px;
            z-index: 22; /* Above buildings, below astronaut? */
            pointer-events: none;
            transition: transform 0.5s linear, left 0.5s linear, top 0.5s linear;
            will-change: transform, left, top;
            transform-origin: center center;
        }
        
        /* Toast notification styles - Modern 2025 Design */
        .toast {
            position: fixed;
            bottom: 100px; /* Increased to avoid overlap with drawing/road indicators */
            top: auto;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background: linear-gradient(135deg, rgba(29, 36, 51, 0.98) 0%, rgba(44, 55, 78, 0.98) 100%);
            color: white;
            padding: 16px 32px;
            border-radius: 24px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                        0 0 40px rgba(66, 133, 244, 0.2),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
            font-size: 15px;
            font-weight: 500;
            z-index: 10000;
            opacity: 0;
            transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
            pointer-events: none;
            max-width: min(90vw, 400px);
            min-width: 200px;
            width: auto;
            max-height: 80px;
            height: auto;
            text-align: center;
            border: 1px solid rgba(255, 255, 255, 0.1);
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            white-space: normal;
            word-wrap: break-word;
        }
        
        .toast::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
            animation: shimmer 2s infinite;
        }
        
        @keyframes shimmer {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }
        
        .toast.show {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
            pointer-events: auto;
        }
        
        /* Toast type variations */
        .toast.success {
            background: linear-gradient(135deg, rgba(16, 142, 89, 0.95) 0%, rgba(5, 150, 105, 0.95) 100%);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                        0 0 40px rgba(16, 185, 129, 0.3),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }
        
        .toast.error {
            background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(239, 68, 68, 0.95) 100%);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                        0 0 40px rgba(248, 113, 113, 0.3),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }
        
        .toast.warning {
            background: linear-gradient(135deg, rgba(217, 119, 6, 0.95) 0%, rgba(245, 158, 11, 0.95) 100%);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                        0 0 40px rgba(251, 191, 36, 0.3),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }
        
        /* Portrait mode adjustments */
        @media (orientation: portrait) {
            .toast {
                position: fixed !important;
                bottom: max(env(safe-area-inset-bottom) + 100px, 120px) !important;
                top: auto !important;
                max-width: 280px !important;
                width: auto !important;
                max-height: 60px !important;
                height: auto !important;
                font-size: 14px;
                padding: 12px 20px;
                min-width: 180px;
                line-height: 1.4;
                transform: translateX(-50%) translateY(100px);
            }
            
            .toast.show {
                transform: translateX(-50%) translateY(0) !important;
            }
        }
        
        /* iOS specific portrait adjustments */
        @media (orientation: portrait) and (-webkit-min-device-pixel-ratio: 2) {
            .toast {
                position: fixed !important;
                bottom: max(env(safe-area-inset-bottom) + 110px, 130px) !important;
                top: auto !important;
                max-width: 260px !important;
            }
        }
        
        /* Small screens */
        @media (max-width: 480px) {
            .toast {
                font-size: 14px;
                padding: 12px 20px;
                border-radius: 20px;
                max-width: 260px !important;
            }
        }
        
        /* Extra safeguard for iOS app */
        body.ios-app .toast {
            position: fixed !important;
            bottom: max(env(safe-area-inset-bottom) + 100px, 120px) !important;
            top: auto !important;
            max-width: min(80vw, 320px) !important;
            max-height: 70px !important;
            height: auto !important;
        }
        
        
        
        /* Building controls */
        .building-controls {
            position: absolute;
            display: flex;
            gap: 15px;
            pointer-events: all !important;
            z-index: 150; /* Ensure it's on top of other UI */
            -webkit-tap-highlight-color: transparent;
        }
        
        .building-control {
            width: 44px;
            height: 44px;
            min-width: 44px;
            min-height: 44px;
            border-radius: 50%;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            user-select: none;
            position: relative;
            background-clip: padding-box;
        }
        
        .building-control:hover {
            transform: scale(1.1);
        }
        
        .building-control:active {
            transform: scale(0.95);
        }
        
        .building-control svg {
            pointer-events: none;
        }
        
        .building-control.delete {
            background-color: #f44336;
        }
        
        .building-control.delete:hover {
            background-color: #d32f2f;
        }
        
        .building-control.confirm {
            background-color: #4CAF50;
        }
        
        .building-control.confirm:hover {
            background-color: #45a049;
        }
        
        /* Arrow controls for moving buildings */
        .building-control.arrow-up,
        .building-control.arrow-down,
        .building-control.arrow-left,
        .building-control.arrow-right {
            background-color: #2196F3;
        }
        
        .building-control.arrow-up:hover,
        .building-control.arrow-down:hover,
        .building-control.arrow-left:hover,
        .building-control.arrow-right:hover {
            background-color: #1976D2;
        }
        
        /* Adjust building controls layout for 6 buttons */
        .building-controls.with-arrows {
            display: grid;
            grid-template-columns: repeat(3, 44px);
            grid-template-rows: repeat(2, 44px);
            gap: 8px;
            bottom: auto;
        }
        
        .building-controls.with-arrows .arrow-up {
            grid-column: 2;
            grid-row: 1;
        }
        
        .building-controls.with-arrows .arrow-left {
            grid-column: 1;
            grid-row: 2;
        }
        
        .building-controls.with-arrows .arrow-down {
            grid-column: 2;
            grid-row: 2;
        }
        
        .building-controls.with-arrows .arrow-right {
            grid-column: 3;
            grid-row: 2;
        }
        
        .building-controls.with-arrows .delete {
            grid-column: 1;
            grid-row: 1;
        }
        
        .building-controls.with-arrows .confirm {
            grid-column: 3;
            grid-row: 1;
        }
        
        /* Preview state for buildings */
        .building.preview {
            opacity: 0.7;
            pointer-events: none;
        }

        /* Top toolbar container */
        .top-toolbar {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 15px;
            background: rgba(0, 0, 0, 0.6);
            border-radius: 20px;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
            z-index: 100;
            margin-top: env(safe-area-inset-top);
        }

        /* Portrait mode adjustments for top toolbar */
        @media (orientation: portrait) {
            .top-toolbar {
                top: max(calc(env(safe-area-inset-top) + 10px), 20px);
                width: 90%;
                max-width: 450px;
                padding: 8px 10px;
                gap: 8px;
                justify-content: space-evenly;
            }
            
            .top-toolbar .toolbar-button {
                width: calc((100% - 80px) / 7) !important;
                max-width: 48px !important;
                min-width: 40px !important;
            }
        }

        /* Landscape mode adjustments for top toolbar */
        @media (orientation: landscape) and (max-width: 1024px) {
            .top-toolbar {
                /* Keep centered but fix width */
                left: 50%;
                transform: translateX(-50%);
                
                /* Force shrink-to-fit */
                width: -webkit-fit-content !important;
                width: -moz-fit-content !important;
                width: fit-content !important;
                max-width: none;
                
                /* Layout */
                gap: 8px;
                padding: 8px 12px;
            }
            
            .top-toolbar .toolbar-button {
                width: 48px !important;
                height: 48px !important;
            }
        }

        /* Small screens - compact top toolbar (portrait only) */
        @media (max-width: 480px) and (orientation: portrait) {
            .top-toolbar {
                padding: 8px 10px;
                gap: 6px;
            }
            
            .top-toolbar .toolbar-button {
                width: 44px !important;
                height: 44px !important;
            }
            
            /* 3x3 grid layout for road options on small portrait screens */
            .road-options {
                grid-template-columns: repeat(3, 1fr) !important;
                gap: 12px !important;
                padding: 15px !important;
                max-height: calc(100vh - 180px) !important;
            }
        }
        
        /* Small screens landscape - ensure fit-content */
        @media (max-width: 480px) and (orientation: landscape) {
            .top-toolbar {
                width: -webkit-fit-content !important;
                width: -moz-fit-content !important;
                width: fit-content !important;
                max-width: none !important;
            }
        }
        
        /* Progress bars containers */
        .progress-bars-left {
            position: fixed;
            top: 20px;
            left: 20px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            z-index: 90;
        }
        
        .progress-bars-right {
            position: fixed;
            top: 20px;
            right: 20px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            z-index: 90;
        }
        
        /* Landscape mode - keep progress bars stacked vertically */
        @media (orientation: landscape) {
            .progress-bars-left {
                /* Keep default flex-direction: column */
                gap: 10px;
                left: max(calc(env(safe-area-inset-left) + 10px), 20px);
            }
            
            .progress-bars-right {
                /* Keep default flex-direction: column */
                gap: 10px;
                right: max(calc(env(safe-area-inset-right) + 10px), 20px);
            }
        }
        
        /* Portrait mode - adjust positions and top toolbar */
        @media (orientation: portrait) {
            .top-toolbar {
                top: max(env(safe-area-inset-top), 10px) !important;
                margin-top: 0 !important;
            }
            
            .progress-bars-left {
                top: max(calc(env(safe-area-inset-top) + 70px), 80px);
                gap: 8px;
            }
            
            .progress-bars-right {
                top: max(calc(env(safe-area-inset-top) + 70px), 80px);
                gap: 8px;
            }
        }
        
        /* Small portrait screens */
        @media (max-width: 430px) and (orientation: portrait) {
            .progress-bars-left,
            .progress-bars-right {
                top: max(calc(env(safe-area-inset-top) + 65px), 75px);
            }
        }
        

        /* Bottom toolbar container */
        .bottom-toolbar {
            position: fixed;
            bottom: 0;
            right: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 15px;
            background: rgba(0, 0, 0, 0.6);
            border-radius: 20px;
            box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.3);
            z-index: 150;
             margin-bottom: max(env(safe-area-inset-bottom), 20px);
        }

        /* Toolbar button base styles */
        .toolbar-button {
            position: relative !important;
            width: 55px;
            height: 55px;
            background-color: transparent;
            border-radius: 8px;
            border: none;
            cursor: pointer;
            box-shadow: none;
            transition: transform 0.2s ease, background-color 0.2s ease;
            margin: 0 !important;
            padding: 0 !important;
            right: auto !important;
            bottom: auto !important;
            top: auto !important;
            left: auto !important;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: visible;
            flex-shrink: 0;
        }

        .toolbar-button:hover {
            transform: scale(1.08);
            background-color: rgba(255, 255, 255, 0.1);
        }

        .toolbar-button.active {
            background-color: rgba(255, 255, 255, 0.15);
        }
        
        /* Toolbar button images */
        .toolbar-button img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            border-radius: 0;
            display: block;
        }
        
        /* Daily Quest button specific styles */
        .daily-quest-button {
            position: relative;
        }
        
        .daily-quest-button svg {
            width: 100%;
            height: 100%;
        }
        
        /* Quest indicator (notification dot) */
        .quest-indicator {
            position: absolute;
            top: -2px;
            right: -2px;
            width: 16px;
            height: 16px;
            background: #ff6b6b;
            border-radius: 50%;
            border: 2px solid #1a1a2e;
            display: flex;
            align-items: center;
            justify-content: center;
            animation: questPulse 2s ease-in-out infinite;
        }
        
        .quest-dot {
            width: 8px;
            height: 8px;
            background: white;
            border-radius: 50%;
        }
        
        @keyframes questPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.2); }
        }
        
        /* Rocket orders indicator */
        .rocket-indicator {
            position: absolute;
            top: -2px;
            right: -2px;
            width: 18px;
            height: 18px;
            background: linear-gradient(135deg, #2d7a2d, #3a8b3a);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
            animation: rocketWobble 3s ease-in-out infinite, rocketPulse 2s ease-in-out infinite;
        }
        
        .rocket-check {
            font-size: 11px;
            color: rgba(255, 255, 255, 0.9);
            font-weight: bold;
            text-shadow: 0 1px 1px rgba(0,0,0,0.4);
        }
        
        @keyframes rocketWobble {
            0%, 100% {
                transform: rotate(0deg) scale(1);
            }
            25% {
                transform: rotate(-5deg) scale(1.02);
            }
            75% {
                transform: rotate(5deg) scale(1.02);
            }
        }
        
        @keyframes rocketPulse {
            0%, 100% {
                box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
            }
            50% {
                box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 0 8px rgba(45, 122, 45, 0.2);
            }
        }

        /* Decoration button - old positioning removed, now uses toolbar-button class */
        
        /* Eraser button - old positioning removed, now uses toolbar-button class */
        
        /* Minigame button - old positioning removed, now uses toolbar-button class */
        
        /* Minigame availability indicator - similar to rocket indicator */
        .minigame-indicator {
            position: absolute;
            top: -2px;
            right: -2px;
            width: 18px;
            height: 18px;
            background: linear-gradient(135deg, #2d7a2d, #3a8b3a);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
            animation: rocketWobble 3s ease-in-out infinite, rocketPulse 2s ease-in-out infinite;
        }
        
        .minigame-indicator::after {
            content: '!';
            font-size: 11px;
            color: rgba(255, 255, 255, 0.9);
            font-weight: bold;
            text-shadow: 0 1px 1px rgba(0,0,0,0.4);
        }
        
        /* Make minigame button position relative for indicator */
        #minigameButton {
            position: relative;
        }
        
        /* Minigame item timer styling */
        .minigame-item {
            position: relative;
        }
        
        .minigame-timer {
            position: absolute;
            top: 5px;
            right: 5px;
            font-size: 11px;
            color: rgba(255, 255, 255, 0.7);
            background: rgba(0, 0, 0, 0.6);
            padding: 2px 6px;
            border-radius: 3px;
            font-family: monospace;
            pointer-events: none;
            z-index: 5;
        }
        
        /* Save button - now uses toolbar-button class */
        
        /* Portrait mode - save button handled by toolbar */
        
        /* Save button styles handled by toolbar-button */
        
        /* Leaderboard button - now uses toolbar-button class */
        
        /* Leaderboard button styles handled by toolbar-button */
        
        /* Expand Area button - now uses toolbar-button class */
        
        /* Landscape - button positioning handled by toolbar */
        
        /* Portrait mode - button positioning handled by toolbar */
        
        /* Expand area button styles handled by toolbar-button */
        
        /* Load button - to be removed */
        .load-button {
            display: none;
        }
        
        /* Save status indicator */
        .save-status {
            position: fixed;
            top: 120px;
            right: 20px;
            padding: 8px 16px;
            background-color: rgba(0, 0, 0, 0.8);
            color: white;
            border-radius: 20px;
            font-size: 14px;
            display: none;
            z-index: 100;
        }
        
        .save-status.show {
            display: block;
        }
        
        .save-status.success {
            background-color: rgba(76, 175, 80, 0.9);
        }
        
        .save-status.error {
            background-color: rgba(244, 67, 54, 0.9);
        }
        
        /* FPS meter */
        .fps-meter {
            position: fixed;
            top: 80px;
            left: 160px; /* 20px + 60px (profile) + 10px + 60px (building manager) + 10px */
            padding: 4px 8px;
            background-color: rgba(0, 0, 0, 0.8);
            color: #00ff00;
            font-family: monospace;
            font-size: 12px;
            border-radius: 4px;
            z-index: 100;
            pointer-events: none;
            min-width: 20px;
        }
        
        /* Portrait mode - FPS centered between icons */
        @media screen and (max-width: 430px) and (orientation: portrait) {
            .fps-meter {
                top: max(calc(env(safe-area-inset-top) + 5px), 100px) !important; /* Same level as profile/achievement */
                left: 50% !important;
                transform: translateX(-50%) !important;
            }
        }
        
        /* Level display */
        .level-display {
            display: flex;
            align-items: center;
            gap: 10px;
            pointer-events: none;
        }
        
        /* Portrait mode adjustments for level display */
        @media screen and (max-width: 430px) and (orientation: portrait) {
            .level-display {
                gap: 8px !important;
            }
            
            .level-display .level-icon {
                width: 36px !important;
                height: 36px !important;
            }
            
            .level-display .level-progress {
                width: 100px !important; /* Consistent with all bars */
                height: 24px !important;
                box-sizing: border-box !important;
            }
        }
        
        .level-display.clickable {
            pointer-events: all;
            cursor: pointer;
            transition: transform 0.2s ease;
        }
        
        .level-display.clickable:hover {
            transform: scale(1.05);
        }
        
        .level-display.clickable:active {
            transform: scale(0.98);
        }
        
        .level-icon {
            width: 36px;
            height: 36px;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
        }
        
        .level-progress {
            width: 120px;
            height: 24px;
            background: rgba(0, 0, 0, 0.6);
            border-radius: 10px;
            overflow: hidden;
            border: 2px solid #1976D2;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
            position: relative;
            box-sizing: border-box;
        }
        
        .level-progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #1976D2, #42A5F5);
            transition: width 0.3s ease;
            box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
        }
        
        .level-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-size: 12px;
            font-weight: bold;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
            pointer-events: none;
            z-index: 1;
        }
        
        /* Level up animation */
        .level-up-pulse {
            animation: levelUpPulse 0.5s ease-in-out;
        }
        
        @keyframes levelUpPulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.2); }
            100% { transform: scale(1); }
        }
        
        /* Modern Level Up Modal - Using Unified Modal Structure */
        .level-up-modal {
            z-index: 2000;
        }
        
        .level-up-modal .unified-modal-content {
            max-width: 700px;
            width: 90%;
            background: transparent;
            border: none;
            box-shadow: none;
            padding: 20px;
            box-sizing: border-box;
        }
        
        /* Safe area support for level-up modal - simplified and enhanced */
        .level-up-modal .unified-modal-content {
            /* Always apply safe areas with fallback values */
            padding-top: max(20px, env(safe-area-inset-top, 20px)) !important;
            padding-bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
            padding-left: max(20px, env(safe-area-inset-left, 20px)) !important;
            padding-right: max(20px, env(safe-area-inset-right, 20px)) !important;
        }
        
        .level-up-modal.show {
            display: block;
            animation: modalFadeIn 0.5s ease-out;
        }
        
        .level-up-modal.closing {
            animation: modalFadeOut 0.5s ease-out;
        }
        
        @keyframes modalFadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }
        
        @keyframes modalFadeOut {
            from {
                opacity: 1;
            }
            to {
                opacity: 0;
            }
        }
        
        /* Particle Effects */
        .particles-container {
            position: absolute;
            width: 100%;
            height: 100%;
            overflow: hidden;
            pointer-events: none;
        }
        
        .particle {
            position: absolute;
            width: 4px;
            height: 4px;
            background: linear-gradient(45deg, #00d4ff, #ff00ff, #ffff00);
            border-radius: 50%;
            bottom: -10px;
            animation: particleFloat linear infinite;
        }
        
        @keyframes particleFloat {
            to {
                transform: translateY(-100vh) rotate(360deg);
                opacity: 0;
            }
        }
        
        /* Level Up Content - Inner container */
        .level-up-content {
            background: linear-gradient(135deg, rgba(10, 25, 47, 0.95), rgba(20, 10, 50, 0.95));
            border: 2px solid rgba(0, 212, 255, 0.5);
            border-radius: 30px;
            padding: 40px;
            padding-top: max(40px, env(safe-area-inset-top, 40px));
            padding-bottom: max(40px, env(safe-area-inset-bottom, 40px));
            padding-left: max(40px, env(safe-area-inset-left, 40px));
            padding-right: max(40px, env(safe-area-inset-right, 40px));
            max-width: 800px;
            width: 100%;
            max-height: 100%;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0, 212, 255, 0.4),
                        inset 0 1px 0 rgba(255, 255, 255, 0.2);
            animation: contentSlideIn 0.8s ease-out;
            margin: 0;
            box-sizing: border-box;
        }
        
        
        @keyframes contentSlideIn {
            from {
                transform: scale(0.8) translateY(50px);
                opacity: 0;
            }
            to {
                transform: scale(1) translateY(0);
                opacity: 1;
            }
        }
        
        /* Level Up Header */
        .level-up-header {
            text-align: center;
            margin-bottom: 30px;
            position: relative;
        }
        
        .level-up-stars {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            pointer-events: none;
        }
        
        .star {
            position: absolute;
            width: 30px;
            height: 30px;
            color: #ffd700;
            filter: drop-shadow(0 0 10px #ffd700);
            animation: starPulse 2s ease-in-out infinite;
        }
        
        .star-1 {
            top: -10px;
            left: 20%;
            animation-delay: 0s;
        }
        
        .star-2 {
            top: 0;
            right: 25%;
            animation-delay: 0.3s;
            width: 25px;
            height: 25px;
        }
        
        .star-3 {
            top: 40px;
            left: 15%;
            animation-delay: 0.6s;
            width: 20px;
            height: 20px;
        }
        
        @keyframes starPulse {
            0%, 100% {
                transform: scale(1) rotate(0deg);
                opacity: 0.8;
            }
            50% {
                transform: scale(1.3) rotate(180deg);
                opacity: 1;
            }
        }
        
        .level-up-title {
            font-size: 48px;
            font-weight: 900;
            margin: 0 0 20px 0;
            background: linear-gradient(45deg, #00d4ff, #ff00ff, #00d4ff);
            background-size: 200% 200%;
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
            animation: gradientShift 3s ease-in-out infinite;
            letter-spacing: 2px;
        }
        
        @keyframes gradientShift {
            0%, 100% {
                background-position: 0% 50%;
            }
            50% {
                background-position: 100% 50%;
            }
        }
        
        .level-badge {
            display: inline-flex;
            background: linear-gradient(135deg, #1976D2, #42A5F5);
            border-radius: 50%;
            width: 80px;
            height: 80px;
            align-items: center;
            justify-content: center;
            box-shadow: 0 8px 25px rgba(25, 118, 210, 0.5),
                        inset 0 2px 4px rgba(255, 255, 255, 0.3);
            animation: badgePulse 2s ease-in-out infinite;
            margin: 0 auto;
        }
        
        @keyframes badgePulse {
            0%, 100% {
                transform: scale(1);
                box-shadow: 0 8px 25px rgba(25, 118, 210, 0.5),
                            inset 0 2px 4px rgba(255, 255, 255, 0.3);
            }
            50% {
                transform: scale(1.1);
                box-shadow: 0 12px 35px rgba(25, 118, 210, 0.8),
                            inset 0 2px 4px rgba(255, 255, 255, 0.3);
            }
        }
        
        .level-number {
            font-size: 36px;
            font-weight: bold;
            color: white;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        }
        
        /* Unlocks Container */
        .unlocks-container {
            margin-top: 30px;
        }
        
        .new-unlocks-title {
            text-align: center;
            font-size: 24px;
            color: #ffd700;
            margin-bottom: 25px;
            text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
            animation: glowPulse 2s ease-in-out infinite;
        }
        
        @keyframes glowPulse {
            0%, 100% {
                text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
            }
            50% {
                text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
            }
        }
        
        .unlocks-section {
            margin-bottom: 25px;
        }
        
        .unlocks-header {
            font-size: 18px;
            color: #00d4ff;
            margin-bottom: 15px;
            text-align: center;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .unlocks-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 20px;
            max-width: 600px;
            margin: 0 auto;
        }
        
        .unlock-item {
            text-align: center;
            animation: itemFadeIn 0.5s ease-out forwards;
            opacity: 0;
        }
        
        .unlock-item:nth-child(1) { animation-delay: 0.1s; }
        .unlock-item:nth-child(2) { animation-delay: 0.2s; }
        .unlock-item:nth-child(3) { animation-delay: 0.3s; }
        .unlock-item:nth-child(4) { animation-delay: 0.4s; }
        .unlock-item:nth-child(5) { animation-delay: 0.5s; }
        .unlock-item:nth-child(6) { animation-delay: 0.6s; }
        
        @keyframes itemFadeIn {
            from {
                opacity: 0;
                transform: translateY(20px) scale(0.8);
            }
            to {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }
        
        .unlock-image {
            width: 100px;
            height: 100px;
            margin: 0 auto 10px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            border-radius: 15px;
            border: 2px solid rgba(0, 212, 255, 0.3);
            box-shadow: 0 4px 15px rgba(0, 212, 255, 0.2);
            transition: all 0.3s ease;
            animation: floatAnimation 3s ease-in-out infinite;
        }
        
        .unlock-item:nth-child(odd) .unlock-image {
            animation-delay: 0s;
        }
        
        .unlock-item:nth-child(even) .unlock-image {
            animation-delay: 1.5s;
        }
        
        @keyframes floatAnimation {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-10px);
            }
        }
        
        .unlock-image:hover {
            transform: scale(1.1);
            border-color: rgba(0, 212, 255, 0.6);
            box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
        }
        
        .unlock-name {
            font-size: 14px;
            color: white;
            font-weight: 600;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
        }
        
        .more-items {
            text-align: center;
            color: rgba(255, 255, 255, 0.7);
            font-style: italic;
            margin-top: 15px;
            font-size: 14px;
        }
        
        /* Continue Button */
        .level-up-close {
            display: block;
            margin: 30px auto 0;
            padding: 15px 40px;
            background: linear-gradient(135deg, #00d4ff, #0096c7);
            border: none;
            border-radius: 30px;
            color: white;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4);
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            /* Add bottom margin for safe area on mobile */
            margin-bottom: max(30px, env(safe-area-inset-bottom, 30px));
        }
        
        .level-up-close:hover {
            transform: translateY(-2px);
            box-shadow: 0 12px 35px rgba(0, 212, 255, 0.6);
            background: linear-gradient(135deg, #00b8e6, #0084b4);
        }
        
        .level-up-close:active {
            transform: translateY(0);
        }
        
        /* Mobile Responsive */
        @media (max-width: 768px) {
            .level-up-modal .unified-modal-content {
                width: 100%;
                max-width: 100%;
                height: 100%;
                max-height: 100dvh;
                margin: 0;
                padding: 0;
                /* Add safe area padding directly */
                padding-top: env(safe-area-inset-top, 0px);
                padding-bottom: env(safe-area-inset-bottom, 0px);
                padding-left: env(safe-area-inset-left, 0px);
                padding-right: env(safe-area-inset-right, 0px);
            }
            
            .level-up-content {
                padding: 25px;
                width: 100%;
                height: 100%;
                border-radius: 0;
                max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
                /* Ensure content doesn't go under notch */
                position: relative;
            }
        }
            
            .level-up-title {
                font-size: 36px;
            }
            
            .level-badge {
                width: 60px;
                height: 60px;
            }
            
            .level-number {
                font-size: 28px;
            }
            
            .unlocks-grid {
                grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
                gap: 15px;
            }
            
            .unlock-image {
                width: 70px;
                height: 70px;
            }
            
            .unlock-name {
                font-size: 12px;
            }
        
        .decoration-option:hover {
            border-color: #9C27B0;
            transform: scale(1.05);
        }
        
        .decoration-option span {
            position: absolute;
            bottom: 5px;
            left: 0;
            right: 0;
            text-align: center;
            color: white;
            font-size: 12px;
            font-weight: bold;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
        }
        
        .decoration-preview {
            position: fixed;
            width: 64px;
            height: 64px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            pointer-events: none;
            z-index: 50;
            opacity: 0.7;
            display: none;
        }
        
        
        .road-option:hover {
            border-color: #FF5722;
            transform: scale(1.05);
        }
        
        .road-preview {
            width: 80px;
            height: 80px;
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center;
            border-radius: 4px;
            margin-bottom: 10px;
        }
        
        .road-preview.road-asphalt-wide {
            background-image: url('../images/roads/asphalt/asphalt_straight.svg');
        }
        
        .road-preview.road-asphalt-narrow {
            background-image: url('../images/roads/asphalt_narrow/asphalt_straight.svg');
        }
        
        .road-preview.road-cobblestone {
            background-image: url('../images/roads/cobblestone_pave_10.webp');
        }
        
        .road-preview.road-wood {
            background-image: url('../images/wood/wood.webp');
        }
        
        .road-preview.road-cosmo-paver {
            background-image: url('../images/roads/cosmo_paver.webp');
        }
        
        .road-preview.road-hexway {
            background-image: url('../images/roads/Hexway_2.webp');
        }
        
        .road-preview.road-mosaic-plaza {
            background-image: url('../images/roads/Mosaic_Plaza.webp');
        }
        
        .road-preview.road-pixelstone {
            background-image: url('../images/roads/Pixelstone.webp');
        }
        
        .road-option span {
            color: white;
            font-weight: bold;
            text-align: center;
        }
        
        /* Button image styles - moved to toolbar-button img */
        
        /* Mini-game modal styles */
        .minigame-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.9);
            z-index: 500;
            display: none;
        }
        
        .minigame-modal iframe {
            width: 100%;
            height: 100%;
            border: none;
        }
        
        /* iOS safe area support for minigame modal */
        body.ios-app .minigame-modal {
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
            box-sizing: border-box;
        }
        
        body.ios-app .minigame-modal iframe {
            /* Geen padding op iframe zelf, modal handelt safe areas af */
            padding: 0;
            width: 100%;
            height: 100%;
            box-sizing: border-box;
        }
        
        /* Portrait mode adjustments for bottom buttons */
        /* Portrait mode adjustments for bottom toolbar */
        @media (orientation: portrait) {
            .bottom-toolbar {
                left: 0;
                right: 0;
                bottom: 0;
                width: 90%;
                max-width: 450px;
                margin: 0 auto;
                margin-bottom: 0;
                padding: 12px 20px calc(env(safe-area-inset-bottom)) 20px;
                justify-content: space-evenly;
                border-radius: 20px 20px 0 0;
                gap: 0;
            }
            
            .toolbar-button {
                width: calc((100% - 120px) / 6) !important;
                max-width: 55px !important;
                height: auto !important;
                aspect-ratio: 1;
                min-width: 45px !important;
            }
        }
        
        /* Small screens - compact toolbar */
        @media (max-width: 480px) and (orientation: portrait) {
            .bottom-toolbar {
                padding: 10px 15px calc(env(safe-area-inset-bottom)) 15px;
                max-width: 90%;
            }
            
            .toolbar-button {
                width: calc((100% - 90px) / 6) !important;
                max-width: 48px !important;
                min-width: 40px !important;
            }
        }
        
        /* Landscape mode adjustments */
        @media (orientation: landscape) and (max-width: 1024px) {
            .bottom-toolbar {
                /* Remove any left positioning */
                left: unset;
                
                /* Force shrink-to-fit */
                width: -webkit-fit-content !important;
                width: -moz-fit-content !important;
                width: fit-content !important;
                max-width: none;
                
                /* Position with safe area */
                right: max(calc(env(safe-area-inset-right) + 10px), 20px);
                
                /* Layout */
                gap: 10px;
                padding: 8px 15px;
            }
            
            .toolbar-button {
                width: 50px !important;
                height: 50px !important;
            }
        }
        
        
        /* Level Progress Modal Styles - using unified modal structure */
        .level-progress-modal {
            z-index: 2500;
        }
        
        .level-progress-modal .unified-modal-content {
            max-width: 900px;
            width: 90%;
        }
        
        .level-progress-content {
            overflow: visible !important;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            padding: 0 !important;
            /* Respect safe areas */
            padding-top: env(safe-area-inset-top, 0px) !important;
            padding-bottom: env(safe-area-inset-bottom, 0px) !important;
            padding-left: env(safe-area-inset-left, 0px) !important;
            padding-right: env(safe-area-inset-right, 0px) !important;
        }
        
        .level-progress-inner {
            padding: 20px;
            max-height: 70vh;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        /* Mobile portrait adjustments */
        @media (max-width: 768px) and (orientation: portrait) {
            .level-progress-inner {
                max-height: calc(100vh - 150px);
            }
        }
        
        
        .popup-header {
            text-align: center;
            margin-bottom: 40px;
            position: relative;
        }
        
        .level-badge-large {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 120px;
            height: 120px;
            background: radial-gradient(circle at 30% 30%, 
                rgba(66, 165, 245, 0.8) 0%,
                rgba(25, 118, 210, 0.9) 50%,
                rgba(13, 71, 161, 1) 100%);
            border-radius: 50%;
            border: 3px solid rgba(66, 165, 245, 0.8);
            box-shadow: 
                0 0 40px rgba(66, 165, 245, 0.6),
                inset 0 0 20px rgba(255, 255, 255, 0.2);
            margin-bottom: 20px;
            position: relative;
            overflow: hidden;
        }
        
        .level-badge-large::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: linear-gradient(45deg, 
                transparent 30%, 
                rgba(255, 255, 255, 0.1) 50%, 
                transparent 70%);
            transform: rotate(45deg);
            animation: shimmer 3s infinite;
        }
        
        @keyframes shimmer {
            0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
            100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
        }
        
        .level-badge-large .level-number {
            font-size: 48px;
            font-weight: bold;
            color: white;
            text-shadow: 
                0 0 20px rgba(255, 255, 255, 0.8),
                0 2px 4px rgba(0, 0, 0, 0.5);
            z-index: 1;
            position: relative;
        }
        
        .popup-title {
            font-size: 36px;
            color: white;
            margin: 0;
            text-shadow: 
                0 0 30px rgba(66, 165, 245, 0.8),
                0 2px 4px rgba(0, 0, 0, 0.5);
            font-weight: bold;
            background: linear-gradient(90deg, #42A5F5, #66BB6A, #42A5F5);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-size: 200% 100%;
            animation: gradientShift 3s ease infinite;
        }
        
        @keyframes gradientShift {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        
        /* XP Progress Section */
        .xp-progress-section {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 20px;
            padding: 30px;
            margin-bottom: 30px;
            border: 1px solid rgba(66, 165, 245, 0.2);
            box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
        }
        
        .xp-bar-container {
            position: relative;
            margin-bottom: 20px;
        }
        
        .xp-bar {
            width: 100%;
            height: 40px;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 20px;
            overflow: hidden;
            position: relative;
            border: 2px solid rgba(66, 165, 245, 0.3);
            box-shadow: 
                inset 0 2px 10px rgba(0, 0, 0, 0.5),
                0 0 20px rgba(66, 165, 245, 0.2);
        }
        
        .xp-bar-fill {
            height: 100%;
            background: linear-gradient(90deg, 
                #1976D2 0%,
                #42A5F5 50%,
                #66BB6A 100%);
            position: relative;
            transition: width 0.5s ease;
            box-shadow: 
                0 0 20px rgba(66, 165, 245, 0.8),
                inset 0 0 10px rgba(255, 255, 255, 0.3);
        }
        
        .xp-bar-glow {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 100%;
            background: linear-gradient(90deg, 
                transparent 0%,
                rgba(255, 255, 255, 0.3) 50%,
                transparent 100%);
            animation: xpGlow 2s ease-in-out infinite;
        }
        
        @keyframes xpGlow {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }
        
        .xp-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 20px;
            font-weight: bold;
            color: white;
            text-shadow: 
                0 0 10px rgba(0, 0, 0, 0.8),
                0 2px 4px rgba(0, 0, 0, 0.5);
            z-index: 2;
        }
        
        .xp-separator {
            margin: 0 8px;
            opacity: 0.7;
        }
        
        .xp-info {
            text-align: center;
            color: rgba(255, 255, 255, 0.8);
            font-size: 16px;
        }
        
        .xp-remaining {
            color: #66BB6A;
            font-weight: bold;
            text-shadow: 0 0 10px rgba(102, 187, 106, 0.5);
        }
        
        /* Next Level Unlocks */
        .next-level-unlocks {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 20px;
            padding: 30px;
            border: 1px solid rgba(102, 187, 106, 0.3);
        }
        
        .unlocks-title {
            text-align: center;
            color: white;
            font-size: 24px;
            margin-bottom: 25px;
            text-shadow: 0 0 20px rgba(102, 187, 106, 0.8);
        }
        
        .unlocks-category {
            margin-bottom: 30px;
        }
        
        .category-title {
            color: #66BB6A;
            font-size: 20px;
            margin-bottom: 15px;
            text-transform: uppercase;
            letter-spacing: 1px;
            text-shadow: 0 0 10px rgba(102, 187, 106, 0.5);
        }
        
        .unlocks-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
            gap: 15px;
            margin-bottom: 10px;
        }
        
        .unlock-item {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 15px;
            text-align: center;
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .unlock-item:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(102, 187, 106, 0.5);
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
        }
        
        .unlock-image {
            width: 70px;
            height: 70px;
            margin: 0 auto 10px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
        }
        
        .unlock-name {
            color: white;
            font-size: 12px;
            font-weight: bold;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
        }
        
        .more-unlocks {
            text-align: center;
            color: rgba(255, 255, 255, 0.6);
            font-style: italic;
            margin-top: 10px;
        }
        
        .no-unlocks {
            text-align: center;
            color: rgba(255, 255, 255, 0.6);
            font-size: 18px;
            padding: 40px;
            font-style: italic;
        }
        
        /* Mobile adjustments for level progress modal */
        @media (max-width: 768px) {
            .level-progress-inner {
                padding: 15px;
            }
            
            .level-badge-large {
                width: 80px;
                height: 80px;
            }
            
            .level-badge-large .level-number {
                font-size: 32px;
            }
            
            .popup-title {
                font-size: 28px;
            }
            
            .xp-bar {
                height: 35px;
            }
            
            .xp-text {
                font-size: 16px;
            }
            
            .unlocks-grid {
                grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
                gap: 10px;
            }
            
            .unlock-image {
                width: 50px;
                height: 50px;
            }
            
            .unlock-name {
                font-size: 11px;
            }
        }
        
        /* Mobile adjustments for save button and status */
        @media (max-width: 768px) {
            /* Save button handled by toolbar */
            
            .save-status {
                top: 60px;
                right: 20px;
                font-size: 12px;
                padding: 6px 12px;
            }
        }
        
        /* Minigame Selection Modal Styles */
        .minigame-grid-container {
            width: 100%;
            padding: 20px;
            overflow: hidden;
        }
        
        .minigame-grid {
            display: flex;
            gap: 20px;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 10px 0 20px 0;
            scroll-behavior: smooth;
            scrollbar-width: thin;
            scrollbar-color: rgba(0, 212, 255, 0.5) rgba(255, 255, 255, 0.1);
        }
        
        /* Custom scrollbar for webkit browsers */
        .minigame-grid::-webkit-scrollbar {
            height: 8px;
        }
        
        .minigame-grid::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
        }
        
        .minigame-grid::-webkit-scrollbar-thumb {
            background: rgba(0, 212, 255, 0.5);
            border-radius: 4px;
        }
        
        .minigame-grid::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 212, 255, 0.7);
        }
        
        .minigame-item {
            flex: 0 0 auto;
            width: 280px;
            cursor: pointer;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(0, 212, 255, 0.3);
            border-radius: 15px;
            padding: 15px;
            text-align: center;
        }
        
        .minigame-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 30px rgba(0, 212, 255, 0.4);
            border-color: rgba(0, 212, 255, 0.6);
        }
        
        /* Touch device optimizations */
        @media (hover: none) and (pointer: coarse) {
            .minigame-item:active {
                transform: scale(0.98);
                box-shadow: 0 5px 15px rgba(0, 212, 255, 0.3);
            }
        }
        
        .minigame-image {
            width: 100%;
            height: 350px;
            object-fit: cover;
            border-radius: 10px;
            margin-bottom: 15px;
            background: rgba(0, 0, 0, 0.3);
        }
        
        .minigame-title {
            color: #fff;
            font-size: 18px;
            font-weight: 600;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            letter-spacing: 0.5px;
        }
        
        /* Portrait mode - 3 column grid layout with vertical scroll */
        @media (orientation: portrait) {
            .minigame-grid-container {
                width: 90%;
                padding: 15px;
                overflow-y: auto;
                overflow-x: hidden;
                max-height: calc(100vh - 140px);
            }

            .minigame-grid {
                display: grid;
                grid-template-columns: repeat(3, 1fr);
                gap: 35px;
                padding: 10px;
                overflow: visible;
                scrollbar-width: thin;
                scrollbar-color: rgba(0, 212, 255, 0.5) rgba(255, 255, 255, 0.1);
            }
            
            .minigame-grid::-webkit-scrollbar {
                width: 8px;
            }
            
            .minigame-grid::-webkit-scrollbar-track {
                background: rgba(255, 255, 255, 0.1);
                border-radius: 4px;
            }
            
            .minigame-grid::-webkit-scrollbar-thumb {
                background: rgba(0, 212, 255, 0.5);
                border-radius: 4px;
            }
            
            .minigame-item {
                width: 100%;
                padding: 10px;
            }
            
            .minigame-image {
                width: 100%;
                height: 120px;
                object-fit: cover;
                margin-bottom: 8px;
            }
            
            .minigame-title {
                font-size: 14px;
            }
        }
        
        /* Small phones portrait mode */
        @media (max-width: 380px) and (orientation: portrait) {
            .minigame-grid-container {
                padding: 10px;
            }
            
            .minigame-grid {
                gap: 10px;
                padding: 5px;
            }
            
            .minigame-item {
                padding: 8px;
            }
            
            .minigame-image {
                height: 100px;
            }
            
            .minigame-title {
                font-size: 13px;
            }
        }
        
        /* Landscape mode - 3 column grid layout */
        @media (orientation: landscape) {
            .minigame-grid-container {
                width: 100%;
                padding: 15px;
                overflow-y: auto;
                overflow-x: hidden;
            }

            .minigame-grid {
                display: grid;
                grid-template-columns: repeat(3, 1fr);
                gap: 15px;
                padding: 10px 0 20px 0;
                scroll-behavior: smooth;
                max-height: calc(100vh - 120px);
            }

            .minigame-item {
                width: 100%;
                padding: 10px;
            }
            
            .minigame-image {
                width: 100%;
                height: 140px;
                object-fit: cover;
                margin-bottom: 8px;
            }
            
            .minigame-title {
                font-size: 14px;
            }
        }
        
        /* Small screens landscape */
        @media (max-width: 768px) and (orientation: landscape) {
            .minigame-grid-container {
                padding: 10px;
            }

            .minigame-grid {
                grid-template-columns: repeat(3, 1fr);
                gap: 12px;
                max-height: calc(100vh - 100px);
            }

            .minigame-item {
                width: 100%;
                padding: 8px;
            }
            
            .minigame-image {
                height: 120px;
            }
            
            .minigame-title {
                font-size: 13px;
            }
        }
        
        /* Area Expansion Modal Styles */
        .expansion-content {
            padding: 20px;
        }
        
        .expansion-info {
            display: flex;
            gap: 30px;
            margin-bottom: 30px;
        }
        
        .current-area-info,
        .next-area-info {
            flex: 1;
            background: rgba(255, 255, 255, 0.05);
            padding: 20px;
            border-radius: 10px;
            border: 1px solid rgba(0, 212, 255, 0.3);
        }
        
        .current-area-info h3,
        .next-area-info h3 {
            margin-top: 0;
            color: #00d4ff;
            font-size: 18px;
        }
        
        .current-area-info p,
        .next-area-info p {
            margin: 10px 0;
            color: #fff;
        }
        
        .expansion-actions {
            text-align: center;
            margin: 30px 0;
        }
        
        .expand-button {
            background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
            color: white;
            padding: 15px 30px;
            font-size: 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .expand-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 212, 255, 0.4);
        }
        
        .expand-button:disabled {
            background: #666;
            cursor: not-allowed;
            transform: none;
        }
        
        .expansion-history {
            margin-top: 30px;
        }
        
        .expansion-history h3 {
            color: #00d4ff;
            font-size: 16px;
            margin-bottom: 15px;
        }
        
        #expansionHistoryList {
            max-height: 150px;
            overflow-y: auto;
        }
        
        .expansion-history-item {
            background: rgba(255, 255, 255, 0.05);
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 5px;
            font-size: 14px;
            color: #ccc;
        }
        
        @media (max-width: 768px) {
            .expansion-info {
                flex-direction: column;
                gap: 20px;
            }
        }
        
        /* iOS portrait adjustments for ALL modals, popups, and overlays */
        @media screen and (max-width: 480px) and (orientation: portrait) {
            /* Dynamic safe area padding for all iOS devices */
            body.ios-app .modal,
            body.ios-app .minigame-modal,
            body.ios-app .diamond-shop-modal,
            body.ios-app .achievement-panel,
            body.ios-app .level-up-modal {
                padding-top: max(env(safe-area-inset-top), 20px);
            }
            
            /* Remove top margin from modal content to prevent double spacing */
            body.ios-app .modal .modal-content {
                margin-top: 0 !important;
                margin-bottom: auto;
            }
            
            /* Toasts and popups that need top adjustment */
            body.ios-app [class*="toast"]:not(.modal),
            body.ios-app [class*="popup"]:not(.modal) {
                top: max(env(safe-area-inset-top), 20px);
            }
        }
        
        /* iPhone 16 Pro Max and future larger iPhones support */
        @media screen and (max-width: 480px) and (orientation: portrait) {
            body.ios-app .minigame-modal {
                padding-top: max(env(safe-area-inset-top), 20px);
            }
        }
        
        /* iPad iOS app adjustments for modals and overlays */
        @media (min-width: 720px) and (max-width: 1050px) and (orientation: portrait) {
            body.ios-app .modal,
            body.ios-app .minigame-modal,
            body.ios-app .diamond-shop-modal,
            body.ios-app .achievement-panel,
            body.ios-app .level-up-modal {
                padding-top: max(env(safe-area-inset-top), 20px);
            }
            
            body.ios-app .modal .modal-content {
                margin-top: 0 !important;
                margin-bottom: auto;
            }
            
            body.ios-app [class*="toast"]:not(.modal),
            body.ios-app [class*="popup"]:not(.modal) {
                top: max(env(safe-area-inset-top), 20px);
            }
        }
        
        @media (min-width: 1000px) and (max-width: 1400px) and (orientation: landscape) {
            body.ios-app .modal,
            body.ios-app .minigame-modal,
            body.ios-app .diamond-shop-modal,
            body.ios-app .achievement-panel,
            body.ios-app .level-up-modal {
                padding-top: max(env(safe-area-inset-top), 20px);
            }
            
            body.ios-app .modal .modal-content {
                margin-top: 0 !important;
                margin-bottom: auto;
            }
            
            body.ios-app [class*="toast"]:not(.modal),
            body.ios-app [class*="popup"]:not(.modal) {
                top: max(env(safe-area-inset-top), 20px);
            }
        }

        /* Level Progress Modal - Landscape Optimized Layout */
        .level-progress-header {
            padding: 10px 20px 8px !important;
        }
        
        .level-progress-split {
            display: flex;
            gap: 30px;
            align-items: flex-start;
        }
        
        .level-progress-left {
            flex: 0 0 250px;
            padding-right: 20px;
            border-right: 1px solid rgba(0, 212, 255, 0.2);
        }
        
        .level-progress-right {
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            max-width: 100%;
        }
        
        .current-level-section {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
            margin-bottom: 20px;
        }
        
        .level-badge-compact {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 60px;
            height: 60px;
            background: radial-gradient(circle at 30% 30%, 
                rgba(66, 165, 245, 0.8) 0%,
                rgba(25, 118, 210, 0.9) 50%,
                rgba(13, 71, 161, 1) 100%);
            border-radius: 50%;
            box-shadow: 
                0 0 20px rgba(66, 165, 245, 0.6),
                0 4px 15px rgba(0, 0, 0, 0.3),
                inset 0 2px 4px rgba(255, 255, 255, 0.3);
            position: relative;
            overflow: hidden;
        }
        
        .level-badge-compact .level-number {
            font-size: 24px;
            font-weight: bold;
            color: #fff;
            text-shadow: 
                0 2px 4px rgba(0, 0, 0, 0.3),
                0 0 10px rgba(255, 255, 255, 0.3);
            z-index: 1;
        }
        
        .modal-level-text {
            font-size: 20px;
            font-weight: 600;
            color: #fff;
        }
        
        .xp-progress-section-compact {
            margin-bottom: 0;
        }
        
        .xp-bar-compact {
            height: 30px !important;
            margin-bottom: 8px;
        }
        
        .xp-text-compact {
            font-size: 14px;
            color: rgba(255, 255, 255, 0.9);
            text-align: center;
            margin-bottom: 5px;
        }
        
        .xp-info-compact {
            text-align: center;
        }
        
        .xp-info-compact .xp-remaining {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.7);
        }
        
        /* Adjust right side content */
        .level-progress-right .unlocks-title {
            font-size: 16px;
            margin-bottom: 15px;
            color: #fff;
            font-weight: 600;
        }
        
        .level-progress-right .category-title {
            font-size: 14px;
            margin-bottom: 10px;
            color: rgba(255, 255, 255, 0.9);
        }
        
        .level-progress-right .unlocks-grid {
            gap: 10px;
            grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        }
        
        .level-progress-right .unlock-item {
            padding: 8px;
        }
        
        .level-progress-right .unlock-image {
            width: 50px;
            height: 50px;
            margin-bottom: 5px;
        }
        
        .level-progress-right .unlock-name {
            font-size: 11px;
            line-height: 1.2;
        }
        
        /* Mobile and portrait adjustments */
        @media (max-width: 768px), (orientation: portrait) {
            .level-progress-modal .unified-modal-content {
                width: 100%;
                max-width: 100%;
                margin: 0;
                height: 100%;
                max-height: 100dvh;
                border-radius: 0;
                /* Add safe area padding */
                padding-top: env(safe-area-inset-top, 0px);
                padding-bottom: env(safe-area-inset-bottom, 0px);
                padding-left: env(safe-area-inset-left, 0px);
                padding-right: env(safe-area-inset-right, 0px);
            }
            
            .level-progress-inner {
                padding: 15px;
                padding-top: max(15px, env(safe-area-inset-top, 15px));
                padding-bottom: max(15px, env(safe-area-inset-bottom, 15px));
                max-height: calc(100vh - 80px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
            }
            
            .level-progress-split {
                flex-direction: column;
                gap: 20px;
            }
            
            .level-progress-left {
                flex: none;
                width: 100%;
                padding-right: 0;
                border-right: none;
                border-bottom: 1px solid rgba(0, 212, 255, 0.2);
                padding-bottom: 20px;
            }
            
            .level-progress-right {
                width: 100%;
                overflow-x: hidden;
                padding: 0 5px;
            }
            
            .level-progress-right .unlocks-grid {
                grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
                gap: 8px;
                max-width: 100%;
            }
            
            .level-progress-right .unlock-item {
                padding: 5px;
                max-width: 100%;
            }
            
            .level-progress-right .unlock-image {
                width: 45px;
                height: 45px;
            }
            
            .level-progress-right .unlock-name {
                font-size: 10px;
                word-wrap: break-word;
                overflow-wrap: break-word;
            }
            
            .current-level-section {
                justify-content: center;
            }
        }
        
        /* iPhone specific adjustments for portrait mode */
        @media (max-width: 430px) and (orientation: portrait) {
            .level-progress-inner {
                padding: 12px;
            }
            
            .level-progress-right .unlocks-grid {
                grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
                gap: 6px;
            }
            
            .level-progress-right .unlock-image {
                width: 40px;
                height: 40px;
            }
            
            .level-progress-right .unlock-name {
                font-size: 9px;
            }
        }
        
        /* Safe area support for notched devices */
        /* Additional safe area support for notched devices */
        @supports (padding: env(safe-area-inset-top)) {
            .level-progress-modal .unified-modal-content {
                /* Ensure safe areas are respected on all sides */
                padding-top: env(safe-area-inset-top, 0px) !important;
                padding-bottom: env(safe-area-inset-bottom, 0px) !important;
                padding-left: env(safe-area-inset-left, 0px) !important;
                padding-right: env(safe-area-inset-right, 0px) !important;
            }
            
            @media (orientation: landscape) {
                .level-progress-modal .unified-modal-content {
                    /* Extra padding for landscape notches */
                    padding-left: max(20px, env(safe-area-inset-left, 20px)) !important;
                    padding-right: max(20px, env(safe-area-inset-right, 20px)) !important;
                }
            }
        }
        
        /* Landscape specific optimizations */
        @media (orientation: landscape) and (max-height: 600px) {
            .level-progress-header {
                padding: 8px 20px 6px !important;
            }
            
            .level-progress-header .modal-header {
                font-size: 16px;
            }
            
            .level-progress-inner {
                padding: 15px;
                max-height: calc(100vh - 100px);
            }
            
            .level-badge-compact {
                width: 50px;
                height: 50px;
            }
            
            .level-badge-compact .level-number {
                font-size: 20px;
            }
            
            .modal-level-text {
                font-size: 18px;
            }
            
            .xp-bar-compact {
                height: 25px !important;
            }
            
            .level-progress-right .unlock-image {
                width: 40px;
                height: 40px;
            }
            
            .level-progress-right .unlocks-grid {
                grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
                gap: 8px;
            }
        }

/* Profile Button Styles */
.profile-button {
    /* Position handled by toolbar */
    border-radius: 50%;
    overflow: hidden;
}

.profile-button.modal-open {
    display: none;
}

.profile-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Building Manager Button Styles - moved to building-manager.css */

/* Achievement Button Styles */
.achievement-button {
    /* Position handled by toolbar */
    border-radius: 50%;
    overflow: hidden;
}

.achievement-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.achievement-button.has-new::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: #FF5722;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Profile Modal Styles */
.profile-modal .modal-content {
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.profile-modal-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
}

/* Left Section - Profile Info */
.profile-left-section {
    width: 30%;
    background: linear-gradient(135deg, rgba(0, 20, 40, 0.9), rgba(0, 40, 80, 0.9));
    border-radius: 15px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.profile-section-title {
    color: #00E5FF;
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.profile-avatar-container {
    position: relative;
    margin-bottom: 20px;
}

.profile-avatar-display {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    object-fit: cover;
    border: 3px solid #00E5FF;
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.3);
}

.avatar-edit-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    border: 2px solid white;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.avatar-edit-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.profile-base-name-display {
    font-size: 20px;
    color: white;
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.profile-member-since {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* Right Section - Editable Content */
.profile-right-section {
    flex: 1;
    background: linear-gradient(135deg, rgba(20, 40, 60, 0.9), rgba(40, 60, 80, 0.9));
    border-radius: 15px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.base-name-edit-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.base-name-label {
    font-size: 18px;
    color: #00E5FF;
    font-weight: bold;
}

.base-name-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 20px;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 229, 255, 0.3);
    border-radius: 10px;
    color: white;
    text-align: center;
    transition: all 0.3s ease;
}

.base-name-input:focus {
    outline: none;
    border-color: #00E5FF;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
    background: rgba(0, 0, 0, 0.5);
}

.save-base-name-btn {
    padding: 10px 30px;
    background: linear-gradient(135deg, #00E5FF, #00B8D4);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.3);
}

.save-base-name-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 229, 255, 0.5);
}

.save-base-name-btn:active {
    transform: translateY(0);
}

.profile-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    margin: 30px 0;
}

.general-data-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.section-title {
    font-size: 20px;
    color: #00E5FF;
    margin-bottom: 20px;
    text-align: center;
}

.level-info-container {
    text-align: center;
    margin-top: 20px;
}

.level-label {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
}

.level-value {
    font-size: 48px;
    font-weight: bold;
    color: #00E5FF;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
    margin-bottom: 15px;
}

.level-progress-container {
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
}

.level-progress-bar-bg {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.level-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00E5FF, #00B8D4);
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.7);
}

.level-progress-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 10px;
}

/* Avatar Selection View */
.avatar-select-view {
    text-align: center;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
    margin: 30px 0;
    padding: 10px;
}

.avatar-option {
    width: 100px;
    height: 100px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.avatar-option:hover {
    transform: scale(1.05);
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.3);
}

.avatar-option.selected {
    border-color: #00E5FF;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.7);
}

.avatar-option.selected::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: #00E5FF;
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.avatar-actions {
    margin-top: 20px;
}

.cancel-avatar-btn {
    padding: 10px 30px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-avatar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Portrait Mode Adjustments */
@media screen and (max-width: 450px) and (orientation: portrait) {
    /* Top button positioning handled by toolbar */
    
    .profile-modal .modal-content {
        width: 100%;
        max-height: 90vh;
        box-sizing: border-box;
        margin: 5vh auto;
        max-width: 100%;
    }
    
    .profile-modal-container {
        flex-direction: column;
        padding: 10px;
        gap: 15px;
        box-sizing: border-box;
    }
    
    .profile-left-section {
        width: 100%;
        padding: 15px;
        box-sizing: border-box;
    }
    
    .profile-avatar-display {
        width: 100px;
        height: 100px;
    }
    
    .profile-right-section {
        width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 15px;
    }
    
    .avatar-option {
        width: 80px;
        height: 80px;
    }
}

/* Landscape adjustments for small screens */
@media (orientation: landscape) and (max-height: 600px) {
    .profile-modal .modal-content {
        max-height: 90vh;
    }
    
    .profile-modal-container {
        padding: 15px;
        gap: 15px;
    }
    
    .profile-section-title {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .profile-avatar-display {
        width: 80px;
        height: 80px;
    }
    
    .level-value {
        font-size: 36px;
    }
}

/* Portrait mode safe area support for Profile Modal */
@media (max-width: 768px) and (orientation: portrait) {
    .profile-modal-container {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
    
    /* Settings view safe area */
    .settings-view {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
    
    /* Email link view safe area */
    .email-link-view {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
    
    /* Avatar select view safe area */
    .avatar-select-view {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
    
    /* Profile edit view safe area */
    .profile-edit-view {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
}

/* iOS specific safe area adjustments for Profile Modal */
body.ios-app .profile-modal-container {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}

body.ios-app .settings-view,
body.ios-app .email-link-view,
body.ios-app .avatar-select-view,
body.ios-app .profile-edit-view {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}

/* Modern Toast Notifications */
.toast-container {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0) + 25px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.toast-notification {
    background: rgba(20, 20, 20, 0.98);
    border-radius: 12px;
    padding: 16px 24px;
    min-width: 250px;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(20px);
    animation: toastSlideIn 0.3s ease forwards;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-notification.success {
    background: rgba(76, 175, 80, 0.95);
    border-color: rgba(129, 199, 132, 0.3);
}

.toast-notification.error {
    background: rgba(244, 67, 54, 0.95);
    border-color: rgba(239, 83, 80, 0.3);
}

.toast-notification.info {
    background: rgba(33, 150, 243, 0.95);
    border-color: rgba(100, 181, 246, 0.3);
}

.toast-notification.hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

.toast-icon {
    font-size: 20px;
    line-height: 1;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

@keyframes toastSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* Mobile adjustments for toast */
@media screen and (max-width: 430px) {
    .toast-container {
        bottom: calc(env(safe-area-inset-bottom, 0) + 25px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .toast-notification {
        width: 100%;
        max-width: none;
    }
}

/* Ensure iOS safe-area overrides do not force toasts to top */
body.ios-app .toast-container {
    top: auto !important;
    bottom: calc(env(safe-area-inset-bottom, 0) + 25px) !important;
}

/* Building Manager Modal Styles - moved to building-manager.css */

/* Building Manager Factory Card Styles - moved to building-manager.css */

/* Confirmation Dialog Modal - moved to building-manager.css */

/* Account Security Section */
.account-security-section {
    margin-top: 20px;
}

.recovery-methods-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.recovery-method-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.recovery-method-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.recovery-method-icon {
    font-size: 32px;
    width: 50px;
    text-align: center;
}

.recovery-method-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recovery-method-name {
    font-size: 16px;
    color: #fff;
    font-weight: 500;
}

/* Account Choice Modal Styles - Modern Space Theme 2025 */
.account-choice-modal {
    max-width: 520px;
    min-height: 450px;
    position: relative;
}

/* Add starfield animation to modal background - Override modern-modal */
.modal-content.modern-modal.account-choice-modal {
    /* Remove solid background to make starfield visible */
    background: transparent !important;
    border: 1px solid rgba(0, 212, 255, 0.4);
    box-shadow: 
        0 0 60px rgba(0, 212, 255, 0.4),
        0 0 120px rgba(0, 153, 204, 0.3),
        inset 0 0 40px rgba(0, 212, 255, 0.1);
    overflow: hidden;
    position: relative;
}

/* Dark gradient background layer */
.modal-content.modern-modal.account-choice-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0a0e1a 0%, #141b2e 50%, #0f1624 100%);
    z-index: 0;
    pointer-events: none;
}

/* Animated starfield layer - visible over gradient */
.modal-content.modern-modal.account-choice-modal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(3px 3px at 95% 85%, #00d4ff, transparent);
    background-repeat: repeat;
    background-size: 400px 400px;
    opacity: 0.8;
    animation: starfield 120s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes starfield {
    from { transform: translateX(0) translateY(0); }
    to { transform: translateX(-400px) translateY(-400px); }
}

/* Enhanced header with gradient text */
.account-choice-modal .modal-header {
    font-size: clamp(28px, 6vw, 36px);
    font-weight: 800;
    background: linear-gradient(135deg, #00d4ff 0%, #00ffff 50%, #0099cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(0, 212, 255, 0.5);
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    position: relative;
    z-index: 2;
}

.account-choice-content {
    padding: 30px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.account-choice-message {
    font-size: clamp(16px, 4vw, 20px);
    color: #e0f7ff;
    margin-bottom: 40px;
    line-height: 1.6;
    font-weight: 400;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
    opacity: 0.95;
}

.account-choice-options {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 35px;
}

.account-choice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px 35px;
    font-size: clamp(16px, 3.5vw, 20px);
    font-weight: 700;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-height: 56px;
}

/* Shimmer effect */
.account-choice-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
}

.account-choice-btn:hover::before {
    left: 100%;
}

/* Floating animation */
.account-choice-btn {
    animation: subtle-float 4s ease-in-out infinite;
}

.account-choice-btn:nth-child(2) {
    animation-delay: 1.3s;
}

.account-choice-btn:nth-child(3) {
    animation-delay: 2.6s;
}

@keyframes subtle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.primary-btn {
    background: linear-gradient(135deg, #00ff88 0%, #00ffff 50%, #00d4ff 100%);
    color: #000;
    box-shadow: 
        0 5px 25px rgba(0, 255, 136, 0.4),
        0 0 50px rgba(0, 212, 255, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(0, 255, 255, 0.3);
    font-weight: 800;
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 8px 35px rgba(0, 255, 136, 0.5),
        0 0 70px rgba(0, 212, 255, 0.4),
        inset 0 0 25px rgba(255, 255, 255, 0.3);
}

.primary-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.secondary-btn {
    background: linear-gradient(135deg, rgba(79, 103, 183, 0.5), rgba(47, 58, 98, 0.5));
    color: #e0f7ff;
    border: 2px solid rgba(0, 212, 255, 0.3);
    box-shadow: 
        0 4px 20px rgba(0, 212, 255, 0.2),
        inset 0 0 15px rgba(0, 212, 255, 0.1);
}

.secondary-btn:hover {
    background: linear-gradient(135deg, rgba(79, 103, 183, 0.4), rgba(47, 58, 98, 0.4));
    transform: translateY(-3px) scale(1.02);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 
        0 6px 30px rgba(0, 212, 255, 0.3),
        inset 0 0 20px rgba(0, 212, 255, 0.15);
}

.secondary-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.choice-icon {
    font-size: clamp(24px, 5vw, 32px);
    filter: drop-shadow(0 0 8px currentColor);
    animation: icon-pulse 2s ease-in-out infinite;
}

.primary-btn .choice-icon {
    animation: icon-glow 2s ease-in-out infinite;
}

@keyframes icon-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes icon-glow {
    0%, 100% { 
        transform: scale(1);
        filter: drop-shadow(0 0 8px currentColor);
    }
    50% { 
        transform: scale(1.1);
        filter: drop-shadow(0 0 15px currentColor);
    }
}

.choice-text {
    font-size: clamp(14px, 3vw, 18px);
    font-weight: 600;
}

/* Email Recovery Modal Styles - Modern Space Theme 2025 */
.email-recovery-modal {
    max-width: 540px;
    position: relative;
}

/* Match account choice modal background - Override modern-modal */
.modal-content.modern-modal.email-recovery-modal {
    /* Remove solid background to make starfield visible */
    background: transparent !important;
    border: 1px solid rgba(0, 212, 255, 0.4);
    box-shadow: 
        0 0 60px rgba(0, 212, 255, 0.4),
        0 0 120px rgba(0, 153, 204, 0.3),
        inset 0 0 40px rgba(0, 212, 255, 0.1);
    overflow: hidden;
    position: relative;
}

/* Dark gradient background layer */
.modal-content.modern-modal.email-recovery-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0a0e1a 0%, #141b2e 50%, #0f1624 100%);
    z-index: 0;
    pointer-events: none;
}

/* Animated starfield layer - visible over gradient */
.modal-content.modern-modal.email-recovery-modal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(3px 3px at 95% 85%, #00d4ff, transparent);
    background-repeat: repeat;
    background-size: 400px 400px;
    opacity: 0.8;
    animation: starfield 120s linear infinite;
    pointer-events: none;
    z-index: 1;
}

/* Enhanced header */
.email-recovery-modal .modal-header {
    font-size: clamp(24px, 5vw, 32px);
    font-weight: 800;
    background: linear-gradient(135deg, #00d4ff 0%, #00ffff 50%, #0099cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(0, 212, 255, 0.5);
    letter-spacing: 1.5px;
    position: relative;
    z-index: 2;
}

.email-recovery-content {
    padding: 30px;
    position: relative;
    z-index: 2;
}

.recovery-step {
    display: block;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.recovery-instructions {
    font-size: clamp(15px, 3.5vw, 18px);
    color: #e0f7ff;
    margin-bottom: 30px;
    text-align: center;
    line-height: 1.6;
    font-weight: 400;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.recovery-input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    align-items: stretch;
}

.recovery-input {
    flex: 1;
    padding: 14px 24px;
    font-size: clamp(14px, 3vw, 16px);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 100px;
    color: #e0f7ff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.2),
        inset 0 0 10px rgba(0, 212, 255, 0.05);
}

.recovery-input::placeholder {
    color: rgba(224, 247, 255, 0.5);
}

.recovery-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.4),
        0 2px 10px rgba(0, 0, 0, 0.2),
        inset 0 0 15px rgba(0, 255, 255, 0.1);
    transform: scale(1.02);
}

.recovery-input.code-input {
    text-align: center;
    font-size: clamp(20px, 5vw, 28px);
    letter-spacing: 8px;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.recovery-btn {
    padding: 14px 35px;
    font-size: clamp(14px, 3vw, 16px);
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff 0%, #00ffff 50%, #0099cc 100%);
    color: #000;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 4px 20px rgba(0, 212, 255, 0.4),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
}

/* Shimmer effect for recovery button */
.recovery-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.6s ease;
}

.recovery-btn:hover::before {
    left: 100%;
}

.recovery-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 30px rgba(0, 212, 255, 0.5),
        0 0 40px rgba(0, 255, 255, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
}

.recovery-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.recovery-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: linear-gradient(135deg, #333, #555);
    box-shadow: none;
}

.recovery-btn:disabled:hover::before {
    left: -100%;
}

.recovery-error {
    color: #ff6b6b;
    font-size: clamp(13px, 3vw, 15px);
    margin-top: 15px;
    text-align: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.15), rgba(255, 68, 68, 0.1));
    border-radius: 100px;
    border: 1px solid rgba(255, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.25), rgba(255, 68, 68, 0.2));
    box-shadow: 
        0 0 20px rgba(255, 68, 68, 0.2),
        inset 0 0 10px rgba(255, 68, 68, 0.1);
    animation: errorShake 0.5s ease-out;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.recovery-link-btn {
    background: none;
    border: none;
    color: #00ffff;
    font-size: clamp(13px, 3vw, 15px);
    text-decoration: none;
    cursor: pointer;
    padding: 8px 16px;
    margin-top: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
    text-align: center;
    position: relative;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.recovery-link-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: #00ffff;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.recovery-link-btn:hover {
    color: #66ffff;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.recovery-link-btn:hover::after {
    width: 100%;
}

.recovery-success {
    text-align: center;
    padding: 50px 30px;
    animation: successBounce 0.6s ease-out;
}

@keyframes successBounce {
    0% { transform: scale(0.8) translateY(20px); opacity: 0; }
    50% { transform: scale(1.05) translateY(-5px); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.success-icon {
    font-size: clamp(60px, 12vw, 80px);
    display: block;
    margin-bottom: 25px;
    animation: iconSuccess 0.8s ease-out;
    filter: drop-shadow(0 0 30px #00ff88);
}

@keyframes iconSuccess {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.recovery-success-message {
    font-size: clamp(20px, 4vw, 26px);
    color: #00ff88;
    font-weight: 800;
    text-shadow: 
        0 0 20px rgba(0, 255, 136, 0.8),
        0 0 40px rgba(0, 255, 136, 0.4);
    letter-spacing: 1px;
    animation: textGlow 2s ease-in-out infinite;
}

@keyframes textGlow {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; text-shadow: 0 0 30px rgba(0, 255, 136, 1), 0 0 60px rgba(0, 255, 136, 0.6); }
}

.recovery-actions {
    padding: 25px 30px;
    border-top: 1px solid rgba(0, 212, 255, 0.2);
    text-align: center;
    background: linear-gradient(to bottom, transparent, rgba(0, 212, 255, 0.05));
    position: relative;
    z-index: 2;
}

.recovery-back-btn {
    padding: 12px 35px;
    font-size: clamp(13px, 3vw, 15px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: #e0f7ff;
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 
        0 2px 15px rgba(0, 0, 0, 0.2),
        inset 0 0 10px rgba(0, 212, 255, 0.05);
}

.recovery-back-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1));
    border-color: rgba(0, 212, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 
        0 4px 20px rgba(0, 212, 255, 0.3),
        inset 0 0 15px rgba(0, 212, 255, 0.1);
}

.code-sent-message {
    font-size: clamp(14px, 3vw, 16px);
    color: #00ff88;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
    animation: pulse-success 2s ease-in-out infinite;
}

@keyframes pulse-success {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; transform: scale(1.02); }
}

/* Mobile responsive for account modals - iPhone optimized */
@media (max-width: 600px) {
    .account-choice-modal,
    .email-recovery-modal {
        max-width: 95%;
        margin: 10px auto;
    }
    
    .modal-content.modern-modal.account-choice-modal,
    .modal-content.modern-modal.email-recovery-modal {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    
    /* Adjust starfield for mobile - now on ::after */
    .modal-content.modern-modal.account-choice-modal::after,
    .modal-content.modern-modal.email-recovery-modal::after {
        background-size: 300px 300px;
    }
    
    .modal-header-section {
        padding: 15px 20px;
        flex-shrink: 0;
    }
    
    .account-choice-modal .modal-header,
    .email-recovery-modal .modal-header {
        font-size: 24px;
    }
    
    .account-choice-content,
    .email-recovery-content {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .account-choice-message,
    .recovery-instructions {
        font-size: 16px;
        margin-bottom: 25px;
    }
    
    .account-choice-options {
        gap: 16px;
        margin-top: 20px;
    }
    
    .account-choice-btn {
        padding: 16px 24px;
        min-height: 48px;
        font-size: 16px;
    }
    
    .choice-icon {
        font-size: 24px;
    }
    
    .choice-text {
        font-size: 15px;
    }
    
    .recovery-input-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .recovery-input {
        width: 100%;
        box-sizing: border-box;
        padding: 16px 24px;
        font-size: 16px;
    }
    
    .recovery-input.code-input {
        font-size: 24px;
        letter-spacing: 6px;
    }
    
    .recovery-btn {
        width: 100%;
        padding: 16px 24px;
        font-size: 16px;
    }
    
    .recovery-actions {
        padding: 20px;
        padding-bottom: calc(env(safe-area-inset-bottom) + 60px);
    }
    
    .recovery-back-btn {
        padding: 12px 24px;
    }
    
    .success-icon {
        font-size: 60px;
    }
    
    .recovery-success-message {
        font-size: 20px;
    }
}

/* iPhone landscape optimization */
@media (max-width: 932px) and (orientation: landscape) {
    .modal-content.modern-modal.account-choice-modal,
    .modal-content.modern-modal.email-recovery-modal {
        max-height: 100vh;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .modal-header-section {
        padding: 10px 20px;
    }
    
    .account-choice-modal .modal-header,
    .email-recovery-modal .modal-header {
        font-size: 22px;
    }
    
    .account-choice-content,
    .email-recovery-content {
        padding: 15px 30px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .account-choice-message,
    .recovery-instructions {
        font-size: 15px;
        margin-bottom: 20px;
    }
    
    .account-choice-options {
        gap: 12px;
        margin-top: 15px;
    }
    
    .account-choice-btn {
        padding: 12px 20px;
        min-height: 44px;
        font-size: 15px;
    }
    
    .choice-icon {
        font-size: 20px;
    }
    
    .recovery-input-container {
        flex-direction: row;
        align-items: stretch;
    }
    
    .recovery-input {
        padding: 12px 20px;
    }
    
    .recovery-input.code-input {
        font-size: 20px;
    }
    
    .recovery-btn {
        width: auto;
        padding: 12px 24px;
    }
    
    .recovery-success {
        padding: 30px;
    }
    
    .success-icon {
        font-size: 50px;
        margin-bottom: 15px;
    }
    
    .recovery-success-message {
        font-size: 18px;
    }
    
    /* Compact email recovery for landscape */
    .recovery-step {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .recovery-actions {
        padding: 15px 30px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Small phone portrait (iPhone SE, etc) */
@media (max-width: 380px) and (orientation: portrait) {
    .account-choice-modal .modal-header,
    .email-recovery-modal .modal-header {
        font-size: 22px;
    }
    
    .account-choice-content,
    .email-recovery-content {
        padding: 15px;
    }
    
    .account-choice-btn {
        padding: 14px 20px;
        font-size: 15px;
        gap: 12px;
    }
    
    .choice-icon {
        font-size: 22px;
    }
    
    .recovery-input {
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .recovery-input.code-input {
        font-size: 22px;
        letter-spacing: 4px;
    }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 3) {
    .modal-content.modern-modal.account-choice-modal,
    .modal-content.modern-modal.email-recovery-modal {
        border-width: 0.5px;
    }
}

/* ========================================
   UNIFIED BUILD MODAL - Modern 2025 Design
   ======================================== */

/* Modal overlay - lighter for better blur visibility */
.unified-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    /* No animation on main element to prevent blur lag */
}

/* Animated overlay background - using ::before with z-index to stay behind content */
.unified-modal::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    animation: unifiedModalFadeIn 0.3s ease-out;
    pointer-events: none;
    z-index: -1;
}

/* Modal content container - with blur background */
.unified-modal-content {
    position: relative;
    z-index: 1;
    background: linear-gradient(145deg, rgba(10, 25, 47, 0.3), rgba(0, 15, 30, 0.3));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin: 5% auto;
    padding: 0;
    border: 1px solid rgba(0, 212, 255, 0.5);
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    text-align: center;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 
        0 8px 32px rgba(0, 212, 255, 0.4),
        0 2px 20px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Fallback for browsers without blur support */
@supports not (backdrop-filter: blur(10px)) {
    .unified-modal-content {
        background: linear-gradient(145deg, rgba(10, 25, 47, 0.9), rgba(0, 15, 30, 0.9));
    }
}

/* Modal header */
.unified-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(0, 150, 200, 0.05) 100%);
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 24px 24px 0 0;
}

.unified-modal-header h2 {
    margin: 0;
    margin-right: auto;
    margin-left: 16px;
    font-size: 24px;
    font-weight: 700;
    color: #00d4ff;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    letter-spacing: 0.5px;
}

/* Close button */
.unified-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

.unified-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: rotate(90deg) scale(1.1);
}

/* Go back button */
.unified-go-back-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

.unified-go-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    transform: translateX(-4px);
}

/* Options grid container */
.unified-options-grid {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    justify-items: center;
}

/* Option tiles */
.unified-option-tile {
    width: 100%;
    aspect-ratio: 1;
    max-width: 150px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08) 0%, rgba(15, 25, 45, 0.6) 100%);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    position: relative;
    overflow: visible;
}

/* Hover glow effect */
.unified-option-tile::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.4s ease;
    pointer-events: none;
}

.unified-option-tile:hover {
    transform: translateY(-4px) scale(1.05);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(15, 25, 45, 0.8) 100%);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(0, 212, 255, 0.3);
}

.unified-option-tile:hover::before {
    transform: translate(-50%, -50%) scale(1.5);
}

.unified-option-tile:active {
    transform: translateY(-2px) scale(1.02);
}

/* Option icon */
.unified-option-icon {
    width: 60%;
    height: 60%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    margin-bottom: 8px;
}

/* Option label */
.unified-option-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
}

/* Portrait mode - 2 columns, 3 rows */
@media (orientation: portrait) {
    .unified-modal-content {
        width: 90%;
        max-width: 900px;
    }
    
    .unified-options-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 20px;
        gap: 14px;
    }
    
    /* Last item no longer needs special handling - all tiles remain in the grid */
    .unified-option-tile:last-child {
        grid-column: auto;
        max-width: none;
        justify-self: auto;
    }
    
    .unified-option-tile {
        max-width: none;
    }
}

/* Landscape mode - 3 columns, 2 rows */
@media (orientation: landscape) {
    .unified-modal-content {
        width: 85%;
        max-width: 900px;
        max-height: 90vh;
    }
    
    .unified-modal-header {
        padding: 16px 20px;
    }
    
    .unified-modal-header h2 {
        font-size: 20px;
    }
    
    .unified-options-grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 20px;
        gap: 14px;
    }
    
    .unified-option-tile {
        max-width: 140px;
    }
    
    .unified-option-tile:last-child {
        grid-column: auto;
    }
}

/* Small screens and mobile - portrait */
@media (max-width: 768px) {
    .unified-modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100vh;
        /* Remove border for fullscreen to prevent edge visibility */
        border: none;
        border-radius: 0;
        /* More transparent background for better blur visibility */
        background: linear-gradient(145deg, rgba(10, 25, 47, 0.25), rgba(0, 15, 30, 0.25));
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        /* Enable smooth scrolling */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* Remove cyan glow on mobile, keep only subtle shadow */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        /* Add safe area padding to content with fallback values */
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Fallback for mobile browsers without blur support */
    @supports not (backdrop-filter: blur(10px)) {
        .unified-modal-content {
            background: linear-gradient(145deg, rgba(10, 25, 47, 0.95), rgba(0, 15, 30, 0.95));
        }
    }
    
    .unified-modal-header {
        padding: 16px 20px;
    }
    
    .unified-modal-header h2 {
        font-size: 20px;
    }
    
    .unified-options-grid {
        padding: 16px;
        gap: 12px;
    }
    
    .unified-option-tile {
        border-radius: 12px;
    }
    
    .unified-option-label {
        font-size: 12px;
    }
}

/* iPhone notch support - removed to prevent frame effect */

/* Animations */
@keyframes unifiedModalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Removed GPU optimization to prevent jumping issues */

/* Modal size variants */
.unified-modal-large {
    max-width: 1200px !important;
}

.unified-modal-small {
    max-width: 600px !important;
}

/* Safe area support for notched devices */
@supports (padding: env(safe-area-inset-top)) {
    @media (orientation: portrait) {
        .modal-header-section {
            /* Removed to prevent double padding - safe area is already handled on .modal level */
            /* padding-top: max(15px, env(safe-area-inset-top)); */
        }
        
        .recovery-actions {
            padding-bottom: calc(env(safe-area-inset-bottom) + 60px);
        }
    }
    
    @media (orientation: landscape) {
        .account-choice-content,
        .email-recovery-content {
            padding-left: max(30px, env(safe-area-inset-left));
            padding-right: max(30px, env(safe-area-inset-right));
        }
    }
}

/* Accessibility: Reduced motion support for modals */
@media (prefers-reduced-motion: reduce) {
    .account-choice-modal *,
    .email-recovery-modal * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .modal-content.modern-modal.account-choice-modal::after,
    .modal-content.modern-modal.email-recovery-modal::after {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modal-content.modern-modal.account-choice-modal,
    .modal-content.modern-modal.email-recovery-modal {
        border: 2px solid #fff;
    }
    
    .account-choice-btn,
    .recovery-btn,
    .recovery-input {
        border-width: 2px;
    }
    
    .recovery-error {
        border-width: 2px;
        color: #ff0000;
    }
}

/* Dark mode optimizations (already dark by default) */
@media (prefers-color-scheme: light) {
    /* Keep dark theme even in light mode for consistency */
}

/* Focus visible for keyboard navigation */
.account-choice-btn:focus-visible,
.recovery-btn:focus-visible,
.recovery-input:focus-visible,
.recovery-back-btn:focus-visible,
.recovery-link-btn:focus-visible {
    outline: 3px solid #00ffff;
    outline-offset: 3px;
}

/* Loading state for buttons */
.account-choice-btn.loading,
.recovery-btn.loading {
    position: relative;
    color: transparent;
}

.account-choice-btn.loading::after,
.recovery-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

.recovery-method-status {
    font-size: 14px;
    color: #888;
}

.recovery-method-status.linked {
    color: #4CAF50;
    font-weight: 500;
}

.link-email-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #0066cc, #0052a3);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.link-email-btn:hover {
    background: linear-gradient(135deg, #0052a3, #003d7a);
    transform: translateY(-1px);
}

/* Email Linking View */
.email-link-view {
    padding: 20px;
}

.email-link-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.email-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.email-input {
    flex: 1;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.email-input:focus {
    outline: none;
    border-color: #0066cc;
    background: rgba(255, 255, 255, 0.08);
}

.send-code-btn, .verify-code-btn {
    padding: 12px 25px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.send-code-btn:hover, .verify-code-btn:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-1px);
}

.send-code-btn:disabled, .verify-code-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

.code-verification-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-sent-message {
    color: #4CAF50;
    font-size: 14px;
    margin: 0;
}

.code-input {
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 24px;
    text-align: center;
    letter-spacing: 10px;
    width: 200px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.code-input:focus {
    outline: none;
    border-color: #0066cc;
    background: rgba(255, 255, 255, 0.08);
}

.resend-code-btn {
    padding: 8px 20px;
    background: transparent;
    color: #0066cc;
    border: 1px solid #0066cc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.resend-code-btn:hover {
    background: rgba(0, 102, 204, 0.1);
}

.resend-code-btn:disabled {
    color: #555;
    border-color: #555;
    cursor: not-allowed;
}

.email-link-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.cancel-email-btn {
    padding: 10px 30px;
    background: transparent;
    color: #888;
    border: 1px solid #888;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.cancel-email-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #aaa;
    border-color: #aaa;
}

/* Mobile responsive for account security */
@media (max-width: 768px) {
    .recovery-method-item {
        padding: 12px;
    }
    
    .recovery-method-icon {
        font-size: 24px;
        width: 40px;
    }
    
    .recovery-method-name {
        font-size: 14px;
    }
    
    .email-input-container {
        flex-direction: column;
    }
    
    .email-input {
        width: 100%;
    }
    
    .send-code-btn {
        width: 100%;
    }
    
    .code-input {
        width: 100%;
        max-width: 200px;
    }
}

/* Active Sessions Management Styles */
.manage-sessions-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.manage-sessions-btn:hover {
    background: linear-gradient(135deg, #1976D2, #1565C0);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

/* Active Sessions Modal */
.active-sessions-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: modalFadeIn 0.3s ease-out;
}

.active-sessions-modal .modal-content {
    background: linear-gradient(135deg, #001428, #002244);
    margin: 5% auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.active-sessions-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.active-sessions-title {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
}

.active-sessions-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.active-sessions-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.active-sessions-body {
    padding: 20px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

/* Sessions List */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.session-item.current-session {
    background: rgba(33, 150, 243, 0.1);
    border-color: rgba(33, 150, 243, 0.3);
}

.session-icon {
    font-size: 32px;
    width: 50px;
    text-align: center;
}

.session-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.session-device-name {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
}

.session-details {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #888;
}

.current-badge {
    background: #2196F3;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.session-last-active {
    color: #aaa;
}

.session-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #666;
}

.session-os {
    color: #888;
}

.session-added {
    color: #666;
}

/* Terminate Session Button */
.session-terminate-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #f44336;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.session-terminate-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: #f44336;
    transform: translateY(-50%) scale(1.1);
}

.terminate-icon {
    font-size: 18px;
    font-weight: bold;
}

/* Loading and Empty States */
.sessions-loading,
.sessions-empty {
    text-align: center;
    padding: 40px;
    color: #888;
}

.sessions-loading {
    font-size: 16px;
}

.sessions-empty {
    font-size: 16px;
    color: #666;
}

/* Sessions Info Note */
.sessions-info-note {
    padding: 15px 20px;
    background: rgba(33, 150, 243, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sessions-info-note p {
    margin: 0;
    font-size: 14px;
    color: #aaa;
    font-style: italic;
}

/* Scrollbar styling for sessions list */
.active-sessions-body::-webkit-scrollbar {
    width: 8px;
}

.active-sessions-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.active-sessions-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.active-sessions-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile responsive for active sessions */
@media (max-width: 768px) {
    .active-sessions-modal .modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: calc(100vh - 20px);
    }
    
    .active-sessions-header {
        padding: 15px;
    }
    
    .active-sessions-title {
        font-size: 20px;
    }
    
    .active-sessions-body {
        padding: 15px;
        max-height: calc(100vh - 120px);
    }
    
    .session-item {
        padding: 12px;
        gap: 12px;
    }
    
    .session-icon {
        font-size: 28px;
        width: 40px;
    }
    
    .session-device-name {
        font-size: 15px;
    }
    
    .session-details {
        font-size: 13px;
        flex-wrap: wrap;
    }
    
    .session-meta {
        font-size: 12px;
        flex-direction: column;
        gap: 5px;
    }
    
    .session-terminate-btn {
        position: static;
        transform: none;
        margin-left: auto;
        flex-shrink: 0;
    }
    
    .manage-sessions-btn {
        padding: 6px 16px;
        font-size: 13px;
    }
}/* Settings Button in Profile Modal */
.settings-btn {
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #4a9eff, #3a7ecc);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: linear-gradient(135deg, #3a7ecc, #2a5ea0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.settings-icon {
    font-size: 20px;
}

/* Settings View */
.settings-view {
    padding: 20px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 12px;
}

/* Quality Selector */
.quality-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
}

.quality-arrow {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
}

.quality-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.6);
    color: #00d4ff;
}

.quality-arrow.left {
    transform: rotate(0deg);
}

.quality-arrow.right {
    transform: rotate(0deg);
}

.quality-options {
    display: flex;
    gap: 30px;
}

.quality-option {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.6);
    opacity: 0.5;
    transition: all 0.3s ease;
    cursor: default;
}

.quality-option.active {
    color: #00d4ff;
    font-weight: 600;
    opacity: 1;
    transform: scale(1.1);
}

/* Language Selector */
.language-selector {
    position: relative;
    width: 100%;
}

.language-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.language-current:hover {
    border-color: rgba(0, 212, 255, 0.6);
}

.language-flag {
    font-size: 24px;
}

.language-name {
    flex: 1;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
}

.dropdown-arrow {
    color: rgba(255, 255, 255, 0.6);
    transition: transform 0.2s ease;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #1a1a2e;
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: rgba(255, 255, 255, 0.9);
}

.language-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.language-option:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Settings Actions */
.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

.save-settings-btn,
.cancel-settings-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-settings-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.save-settings-btn:hover {
    background: linear-gradient(135deg, #45a049, #3d8b41);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.cancel-settings-btn {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.cancel-settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .quality-selector {
        padding: 15px;
        gap: 15px;
    }
    
    .quality-options {
        gap: 20px;
    }
    
    .quality-option {
        font-size: 14px;
    }
    
    .quality-arrow {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

/* iOS-specific toolbar fixes for landscape */
@media (orientation: landscape) {
    body.ios-app .top-toolbar {
        /* Fallback for iOS if fit-content doesn't work */
        display: inline-flex !important;
        width: auto !important;
    }
    
    body.ios-app .bottom-toolbar {
        /* Fallback for iOS if fit-content doesn't work */
        display: inline-flex !important;
        width: auto !important;
    }
}

/* ========================================
   User Profile Modal Styles
   ======================================== */

/* Z-index hierarchy for modals */
.modal {
    z-index: 1000;
}

.leaderboard-modal {
    z-index: 2000;
}

/* Player profile modal - highest z-index to appear above all other modals */
#playerProfileModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100000 !important;
    display: block;
}

/* User Profile Modal - Space Theme Design */
.user-profile-modal {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    padding: 0;
    background: #0a0511;
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Space theme background effect */
.user-profile-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 107, 53, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(155, 89, 182, 0.04) 0%, transparent 70%);
    pointer-events: none;
    animation: spaceFloat 20s ease-in-out infinite;
}

@keyframes spaceFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-20px, -20px) scale(1.05); }
    66% { transform: translate(20px, -10px) scale(0.98); }
}

.user-profile-modal .modal-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: env(safe-area-inset-top, 20px) 20px 16px 20px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08) 0%, rgba(155, 89, 182, 0.05) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.user-profile-modal .modal-header-section h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #00d4ff;
    letter-spacing: -0.5px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.user-profile-modal .close-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    outline: none;
}

.user-profile-modal .close-btn svg {
    width: 24px;
    height: 24px;
    display: block;
}

.user-profile-modal .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.user-profile-modal .close-btn:active {
    transform: scale(0.95);
}

/* Profile Content Container */
.profile-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.2) transparent;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.profile-content::-webkit-scrollbar {
    width: 6px;
}

.profile-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.profile-content::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 3px;
}

.profile-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.5);
}

/* Loading and Error States */
.user-profile-loading {
    padding: 80px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.user-profile-loading .loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    border: 2px solid rgba(0, 212, 255, 0.1);
    border-top-color: #00d4ff;
    border-right-color: #ff6b35;
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    box-sizing: border-box;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.user-profile-loading p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.user-profile-error {
    padding: 60px 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.user-profile-error .error-message {
    color: #ff5252;
    font-size: 15px;
    font-weight: 400;
    padding: 20px;
    background: rgba(211, 47, 47, 0.1);
    border: 1px solid rgba(211, 47, 47, 0.2);
    border-radius: 12px;
}

/* User Profile Header - Space Theme Design */
.user-profile-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 24px 20px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    overflow: visible;
}

.user-profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(0, 212, 255, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    position: relative;
}

.user-profile-basic-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-profile-username {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.user-profile-base-name {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Level Bar Display */
.user-profile-level-bar {
    margin-top: 8px;
    padding: 6px 14px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    height: 28px;
}

.user-profile-level-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
    animation: levelShimmer 3s ease-in-out infinite;
}

@keyframes levelShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.user-profile-level-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    line-height: 16px;
}

.user-profile-level-value {
    font-size: 12px;
    font-weight: 700;
    color: #00d4ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    line-height: 16px;
    position: relative;
    top: 5px;
}

.user-profile-online-status {
    position: absolute;
    top: 24px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.user-profile-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.user-profile-status-indicator.online {
    background: #4CAF50;
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.8);
    animation: onlinePulse 2s ease-in-out infinite;
}

.user-profile-status-indicator.offline {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes onlinePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* Prestige Section - Space Theme Style */
.user-profile-prestige-section {
    padding: 20px;
    margin: 20px 20px 0;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-profile-prestige-display {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.user-profile-prestige-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.6));
    animation: prestigeGlow 3s ease-in-out infinite;
}

@keyframes prestigeGlow {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.user-profile-prestige-value {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.user-profile-prestige-label {
    font-size: 13px;
    color: rgba(251, 191, 36, 0.8);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Visit City and Send Message Buttons */
.user-profile-visit-city-section {
    padding: 0 20px;
    margin: 15px auto 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    max-width: 520px;
    box-sizing: border-box;
}

.user-profile-visit-city-btn,
.user-profile-send-message-btn {
    width: 100%;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(155, 89, 182, 0.12) 100%);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 12px;
    color: #00d4ff;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 12px rgba(0, 212, 255, 0.1),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.user-profile-visit-city-btn::before,
.user-profile-send-message-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.user-profile-visit-city-btn:hover::before,
.user-profile-send-message-btn:hover::before {
    left: 100%;
}

.user-profile-visit-city-btn:hover,
.user-profile-send-message-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.25) 0%, rgba(155, 89, 182, 0.2) 100%);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow:
        0 6px 20px rgba(0, 212, 255, 0.2),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.user-profile-visit-city-btn:active,
.user-profile-send-message-btn:active {
    transform: translateY(0);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2) 0%, rgba(155, 89, 182, 0.15) 100%);
    box-shadow:
        0 2px 8px rgba(0, 212, 255, 0.1),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.user-profile-visit-city-btn .visit-icon,
.user-profile-send-message-btn .message-icon {
    font-size: 18px;
}

.user-profile-visit-city-btn .visit-text,
.user-profile-send-message-btn .message-text {
    font-size: 15px;
    letter-spacing: 0.3px;
}

/* Statistics Grid - Modern Card Design */
.user-profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 20px;
    margin: 20px 0;
}

.user-profile-stat-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 16px 12px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.user-profile-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, 
        rgba(0, 212, 255, 0.08) 0%, 
        transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.user-profile-stat-card:hover::before {
    opacity: 1;
}

.user-profile-stat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 212, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.user-profile-stat-icon {
    font-size: 24px;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.user-profile-stat-value {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff 0%, #ff6b35 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.user-profile-stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Recent Achievements - Space Style */
.user-profile-achievements-section {
    padding: 20px;
    margin: 0 20px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.user-profile-achievements-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-profile-recent-achievements-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-profile-achievement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-profile-achievement-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-profile-achievement-icon {
    font-size: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.user-profile-achievement-name {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* Production Statistics - Space Theme */
.user-profile-production-section {
    padding: 20px;
    margin: 0 20px 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.user-profile-production-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-profile-production-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 3px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.user-profile-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    outline: none;
}

.user-profile-tab-btn.active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(255, 107, 53, 0.15) 100%);
    color: #00d4ff;
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.2);
}

.user-profile-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00d4ff, transparent);
    border-radius: 1px;
}

.user-profile-tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

.user-profile-production-display {
    text-align: center;
    padding: 24px;
    background: 
        radial-gradient(ellipse at center, rgba(0, 212, 255, 0.05) 0%, transparent 60%),
        rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.user-profile-production-value {
    display: block;
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff 0%, #ff6b35 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -1px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.user-profile-production-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Mobile Optimizations - Full Screen */
@media (max-width: 768px) {
    #playerProfileModal {
        margin: 0;
        width: 100vw;
        height: 100vh;
    }
    
    
    .user-profile-modal {
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .user-profile-header {
        padding: 20px 16px;
        gap: 16px;
    }
    
    .user-profile-avatar {
        width: 72px;
        height: 72px;
    }
    
    
    .user-profile-username {
        font-size: 20px;
    }
    
    .user-profile-stats-grid {
        padding: 0 16px;
        gap: 10px;
    }
    
    .user-profile-stat-card {
        padding: 14px 10px;
    }
    
    .user-profile-stat-icon {
        font-size: 22px;
    }
    
    .user-profile-stat-value {
        font-size: 18px;
    }
    
    .user-profile-prestige-section,
    .user-profile-achievements-section,
    .user-profile-production-section {
        margin-left: 16px;
        margin-right: 16px;
    }
    
    .user-profile-production-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }
    
    .user-profile-production-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .user-profile-tab-btn {
        flex-shrink: 0;
        min-width: 80px;
    }
}

/* iPhone 14 Pro Max and similar large phones */
@media (max-width: 430px) {
    .user-profile-modal .modal-header-section h2 {
        font-size: 16px;
    }
    
    .user-profile-prestige-value {
        font-size: 20px;
    }
    
    .user-profile-production-value {
        font-size: 24px;
    }
}

/* Landscape Mode - Optimized */
@media (orientation: landscape) {
    .user-profile-modal {
        max-width: 600px;
        margin: 0 auto;
        height: 100vh;
    }
    
    .user-profile-modal .modal-header-section {
        padding: 16px 20px;
    }
    
    .profile-content {
        padding-bottom: 20px;
    }
    
    .user-profile-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 560px;
        margin: 16px auto;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .user-profile-modal .modal-header-section {
        padding: 12px 20px;
    }
    
    .user-profile-header {
        padding: 16px 20px;
        flex-direction: row;
    }
    
    .user-profile-avatar {
        width: 60px;
        height: 60px;
    }
    
    .user-profile-online-status {
        top: 16px;
    }
    
    .profile-content {
        padding-bottom: 20px;
    }
}

/* Animation for level progress */
@keyframes levelProgressFill {
    from {
        stroke-dashoffset: 283;
    }
    to {
        stroke-dashoffset: var(--progress-offset, 283);
    }
}

/* Additional animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-profile-data > * {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.user-profile-data > *:nth-child(1) { animation-delay: 0.1s; }
.user-profile-data > *:nth-child(2) { animation-delay: 0.2s; }
.user-profile-data > *:nth-child(3) { animation-delay: 0.3s; }
.user-profile-data > *:nth-child(4) { animation-delay: 0.4s; }
.user-profile-data > *:nth-child(5) { animation-delay: 0.5s; }

/* Fix modal positioning */
#playerProfileModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#playerProfileModal .modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
}

/* iPad and Tablets */
@media (min-width: 768px) and (max-width: 1024px) {
    #playerProfileModal .modal-content {
        max-width: 500px;
        max-height: 90vh;
        border-radius: 20px;
    }
    
    .user-profile-modal {
        max-width: 500px;
        border-radius: 20px;
        border: 1px solid rgba(255, 152, 0, 0.2);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    }
}

/* SVG gradient for level ring */
.user-profile-level-gradient {
    position: absolute;
    width: 0;
    height: 0;
    visibility: hidden;
}

/* Desktop - Wider modal */
@media (min-width: 1025px) {
    .user-profile-modal {
        max-width: 800px;
        border-radius: 24px;
        border: 1px solid rgba(0, 212, 255, 0.2);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    }
    
    .user-profile-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 600px;
        margin: 20px auto;
    }
}

/* Building notification system - moved from index.php inline styles */

/* Special buildings indicator */
.special-building-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: #ff4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* White exclamation mark using CSS */
.special-building-indicator::after {
    content: '!';
    color: white;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

.category-tab {
    position: relative;
    overflow: visible !important;
}

/* Fix overflow for category tabs container */
.category-tabs-container {
    overflow: visible !important;
}

.category-tabs {
    overflow-x: auto;
    overflow-y: visible !important;
}

/* Build notification badge for main build button and unified modal */
.build-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: #ff4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* White exclamation mark using CSS */
.build-notification-badge::after {
    content: '!';
    color: white;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

/* Make build button and unified option tile position relative for badge */
#buildButton {
    position: relative;
}

.unified-option-tile {
    position: relative;
    overflow: visible !important;
}

/* Subtle notification badge for individual building options */
.building-option-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    background-color: rgba(255, 68, 68, 0.8); /* More subtle with transparency */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* White exclamation mark using CSS */
.building-option-indicator::after {
    content: '!';
    color: white;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
}
