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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    position: relative;
}

/* Screen Management */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

/* Welcome Screen */
#welcomeScreen {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    animation: backgroundShift 10s ease-in-out infinite;
}

@keyframes backgroundShift {
    0%, 100% { background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); }
    50% { background: linear-gradient(135deg, #2a5298 0%, #7e8ba3 100%); }
}

.welcome-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 95vh;
    width: 600px;
    overflow-y: auto;
    animation: slideIn 0.8s ease-out;
}

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

.game-logo {
    width: 120px;
    height: auto;
    margin-bottom: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.game-title {
    font-size: 2em;
    color: #2a5298;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: pulse 2s ease-in-out infinite;
}

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

.user-info {
    margin: 20px 0;
}

.user-info input {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.user-info input:focus {
    outline: none;
    border-color: #667eea;
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

.instructions {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
}

.instructions h3 {
    color: #2a5298;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1.2em;
}

.instructions p {
    margin: 6px 0;
    color: #333;
    font-size: 0.95em;
    padding-left: 10px;
}

.start-game-btn {
    padding: 18px 50px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-top: 20px;
    width: 80%;
}

.start-game-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.start-game-btn:active {
    transform: translateY(0);
}

/* Customization Screen */
#customizationScreen, #musicSelectionScreen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.customization-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
}

.customization-section {
    margin: 30px 0;
}

.customization-section h3 {
    color: #2a5298;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.character-options, .background-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.character-option, .bg-option {
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 15px;
    border-radius: 15px;
    border: 3px solid transparent;
}

.character-option:hover, .bg-option:hover {
    transform: scale(1.05);
    background: rgba(102, 126, 234, 0.1);
}

.character-option.selected, .bg-option.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.08);
}

.character-preview, .bg-preview {
    width: 80px;
    height: 80px;
    margin: 0 auto 10px;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

/* Character Previews */
.character-preview {
    background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
    position: relative;
}

.character-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Background Previews */
.bg-preview.space-bg {
    background-image: url('assets/backgrounds/bggame.jpg');
    background-size: cover;
    background-position: center;
    position: relative;
}

.bg-preview.galaxy-bg {
    background-image: url('assets/backgrounds/Purple and Pink Pixel Retro Nostalgia Fever Fandom Game Presentation.jpg');
    background-size: cover;
    background-position: center;
}

.bg-preview.nebula-bg {
    background-image: url('assets/backgrounds/Purple and Pink Pixel Retro Nostalgia Fever Fandom Game Presentation (1).jpg');
    background-size: cover;
    background-position: center;
}

.bg-preview.cosmos-bg {
    background-image: url('assets/backgrounds/Purple and Pink Pixel Retro Nostalgia Fever Fandom Game Presentation (2).jpg');
    background-size: cover;
    background-position: center;
}

.start-btn {
    padding: 15px 50px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Game Screen */
#gameScreen {
    background: #000;
    position: relative;
}

#gameScreen.space-theme {
    background-image: url('assets/backgrounds/bggame.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

#gameScreen.galaxy-theme {
    background-image: url('assets/backgrounds/Purple and Pink Pixel Retro Nostalgia Fever Fandom Game Presentation.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

#gameScreen.nebula-theme {
    background-image: url('assets/backgrounds/Purple and Pink Pixel Retro Nostalgia Fever Fandom Game Presentation (1).jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

#gameScreen.cosmos-theme {
    background-image: url('assets/backgrounds/Purple and Pink Pixel Retro Nostalgia Fever Fandom Game Presentation (2).jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.game-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-stats {
    display: flex;
    gap: 30px;
    color: white;
    font-size: 18px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 15px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.stat-label {
    font-weight: bold;
    color: #ffd700;
}

.lives-container {
    display: flex;
    gap: 5px;
}

.heart {
    width: 25px;
    height: 25px;
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.control-btn {
    padding: 10px 25px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
    display: block;
    background: transparent;
}

.controls-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

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

.modal-content h2, .modal-content h3 {
    color: #2a5298;
    margin-bottom: 20px;
}

#questionText {
    font-size: 18px;
    margin: 20px 0;
    color: #333;
}

.answer-options {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

.answer-btn {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.answer-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.answer-btn.correct {
    background: linear-gradient(135deg, #00c851 0%, #00ff00 100%);
    animation: correctPulse 0.5s ease;
}

.answer-btn.incorrect {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.feedback {
    margin-top: 20px;
    font-size: 18px;
    font-weight: bold;
    padding: 10px;
    border-radius: 10px;
}

.feedback.correct {
    color: #00c851;
    background: rgba(0, 200, 81, 0.1);
}

.feedback.incorrect {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.restart-btn, .menu-btn {
    padding: 15px 40px;
    margin: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.restart-btn:hover, .menu-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

#finalScore, #starsInfo {
    font-size: 20px;
    margin: 15px 0;
    color: #333;
}

/* Star animation on game canvas */
@keyframes starFloat {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(180deg); }
    100% { transform: translateY(0) rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.8em;
    }
    
    .welcome-container, .customization-container {
        padding: 30px;
        margin: 20px;
    }
    
    .game-stats {
        flex-wrap: wrap;
        gap: 15px;
        font-size: 14px;
    }
    
    .character-options, .background-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls-hint {
        font-size: 12px;
        padding: 8px 15px;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Achievement Notification */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: -400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 2000;
    transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.achievement-notification.show {
    right: 20px;
}

.achievement-icon {
    font-size: 40px;
    animation: bounce 0.5s ease infinite alternate;
}

.achievement-title {
    font-size: 14px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-name {
    font-size: 18px;
    font-weight: bold;
    margin-top: 5px;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

/* Dash cooldown indicator */
.dash-indicator {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #00FFFF;
}

.dash-indicator.ready {
    animation: pulse-dash 1s ease-in-out infinite;
}

@keyframes pulse-dash {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(0, 255, 255, 0.7);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(0, 255, 255, 0);
        transform: scale(1.05);
    }
}

/* Power-up active effect */
.power-up-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.power-up-glow.shield {
    box-shadow: inset 0 0 50px rgba(79, 195, 247, 0.3);
    animation: shield-pulse 2s ease-in-out infinite;
}

.power-up-glow.speed {
    box-shadow: inset 0 0 50px rgba(255, 215, 0, 0.3);
    animation: speed-lines 0.5s linear infinite;
}

@keyframes shield-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

@keyframes speed-lines {
    from { background-position: 0 0; }
    to { background-position: 100px 0; }
}

/* Question Enhancements */
.question-timer {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    animation: pulse 1s ease-in-out infinite;
}

.question-category {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.obligatory-notice {
    background: #ff6b6b;
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 20px;
    font-weight: bold;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Music Selection Screen */
.music-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 30px;
    margin: 30px 0;
    max-width: 100%;
}

.music-option {
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid transparent;
    border-radius: 20px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 180px;
    max-width: 200px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.music-option:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 1);
}

.music-option.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.15);
    transform: translateY(-8px) scale(1.08);
    box-shadow: 0 20px 50px rgba(102, 126, 234, 0.3);
}

.music-option.selected::before {
    content: "✓";
    position: absolute;
    top: -10px;
    right: -10px;
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    animation: checkmark 0.3s ease;
}

@keyframes checkmark {
    from {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.music-preview {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
}

.music-preview::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.1) 75%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.music-icon {
    font-size: 35px;
    z-index: 1;
    position: relative;
    animation: musicPulse 2s ease-in-out infinite;
}

@keyframes musicPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.music-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.music-title {
    font-size: 18px;
    font-weight: bold;
    color: #2a5298;
    margin-bottom: 5px;
}

.music-desc {
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Center all buttons properly */
.customization-container h2 {
    text-align: center;
    margin-bottom: 10px;
}

.customization-container p {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.character-options, .background-options, .music-options {
    justify-content: center;
}

/* Improve responsive design for music selection */
@media (max-width: 768px) {
    .music-options {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .music-option {
        min-width: 250px;
        max-width: 280px;
    }
    
    .character-options, .background-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .music-options {
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .character-options, .background-options {
        grid-template-columns: 1fr 1fr;
    }
    
    .music-option {
        min-width: 200px;
        max-width: 220px;
    }
}
