* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f3f3f3;
    width: 100vw;
    height: 100vh;
    position: relative;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
}

/* Layout Structure */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(243, 243, 243, 1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 20;
    border-bottom: 1px solid rgba(18, 18, 18, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: rgba(243, 243, 243, 1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 40px;
    z-index: 20;
    border-top: 1px solid rgba(18, 18, 18, 0.1);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.center-window {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 90px;
    z-index: 1;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: rgb(243, 243, 243);
}

/* Well animation fade-in */
.well-hidden {
    opacity: 0 !important;
}

.well-visible {
    opacity: 1 !important;
    transition: opacity 1.2s ease-in-out !important;
}

/* Paper texture overlay */
.paper-overlay {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 90px;
    pointer-events: none;
    z-index: 10;
    background-image: url('./assets/paper.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    mix-blend-mode: multiply;  /* overlay works better on dark backgrounds than multiply */
    opacity: 0.6;  /* Subtle texture overlay */
}

/* Top Bar Elements */
.top-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.top-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ukai-logo {
    width: 80px;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.ukai-logo:hover {
    transform: scale(1.1);
}

.game-title {
    font-family: 'Cormorant', serif;
    font-size: 32px;
    font-weight: 500;
    color: #1a1a1a;
    letter-spacing: 0.5px;
}

.user-button, .settings-button {
    background: rgb(243, 243, 243);
    border: 1px solid rgb(18, 18, 18);
    color: rgb(18, 18, 18);
    height: 40px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.user-button {
    padding: 0 16px;
}

.settings-button {
    width: 40px;
    padding: 0;
}

.user-button:hover, .settings-button:hover {
    background: rgba(18, 18, 18, 0.12);
    border-color: rgb(18, 18, 18);
}

.settings-icon {
    width: 20px;
    height: 20px;
    display: block;
    filter: grayscale(1);
    opacity: 0.8;
}

/* Bottom Bar - Audio Controls */
.audio-controls {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.audio-controls-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.audio-controls-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
}

.audio-controls-right {
    display: flex;
    align-items: center;
}

.mute-button {
    border: none;
    background: transparent;
    cursor: pointer;
    width: 40px;
    height: 40px;
    padding: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mute-button:hover {
    opacity: 0.7;
}
.button-icon {
    width: 24px;
    height: 24px;
    display: block;
    filter: grayscale(1);
    opacity: 0.8;
}

.volume-container {
    position: relative;
    width: 150px;
    height: 40px;
    display: flex;
    align-items: center;
}

.volume-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(18, 18, 18, 0.15);
    outline: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.volume-slider:hover {
    background: rgba(18, 18, 18, 0.2);
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgb(18, 18, 18);
    cursor: pointer;
    border: 2px solid rgba(18, 18, 18, 0.3);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: rgb(0, 0, 0);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgb(18, 18, 18);
    cursor: pointer;
    border: 2px solid rgba(18, 18, 18, 0.3);
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    background: rgb(0, 0, 0);
}

.now-playing {
    background: rgb(243, 243, 243);
    border: 1px solid rgb(18, 18, 18);
    padding: 0 20px;
    height: 40px;
    min-width: 350px;
    max-width: 500px;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.now-playing-label {
    font-size: 12px;
    color: rgb(18, 18, 18);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.song-info {
    color: rgb(18, 18, 18);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgb(243, 243, 243);
    border: 1px solid rgb(18, 18, 18);
    padding: 0 16px;
    height: 40px;
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff3333;
    animation: pulse 2s ease-in-out infinite;
}

.live-dot.offline {
    background: #999;
    animation: none;
}

.live-text {
    color: rgb(18, 18, 18);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Auth Modal */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.auth-modal-overlay.active {
    display: flex;
}

.auth-modal {
    background: rgba(240, 240, 245, 0.98);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.auth-modal h2 {
    margin: 0 0 20px 0;
    color: #1a1a1a;
    font-size: 24px;
    text-align: center;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: rgb(243, 243, 243);
    border: 1px solid rgb(18, 18, 18);
    cursor: pointer;
    text-align: center;
    font-weight: 500;
    color: rgb(18, 18, 18);
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: rgba(18, 18, 18, 0.12);
    color: rgb(18, 18, 18);
    border-color: rgb(18, 18, 18);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    color: #1a1a1a;
}

.form-group input:focus {
    outline: none;
    border-color: rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 1);
}

.auth-error {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #cc0000;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

.auth-error.active {
    display: block;
}

.auth-success {
    background: rgba(0, 200, 0, 0.1);
    border: 1px solid rgba(0, 200, 0, 0.3);
    color: #008800;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

.auth-success.active {
    display: block;
}

.auth-submit {
    width: 100%;
    padding: 12px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.auth-submit:hover {
    background: #000;
}

.auth-submit:disabled {
    background: #999;
    cursor: not-allowed;
}

.auth-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
}

.auth-close:hover {
    color: #000;
}

/* Logout Modal */
.logout-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.logout-modal-overlay.active {
    display: flex;
}

.logout-modal {
    background: rgba(240, 240, 245, 0.98);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.logout-modal h3 {
    margin: 0 0 15px 0;
    color: #1a1a1a;
    font-size: 20px;
    font-weight: 600;
}

.logout-modal p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.logout-modal-buttons {
    display: flex;
    gap: 10px;
}

.logout-modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-modal-btn.confirm {
    background: #cc0000;
    color: #fff;
}

.logout-modal-btn.confirm:hover {
    background: #aa0000;
}

.logout-modal-btn.cancel {
    background: rgb(243, 243, 243);
    border: 1px solid rgb(18, 18, 18);
    color: rgb(18, 18, 18);
}

.logout-modal-btn.cancel:hover {
    background: rgba(18, 18, 18, 0.12);
}

/* Payment Modal - reuses auth modal styles */
.payment-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.payment-modal-overlay.active {
    display: flex;
}

.payment-modal {
    background: rgba(240, 240, 245, 0.98);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.payment-modal h3 {
    margin: 0 0 20px 0;
    color: #1a1a1a;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

.payment-item-details {
    background: rgba(0, 0, 0, 0.05);
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.payment-item-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.payment-amount {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
}

.payment-error, .payment-success {
    padding: 10px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

.payment-error {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #cc0000;
}

.payment-error.active {
    display: block;
}

.payment-success {
    background: rgba(0, 200, 0, 0.1);
    border: 1px solid rgba(0, 200, 0, 0.3);
    color: #008800;
}

.payment-success.active {
    display: block;
}

.payment-submit {
    width: 100%;
    padding: 14px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.payment-submit:hover {
    background: #000;
}

.payment-submit:disabled {
    background: #999;
    cursor: not-allowed;
}

/* Settings Modal */
.settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.settings-modal-overlay.active {
    display: flex;
}

.settings-modal {
    background: rgba(240, 240, 245, 0.98);
    padding: 30px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.settings-modal h3 {
    margin: 0 0 20px 0;
    color: #1a1a1a;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    gap: 20px;
}

.settings-option-info {
    flex: 1;
}

.settings-option-label {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.settings-option-description {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #1a1a1a;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #1a1a1a;
}

/* Background image overlay for when game is disabled */
.game-disabled-overlay {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 90px;
    z-index: 2;
    background-image: url('./assets/El_Aquelarre.webp');
    background-size: cover;
    background-position: calc(0% - 2px) calc(50% - 2px); /* Offset to crop border */
    background-repeat: no-repeat;
    background-color: #f3f3f3; /* Match page background to prevent black edges */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out;
    overflow: hidden;
}

.game-disabled-overlay.visible {
    opacity: 1;
}

/* Responsive Design - Mobile Optimizations */
@media (max-width: 768px) {
    /* Moderately bigger bars for touch targets */
    .top-bar {
        height: 65px;
        padding: 0 12px;
    }

    .bottom-bar {
        height: 80px;
        padding: 0 12px;
    }

    /* Update canvas to match mobile bar sizes */
    .center-window {
        top: 65px;
        bottom: 80px;
    }

    .paper-overlay {
        top: 65px;
        bottom: 80px;
    }

    .game-disabled-overlay {
        top: 65px;
        bottom: 80px;
        background-position: calc(20% - 2px) calc(50% - 2px); /* More centered on mobile, offset to crop border */
    }

    /* Prevent title from overlapping buttons */
    .top-center {
        position: static;
        transform: none;
        flex: 1;
        justify-content: center;
        margin: 0 10px;
    }

    /* Slightly larger, readable text */
    .game-title {
        font-size: 22px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ukai-logo {
        width: 50px;
    }

    /* Good touch targets for buttons (44px min) */
    .user-button, .settings-button {
        min-width: 44px;
        min-height: 44px;
        padding: 8px 12px;
        font-size: 13px;
        flex-shrink: 0;
    }

    .top-right {
        gap: 8px;
    }

    /* Hide volume slider on mobile - users use system controls */
    .volume-container {
        display: none;
    }

    /* Mute button with good touch target */
    .mute-button {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }

    .mute-button img {
        width: 24px;
        height: 24px;
    }

    /* Hide LIVE/Auto DJ indicator on mobile */
    .live-indicator {
        display: none;
    }

    /* Reverse layout: Now Playing (left) | Mute (right) with even spacing */
    .audio-controls {
        justify-content: space-around;
        gap: 12px;
        padding: 0 10px;
    }

    .audio-controls-left {
        gap: 8px;
        flex-shrink: 0;
        order: 2; /* Mute button second = right side */
    }

    .audio-controls-center {
        position: static;
        transform: none;
        flex: 1;
        display: flex;
        justify-content: center;
        order: 1; /* Now Playing first = left side */
    }

    .audio-controls-right {
        display: none; /* Hidden since LIVE indicator is in here */
    }

    /* Now Playing - left-aligned, takes remaining space */
    .now-playing {
        min-width: 0;
        max-width: none;
        padding: 0 10px;
        height: 44px;
        font-size: 13px;
    }

    .now-playing-label {
        font-size: 10px;
    }

    .song-info {
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 430px) {
    /* Fine-tune for smaller phones */
    .game-title {
        font-size: 18px;
    }

    .now-playing {
        padding: 0 10px;
    }

    .song-info {
        font-size: 13px;
    }
}
