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

body {
    background-color: #fff;
    font-family: 'Arial', sans-serif;
    overflow: hidden; /* Prevent scrolling */
    height: 100vh;
    width: 100vw;
    /* Prevent mobile scroll bounce/overscroll */
    position: fixed; 
    top: 0;
    left: 0;
    touch-action: none; /* Disable default touch actions (scrolling, zooming) */
}

.grid-container {
    display: grid;
    width: 100%;
    height: 100%;
}

.grid-item {
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 1000px; /* Essential for 3D flip */
    cursor: pointer;
    background: #fff;
    border: 1px solid #eee;
}

/* The flipper container */
.flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Faster, snappier transition */
    transform-style: preserve-3d;
}

/* Flip state applied by JS */
.grid-item.flipped .flipper {
    transform: rotateY(180deg);
}

/* Front and Back of the card */
.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
}

/* Front: White square */
.front {
    background-color: #ffffff;
}

/* Back: The Image */
.back {
    transform: rotateY(180deg);
    background-color: #000;
}

.back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Token Bubble Container */
.token-bubble-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200; /* Above grid and footer */
    pointer-events: auto;
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column; /* Stack button and address bubble vertically */
    align-items: center;
    gap: 20px;
}

/* PFP Button Styling */
.pfp-button {
    background: #000;
    color: #fff;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, background 0.2s;
    border: 2px solid #fff;
}

.pfp-button:hover {
    transform: scale(1.1);
    background: #333;
}

.pfp-button:active {
    transform: scale(0.9);
}

.token-bubble {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    border: 2px solid #000;
    border-radius: 50px;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s, background 0.2s;
    position: relative;
    overflow: hidden;
    width: 100%; /* Take full width of container */
    max-width: 100%;
}

.token-bubble:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 1);
}

.token-bubble:active {
    transform: scale(0.98);
}

.token-label {
    font-weight: bold;
    font-family: 'Impact', sans-serif;
    font-size: 1.2rem;
    color: #000;
    white-space: nowrap;
}

.token-address {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1; /* Allow address to take available space */
}

.copy-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    font-family: sans-serif;
    white-space: nowrap;
}

.token-bubble:hover .copy-tooltip {
    opacity: 1;
}

/* Modal Styling */
.modal {
    display: none; 
    position: fixed; 
    z-index: 300; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.8); 
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    pointer-events: auto; /* Enable interaction */
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    border-radius: 15px;
    text-align: center;
    position: relative;
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    from {transform: scale(0.8); opacity: 0;}
    to {transform: scale(1); opacity: 1;}
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.pfp-display img {
    max-width: 100%;
    height: auto;
    max-height: 60vh;
    border-radius: 10px;
    border: 2px solid #000;
    margin: 15px 0;
}

.modal h2 {
    font-family: 'Impact', sans-serif;
    letter-spacing: 1px;
    margin-bottom: 25px; /* Increased space */
}

.pfp-instruction {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
    font-family: 'Impact', sans-serif; /* Consistent font */
}

.download-btn {
    background-color: #000;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-family: 'Impact', sans-serif; /* Consistent font */
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: normal;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s;
}

.download-btn:hover {
    background-color: #333;
}

/* Footer Styling */
.footer {
    position: fixed;
    bottom: 30px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 40px;
    z-index: 100;
    pointer-events: none; /* Let clicks pass through to grid except on links */
}

.footer a {
    font-family: 'Impact', sans-serif;
    color: black;
    font-size: 2rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: normal; /* Remove bold if Impact supports it, otherwise font-family might dictate weight */
    pointer-events: auto; /* Enable clicking on links */
    transition: transform 0.2s;
}

.footer a:hover {
    transform: scale(1.1);
    color: #333; /* Dark gray hover */
}

/* Responsive adjust for mobile */
@media (max-width: 600px) {
    .footer {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        bottom: 20px;
    }
    .footer a {
        font-size: 1.5rem;
    }
    
    .token-bubble {
        padding: 10px 20px;
        border-radius: 30px;
    }
    
    .token-label {
        font-size: 1rem;
    }
    
    .token-address {
        font-size: 0.8rem;
    }
    
    .token-bubble-container {
        gap: 15px;
    }
}

/* PFP Controls and Spinner */
.pfp-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    width: 100%;
}

.upload-btn, .random-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: 'Impact', sans-serif; /* Consistent font */
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: normal;
    cursor: pointer;
    transition: transform 0.1s;
    width: 100%;
}

.upload-btn {
    background-color: #007bff;
    color: white;
}

.upload-btn:hover {
    background-color: #0056b3;
}

.random-btn {
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

.random-btn:hover {
    background-color: #e0e0e0;
}

.or-divider {
    font-size: 1rem;
    color: #888;
    margin: 10px 0;
    font-family: 'Impact', sans-serif;
    letter-spacing: 1px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #000;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 20px;
    background-color: #f3f3f3;
    border-radius: 10px;
    border: 1px solid #ddd;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background-color: #000; /* Side Eye Coin Black */
    transition: width 0.3s ease;
    border-radius: 10px;
}

#loadingText {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin-top: 10px;
    color: #333;
}
