/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    z-index: 10;
}

.beat-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    outline: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 40px;
}

.loading-icon {
    font-size: 4rem;
    animation: bounce 0.8s ease-in-out infinite alternate;
    margin-bottom: 20px;
}

@keyframes bounce {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-20px) scale(1.1); }
}

.loading-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #ff9f43, #feca57);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.loading-content p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Menu */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.menu-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: 3.5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
    font-weight: 700;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 107, 107, 0.3); }
    to { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 107, 107, 0.6); }
}

.game-subtitle {
    font-size: 1.3rem;
    color: #feca57;
    font-weight: 400;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 600px;
    width: 100%;
}

.dj-mascot {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.mascot {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: headbob 1.5s ease-in-out infinite alternate;
}

@keyframes headbob {
    from { transform: rotate(-5deg); }
    to { transform: rotate(5deg); }
}

.mascot-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 500;
}

.game-modes h3,
.difficulty-selection h3 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

.mode-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-button {
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    border: none;
    border-radius: 20px;
    padding: 25px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 180px;
    font-family: 'Fredoka', sans-serif;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
}

.mode-button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 35px rgba(255, 107, 107, 0.4);
}

.mode-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.mode-button h4 {
    font-size: 1.2rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.mode-button p {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 400;
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.difficulty-button {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 15px;
    padding: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 120px;
    font-family: 'Fredoka', sans-serif;
    backdrop-filter: blur(10px);
}

.difficulty-button:hover {
    border-color: #feca57;
    background: rgba(254, 202, 87, 0.2);
    transform: translateY(-2px);
}

.difficulty-emoji {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.difficulty-button span:nth-child(2) {
    font-size: 1.1rem;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

.difficulty-button small {
    font-size: 0.9rem;
    opacity: 0.8;
}

.menu-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-button {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Fredoka', sans-serif;
    backdrop-filter: blur(10px);
}

.menu-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Game UI */
.game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.ui-top {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: auto;
}

.score-display {
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 20px;
    border-radius: 15px;
    display: flex;
    gap: 20px;
    backdrop-filter: blur(10px);
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.score-label {
    font-size: 0.9rem;
    opacity: 0.8;
    font-weight: 500;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #feca57;
}

.level-info {
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 20px;
    border-radius: 15px;
    text-align: center;
    backdrop-filter: blur(10px);
    min-width: 200px;
}

.level-title {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #feca57);
    width: 0%;
    transition: width 0.3s ease;
}

.ui-controls {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.key-guide p {
    color: white;
    font-size: 0.9rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.key-map {
    display: flex;
    gap: 5px;
}

.key {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.key.active {
    background: #feca57;
    color: #333;
    border-color: #ff6b6b;
    transform: scale(1.1);
}

.ui-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    align-items: center;
    pointer-events: auto;
}

.hit-feedback {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.hit-feedback.show {
    opacity: 1;
    transform: translateY(0);
}

.hit-feedback.perfect {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.hit-feedback.good {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.hit-feedback.miss {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.ui-button {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ui-button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

/* Freestyle Mode */
.freestyle-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 20px;
}

.freestyle-header {
    text-align: center;
    color: white;
}

.freestyle-header h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.freestyle-header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.freestyle-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.freestyle-button {
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.freestyle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.freestyle-button:active {
    transform: translateY(0);
}

.tempo-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: white;
}

.tempo-control label {
    font-size: 1.1rem;
    font-weight: 600;
}

.tempo-slider {
    width: 200px;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    appearance: none;
}

.tempo-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #feca57;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.tempo-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #feca57;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.freestyle-exit {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.freestyle-exit:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 25px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    color: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.pause-stats,
.results-stats {
    margin: 20px 0;
}

.pause-stats p {
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-label {
    font-size: 1.1rem;
    font-weight: 500;
    flex: 1;
    text-align: left;
    margin-left: 10px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #feca57;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.modal-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.modal-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Audio Context Notice */
.audio-notice {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 300;
    backdrop-filter: blur(10px);
    border: 2px solid #feca57;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .mode-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-button {
        width: 100%;
        max-width: 280px;
    }
    
    .difficulty-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .difficulty-button {
        width: 100%;
        max-width: 200px;
    }
    
    .ui-top {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .score-display {
        justify-content: space-around;
    }
    
    .ui-controls {
        position: static;
        transform: none;
        margin: 10px auto;
        align-self: center;
    }
    
    .ui-bottom {
        bottom: 10px;
        flex-wrap: wrap;
        max-width: 90%;
    }
    
    .freestyle-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .freestyle-button {
        width: 100%;
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .modal-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-button {
        width: 100%;
        max-width: 200px;
    }
    
    .stat-item {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
    
    .stat-label {
        text-align: center;
        margin-left: 0;
    }
}