<style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        body {
            background: linear-gradient(135deg, #0c0c1d, #1a1a2e, #16213e);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: #e6e6e6;
            overflow: hidden;
            height: 100vh;
            display: flex;
            align-items: center;
            touch-action: none;
            padding: 5px;
            flex-direction: column;  /* change from center alignment */
            justify-content: flex-start;
            padding-top: 55px;  /* reserve for top banner ad */
        }

        #game-container {
            position: relative;
            width: 100%;
            max-width: 800px;
            height: 88vh;
            max-height: 700px;
            background: radial-gradient(circle at 20% 30%, rgba(30, 40, 80, 0.7) 0%, rgba(10, 15, 30, 0.9) 100%);
            border-radius: 16px;
            box-shadow: 0 0 25px rgba(0, 30, 80, 0.8), 0 0 40px rgba(30, 100, 255, 0.3);
            overflow: hidden;
            touch-action: none;
        }

        canvas {
            display: block;
            background: rgba(10, 15, 30, 0.95);
            width: 100%;
            height: 100%;
            touch-action: none;
        }

        #ui-container {
            position: absolute;
            bottom: 10px;
            left: 0;
            right: 0;
            display: flex;
            justify-content: space-between;
            padding: 0 10px;
            z-index: 10;
            gap: 8px;
            pointer-events: none;
        }

        #ui-container > * {
            pointer-events: auto;
        }

        #resources {
            background: rgba(20, 30, 60, 0.85);
            border: 1px solid #4a6fa5;
            border-radius: 8px;
            padding: 6px 8px;
            flex: 1;
            min-width: 50px;
            max-width: 95px;
            box-shadow: 0 0 8px rgba(30, 100, 255, 0.3);
            font-size: 11px;
        }

        #ship-stats {
            background: rgba(20, 30, 60, 0.85);
            border: 1px solid #4a6fa5;
            border-radius: 8px;
            padding: 6px 8px;
            min-width: 95px;
            max-width: 120px;
            box-shadow: 0 0 8px rgba(30, 100, 255, 0.3);
            font-size: 11px;
        }

        #weapon-panel {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(20, 30, 60, 0.92);
            border: 1px solid #4a6fa5;
            border-radius: 10px;
            padding: 10px;
            width: 190px;
            box-shadow: 0 0 10px rgba(30, 100, 255, 0.3);
            z-index: 10;
            font-size: 12px;
            pointer-events: auto;
        }

        .panel-title {
            text-align: center;
            font-size: 15px;
            margin-bottom: 8px;
            color: #6da4e9;
            text-shadow: 0 0 2px rgba(100, 180, 255, 0.7);
            font-weight: bold;
            border-bottom: 1px solid #3a5a80;
            padding-bottom: 4px;
        }

        .weapon-slot {
            background: rgba(15, 25, 50, 0.8);
            border-radius: 6px;
            padding: 8px;
            border-left: 3px solid #6da4e9;
            position: relative;
            font-size: 12px;
        }

        .weapon-name {
            font-weight: bold;
            margin-bottom: 4px;
            display: flex;
            justify-content: space-between;
            font-size: 14px;
        }

        .weapon-stats {
            font-size: 11px;
            opacity: 0.85;
            margin-bottom: 6px;
            min-height: 30px;
        }

        .spread-preview {
            display: flex;
            justify-content: center;
            margin: 6px 0;
            height: 24px;
            position: relative;
            background: rgba(10, 20, 40, 0.5);
            border-radius: 4px;
            border: 1px solid #3a5a80;
        }

        .bullet-preview {
            position: absolute;
            width: 6px;
            height: 6px;
            background: #6da4e9;
            border-radius: 50%;
            bottom: 4px;
            box-shadow: 0 0 4px #6da4e9;
        }

        .upgrade-requirements {
            display: flex;
            flex-wrap: wrap;
            gap: 3px;
            margin: 4px 0;
            font-size: 10px;
        }

        .requirement-item {
            display: flex;
            align-items: center;
            background: rgba(30, 40, 70, 0.7);
            padding: 1px 4px;
            border-radius: 8px;
        }

        .ore-icon {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            margin-right: 3px;
            display: inline-block;
            border: 1px solid rgba(255, 255, 255, 0.3);
            position: relative;
            overflow: hidden;
        }

        .iron { background: linear-gradient(45deg, #8a7a6b, #a89a8b); }
        .titanium { background: linear-gradient(45deg, #7d9abf, #9db4d6); }
        .gold { background: linear-gradient(45deg, #d4af37, #e6b422); box-shadow: 0 0 4px #ffd700; }
        .platinum { background: linear-gradient(45deg, #e5e4e2, #f0f0f0); box-shadow: 0 0 3px #c0c0c0; }
        .rhodium {
            background: linear-gradient(45deg, #ffffff, #e0e0e0);
            box-shadow: 0 0 6px #a0d0ff;
            position: relative;
        }

        .rhodium::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 70%);
            border-radius: 50%;
        }

        .upgrade-btn {
            background: rgba(30, 50, 100, 0.9);
            border: 1px solid #4a6fa5;
            color: #e6e6e6;
            border-radius: 5px;
            padding: 4px 8px;
            font-size: 12px;
            margin-top: 3px;
            cursor: pointer;
            transition: all 0.15s;
            width: 100%;
            font-weight: bold;
            pointer-events: auto;
        }

        .upgrade-btn:hover {
            background: rgba(40, 70, 130, 0.9);
            box-shadow: 0 0 6px rgba(100, 180, 255, 0.5);
        }

        .upgrade-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .upgrade-btn:active {
            transform: scale(0.98);
        }

        #toggle-buttons {
            position: absolute;
            top: 10px;
            left: 10px;
            display: flex;
            gap: 8px;
            z-index: 15;
            pointer-events: auto;
        }

        .toggle-btn {
            background: rgba(20, 30, 60, 0.85);
            border: 1px solid #4a6fa5;
            border-radius: 20px;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #6da4e9;
            font-weight: bold;
            font-size: 16px;
            cursor: pointer;
            box-shadow: 0 0 8px rgba(30, 100, 255, 0.4);
            transition: all 0.2s;
            z-index: 20;
        }

        .toggle-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 0 12px rgba(100, 180, 255, 0.6);
        }

        .toggle-btn.active {
            background: rgba(30, 50, 100, 0.9);
            box-shadow: 0 0 12px rgba(100, 180, 255, 0.7);
            transform: scale(1.05);
        }

        #info-panels {
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 100%;
            max-width: 98%;
            height: 100%;
            background: rgba(15, 25, 50, 0.95);
            border-radius: 16px;
            padding: 15px;
            box-shadow: 0 0 30px rgba(0, 30, 80, 0.9);
            z-index: 100;  /* or higher, just below ad z-index */
            display: none;
            flex-direction: column;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;  /* add here */
        }

        #info-panels.active {
            display: flex !important;
        }

        .panel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #4a6fa5;
        }

        .panel-title-large {
            font-size: 24px;
            color: #6da4e9;
            text-shadow: 0 0 8px rgba(100, 180, 255, 0.8);
            font-weight: bold;
        }

        .close-panel {
            background: rgba(30, 50, 100, 0.9);
            border: 1px solid #4a6fa5;
            color: #ff8888;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            font-weight: bold;
            font-size: 18px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        #instructions-content,
        #scores-content {
            font-size: 14px;
            line-height: 1.6;
        }

        #instructions-content ul {
            padding-left: 20px;
            margin: 10px 0;
        }

        #instructions-content li {
            margin-bottom: 8px;
        }

        #scores-list {
            margin-top: 15px;
        }

        .score-entry {
            display: flex;
            justify-content: space-between;
            padding: 8px 12px;
            background: rgba(25, 40, 75, 0.7);
            border-radius: 8px;
            margin-bottom: 6px;
            font-size: 14px;
        }

        .score-entry.highlight {
            background: rgba(50, 80, 150, 0.8);
            border-left: 3px solid #ffd700;
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
        }

        #score-input-container {
            margin: 15px 0;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        #player-name {
            padding: 8px 12px;
            border: 2px solid #4a6fa5;
            border-radius: 8px;
            background: rgba(30, 45, 80, 0.9);
            color: #e6e6e6;
            font-size: 16px;
            width: 100%;
            max-width: 300px;
        }

        #save-score-btn {
            background: rgba(30, 80, 30, 0.9);
            border: 1px solid #4a6fa5;
            color: #aaffaa;
            border-radius: 8px;
            padding: 10px 20px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            width: max-content;
            margin: 0 auto;
            transition: all 0.2s;
        }

        #save-score-btn:hover {
            background: rgba(40, 100, 40, 0.9);
            box-shadow: 0 0 12px rgba(100, 255, 100, 0.6);
            transform: scale(1.05);
        }

        #save-score-btn:active {
            transform: scale(0.98);
        }

        #save-score-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .ore-item {
            display: flex;
            align-items: center;
            margin-bottom: 4px;
            white-space: nowrap;
            font-size: 11px;
        }

        .ore-icon-large {
            width: 18px;
            height: 18px;
            border-radius: 50%;
            margin-right: 6px;
            flex-shrink: 0;
            border: 1px solid rgba(255, 255, 255, 0.4);
            position: relative;
            font-size: 9px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(0, 0, 0, 0.7);
            font-weight: bold;
        }

        .iron-large { background: linear-gradient(45deg, #8a7a6b, #a89a8b); }
        .titanium-large { background: linear-gradient(45deg, #7d9abf, #9db4d6); }
        .gold-large { background: linear-gradient(45deg, #d4af37, #e6b422); box-shadow: 0 0 4px #ffd700; }
        .platinum-large { background: linear-gradient(45deg, #e5e4e2, #f0f0f0); box-shadow: 0 0 3px #c0c0c0; }
        .rhodium-large { background: linear-gradient(45deg, #ffffff, #e0e0e0); box-shadow: 0 0 6px #a0d0ff; }

        #ship-container {
            position: absolute;
            bottom: 55px;
            left: 50%;
            transform: translateX(-50%);
            width: 60px;
            height: 40px;
            z-index: 5;
            pointer-events: auto;
            cursor: pointer;
            touch-action: none;
        }

        #ship-container.active {
            transform: translateX(-50%) scale(0.95);
        }

        #ship {
            position: absolute;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            pointer-events: none;
        }

        #ship svg {
            overflow: visible;
            transform-origin: 50% 50%;
            animation: ship-bob 2.8s ease-in-out infinite;
        }

        .engine-flame {
            transform-box: fill-box;
            transform-origin: center top;
            animation: engine-flicker 0.12s ease-in-out infinite alternate;
            filter: drop-shadow(0 0 4px rgba(120, 220, 255, 0.7)) drop-shadow(0 0 8px rgba(80, 160, 255, 0.45));
        }

        .engine-glow {
            animation: engine-glow 0.35s ease-in-out infinite alternate;
        }

        #ship-container.active .engine-flame {
            animation-duration: 0.08s;
            filter: drop-shadow(0 0 6px rgba(140, 235, 255, 0.9)) drop-shadow(0 0 12px rgba(90, 175, 255, 0.55));
        }

        #ship-container.active .engine-glow {
            animation-duration: 0.22s;
        }

        #force-field,
        #gravity-field {
            position: absolute;
            left: 50%;
            top: 35%;
            transform: translate(-50%, -50%);
            border-radius: 50%;
            pointer-events: none;
            transition: width 0.3s ease, height 0.3s ease;
            will-change: transform, width, height;
        }

        #force-field {
            width: 90px;
            height: 90px;
            background: radial-gradient(circle, rgba(70, 150, 255, 0.1) 0%, rgba(30, 60, 120, 0) 70%);
            z-index: 1;
            box-shadow: 0 0 12px rgba(100, 200, 255, 0.4);
            animation: pulse 3s infinite;
        }

        #gravity-field {
            width: 130px;
            height: 130px;
            background: radial-gradient(circle, rgba(100, 200, 255, 0.35) 0%, rgba(30, 80, 150, 0.15) 40%, rgba(10, 30, 60, 0) 70%);
            z-index: 1;
            transition: width 0.3s ease 0.05s, height 0.3s ease 0.05s;
            box-shadow: 0 0 25px rgba(100, 200, 255, 0.6);
            border: 2px solid rgba(100, 200, 255, 0.4);
        }

        #charge-bar {
            position: absolute;
            bottom: 65px;
            left: 50%;
            transform: translateX(-50%);
            width: 100px;
            height: 8px;
            background: rgba(30, 40, 70, 0.8);
            border-radius: 4px;
            overflow: hidden;
            z-index: 10;
        }

        #charge-fill {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, #4a6fa5, #6da4e9, #4a6fa5);
            border-radius: 4px;
            transition: width 0.1s;
            box-shadow: 0 0 6px rgba(100, 180, 255, 0.7);
        }

        .stat-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 3px;
            font-size: 11px;
        }

        .stat-label {
            opacity: 0.75;
        }

        .stat-value {
            font-weight: bold;
            color: #6da4e9;
        }

        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 rgba(100, 200, 255, 0.4); }
            70% { box-shadow: 0 0 0 8px rgba(100, 200, 255, 0); }
            100% { box-shadow: 0 0 0 0 rgba(100, 200, 255, 0); }
        }

        @keyframes ship-bob {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-2px); }
        }

        @keyframes engine-flicker {
            from { transform: translateY(0) scaleX(0.96) scaleY(0.88); opacity: 0.72; }
            to { transform: translateY(0.4px) scaleX(1.03) scaleY(1.05); opacity: 0.95; }
        }

        @keyframes engine-glow {
            from { opacity: 0.35; }
            to { opacity: 0.75; }
        }

        @keyframes gravity-pulse {
            0% {
                box-shadow: 0 0 25px rgba(100, 255, 255, 0.8), 0 0 40px rgba(100, 255, 255, 0.6);
                transform: translate(-50%, -50%) scale(1);
            }
            50% {
                box-shadow: 0 0 35px rgba(100, 255, 255, 1), 0 0 50px rgba(100, 255, 255, 0.8);
                transform: translate(-50%, -50%) scale(1.05);
            }
            100% {
                box-shadow: 0 0 25px rgba(100, 255, 255, 0.8), 0 0 40px rgba(100, 255, 255, 0.6);
                transform: translate(-50%, -50%) scale(1);
            }
        }

        .upgrade-notification {
            position: absolute;
            color: #ffd700;
            font-weight: bold;
            font-size: 16px;
            text-shadow: 0 0 5px rgba(255, 215, 0, 0.8);
            z-index: 30;
            pointer-events: none;
            animation: float-up 1.3s ease-out forwards;
            text-align: center;
            left: 50%;
            transform: translateX(-50%);
            width: 85%;
            background: rgba(40, 20, 20, 0.85);
            border-radius: 25px;
            padding: 5px 0;
            top: 25%;
            letter-spacing: 1px;
            border: 1px solid #ffd700;
            box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
        }

        @keyframes float-up {
            0% { opacity: 1; transform: translateX(-50%) translateY(0); }
            100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
        }

        #level-display {
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            text-align: center;
            font-size: 17px;
            font-weight: bold;
            color: #6da4e9;
            text-shadow: 0 0 6px rgba(100, 180, 255, 0.8);
            z-index: 20;
            background: rgba(20, 30, 60, 0.85);
            padding: 3px 12px;
            border-radius: 18px;
            border: 1px solid #4a6fa5;
            box-shadow: 0 0 8px rgba(30, 100, 255, 0.4);
        }

        #idle-indicator {
            position: absolute;
            bottom: 65px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(40, 80, 40, 0.85);
            color: #aaffaa;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 11px;
            font-weight: bold;
            z-index: 15;
            display: none;
            animation: pulse-idle 2s infinite;
        }

        @keyframes pulse-idle {
            0%, 100% { box-shadow: 0 0 0 0 rgba(100, 255, 100, 0.4); }
            50% { box-shadow: 0 0 0 5px rgba(100, 255, 100, 0); }
        }

        #manual-fire-prompt {
            position: absolute;
            bottom: 65px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(80, 40, 20, 0.85);
            color: #ffccaa;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 11px;
            font-weight: bold;
            z-index: 15;
            animation: pulse-prompt 2s infinite;
        }

        @keyframes pulse-prompt {
            0%, 100% { box-shadow: 0 0 0 0 rgba(255, 150, 100, 0.4); }
            50% { box-shadow: 0 0 0 5px rgba(255, 150, 100, 0); }
        }

        #aim-assist {
            position: absolute;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            border: 2px solid rgba(100, 200, 255, 0.7);
            pointer-events: none;
            z-index: 8;
            transform: translate(-50%, -50%);
            display: none;
            box-shadow: 0 0 8px rgba(100, 200, 255, 0.5);
        }

        #turret-barrel {
            transform-origin: 30px 14px;
            transition: transform 0.08s ease-out;
        }

        .gravity-pulse {
            animation: gravity-pulse 0.8s ease-out;
        }

        @media (max-width: 480px) {
            body {
                padding-top: 50px;
                padding-left: 5px;
                padding-right: 5px;
                padding-bottom: 5px;
            }
            
            #game-container {
                height: 88vh;
                max-height: 650px;
                border-radius: 12px;
            }

            #weapon-panel {
                top: 8px;
                right: 8px;
                width: 170px;
                padding: 8px;
                font-size: 11px;
            }

            .panel-title {
                font-size: 14px;
                margin-bottom: 6px;
            }

            .weapon-name {
                font-size: 13px;
            }

            #ui-container {
                bottom: 8px;
                padding: 0 8px;
                flex-direction: row;
                align-items: flex-end;
                gap: 8px;
            }

            #resources {
                max-width: 48%;
                margin-right: 0;
                width: 48%;
                padding: 5px 7px;
                font-size: 10px;
            }

            #ship-stats {
                min-width: 48%;
                width: 48%;
                padding: 5px 7px;
                font-size: 10px;
            }

            .stat-row {
                font-size: 10px;
            }

            #level-display {
                top: 8px;
                font-size: 15px;
                padding: 2px 10px;
            }

            #charge-bar {
                bottom: 58px;
                width: 90px;
                height: 7px;
            }

            #idle-indicator,
            #manual-fire-prompt {
                bottom: 58px;
                font-size: 10px;
                padding: 1px 6px;
            }

            #toggle-buttons {
                top: 8px;
                left: 8px;
                gap: 6px;
            }

            .toggle-btn {
                width: 32px;
                height: 32px;
                font-size: 14px;
            }

            .close-panel {
                width: 32px;
                height: 32px;
                font-size: 16px;
            }

            #info-panels {
                padding: 15px;
            }

            .panel-title-large {
                font-size: 20px;
            }

            #player-name {
                font-size: 14px;
                padding: 6px 10px;
            }

            #save-score-btn {
                font-size: 14px;
                padding: 8px 16px;
            }
        }
    </style>