/* ====================================
   Mobile Responsive Styles
   ==================================== */

/* Base adjustments for all mobile devices */
@media screen and (max-width: 768px) {

    body {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        position: fixed;
    }

    #container {
        width: 100vw;
        height: 100vh;
        position: relative;
        overflow: hidden;
    }

    /* Canvas scaling for mobile - centered and full screen */
    #mycanvas {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        object-fit: cover;
        float: none !important;
        transform: none !important;
    }

    /* Metadata positioning */
    #metadata {
        position: fixed;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 80px);
        text-align: center;
        font-size: 16px;
        line-height: 1.4;
        padding: 10px 15px;
        background: rgba(0, 0, 0, 0.6);
        border-radius: 8px;
        backdrop-filter: blur(10px);
        z-index: 100;
    }

    /* Player controls */
    #player {
        position: fixed;
        bottom: 60px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 20px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 20px;
        backdrop-filter: blur(10px);
        z-index: 100;
        width: auto;
        top: auto;
    }

    /* Play button */
    #play-icon {
        width: 80px;
        height: 80px;
        margin: 10px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Volume slider */
    input[type="range"] {
        width: 60vw;
        max-width: 300px;
        margin-top: 15px;
        touch-action: manipulation;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        bottom: 12px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    /* Art credit */
    #artCredit {
        position: fixed;
        bottom: 15px;
        right: 50%;
        transform: translateX(50%);
        font-size: 18px;
        text-align: center;
        width: auto;
        padding: 5px 10px;
        background: rgba(0, 0, 0, 0.4);
        border-radius: 5px;
        z-index: 99;
    }

    /* Info button */
    #info-button {
        position: fixed;
        top: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        z-index: 101;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #donate-button {
        position: fixed;
        top: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
        z-index: 101;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Info window */
    #info-window {
        width: 85vw;
        max-width: 320px;
        height: auto;
        min-height: 200px;
        padding: 20px;
        border-radius: 15px;
        font-size: 14px;
        z-index: 1000;
    }

    #donate-window {
        width: 85vw;
        max-width: 320px;
        height: auto;
        min-height: 200px;
        padding: 20px;
        border-radius: 15px;
        font-size: 14px;
        z-index: 1000;
    }

    #info-window p {
        padding: 15px 10px;
        margin: 10px 0;
    }

    #donate-window p {
        padding: 15px 10px;
        margin: 10px 0;
        position: relative;
        top: 70px;
    }

    #close-info {
        padding: 10px 30px;
        font-size: 16px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #close-donate {
        padding: 10px 30px;
        font-size: 16px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #donate {
        padding: 10px 30px;
        font-size: 20px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: bold;
        box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
        transition: all 0.2s ease;
    }

    #donate:active {
        transform: translateX(-50%) scale(0.95);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
    #donate-window p {
        padding: 15px 10px;
        margin: 10px 0;
    }

    #donate {
        padding: 10px 30px;
        font-size: 20px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: bold;
        box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
        transition: all 0.2s ease;
    }

    #donate:active {
        transform: translateX(-50%) scale(0.95);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
}

/* Small phones (portrait) */
@media screen and (max-width: 480px) {

    #metadata {
        font-size: 15px;
        width: calc(100% - 60px);
        top: 15px;
        padding: 8px 12px;
    }

    #player {
        bottom: 40px;
        padding: 15px;
    }

    #play-icon {
        width: 70px;
        height: 70px;
    }

    input[type="range"] {
        width: 70vw;
    }

    #artCredit {
        font-size: 18px;
        bottom: 10px;
    }

    #info-button {
        width: 46px;
        height: 46px;
        top: 15px;
        right: 15px;
    }

    #donate-button {
        width: 46px;
        height: 46px;
        top: 15px;
        left: 15px;
    }
}

/* Landscape orientation */
@media screen and (max-width: 896px) and (orientation: landscape) {

    #player {
        bottom: 30px;
        padding: 10px 20px;
        flex-direction: row;
        gap: 20px;
    }

    #play-icon {
        width: 60px;
        height: 60px;
        margin: 0;
    }

    input[type="range"] {
        width: 40vw;
        max-width: 250px;
        margin: 0;
    }

    #metadata {
        top: 14px;
        font-size: 12px;
        padding: 6px 10px;
    }

    #artCredit {
        bottom: 10px;
        font-size: 22px;
    }
}

/* Tablets (portrait) */
@media screen and (min-width: 481px) and (max-width: 768px) {

    #play-icon {
        width: 100px;
        height: 100px;
    }

    #metadata {
        font-size: 20px;
        top: 30px;
    }

    input[type="range"] {
        width: 50vw;
        max-width: 350px;
    }

    #artCredit {
        font-size: 20px;
    }
}

/* Prevent text selection on mobile */
@media (pointer: coarse) {
    * {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    input, button {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Improve touch targets */
@media (hover: none) and (pointer: coarse) {
    button,
    input[type="range"],
    #info-button {
        min-width: 46px;
        min-height: 46px;
    }

    #donate-button {
        min-width: 46px;
        min-height: 46px;
    }
}

/* Dark theme adjustments for OLED screens */
@media screen and (max-width: 768px) {
    body {
        background: #000000;
    }

    #container {
        background: #000000;
    }
}

/* Safe area insets for notched devices (iPhone X and newer) */
@supports (padding: max(0px)) {
    @media screen and (max-width: 768px) {
        #metadata {
            top: max(25px, env(safe-area-inset-top));
        }

        #player {
            bottom: max(60px, env(safe-area-inset-bottom));
        }

        #artCredit {
            bottom: max(20px, env(safe-area-inset-bottom));
        }

        #info-button {
            top: max(20px, env(safe-area-inset-top));
            right: max(20px, env(safe-area-inset-right));
        }

        #donate-button {
            top: max(20px, env(safe-area-inset-top));
            left: max(20px, env(safe-area-inset-right));
        }
    }
}