@font-face {
    font-family: 'ProtoMono';
    src: url('ProtoMono-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
}

:root {
    --blue: #234fde;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100%;
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; /* Dynamic viewport height - adjusts for mobile browser UI */
    overflow: hidden;
    background: white;
    font-family: 'ProtoMono', monospace;
    font-size: 12px;
    color: var(--blue);
}

#container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    position: absolute;
    top: 0;
    left: 0;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

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

/* Top Margin UI */
#top-ui {
    position: absolute;
    top: env(safe-area-inset-top, 0); /* Accounts for notch on iOS */
    left: 0;
    width: 100%;
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    padding-left: max(10px, env(safe-area-inset-left, 10px)); /* Side safe areas */
    padding-right: max(10px, env(safe-area-inset-right, 10px));
    font-size: 12px;
    line-height: 1;
}

#top-left {
    display: flex;
    gap: 20px;
    align-items: center;
}

#top-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

#music-player {
    display: flex;
    align-items: center;
    gap: 8px;
}

#song-title-container {
    width: 120px;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

#song-title {
    display: inline-block;
    padding-right: 50px;
    animation: scroll-text 15s linear infinite;
}

@keyframes scroll-text {
    0%, 20% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-100%);
    }
}

#play-pause-btn {
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--blue);
    cursor: pointer;
    transform: translateY(-5%);
}

#play-pause-btn:hover {
    background: transparent;
    color: var(--blue);
    opacity: 0.7;
}

#top-right {
    display: flex;
    align-items: center;
}

.address-link {
    color: var(--blue);
    text-decoration: underline;
}

.address-link:hover {
    text-decoration: underline;
}

/* Bottom Margin UI */
#bottom-ui {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 0); /* Accounts for mobile browser UI */
    left: 0;
    width: 100%;
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    padding-left: max(10px, env(safe-area-inset-left, 10px)); /* Side safe areas */
    padding-right: max(10px, env(safe-area-inset-right, 10px));
    font-size: 12px;
    line-height: 1;
}

#bottom-left {
    display: flex;
    gap: 15px;
    align-items: center;
}

#bottom-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

#bottom-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Buttons */
button {
    font-family: 'ProtoMono', monospace;
    font-size: 12px;
    background: white;
    border: 1px solid var(--blue);
    padding: 1px 4px;
    cursor: pointer;
    color: var(--blue);
    line-height: 1;
}

button:hover {
    background: var(--blue);
    color: white;
}

.link-button {
    font-family: 'ProtoMono', monospace;
    font-size: 12px;
    color: var(--blue);
    text-decoration: none;
    border: 1px solid var(--blue);
    padding: 1px 4px;
    display: inline-block;
    line-height: 1;
}

.link-button:hover {
    background: var(--blue);
    color: white;
}

#wallet-info {
    display: none;
    gap: 10px;
    align-items: center;
}

#wallet-info.connected {
    display: flex;
}

#connect-btn.connected {
    display: none;
}

#mint-btn, #claim-artwork-btn, #about-btn {
    background: var(--blue);
    color: white;
}

#mint-btn:hover, #claim-artwork-btn:hover, #about-btn:hover {
    background: white;
    color: var(--blue);
}

/* About Modal */
#about-modal {
    position: absolute;
    top: calc(30px + env(safe-area-inset-top, 0px));
    left: 0;
    width: 100%;
    height: calc(100% - 60px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    background: white;
    display: none;
    padding: 40px;
    padding-left: max(40px, env(safe-area-inset-left, 40px));
    padding-right: max(40px, env(safe-area-inset-right, 40px));
    overflow-y: auto;
}

#about-modal.active {
    display: block;
}

#about-modal h2 {
    margin-bottom: 20px;
    font-size: 12px;
    font-weight: 500;
}

#about-modal p {
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 15px;
}

#about-modal p.section-title {
    margin-bottom: 7.5px;
}

#about-modal a {
    color: var(--blue);
}

#about-modal a:visited {
    color: var(--blue);
}

#close-about {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Mint Modal */
#mint-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    background: var(--blue);
    border: 2px solid var(--blue);
    padding: 25px;
    display: none;
    z-index: 1000;
    color: white;
}

#mint-modal.active {
    display: block;
}

#close-mint {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 12px;
    background: var(--blue);
    color: white;
    border: 1px solid white;
    padding: 1px 4px;
    cursor: pointer;
    font-family: 'ProtoMono', monospace;
}

#close-mint:hover {
    background: white;
    color: var(--blue);
    border: 1px solid white;
}

#mint-limit-display {
    text-align: center;
    margin-bottom: 20px;
    font-size: 12px;
    color: white;
}

#mint-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.mint-option-btn {
    flex: 1;
    padding: 15px 10px;
    background: var(--blue);
    border: 1px solid white;
    cursor: pointer;
    color: white;
    font-family: 'ProtoMono', monospace;
    font-size: 12px;
    text-align: center;
}

.mint-option-btn:hover {
    background: white;
    color: var(--blue);
    border: 1px solid white;
}

.mint-title {
    font-size: 12px;
    margin-bottom: 6px;
    font-weight: 500;
}

.mint-amount {
    font-size: 12px;
    margin-bottom: 6px;
}

.mint-cost {
    font-size: 12px;
    opacity: 0.8;
}

#mint-status {
    text-align: center;
    font-size: 12px;
    min-height: 14px;
    color: white;
}

/* Artwork Gallery Modal */
#artwork-modal {
    position: absolute;
    top: calc(30px + env(safe-area-inset-top, 0px));
    left: 0;
    width: 100%;
    height: calc(100% - 60px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    background: white;
    display: none;
    padding: 40px;
    padding-left: max(40px, env(safe-area-inset-left, 40px));
    padding-right: max(40px, env(safe-area-inset-right, 40px));
    overflow-y: auto;
}

#artwork-modal.active {
    display: block;
}

#artwork-modal h2 {
    margin-bottom: 30px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

#close-artwork {
    position: absolute;
    top: 10px;
    right: 10px;
}

#artwork-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.nft-box {
    border: 2px solid var(--blue);
    background: white;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nft-artwork {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.nft-artwork svg {
    width: 100%;
    height: 100%;
}

.nft-artwork.unminted {
    font-size: 12px;
    color: var(--blue);
    border: 1px solid var(--blue);
}

.nft-traits {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
}

.nft-trait {
    display: flex;
    justify-content: space-between;
}

.trait-label {
    font-weight: 500;
}

.trait-value {
    word-break: break-all;
}

.nft-view-btn {
    width: 100%;
    padding: 4px;
    font-size: 12px;
}

.nft-view-btn.mint-style {
    background: var(--blue);
    color: white;
}

.nft-view-btn.mint-style:hover {
    background: white;
    color: var(--blue);
}

.nft-view-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: white;
    color: var(--blue);
}

/* ============================================ */
/* MOBILE RESPONSIVE STYLES */
/* ============================================ */

@media (max-width: 768px) {
    /* Reduce font size to 10px on mobile for all elements */
    body {
        font-size: 10px;
    }

    button {
        font-size: 10px;
    }

    .link-button {
        font-size: 10px;
    }

    #top-ui,
    #bottom-ui,
    #about-modal h2,
    #about-modal p,
    #close-mint,
    #mint-limit-display,
    .mint-option-btn,
    .mint-title,
    .mint-amount,
    .mint-cost,
    #mint-status,
    #artwork-modal h2,
    .nft-traits,
    .nft-view-btn,
    .nft-artwork.unminted,
    #play-pause-btn {
        font-size: 10px;
    }

    /* Hide extra counters on mobile - only show total mint counter */
    #colors-counter,
    #value-counter,
    #minters-counter {
        display: none;
    }

    /* Hide activity feed on mobile */
    #address-feed {
        display: none;
    }

    /* Hide song title on mobile - only show play/pause button */
    #song-title-container {
        display: none;
    }

    /* Hide USDC balance, wallet address, and highlight button on mobile to save space */
    #wallet-usdc,
    #wallet-address,
    #highlight-btn {
        display: none !important;
    }

    /* Hide contract links on mobile */
    #contract-erc20-link,
    #contract-erc721-link {
        display: none;
    }

    /* Hide mint button on mobile by default */
    #mint-btn {
        display: none !important;
    }

    /* Show mint button when wallet is connected on mobile */
    #wallet-info.connected ~ #mint-btn {
        display: inline-flex !important;
    }

    /* Move claim artwork button to the left on mobile */
    #bottom-center {
        position: static;
        transform: none;
        order: 1;
        margin-left: 8px;
    }

    #bottom-left {
        order: 0;
        gap: 8px;
    }

    #bottom-right {
        order: 2;
        margin-left: auto;
    }

    /* Increase touch target sizes for buttons with equal padding */
    button {
        padding: 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .link-button {
        padding: 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    #play-pause-btn {
        width: 44px;
        height: 44px;
        min-height: 44px;
    }

    /* Make mint modal responsive and compact */
    #mint-modal {
        width: 75%;
        max-width: 300px;
        padding: 15px;
    }

    #mint-limit-display {
        margin-bottom: 15px;
    }

    #mint-options {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 15px;
    }

    .mint-option-btn {
        padding: 8px 12px;
        width: 70%;
        flex-direction: column;
        gap: 4px;
    }

    .mint-title,
    .mint-amount,
    .mint-cost {
        margin-bottom: 0;
    }

    .mint-title {
        margin-bottom: 4px;
    }

    .mint-amount {
        margin-bottom: 4px;
    }

    /* Reduce modal padding on mobile */
    #about-modal {
        padding: 20px;
        padding-left: max(20px, env(safe-area-inset-left, 20px));
        padding-right: max(20px, env(safe-area-inset-right, 20px));
    }

    #artwork-modal {
        padding: 20px;
        padding-left: max(20px, env(safe-area-inset-left, 20px));
        padding-right: max(20px, env(safe-area-inset-right, 20px));
    }

    /* Make close buttons consistent with mint modal on mobile */
    #close-about,
    #close-artwork {
        padding: 6px;
        font-size: 10px;
    }

    /* Adjust UI bar spacing */
    #top-left {
        gap: 10px;
    }

    #bottom-left {
        gap: 8px;
    }

    #bottom-right {
        gap: 8px;
    }

    /* Reduce wallet info gap */
    #wallet-info {
        gap: 8px;
    }
}
