        :root {
            --sky-blue: #5dade2;
            --dark-blue: #23415c;
            --gold: #f1c40f;
            --grass-green: #7dbc43;
            --dirt-brown: #7a5230;
            --panel-bg: rgba(35, 65, 92, 0.95);
            --border-glow: #00ecff;
        }

        * {
            box-sizing: border-box;
            font-family: 'Outfit', sans-serif;
            margin: 0;
            padding: 0;
            user-select: none;
            -webkit-user-select: none;
            touch-action: manipulation; /* Prevent double-tap zoom delay */
        }

        body {
            background: #111a24;
            color: #fff;
            margin: 0;
            padding: 0;
            width: 100vw;
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #game-viewport {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100%;
            overflow: hidden;
            position: relative;
        }

        /* simulated mobile device container */
        #device-wrapper {
            background: #1e2730;
            border: 8px solid #2c3e50;
            border-radius: 36px;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.5);
            width: 406px;
            height: 796px;
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-between;
            flex-shrink: 0;
        }

        /* Top Header UI */
        #header-ui {
            background: var(--sky-blue);
            width: 100%;
            height: 70px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 16px;
            z-index: 5;
            position: relative;
            border-bottom: 2px solid rgba(0, 0, 0, 0.08);
            flex-shrink: 0;
        }

        .settings-btn {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            border-radius: 50%;
            width: 38px;
            height: 38px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: transform 0.2s, background-color 0.2s;
        }

        .settings-btn:hover {
            transform: rotate(45deg);
            background: rgba(255, 255, 255, 0.35);
        }

        .settings-btn svg {
            fill: #34495e;
            width: 22px;
            height: 22px;
        }

        .wave-pill {
            background: var(--dark-blue);
            border-radius: 20px;
            padding: 6px 16px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-width: 120px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
        }

        .wave-title {
            font-size: 13px;
            font-weight: 800;
            color: #d1ecf1;
            letter-spacing: 0.5px;
            text-transform: uppercase;
        }

        /* Progress track inside wave pill */
        .wave-progress-track {
            background: #142738;
            border-radius: 4px;
            width: 80px;
            height: 5px;
            margin-top: 4px;
            position: relative;
            overflow: hidden;
        }

        .wave-progress-bar {
            background: var(--gold);
            height: 100%;
            width: 0%;
            transition: width 0.3s ease;
        }

        .coin-pill {
            background: var(--dark-blue);
            border-radius: 20px;
            padding: 6px 14px;
            display: flex;
            align-items: center;
            gap: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .coin-icon {
            background: var(--gold);
            border: 2px solid #fff;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            box-shadow: 0 0 5px rgba(241, 196, 15, 0.6);
            position: relative;
        }

        .coin-icon::after {
            content: '$';
            color: #7f6000;
            font-size: 11px;
            font-weight: 800;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .coin-amount {
            color: #fff;
            font-size: 17px;
            font-weight: 800;
        }

        /* Game Canvas Area */
        #canvas-container {
            width: 100%;
            max-width: 390px;
            aspect-ratio: 390 / 520;
            position: relative;
            background: var(--sky-blue);
            flex-grow: 0;
            flex-shrink: 0;
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
            touch-action: none; /* Prevent default scrolling/gestures on canvas when dragging */
        }

        /* Floating HUD overlays on top of the canvas */
        .hud-pills-container {
            position: absolute;
            bottom: 12px;
            left: 0;
            right: 0;
            display: flex;
            justify-content: space-between;
            padding: 0 16px;
            pointer-events: none;
            z-index: 2;
        }

        .hud-pill {
            background: rgba(0, 0, 0, 0.65);
            backdrop-filter: blur(4px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 20px;
            padding: 6px 12px;
            display: flex;
            align-items: center;
            gap: 6px;
            color: #fff;
            font-weight: 800;
            font-size: 15px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        }

        .hud-pill.health {
            border-color: rgba(231, 76, 60, 0.4);
        }

        .hud-pill.enemies {
            border-color: rgba(255, 255, 255, 0.2);
        }

        .hud-pill .icon {
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .svg-icon {
            width: 1em;
            height: 1em;
            display: block;
            object-fit: contain;
            pointer-events: none;
        }

        /* Shop & Action Footer */
        #footer-ui {
            background: #18222b;
            width: 100%;
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            padding: 12px 16px 18px 16px;
            border-top: 3px solid #23313e;
            z-index: 5;
            min-height: 120px;
        }

        .shop-row {
            display: flex;
            justify-content: center;
            width: 100%;
            gap: 8px;
            flex-wrap: wrap;
        }

        .shop-card {
            background: #23313e;
            border: 2px solid transparent;
            border-radius: 16px;
            flex: 1;
            padding: 10px;
            display: flex;
            flex-direction: column;
            align-items: center;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            touch-action: none; /* Prevent scroll/bounce on mobile during dragging */
        }

        .shop-card:hover {
            background: #2a3a4a;
            transform: translateY(-2px);
        }

        .shop-card.selected {
            border-color: var(--border-glow);
            box-shadow: 0 0 10px rgba(0, 236, 255, 0.4);
            background: #2c3e50;
        }

        .shop-card.disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none !important;
            box-shadow: none !important;
        }

        .shop-card-title {
            font-size: 12px;
            font-weight: 800;
            color: #9cb2c6;
            margin-bottom: 4px;
            text-transform: uppercase;
        }

        .shop-card-price {
            display: flex;
            align-items: center;
            gap: 4px;
            background: rgba(0, 0, 0, 0.25);
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 13px;
            font-weight: 800;
            color: var(--gold);
        }

        .shop-card-icon {
            width: 24px;
            height: 24px;
            margin-bottom: 2px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .shop-card-icon .svg-icon {
            width: 22px;
            height: 22px;
        }

        .start-btn {
            background: #2ecc71;
            border: none;
            border-radius: 20px;
            width: 100%;
            height: 48px;
            color: #fff;
            font-size: 18px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 6px 0 #27ae60, 0 8px 15px rgba(0, 0, 0, 0.3);
            transition: all 0.1s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-top: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .start-btn:hover:not(:disabled) {
            background: #27ae60;
        }

        .start-btn:active:not(:disabled) {
            transform: translateY(4px);
            box-shadow: 0 2px 0 #27ae60, 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .start-btn:disabled {
            background: #7f8c8d;
            box-shadow: 0 6px 0 #95a5a6;
            opacity: 0.6;
            cursor: not-allowed;
        }

        /* Beautiful Popup Overlay Modals */
        .modal-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(10, 20, 30, 0.75);
            backdrop-filter: blur(6px);
            z-index: 10;
            display: none;
            justify-content: center;
            align-items: center;
            padding: 24px;
        }

        .modal-content {
            background: var(--panel-bg);
            border: 3px solid #34495e;
            border-radius: 24px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 236, 255, 0.2);
            width: 100%;
            max-width: 320px;
            padding: 24px;
            text-align: center;
            animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        @keyframes bounceIn {
            0% {
                transform: scale(0.3);
                opacity: 0;
            }

            50% {
                transform: scale(1.05);
                opacity: 0.8;
            }

            70% {
                transform: scale(0.9);
                opacity: 0.9;
            }

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

        .modal-title {
            font-size: 26px;
            font-weight: 800;
            margin-bottom: 8px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        .modal-title.win {
            color: #2ecc71;
        }

        .modal-title.lose {
            color: #e74c3c;
        }

        .modal-subtitle {
            font-size: 14px;
            color: #aebcc8;
            margin-bottom: 20px;
            line-height: 1.4;
        }

        .upgrade-option {
            background: #1c2d3d;
            border: 2px solid #34495e;
            border-radius: 16px;
            padding: 12px;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            text-align: left;
            transition: all 0.2s;
        }

        .upgrade-option:hover {
            background: #273d52;
            border-color: var(--border-glow);
            transform: scale(1.02);
        }

        .upgrade-option-icon {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            width: 44px;
            height: 44px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .upgrade-option-icon .svg-icon {
            width: 26px;
            height: 26px;
        }

        .upgrade-option-details {
            flex-grow: 1;
        }

        .upgrade-option-name {
            font-weight: 800;
            font-size: 14px;
            color: #fff;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 6px;
        }

        .badge-powerful {
            background: #e74c3c;
            color: #fff;
            font-size: 9px;
            font-weight: 800;
            text-transform: uppercase;
            padding: 2px 6px;
            border-radius: 6px;
            display: inline-block;
            letter-spacing: 0.5px;
            box-shadow: 0 0 8px rgba(231, 76, 60, 0.4);
            border: 1px solid rgba(255, 255, 255, 0.2);
            line-height: 1.2;
        }

        .upgrade-option-desc {
            font-size: 11px;
            color: #8b9eb0;
            margin-top: 2px;
        }

        .modal-btn {
            background: var(--gold);
            color: #3e2e00;
            border: none;
            border-radius: 20px;
            width: 100%;
            height: 44px;
            font-size: 16px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 4px 0 #b7950b;
            transition: all 0.1s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-top: 10px;
        }

        .modal-btn:hover {
            background: #f4d03f;
        }

        .modal-btn:active {
            transform: translateY(2px);
            box-shadow: 0 2px 0 #b7950b;
        }

        .modal-btn.secondary {
            background: #34495e;
            color: #dbe7f1;
            box-shadow: 0 4px 0 #1b2834;
        }

        .modal-btn.secondary:hover {
            background: #3f5870;
        }

        /* Mock Ad Screen Overlay (Vibrant and Premium) */
        #ad-overlay {
            background: #0f161c;
            z-index: 100;
            display: none;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        .ad-logo {
            font-size: 20px;
            font-weight: 800;
            color: #888;
            margin-bottom: 24px;
            letter-spacing: 2px;
        }

        .ad-spinner {
            border: 4px solid rgba(255, 255, 255, 0.1);
            border-top: 4px solid var(--border-glow);
            border-radius: 50%;
            width: 50px;
            height: 50px;
            animation: spin 1s linear infinite;
            margin-bottom: 16px;
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        .ad-text {
            font-size: 16px;
            font-weight: 600;
            color: #fff;
            margin-bottom: 8px;
        }

        .ad-subtext {
            font-size: 12px;
            color: #7f8c8d;
        }

        /* Responsiveness for Mobile Viewports */
        @media (max-width: 480px) {
            body {
                padding: 0;
            }

            #device-wrapper {
                width: 100vw;
                height: 100vh;
                height: 100dvh;
                border: none;
                border-radius: 0;
                box-shadow: none;
            }

            #canvas-container {
                max-width: 100vw;
            }

            #footer-ui {
                padding: 8px 12px 14px 12px;
                min-height: 100px;
            }

            .shop-card {
                padding: 6px 8px;
                border-radius: 12px;
                min-width: 75px;
            }

            .start-btn {
                height: 42px;
                font-size: 16px;
                margin-top: 6px;
            }
        }

        /* Mobile View Device Wrapper Override for dynamic scaling */
        #device-wrapper.mobile-view {
            width: 390px !important;
            height: 710px !important;
            border: none !important;
            border-radius: 0 !important;
            box-shadow: none !important;
        }

        /* --- GOOGLE ADSENSE RESPONSIVE LAYOUT & STYLING --- */
        .ad-container {
            display: none; /* Controlled dynamically by JavaScript active-state class */
            justify-content: center;
            align-items: center;
            box-sizing: border-box;
            border-radius: 12px;
            overflow: hidden;
            position: relative;
            transition: all 0.3s ease;
            /* Hidden until filled/active */
            background: transparent !important;
            border: 2px solid transparent !important;
            box-shadow: none !important;
        }

        /* Show details and styles only when test mode is active or when an ad successfully fills the slot */
        .ad-container.test-mode-active,
        .ad-container.ad-filled {
            background: rgba(30, 39, 48, 0.65) !important;
            border: 2px dashed rgba(255, 255, 255, 0.12) !important;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
        }

        /* Compliant Advertisement Label overlay */
        .ad-container::before {
            content: "ADVERTISEMENT";
            position: absolute;
            top: 6px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 8px;
            font-weight: 800;
            color: rgba(255, 255, 255, 0.25);
            letter-spacing: 1.5px;
            pointer-events: none;
            z-index: 1;
            display: none; /* Hidden by default */
        }

        /* Show the Advertisement header label only when active/filled */
        .ad-container.test-mode-active::before,
        .ad-container.ad-filled::before {
            display: block;
        }

        /* Desktop side ads (fixed positioning) */
        .desktop-ad {
            position: fixed;
            top: 50%;
            transform: translateY(-50%);
            z-index: 90; /* Sit above background but below modals */
            width: 300px;
            height: 600px;
        }

        #left-ad {
            left: 20px;
        }

        #right-ad {
            right: 20px;
        }

        /* Mobile bottom banner ad */
        #mobile-ad {
            position: absolute;
            bottom: 12px;
            left: 50%;
            transform: translateX(-50%);
            width: 320px;
            height: 50px;
            z-index: 8;
            background: rgba(15, 22, 28, 0.98);
            border: 2px dashed rgba(0, 236, 255, 0.2);
            border-radius: 8px;
            box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
        }

        #mobile-ad.height-100 {
            height: 100px;
        }

        /* Slide HUD pills up when Mobile Ad is active to avoid overlapping */
        .hud-pills-container {
            transition: bottom 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        .hud-pills-container.ad-visible {
            bottom: 74px; /* Shift up for 50px height ad + 12px spacing + 12px gap */
        }

        .hud-pills-container.ad-visible.height-100 {
            bottom: 124px; /* Shift up for 100px height ad + 12px spacing + 12px gap */
        }

        /* Settings Modal Specific Styling to match premium theme */
        #settings-modal .modal-content {
            border-color: var(--gold);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(241, 196, 15, 0.3);
        }

        .settings-options label {
            transition: color 0.2s ease, transform 0.2s ease;
        }

        .settings-options label:hover {
            color: #fff;
            transform: translateX(3px);
        }

        /* --- RESPONSIVE MEDIA QUERIES FOR AD VISIBILITY & SIZING --- */

        /* Mobile screen size */
        @media (max-width: 599px) {
            .desktop-ad {
                display: none !important;
            }
            #mobile-ad.active-state {
                display: flex !important;
            }
        }

        /* Tablet screen size - Show only one side ad (right ad) */
        @media (min-width: 600px) and (max-width: 767px) {
            #left-ad {
                display: none !important;
            }
            #right-ad.active-state {
                display: flex !important;
                width: 160px;
                height: 600px;
                right: 12px;
            }
            #mobile-ad {
                display: none !important;
            }
        }

        /* Desktop small screen size - Show both 160px wide */
        @media (min-width: 768px) and (max-width: 1079px) {
            #left-ad.active-state, 
            #right-ad.active-state {
                display: flex !important;
                width: 160px;
                height: 600px;
            }
            #left-ad {
                left: 12px;
            }
            #right-ad {
                right: 12px;
            }
            #mobile-ad {
                display: none !important;
            }
        }

        /* Desktop large screen size - Show both 300px wide */
        @media (min-width: 1080px) {
            #left-ad.active-state, 
            #right-ad.active-state {
                display: flex !important;
                width: 300px;
                height: 600px;
            }
            #mobile-ad {
                display: none !important;
            }
        }

        /* Responsive vertical space rules for Desktop ads */
        @media (max-height: 649px) {
            .desktop-ad {
                height: 400px !important;
            }
        }

        @media (max-height: 449px) {
            .desktop-ad {
                display: none !important;
            }
        }

        /* --- DESKTOP FLOATING FOOTER LINKS --- */
        .footer-links {
            position: absolute;
            bottom: 20px;
            right: 20px;
            display: flex;
            gap: 16px;
            z-index: 95; /* Sit above background/ads but below active modals */
        }

        .footer-links a {
            color: rgba(139, 158, 176, 0.6);
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            text-decoration: none;
            font-family: 'Outfit', sans-serif;
            transition: color 0.2s ease, transform 0.2s ease;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
        }

        .footer-links a:hover {
            color: #ffffff;
            transform: translateY(-1px);
        }

        .footer-links a:active {
            transform: translateY(0);
        }

        /* Hide desktop floating links on mobile to prevent layout conflicts */
        @media (max-width: 600px) {
            .footer-links {
                display: none !important;
            }
        }

        /* Premium Modal Scrollbars */
        .modal-subtitle::-webkit-scrollbar {
            width: 6px;
        }

        .modal-subtitle::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.03);
            border-radius: 8px;
        }

        .modal-subtitle::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.15);
            border-radius: 8px;
        }

        .modal-subtitle::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }

