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

:root {
    --button-size: 100px;
    --button-size-mobile: 80px;
    --button-size-small: 60px;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: Arial, sans-serif;
    background-color: white;
    height: 100vh;
    width: 100vw;
    transition: all 1.5s cubic-bezier(0.25, 0.1, 0.25, 1); /* Smoother transition with easing */
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
    touch-action: manipulation; /* Improves touch response */
    position: relative;
    overflow: hidden;
}

body.with-background {
    /* Base background settings for Safari compatibility */
    background-image: url('background.jpg');
    background-repeat: no-repeat;
    
    /* Better handling for various screen sizes */
    background-size: cover; /* Better coverage across browsers */
    background-position: center center;
    
    /* Safari has issues with fixed backgrounds */
    background-attachment: scroll;
    
    /* Add a subtle fill color to avoid empty spaces on larger screens */
    background-color: #000;
}

/* Desktop-specific adjustments */
@media screen and (min-width: 1024px) {
    body.with-background {
        /* Adjust size to balance between full coverage and quality */
        background-size: cover;
        background-position: center center;
    }
}

/* Mobile-specific adjustments - keep current behavior */
@media screen and (max-width: 768px) {
    body.with-background {
        background-size: cover;
        background-position: center center;
        background-attachment: scroll; /* Remove fixed attachment on mobile to fix touch events */
    }
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 20px;
    position: fixed; /* Keep container fixed to ensure full height on mobile */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.control-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transform: translateY(0); /* Reset any potential offsets */
}

.control-button {
    cursor: pointer;
    transition: transform 0.2s ease;
    /* Use viewport units for more responsive sizing */
    width: var(--button-size);
    height: var(--button-size);
    background-color: black;
    border-radius: 50%;
    position: relative;
    /* Add a subtle shadow for better visibility */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button:hover {
    transform: scale(1.05);
}

/* Mobile-friendly active state */
.control-button:active {
    transform: scale(0.95);
}

.play::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-top: calc(var(--button-size) * 0.2) solid transparent;
    border-bottom: calc(var(--button-size) * 0.2) solid transparent;
    border-left: calc(var(--button-size) * 0.35) solid white;
}

.stop::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(var(--button-size) * 0.35);
    height: calc(var(--button-size) * 0.35);
    background-color: white;
}

.loading-animation {
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: var(--button-size);
    height: var(--button-size);
    border-radius: 50%;
    border: calc(var(--button-size) * 0.1) solid rgba(0, 0, 0, 0.1);
    border-top: calc(var(--button-size) * 0.1) solid black;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none;
}

/* Volume control styling */
.volume-control {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 30px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.volume-control.visible {
    opacity: 0.7;
    display: block;
}

.volume-slider {
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    padding: 0;
    margin: 0;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    -moz-appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #000;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #000;
    cursor: pointer;
    border: none;
}

/* Status indicator */
.status-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

/* Listener count */
.listener-count {
    margin-top: 15px;
    padding: 6px 12px;
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    border-radius: 15px;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    text-align: center;
}

.listener-count:hover {
    opacity: 0.9;
}

.status-indicator.visible {
    opacity: 0.8;
    display: block;
}

/* Keyboard shortcuts help */
.keyboard-hints {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.hint-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.hint-button:hover {
    background-color: black;
    transform: scale(1.1);
}

.hints-content {
    position: absolute;
    bottom: 40px;
    right: 0;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    width: 200px;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.hints-content.hidden {
    opacity: 0;
    pointer-events: none;
}

.hints-content h3 {
    margin-top: 0;
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
}

.hints-content p {
    margin: 5px 0;
    font-size: 12px;
    color: #555;
}

/* Pulse animation for the play/stop button when audio is playing */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Media Queries for Responsive Design */
@media screen and (max-width: 768px) {
    :root {
        --button-size: var(--button-size-mobile);
    }
}

@media screen and (max-width: 480px) {
    :root {
        --button-size: var(--button-size-small);
    }
    
    .container {
        /* Ensure proper centering on small screens */
        align-items: center;
        justify-content: center;
        padding: 10px; /* Reduce padding on small screens */
    }
    
    .control-wrapper {
        /* Place controls truly in the center */
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    /* Ensure touch targets are large enough */
    .control-button {
        min-width: 60px;
        min-height: 60px;
    }
}

/* Ensure proper orientation handling */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .control-button {
        width: calc(var(--button-size) * 0.8);
        height: calc(var(--button-size) * 0.8);
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }
}
