body {
    /* Polkadot BG */
    background-color: #ffa8d3;
    background-image: radial-gradient(circle, #ffffff 20%, transparent 20%);
    background-size: 30px 30px;
    margin: 0;
    padding: 0;
    font-family: 'Space Mono', monospace;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.title-text {
    color: #ffffff;
    font-family: 'Orbitron', monospace;
    font-size: 7rem;
    transform: translate(0px, 75px);
    text-shadow: 2px 0 10px #000000;
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    font-family: 'Space Mono', monospace;
    background-color: #ffa8d3;
    padding: 10px;
    border-top: 1px solid #000;
    box-sizing: border-box;
}

.title {
    text-align: center;
    font-size: 4rem;
    font-weight: bold;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    color: #ffffff;
    font-family: 'Space Mono', monospace;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #ffa8d3;
    backdrop-filter: blur(5px);
    min-width: 200px;
}

#emilia-dance, #emilia-kick {
    width: 320px;
    height: 320px;
    transition: transform 0.1s ease-out, opacity 0.2s ease-in-out;
    will-change: transform;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#emilia-dance.dragging, #emilia-kick.dragging {
    transition: none; /* Disable transitions during drag for immediate response */
}

#emilia-dance {
    cursor: grab;
    user-select: none;
    touch-action: none; /* Prevent default touch behaviors */
}

#emilia-dance:active {
    cursor: grabbing;
}

#emilia-kick {
    cursor: grabbing;
    user-select: none;
    touch-action: none; /* Prevent default touch behaviors */
    position: fixed; /* Ensure kick image is also fixed positioned */
}

.music-player {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1000;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 10px;
    overflow: hidden;
}

.music-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -999;
    text-align: center;
    color: #ffffff;
    font-family: 'Space Mono', monospace;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #ffa8d3;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 168, 211, 0.3);
    border-top: 4px solid #ffa8d3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-error, .loading-message {
    color: #ffffff;
    font-family: 'Space Mono', monospace;
    text-align: center;
}

.loading-error p {
    color: #ff6b6b;
    margin: 10px 0;
}

.loading-message p {
    color: #ffa8d3;
    margin: 10px 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.loading-message p:hover {
    color: #ffffff;
}

#music-button {
    position: fixed;
    top: 5%;
    left: 5%;
    z-index: 1000;
    /* background-color: rgb(255, 181, 218, 0.5); */
    background-color: rgb(255, 255, 255, 0.15);
    border: 1px solid #000;
    border-radius: 10px;
    padding: 10px;
    touch-action: manipulation; /* Improve touch responsiveness */
}

#music-button-text {
    font-size: 1rem;
    font-weight: bold;
    -webkit-text-stroke: 0.1px #ffa8d3;
    font-family: 'Space Mono', monospace;
    color: #000000;
    opacity: 1;
}

#music-button:hover {
    scale: 1.05;
}

#music-button:active {
    scale: 0.95;
}

/* Messages Section - Bottom Left */
.messages {
    position: fixed;
    bottom: 80px; /* Above footer */
    left: 20px;
    width: 350px;
    max-height: 300px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #000;
    border-radius: 15px;
    padding: 15px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.message-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}

.message-item {
    background-color: rgba(255, 168, 211, 0.3);
    border: 1px solid #ffa8d3;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.message-content {
    margin-bottom: 5px;
}

.message-text {
    margin: 0;
    font-size: 0.9rem;
    color: #333;
    line-height: 1.4;
}

.message-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #666;
    margin-top: 5px;
}

.message-name {
    font-weight: bold;
    color: #ff69b4;
}

.message-time {
    font-style: italic;
}

/* Message Form */
.message-form {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 350px;
    display: flex;
    gap: 10px;
    z-index: 100;
    box-sizing: border-box;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #000;
    border-radius: 10px;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    box-sizing: border-box;
}

#message-input:focus {
    outline: none;
    border-color: #ffa8d3;
    box-shadow: 0 0 5px rgba(255, 168, 211, 0.5);
}

#send-button {
    padding: 12px 20px;
    background-color: #ffa8d3;
    border: 2px solid #000;
    border-radius: 10px;
    font-family: 'Space Mono', monospace;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation; /* Improve touch responsiveness */
    box-sizing: border-box;
}

#send-button:hover {
    background-color: #ff8cc8;
    transform: scale(1.05);
}

#send-button:active {
    transform: scale(0.95);
}

/* Scrollbar styling for message list */
.message-list::-webkit-scrollbar {
    width: 6px;
}

.message-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.message-list::-webkit-scrollbar-thumb {
    background: #ffa8d3;
    border-radius: 3px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background: #ff8cc8;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .title-text {
        font-size: 3.5rem;
        transform: translate(0px, 30px);
    }

    .title {
        font-size: 2rem;
    }

    #emilia-dance, #emilia-kick {
        width: 240px;
        height: 240px;
    }
    
    .image-loading {
        padding: 15px;
        min-width: 180px;
    }

    .messages {
        bottom: 140px; /* Increase space above footer */
        left: 10px;
        right: 10px; /* Use right instead of fixed width */
        width: auto; /* Remove fixed width */
        max-width: calc(100vw - 20px);
        max-height: 250px;
        padding: 12px;
    }

    .message-form {
        bottom: 80px; /* Above enlarged footer */
        left: 10px;
        right: 10px; /* Use right instead of fixed width */
        width: auto; /* Remove fixed width */
        max-width: calc(100vw - 20px);
    }

    #music-button {
        top: 3%;
        left: 3%;
        padding: 8px;
    }

    #music-button-text {
        font-size: 0.9rem;
    }

    footer {
        font-size: 0.9rem;
        padding: 15px 10px;
    }

    .message-text {
        font-size: 0.85rem;
    }

    #message-input {
        font-size: 0.85rem;
        padding: 10px;
    }

    #send-button {
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    /* Adjust background pattern for mobile */
    body {
        background-size: 20px 20px;
    }
}

@media screen and (max-width: 480px) {
    .title-text {
        font-size: 2.5rem;
        transform: translate(0px, 20px);
    }

    .title {
        font-size: 1.5rem;
    }

    #emilia-dance, #emilia-kick {
        width: 180px;
        height: 180px;
    }
    
    .image-loading {
        padding: 12px;
        min-width: 160px;
    }
    
    .loading-spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }

    .messages {
        bottom: 150px;
        max-height: 200px;
        padding: 10px;
    }

    .message-form {
        bottom: 90px;
        gap: 8px;
    }

    .message-list {
        max-height: 150px;
    }

    .message-text {
        font-size: 0.8rem;
    }

    .message-info {
        font-size: 0.7rem;
    }

    #message-input {
        font-size: 0.8rem;
        padding: 8px;
    }

    #send-button {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    footer {
        font-size: 0.8rem;
        padding: 12px 8px;
    }

    /* Further reduce background pattern for small screens */
    body {
        background-size: 15px 15px;
    }
}

/* Landscape orientation on mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .title-text {
        font-size: 2rem;
        transform: translate(0px, 10px);
    }

    .title {
        font-size: 1.2rem;
    }

    #emilia-dance, #emilia-kick {
        width: 150px;
        height: 150px;
    }

    .messages {
        bottom: 100px;
        max-height: 180px;
        right: 200px; /* Make room for message form */
        width: 300px;
        left: 10px;
        right: auto;
    }

    .message-form {
        bottom: 40px;
        left: 10px;
        width: 300px;
        right: auto;
    }
}

