@import url('./fonts.css');

/* General Reset */
:root {
    --ui-scale: 1;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    opacity: 1;
    transition: opacity 360ms ease, visibility 360ms ease;
}

.app-loader__bg {
    position: absolute;
    inset: 0;
    background: #000;
}

.app-loader__panel {
    position: relative;
    z-index: 1;
    width: min(84vw, 360px);
    padding: 28px 24px;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(0, 225, 255, 0.38);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5), 0 0 24px rgba(0, 225, 255, 0.22);
    backdrop-filter: blur(8px);
}

.app-loader__ring-wrap {
    position: relative;
    width: 132px;
    height: 132px;
    margin: 0 auto;
}

.app-loader__ring {
    width: 132px;
    height: 132px;
    transform: rotate(-90deg);
}

.app-loader__ring-track {
    fill: none;
    stroke: rgba(168, 238, 255, 0.18);
    stroke-width: 9;
}

.app-loader__ring-progress {
    fill: none;
    stroke: #00e6ff;
    stroke-linecap: round;
    stroke-width: 9;
    stroke-dasharray: 302;
    stroke-dashoffset: 302;
    transition: stroke-dashoffset 180ms ease;
    filter: drop-shadow(0 0 8px rgba(0, 230, 255, 0.6));
}

.app-loader__percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dbfbff;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-shadow: 0 0 10px rgba(0, 230, 255, 0.42);
}

.app-loader__status {
    margin-top: 16px;
    text-align: center;
    color: #a6d8e7;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    min-height: 1.4em;
}

body.app-loading #introScreen {
    visibility: hidden;
}

body.app-loading #gameCanvas {
    opacity: 0;
}

body:not(.app-loading) .app-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body:not(.app-loading) #gameCanvas {
    opacity: 1;
}

body {
    margin: 0;
    padding: 0;
    background-color: #000;
    background-size: cover;
    background-image: url('../assets/images/backgrounds/desktop/menu.jpg');

    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    overflow: visible;
    font-family: 'Arial', sans-serif;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: rgba(10, 12, 18, 0.92);
    color: #f8f9fa;
    padding: 12px 16px;
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    letter-spacing: 0.3px;
    border: 1px solid rgba(0, 210, 255, 0.35);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(8px) scale(var(--ui-scale));
    transform-origin: bottom right;
    transition: opacity 160ms ease, transform 160ms ease;
    pointer-events: none;
    z-index: 9999;
}

.toast.toast--show {
    opacity: 1;
    transform: translateY(0) scale(var(--ui-scale));
}

.toast.toast--success {
    border-color: rgba(46, 204, 113, 0.6);
    box-shadow: 0 10px 25px rgba(46, 204, 113, 0.2);
}

.toast.toast--error {
    border-color: rgba(231, 76, 60, 0.7);
    box-shadow: 0 10px 25px rgba(231, 76, 60, 0.25);
}

/* Game Container */
.game-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

/* Canvas Styling */
#gameCanvas {
    /* Border removed to fix click coordinate issues */
    /* border: 2px solid #00FFFF; */
    border-radius: 0;
    box-shadow: none;
    border: none;
    outline: none;
    background-color: #000;
    overflow: visible;
    /* image-rendering: pixelated; */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#gameCanvas.hide-cursor {
    cursor: none;
}

#gameCanvas:focus,
#gameCanvas:focus-visible {
    outline: none;
}

/* Menu Styling */
/* Menu Styling - Adapted for Intro Frame */
#menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: calc(10px * var(--menu-scale, 1));
    /* Align to top */
    background: transparent;
    border: none;
    box-shadow: none;
    --menu-scale: clamp(0.75, var(--ui-scale), 1);
    padding: calc(20px * var(--menu-scale, 1));
    margin: 0 auto;
    box-sizing: border-box;
    max-height: 100%;
    overflow: visible;
    min-height: 0;
    z-index: 10;
    /* Above image */
    font-family: 'Orbitron', 'Arial', sans-serif;
}

#menu {
    --menu-content-max-width: 1024px;
    --menu-panel-width: min(95%, var(--menu-content-max-width));
    --menu-panel-margin-top: 10px;
}

/* Horizontal Menu Container */
.menu-buttons {
    display: flex;
    flex-wrap: wrap;
    /* allow wrapping on small screens */
    justify-content: center;
    flex: 0 0 auto;
    gap: calc(15px * var(--menu-scale, 1));
    width: 100%;
    margin-top: calc(20px * var(--menu-scale, 1));
    /* Space from top edge */
}

#menu h1 {
    color: #00FFFF;
    font-size: calc(3rem * var(--menu-scale, 1));
    text-shadow: 0 0 10px #00FFFF, 0 0 20px #FF00FF;
    margin-bottom: calc(30px * var(--menu-scale, 1));
}

/* Neon Button Styling */
.neon-button {
    width: auto;
    min-width: calc(140px * var(--menu-scale, 1));
    background: rgba(0, 0, 0, 0.7);
    /* 50% transparent black */
    border: calc(2px * var(--menu-scale, 1)) solid #00FFFF;
    color: #00FFFF;
    padding: calc(8px * var(--menu-scale, 1)) calc(16px * var(--menu-scale, 1));
    margin: 0;
    font-family: 'Orbitron', 'Arial', sans-serif;
    /* Let flex handle gaps */
    font-size: calc(1rem * var(--menu-scale, 1));
    cursor: pointer;
    border-radius: 5px;
    text-shadow: 0 0 5px #00FFFF;
    box-shadow: 0 0 10px #00FFFF;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    /* Allow horizontal */
    text-align: center;
}

.settings-panel,
.scores-panel,
.instructions-panel,
#saveLoadPanel,
#about {
    font-family: 'Arial', sans-serif;
}

.neon-button:hover {
    background: #00FFFF;
    color: #000;
    box-shadow: 0 0 15px #00FFFF, 0 0 25px #FF00FF;
    text-shadow: none;
}

/* Return Button */
.return-button {
    width: calc(150px * var(--menu-scale, 1));
    background: none;
    border: calc(2px * var(--menu-scale, 1)) solid #FF00FF;
    color: #FF00FF;
    padding: calc(10px * var(--menu-scale, 1)) calc(20px * var(--menu-scale, 1));
    margin: 10px auto;
    font-size: calc(1.2rem * var(--menu-scale, 1));
    cursor: pointer;
    border-radius: 5px;
    text-shadow: 0 0 5px #FF00FF;
    box-shadow: 0 0 5px #FF00FF;
    transition: all 0.3s ease;
    display: block;
}

.return-button:hover {
    background: #FF00FF;
    color: #000;
    box-shadow: 0 0 15px #FF00FF;
}

/* Submenu Back Buttons */
#backFromInstructions,
#backFromSettings,
#backFromScores,
#backFromSaveLoad,
#backFromAbout {
    margin-top: 40px;
    width: 100%;
    /* Match width of other buttons in list if preferred, or keep auto/fixed */
}

/* Instructions, Settings, and Scores Panels */
#instructions,
#settings,
#scores,
#saveLoadPanel,
#about {
    background: rgba(0, 0, 0, 0.9);
    padding: calc(20px * var(--menu-scale, 1));
    border-radius: calc(10px * var(--menu-scale, 1));
    border: calc(1px * var(--menu-scale, 1)) solid #00FFFF;
    /* Optional border for style */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);

    width: var(--menu-panel-width);
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    align-self: center;
    max-width: var(--menu-content-max-width);
    max-height: none;
    height: auto;
    overflow-y: auto;
    /* Scroll inside this element */
    color: #FFF;
    text-align: left;
    position: relative;
    flex: 1 1 0;
    min-height: 140px;
    font-size: calc(1rem * var(--menu-scale, 1));
    /* Custom Scrollbar for these panels */
    scrollbar-width: thin;
    scrollbar-color: #00FFFF rgba(0, 0, 0, 0.5);
    margin-top: var(--menu-panel-margin-top);
}

@media (min-width: 1025px) {

    #menu>h1,
    #menu>.menu-buttons,
    #menu>#instructions,
    #menu>#settings,
    #menu>#scores,
    #menu>#saveLoadPanel,
    #menu>#about {
        width: 100%;
        max-width: var(--menu-content-max-width);
        margin-left: auto;
        margin-right: auto;
    }

    #menu>#instructions,
    #menu>#settings,
    #menu>#scores,
    #menu>#saveLoadPanel,
    #menu>#about {
        align-self: center;
    }
}

/* Webkit Scrollbar Styling */
#instructions::-webkit-scrollbar,
#settings::-webkit-scrollbar,
#scores::-webkit-scrollbar,
#saveLoadPanel::-webkit-scrollbar,
#about::-webkit-scrollbar {
    width: 10px;
}

#instructions::-webkit-scrollbar-track,
#settings::-webkit-scrollbar-track,
#scores::-webkit-scrollbar-track,
#saveLoadPanel::-webkit-scrollbar-track,
#about::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
}

#instructions::-webkit-scrollbar-thumb,
#settings::-webkit-scrollbar-thumb,
#scores::-webkit-scrollbar-thumb,
#saveLoadPanel::-webkit-scrollbar-thumb,
#about::-webkit-scrollbar-thumb {
    background: #00FFFF;
    border-radius: 5px;
    border: 1px solid #FF00FF;
    box-shadow: 0 0 5px #00FFFF;
}

#instructions::-webkit-scrollbar-thumb:hover,
#settings::-webkit-scrollbar-thumb:hover,
#scores::-webkit-scrollbar-thumb:hover,
#saveLoadPanel::-webkit-scrollbar-thumb:hover,
#about::-webkit-scrollbar-thumb:hover {
    background: #FF00FF;
    border-color: #00FFFF;
}


.instructions-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.instructions-text,
.instructions-legend {
    display: flex;
    flex-direction: column;
}

.instructions-text .instruction-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.instructions-text .instruction-item p {
    margin: 0;
}

.instructions-text .instruction-item .instruction-brick {
    flex-shrink: 0;
}

#instructions h2,
#settings h2,
#scores h2,
#saveLoadPanel h2,
#about h2 {
    color: #00FFFF;
    text-shadow: 0 0 10px #00FFFF;
    margin-bottom: 20px;
    text-align: center;
    animation: none;
}

#about p {
    color: #FFF;
    text-shadow: 0 0 5px #00FFFF;
    line-height: 1.8;
    margin-bottom: 15px;
}

@keyframes pulse-glow {
    0% {
        text-shadow: 0 0 10px #00FFFF, 0 0 20px #00FFFF;
    }

    100% {
        text-shadow: 0 0 20px #00FFFF, 0 0 30px #00FFFF, 0 0 40px #00FFFF;
    }
}

#scores h2,
#saveLoadPanel h2 {
    text-align: center;
    margin: 0 1px 40px 1px;
    /* Increased bottom margin */
}

/* Instruction Items */
.instruction-item p {
    margin: 15px 0;
    font-size: 0.9rem;
    color: #FFF;
    line-height: 1.8;
}

/* Legend Layout */
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.legend-item canvas,
.legend-item img {
    display: block;
    margin-right: 15px;
    width: 60px !important;
    height: 30px !important;
    flex-shrink: 0;
}

.brick-canvas {
    width: 60px;
    height: 30px;
}

/* Settings Content */
#settingsContent {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Settings Rows */
.setting-row {
    display: flex;
    align-items: center;
    margin: 15px 0;
    width: 100%;
    justify-content: space-between;
}

.setting-row label {
    color: #00FFFF;
    font-size: 1.1rem;
    text-shadow: 0 0 5px #00FFFF;
}

.setting-row select,
.setting-row input[type="range"] {
    background: #222;
    border: 1px solid #00FFFF;
    color: #FFF;
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 0 5px #00FFFF;
}

/* Volume Slider Group */
.volume-sound-group {
    display: flex;
    align-items: center;
}

/* Scores List */
#scores {
    text-align: center;
}

#scoreList {
    display: inline-block;
    /* Allow centering while maintaining left alignment inside */
    text-align: left;
    /* Left align the list items */
    list-style: none;
    padding: 20px 30px;
    margin: 20px auto;
    border: 2px solid #00FFFF;
    /* White border */
    border-radius: 15px;
    /* Rounded corners */
    background: rgba(0, 0, 0, 0.3);
    /* Subtle background */
    box-shadow: 0 0 15px #00FFFF, 0 0 25px rgba(0, 255, 255, 0.5);
    /* Subtle glow */
}

#resetScoresButton {
    display: block;
    margin: 20px auto;
}

#scoreList p {
    margin: 10px 0;
    font-size: 1.1rem;
    color: #FFF;
    text-shadow: 0 0 5px #00FFFF;
}

/* Save Slots */
.save-slots {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    gap: 15px;
}

.save-slot {
    flex: 1;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #00FFFF;
    border-radius: 5px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.save-slot .slot-info {
    display: block;
    text-align: center;
}

.save-slot:hover {
    background: rgba(0, 255, 255, 0.2);
}

.save-slot.empty {
    color: #777;
}

.save-slot h4 {
    margin: 0 0 10px 0;
    color: #00FFFF;
}

.save-slot p {
    margin: 5px 0;
    font-size: 14px;
}

.save-slot button {
    width: 100%;
    margin-top: 10px;
}

.erase-btn {
    background: none;
    border: 2px solid #FF0000;
    color: #FF0000;
    padding: 8px 15px;
    margin-top: 5px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 5px;
    text-shadow: 0 0 5px #FF0000;
    box-shadow: 0 0 5px #FF0000;
    transition: all 0.3s ease;
    width: 100%;
    display: none;
}

.erase-btn:hover {
    background: #FF0000;
    color: #000;
    box-shadow: 0 0 10px #FF0000;
    text-shadow: none;
}

/* Game Over Screen */
#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--ui-scale));
    transform-origin: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 30px;
    border-radius: 15px;
    border: 3px solid #00FFFF;
    box-shadow: 0 0 20px #00FFFF, 0 0 30px #FF00FF;
    width: 80%;
    max-width: 800px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#gameOver h2 {
    font-size: 3rem;
    background: linear-gradient(to bottom, #FF8800, #AA4400);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px #FF4400);
    margin-bottom: 20px;
    animation: pulse-glow 2s infinite alternate;
}

#gameOver h3 {
    color: #FF00FF;
    font-size: 1.8rem;
    text-shadow: 0 0 5px #FF00FF;
    margin-bottom: 20px;
}

#gameOverScores {
    margin-bottom: 30px;
    display: inline-block;
    /* Shrink to fit content */
    text-align: left;
    /* Align text inside to the left */
}

#gameOverScores p {
    color: #FFF;
    font-size: 1.2rem;
    text-shadow: 0 0 5px #00FFFF;
    margin: 10px 0;
}

#highScoreInput {
    margin-bottom: 30px;
}

#highScoreInput p {
    color: #FFF;
    font-size: 1.1rem;
    text-shadow: 0 0 5px #00FFFF;
    margin-bottom: 15px;
}

#playerNameInput {
    background: #222;
    border: 2px solid #00FFFF;
    color: #FFF;
    padding: 8px;
    font-size: 1rem;
    border-radius: 5px;
    box-shadow: 0 0 10px #00FFFF;
    margin-right: 10px;
}

#submitNameButton.neon-button {
    width: 200px;
    background: none;
    border: 2px solid #FF00FF;
    color: #FF00FF;
    text-shadow: 0 0 5px #FF00FF;
    box-shadow: 0 0 10px #FF00FF;
}

/* Combo Indicator */
.combo-indicator {
    display: none !important;
    /* Hidden per user request */
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale));
    transform-origin: top center;
    color: #FFFF00;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px #FFFF00;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* Power-up Notification */
.power-up-notification {

    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale));
    transform-origin: top center;
    color: #00FFFF;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 10px #00FFFF;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 20px;
}

.tutorial-content {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00FFFF;
    border-radius: 10px;
    padding: 20px;
    max-width: 500px;
    text-align: center;
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

.tutorial-content h3 {
    color: #00FFFF;
    margin-bottom: 15px;
}

.tutorial-content p {
    color: #FFF;
    margin-bottom: 20px;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

.button-group .neon-button {
    margin: 0;
    display: inline-block;
    width: auto;
    /* Allow dynamic width or keep fixed if preferred, but auto helps with inline */
    min-width: 150px;
}

/* Intermediate breakpoint for instructions to stack earlier */
@media (max-width: 1024px) {
    .instructions-layout {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    #instructions {
        width: 95%;
        max-height: 100%;
    }

    /* Landscape warning removed to allow landscape play */

    .instruction-item p,
    .brick-instruction p {
        font-size: 0.9rem;
        /* Slightly larger than mobile but smaller than desktop default if needed */
    }
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    body {
        background-image: none !important;
        background-color: #000;
        align-items: center;
        padding-top: 0;
    }
}

/* Landscape Warning Overlay - Globally Hidden by Default */
#landscapeWarning {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    transform: scale(var(--ui-scale));
    transform-origin: center;
    background: #000;
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #00FFFF;
}

#landscapeWarning p {
    font-size: 2rem;
    margin-top: 20px;
}

#landscapeWarning svg {
    width: 100px;
    height: 100px;
    fill: #00FFFF;
    animation: rotate-phone 2s infinite ease-in-out;
}

@keyframes rotate-phone {

    0%,
    100% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(-90deg);
    }
}





/* Mobile-specific styles override */
@media (max-width: 768px) {

    #introMenuButton {
        display: inline-flex;
    }

    #menu {
        max-width: 95%;
        /* Override the desktop 700px min-width */
        width: 95%;
        padding: calc(20px * var(--menu-scale, 1));
        min-width: 0;
    }

    #menu h1 {
        font-size: calc(2.2rem * var(--menu-scale, 1));
    }

    .neon-button {
        width: 80%;
        max-width: 300px;
        padding: calc(8px * var(--menu-scale, 1)) calc(12px * var(--menu-scale, 1));
        font-size: calc(0.9rem * var(--menu-scale, 1));
        margin: 1px auto;
    }

    #instructions,
    #settings,
    #scores,
    #saveLoadPanel,
    #about {
        width: var(--menu-panel-width);
        max-width: var(--menu-content-max-width);
        margin-left: auto;
        margin-right: auto;
        margin-top: var(--menu-panel-margin-top);
        padding: calc(15px * var(--menu-scale, 1));
        max-height: 80vh;
    }

    #settings .settings-content {
        gap: 12px !important;
    }

    #settings .setting-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }

    #settings .setting-item label {
        font-size: calc(0.85rem * var(--menu-scale, 1)) !important;
    }

    #settings select,
    #settings input[type="range"],
    #settings input[type="checkbox"] {
        font-size: calc(0.85rem * var(--menu-scale, 1)) !important;
    }

    #settings select {
        width: 100% !important;
        max-width: 100% !important;
    }

    #settings .slider-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 4px !important;
    }

    #settings input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
    }

    .instructions-layout {
        gap: 15px;
    }

    /* Compact text for mobile instructions */
    #instructions p,
    .brick-instruction p {
        font-size: calc(0.95rem * var(--menu-scale, 1));
        margin: 5px 0;
        line-height: 1.4;
    }

    /* Stack settings rows on mobile */
    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin: 4px 0;
    }

    .setting-row label {
        margin-bottom: 4px;
        font-size: calc(0.65rem * var(--menu-scale, 1));
    }

    .setting-row select,
    .setting-row input[type="range"] {
        width: 100%;
        max-width: 100%;
        height: 24px;
        padding: 2px;
        font-size: calc(0.65rem * var(--menu-scale, 1));
    }

    .brick-instruction {
        margin: 0;
    }

    #instructions h2,
    #settings h2,
    #scores h2,
    #saveLoadPanel h2,
    #about h2 {
        font-size: calc(1.4rem * var(--menu-scale, 1));
        margin-bottom: 16px;
    }

    .instruction-item p {
        font-size: calc(0.95rem * var(--menu-scale, 1));
    }

    #scoreList {
        padding: 12px 14px;
        margin: 12px auto;
        border-width: 1px;
        box-shadow: 0 0 10px #00FFFF, 0 0 16px rgba(0, 255, 255, 0.35);
    }

    #scoreList p {
        margin: 6px 0;
        font-size: calc(0.9rem * var(--menu-scale, 1));
    }

    #gameOver {
        width: 90%;
        padding: 30px;
    }

    #gameOver h2 {
        font-size: 2.5rem;
        /* Reduced from 3rem */
    }

    #gameOver h3 {
        font-size: 2rem;
    }

    #gameOverScores p {
        font-size: 1.3rem;
    }

    #playerNameInput {
        width: 90%;
        margin-bottom: 20px;
        font-size: 1.1rem;
        /* Reduced from 1.3rem */
        padding: 10px;
    }

    #submitNameButton {
        width: 150px;
        padding: 12px;
        font-size: 1.1rem;
        /* Reduced from 1.3rem */
    }

    /* Save slots mobile */
    .save-slots {
        flex-direction: column;
        gap: 15px;
    }

    .save-slot {
        padding: 20px;
    }

    .slot-actions {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .slot-actions .neon-button {
        width: 80%;
        max-width: 240px;
    }
}

/* New styles for enhanced features */
.particle {
    position: absolute;
    pointer-events: none;
    opacity: 1;
    border-radius: 50%;
}

/* Level Transition Overlay */
#levelTransition {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--ui-scale));
    transform-origin: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.85), rgba(10, 10, 20, 0.85));
    padding: 36px 44px;
    border-radius: 0;
    border: 2px solid #00FFFF;
    box-shadow: 0 0 25px #00FFFF, 0 0 45px #FF00FF;
    text-align: center;
    z-index: 100;
    min-width: 400px;
    /* Wider to accommodate text */

    /* Enforce column layout for strict separation */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.level-transition-title {
    color: #00FFFF;
    font-size: 3rem;
    letter-spacing: 3px;
    text-shadow: 0 0 12px #00FFFF, 0 0 28px #FF00FF;
    margin: 0;
    line-height: 1.05;
    font-family: 'Orbitron', sans-serif;
}

.level-transition-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.level-transition-content p {
    color: #FFF;
    font-size: 1.5rem;
    margin: 0;
    text-shadow: 0 0 5px #FFF;
}

.press-key {
    font-size: 1.15rem;
    letter-spacing: 0.5px;
}

.level-transition-highlight {
    color: #FFFF00;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 0, 0.6);
    background: rgba(255, 255, 0, 0.08);
    letter-spacing: 0.5px;
}

.level-transition-next {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.boss-defeated-title {
    font-size: 3.2rem;
    letter-spacing: 2.5px;
    line-height: 1.05;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    background: linear-gradient(180deg, #ff2a2a 0%, #ff7a00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.85);
    text-shadow: 0 0 10px rgba(255, 80, 0, 0.8), 0 0 24px rgba(255, 0, 0, 0.6);
}

.boss-defeated-title .boss-defeated-lives {
    display: block;
    font-size: 0.55em;
    letter-spacing: 1px;
    margin-top: 14px;
    margin-bottom: 4px;
    background: linear-gradient(180deg, #fff2a6 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.7);
    text-shadow: 0 0 8px rgba(255, 220, 0, 0.7), 0 0 16px rgba(255, 140, 0, 0.5);
}

/* Pause Menu Overlay */
#pauseMenu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--ui-scale));
    transform-origin: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 30px;
    border-radius: 15px;
    border: 3px solid #FF00FF;
    box-shadow: 0 0 20px #FF00FF, 0 0 30px #00FFFF;
    text-align: center;
    z-index: 100;
    min-width: 300px;
}

#pauseMenu h2 {
    color: #FF00FF;
    font-size: 3rem;
    text-shadow: 0 0 10px #FF00FF;
    margin-bottom: 30px;
}

.pause-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#pauseSettings {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #555;
    text-align: left;
}

#pauseSettings h3 {
    color: #00FFFF;
    text-align: center;
    margin-bottom: 15px;
}

/* Game Stats in Game Over */
/* Game Stats in Game Over */
.game-stats {
    display: flex;
    justify-content: space-between;
    /* Space out evenly */
    gap: 5px;
    /* Small gap */
    margin-bottom: 25px;
    width: 100%;
}

.stat-item {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid #00FFFF;
    border-radius: 8px;
    padding: 5px;
    /* Reduced padding */
    text-align: center;
    flex: 1;
    /* Equal width */
    min-width: 0;
    /* Allow shrinking */
}

.stat-item p {
    margin: 0 0 2px 0;
    font-size: 0.7rem;
    /* Smaller text */
    color: #CCC;
    white-space: nowrap;
    /* Prevent wrapping if possible */
    overflow: visible;
    text-overflow: ellipsis;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #FF00FF;
}

/* Game Over stats should stay plain (no glow). */
#gameOver #gameStats,
#gameOver #gameStats .stat-item,
#gameOver #gameStats .stat-item p,
#gameOver #gameStats .stat-value {
    text-shadow: none !important;
    filter: none !important;
    animation: none !important;
}

#gameOver #gameStats .stat-value {
    color: #FF00FF !important;
    -webkit-text-stroke: 0 transparent;
    text-shadow:
        0 0 5px #FF00FF !important;
}

/* Force buttons to be in one row on mobile and desktop */
.button-group {
    display: flex;
    /* Ensure flex is active */
    flex-direction: row;
    /* Force row direction */
    flex-wrap: nowrap !important;
    gap: 15px !important;
    justify-content: center;
    width: 100%;
}

.button-group button {
    flex: 1;
    /* Make buttons share space equally */
    min-width: 0 !important;
    /* Override the min-width */
    font-size: 1rem !important;
    padding: 10px 5px !important;
    /* Reduce side padding to fit text if needed */
    margin: 0 !important;
    /* Remove individual margins */
}

/* Hide canvas border and glow when in menu/game over */
#gameCanvas.menu-active {
    border: none !important;
    box-shadow: none !important;
}



/* Level Start Icon (HTML Overlay Version) */
.level-start-icon {
    min-width: 120px;
    padding: 15px 40px;
    border: 3px solid #00FFFF;
    border-radius: 30px;
    background: rgba(0, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
    cursor: pointer;
    position: relative;
    box-shadow: 0 0 15px #00FFFF;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    text-shadow: 0 0 10px #00FFFF;
    letter-spacing: 2px;
}

.level-start-icon:hover {
    transform: scale(1.05);
    background: rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 25px #00FFFF, inset 0 0 10px rgba(0, 255, 255, 0.5);
}

.level-start-icon:active {
    transform: scale(0.95);
}

/* Pulsing ring effect */
.level-start-icon::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 1px solid rgba(0, 255, 255, 0.5);
    border-radius: 35px;
    animation: icon-pulse 2s infinite;
}

@keyframes icon-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

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

/* Mobile Adjustments for Level Transition */
@media (max-width: 768px) {
    #levelContinuePrompt {
        display: none !important;
        /* Hide text on mobile */
    }

    .level-start-icon {
        margin-top: 30px;
        /* Ensure it's large enough for touch */
        padding: 20px 50px;
        font-size: 28px;
    }
}

/* Hide HTML Level Text to favor Canvas Rendering - EXCEPTION: We want to show "Level Complete" via HTML now */
#levelTransition h2 {
    opacity: 1 !important;
    pointer-events: auto;
}

#levelTransition p:not(#levelContinuePrompt) {
    opacity: 0 !important;
    pointer-events: none;
}

/* Modern Shiny Text Effect - Red-Yellow Arcade Style */
/* Modern Shiny Text Effect - Life Lost Style */
.level-complete-text {
    font-family: 'Orbitron', sans-serif;
    color: #FF8800;
    text-transform: uppercase;
    text-align: center;
    background: linear-gradient(to bottom,
            #FF8800 0%,
            #AA4400 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 2px #FFF, 0 0 40px #FF4400;
    font-weight: 900;
    letter-spacing: 2px;
    animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {

    0%,
    100% {
        text-shadow: 0 0 2px #FFF, 0 0 30px #FF4400;
        transform: scale(1);
    }

    50% {
        text-shadow: 0 0 4px #FFF, 0 0 50px #FF4400;
        transform: scale(1.05);
    }
}

@keyframes shine {
    0% {
        background-position: 0;
    }

    60% {
        background-position: 180px;
    }

    100% {
        background-position: 180px;
        /* Stay shiny/static or loop */
    }
}

/* ============================================
   MOBILE CONTROLS - SIMPLIFIED
   ============================================ */

.mobile-controls {
    position: fixed;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Hide mobile controls until orientation class is present */
.mobile-controls:not(.portrait):not(.landscape) {
    display: none !important;
}

/* Portrait mode */
.mobile-controls.portrait {
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6));
    border-top: 2px solid rgba(0, 255, 255, 0.3);
    padding: 8px 20px;
}

/* Landscape mode */
.mobile-controls.landscape {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to right, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6));
    border-right: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 0 20px 20px 0;
    padding: 15px 10px;
    flex-direction: column;
}

/* Tablet adjustments */
@media (min-width: 768px) {
    .mobile-controls.portrait {
        padding: 10px 40px;
    }

    .mobile-controls.landscape {
        padding: 20px 10px;
    }
}

/* ============================================
   PADDLE SLIDER
   ============================================ */

.paddle-slider {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    touch-action: none;
    overflow: visible;
}

.paddle-slider.portrait {
    width: 100%;
    max-width: 400px;
    height: 40px;
}

.paddle-slider.landscape {
    width: 40px;
    height: 150px;
}

/* Tablet adjustments */
@media (min-width: 768px) {
    .paddle-slider.portrait {
        height: 50px;
    }

    .paddle-slider.landscape {
        width: 50px;
        height: 200px;
    }
}

/* ============================================
   PADDLE THUMB
   ============================================ */

.paddle-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 30% 30%, #ffffff, #cccccc);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 10px rgba(0, 255, 255, 0.5);
    border: 3px solid rgba(0, 255, 255, 0.8);
    pointer-events: none;
    transition: transform 0.1s ease;
    opacity: 0;
    visibility: hidden;
}

/* Show thumb only after orientation class is applied */
.paddle-slider.portrait .paddle-thumb,
.paddle-slider.landscape .paddle-thumb {
    opacity: 1;
    visibility: visible;
}

/* Hard guard for initial render race conditions */
#paddleThumb {
    display: none;
}

#mobileControls.portrait #paddleSlider.portrait #paddleThumb,
#mobileControls.landscape #paddleSlider.landscape #paddleThumb {
    display: block;
}

/* Tablet adjustments */
@media (min-width: 768px) {
    .paddle-thumb {
        width: 50px;
        height: 50px;
    }

    .landscape .paddle-thumb {
        width: 45px;
        height: 45px;
    }
}

/* Active state */
.paddle-slider:active .paddle-thumb {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 255, 255, 0.8);
}

/* ============================================
   DOUBLE TAP HINT
   ============================================ */

.double-tap-hint {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(0, 255, 255, 0.8);
    font-size: 12px;
    font-family: 'Orbitron', sans-serif;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    opacity: 1;
    transition: opacity 1s ease;
}

.double-tap-hint.hidden {
    opacity: 0;
}

/* ============================================
   HIDE ON DESKTOP
   ============================================ */

@media (min-width: 1025px) {
    .mobile-controls {
        display: none !important;
    }
}

/* Intro Screen */
.intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.intro-frame {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    /* Margin 10px from all sides effect: Max size is screen - 20px */
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border: 5px solid white;
    border-radius: 0;
    overflow: visible;
    /* Clip image to rounded corners */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    /* Behind image */
}

.intro-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 30px);
    /* 100vh - 20px (margin) - 10px (border) */
    object-fit: contain;
}

@media (min-width: 1025px) {
    .intro-frame {
        width: auto;
        height: auto;
        max-width: 1024px;
        max-height: 720px;
        padding: 16px;
    }

    .intro-image {
        max-width: 100%;
        max-height: 100%;
    }
}

.intro-buttons {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center;
    display: flex;
    flex-direction: column;
    gap: calc(20px * var(--ui-scale, 1));
    align-items: center;
}

.intro-buttons button {
    width: calc(200px * var(--ui-scale, 1));
    font-size: calc(1.5rem * var(--ui-scale, 1));
    background-color: rgba(0, 0, 0, 0.7);
    /* 70% transparent */
    box-shadow: 0 0 10px #000;
}

/* Game Complete Screen */
#gameComplete {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
}

#gameComplete .complete-frame {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 3px solid #00FFFF;
    padding: 40px;
    border-radius: 20px;
    transform: scale(var(--ui-scale));
    transform-origin: center;
    text-align: center;
    box-shadow: 0 0 30px #00FFFF, 0 0 50px #FF00FF;
    max-width: 600px;
    width: 90%;
}

#completeHighScoreInput,
#completeScoresContainer {
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #00FFFF;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

#completeScoresList {
    text-align: left;
    margin-top: 10px;
}

#completeScoresList p {
    margin: 5px 0;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px hide-cursor rgba(0, 255, 255, 0.2);
}

#completePlayerNameInput {
    background: #000;
    border: 2px solid #00FFFF;
    color: #00FFFF;
    font-family: 'Orbitron', sans-serif;
    padding: 10px;
    font-size: 1.2rem;
    text-align: center;
    width: 150px;
    border-radius: 5px;
    margin-right: 10px;
    text-transform: uppercase;
}

#completePlayerNameInput:focus {
    outline: none;
    box-shadow: 0 0 10px #00FFFF;
}

#gameComplete h2 {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #00FFFF;
    text-transform: uppercase;
}

#gameComplete .complete-content p {
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #00FFFF;
}

#gameComplete .complete-stats {
    margin: 30px 0;
    padding: 20px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
}

#gameComplete .complete-stats p {
    font-size: 1.2rem;
    margin: 5px 0;
}

#gameComplete .stat-value {
    color: #FFFF00;
    font-weight: bold;
    font-size: 1.4rem;
}



#gameComplete .button-group {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

#gameComplete .neon-button {
    min-width: 180px;
}

#demoComplete {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
}

#demoComplete .complete-frame {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 3px solid #00FFFF;
    padding: 40px;
    border-radius: 20px;
    transform: scale(var(--ui-scale));
    transform-origin: center;
    text-align: center;
    box-shadow: 0 0 30px #00FFFF, 0 0 50px #FF00FF;
    max-width: 700px;
    width: 90%;
}

#demoComplete h2 {
    font-size: 2.4rem;
    margin-bottom: 16px;
    color: #00FFFF;
}

#demoComplete .demo-subheadline {
    font-size: 1.3rem;
    margin-bottom: 16px;
    text-shadow: 0 0 10px #00FFFF;
}

#demoComplete .demo-body {
    font-size: 1.05rem;
    line-height: 1.5;
    margin-bottom: 24px;
    text-shadow: none;
}

#demoComplete .button-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

#demoComplete .neon-button {
    min-width: 220px;
}

#demoUnlockButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

/* Controls Hint */
.controls-hint {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale));
    transform-origin: bottom center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    text-shadow: 0 0 5px #000;
    pointer-events: none;
    z-index: 20;
    /* Above intro screen elements if needed, but intro is z-index 10 or auto */
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: opacity 1s ease-out;
    white-space: nowrap;
}

.controls-hint span {
    color: #00FFFF;
    font-weight: bold;
}

.life-lost-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: calc(12px * var(--ui-scale, 1));
    pointer-events: none;
    z-index: 60;
    text-align: center;
}

.life-lost-overlay__title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(40px, calc(8vw * var(--ui-scale, 1)), 110px);
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1;
    color: #ffffff;
    -webkit-text-stroke: 2px rgba(255, 255, 255, 0.95);
    text-shadow:
        0 0 10px rgba(0, 255, 255, 0.9),
        0 0 22px rgba(0, 220, 255, 0.75),
        0 0 38px rgba(0, 180, 255, 0.65);
}

.life-lost-overlay__subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(16px, calc(2.2vw * var(--ui-scale, 1)), 28px);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #d6fbff;
    text-shadow: 0 0 10px rgba(0, 230, 255, 0.6);
}

/* Hide controls hint on phones and tablets */
@media (max-width: 1024px) {
    .controls-hint {
        display: none !important;
    }
}

body.is-mobile .controls-hint {
    display: none !important;
}

body.is-touch .controls-hint {
    display: none !important;
}

@media (hover: none) and (pointer: coarse) {
    .controls-hint {
        display: none !important;
    }
}
