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

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', cursive;
    background: linear-gradient(135deg, #0c1445 0%, #1a237e 50%, #283593 100%);
    color: white;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none;
}

/* Main Menu Styles */
.menu-container {
    text-align: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 3;
}

.game-title {
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    color: #ffd700;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.menu-button {
    padding: 1rem 2rem;
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.play-button {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.play-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

.customize-button {
    background: linear-gradient(45deg, #FF9800, #F57C00);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4);
}

.customize-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.6);
}

.options-button {
    background: linear-gradient(45deg, #9C27B0, #7B1FA2);
    color: white;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.4);
}

.options-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.6);
}

/* Game Screen Styles */
.game-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.shield-meter, .star-shards {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.shield-label, .shards-label {
    font-size: 1rem;
    margin-bottom: 5px;
    color: #ffd700;
}

.shield-hearts {
    display: flex;
    gap: 5px;
}

.heart {
    font-size: 1.5rem;
}

.shards-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
}

.game-speed, .star-shards, .shield-meter {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.speed-label {
    font-size: 1rem;
    margin-bottom: 5px;
    color: #ffd700;
}

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

.speed-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #FFD700, #FF5722);
    border-radius: 4px;
    width: 10%;
    transition: width 0.3s ease;
}

#game-canvas {
    border-radius: 10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #000428 0%, #004e92 100%);
}

.input-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.math-problem {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    min-width: 200px;
}

.answer-input {
    font-size: 2rem;
    padding: 0.5rem 1rem;
    text-align: center;
    border: 3px solid #ffd700;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    width: 150px;
    font-family: 'Comic Sans MS', monospace;
}

.answer-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

/* Boutique Screen Styles */
.boutique-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.boutique-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #ffd700;
    font-size: 2rem;
}

.boutique-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.boutique-tab {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.boutique-tab.active {
    background: #ffd700;
    color: #333;
}

.boutique-tab:hover {
    background: rgba(255, 255, 255, 0.3);
}

.boutique-content {
    min-height: 200px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Boutique Screen Styles */
.boutique-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 2;
}

/* Dynamic background scenes for shop */
.boutique-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.boutique-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(0, 4, 40, 0.8) 0%, rgba(0, 78, 146, 0.8) 100%);
    animation: nebulaShift 20s ease-in-out infinite alternate;
}

@keyframes nebulaShift {
    0% { filter: hue-rotate(0deg) brightness(1); }
    50% { filter: hue-rotate(30deg) brightness(1.1); }
    100% { filter: hue-rotate(60deg) brightness(0.9); }
}

/* Floating planets in shop background */
.shop-planet {
    position: absolute;
    border-radius: 50%;
    animation: float 15s ease-in-out infinite;
    filter: blur(0.5px);
}

.shop-planet:nth-child(1) {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, #8B4513, #654321);
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.shop-planet:nth-child(2) {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #2E8B57, #228B22);
    top: 60%;
    right: 15%;
    animation-delay: 3s;
}

.shop-planet:nth-child(3) {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #4682B4, #1e90ff);
    bottom: 20%;
    left: 20%;
    animation-delay: 6s;
}

.shop-planet:nth-child(4) {
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, #DC143C, #B22222);
    top: 30%;
    right: 30%;
    animation-delay: 9s;
}

.shop-planet:nth-child(5) {
    width: 70px;
    height: 70px;
    background: radial-gradient(circle, #9932CC, #8A2BE2);
    bottom: 40%;
    right: 40%;
    animation-delay: 12s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(90deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
    75% { transform: translateY(-10px) rotate(270deg); }
}

/* Twinkling stars in shop */
.shop-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.shop-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 4s ease-in-out infinite;
}

.shop-star:nth-child(1) { top: 15%; left: 25%; animation-delay: 0s; }
.shop-star:nth-child(2) { top: 35%; left: 75%; animation-delay: 1s; }
.shop-star:nth-child(3) { top: 55%; left: 15%; animation-delay: 2s; }
.shop-star:nth-child(4) { top: 75%; left: 85%; animation-delay: 3s; }
.shop-star:nth-child(5) { top: 25%; left: 60%; animation-delay: 0.5s; }
.shop-star:nth-child(6) { top: 45%; left: 35%; animation-delay: 1.5s; }
.shop-star:nth-child(7) { top: 65%; left: 55%; animation-delay: 2.5s; }
.shop-star:nth-child(8) { top: 85%; left: 10%; animation-delay: 3.5s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.5); }
}

.boutique-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.boutique-header h2 {
    color: #ffd700;
    font-size: 2rem;
    margin: 0;
}

.currency-display {
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.currency-icon {
    font-size: 1.2rem;
}

.currency-amount {
    font-size: 1.3rem;
    font-weight: bold;
    color: #ffd700;
}

.currency-label {
    font-size: 0.9rem;
    color: #ccc;
}

.boutique-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.boutique-tab {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    min-width: 120px;
}

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

.boutique-tab.active {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    border-color: #4CAF50;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.boutique-content {
    margin-bottom: 2rem;
}

.shop-category {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.shop-category.hidden {
    display: none;
}

.shop-item {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.shop-item:hover {
    transform: scale(1.05);
    border-color: #ffd700;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
}

.shop-item.purchased {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
}

.shop-item.equipped {
    background: rgba(255, 152, 0, 0.2);
    border-color: #FF9800;
}

.item-preview {
    font-size: 3rem;
    margin-bottom: 1rem;
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-name {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: white;
}

.item-price {
    font-size: 1rem;
    color: #ffd700;
    margin-bottom: 1rem;
    font-weight: bold;
}

.purchase-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.purchase-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.purchase-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
    opacity: 0.6;
}

.purchase-btn.equip-btn {
    background: linear-gradient(45deg, #FF9800, #F57C00);
}

.purchase-btn.owned-btn {
    background: linear-gradient(45deg, #9C27B0, #7B1FA2);
}

/* Options Screen Styles */
.options-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    max-width: 400px;
    width: 90%;
}

.options-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #ffd700;
}

.option-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-item label {
    font-size: 1.2rem;
    font-weight: bold;
}

#volume-slider {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    -webkit-appearance: none;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #ffd700;
    cursor: pointer;
}

.back-button {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Boutique back button positioned outside scroll area */
.boutique-back-button {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: linear-gradient(45deg, #9C27B0, #7B1FA2);
    border-color: #9C27B0;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.4);
    font-weight: bold;
}

.boutique-back-button:hover {
    background: linear-gradient(45deg, #AD42C5, #8E24AA);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.6);
    transform: translateX(-50%) scale(1.05);
}

/* Responsive Design */
/* Main Menu Background Effects */
.menu-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0, 4, 40, 0.9) 0%, rgba(0, 78, 146, 0.9) 100%);
}

.menu-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.menu-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    animation: menuTwinkle 6s ease-in-out infinite;
}

.menu-star:nth-child(1) { top: 20%; left: 15%; animation-delay: 0s; }
.menu-star:nth-child(2) { top: 30%; left: 80%; animation-delay: 1s; }
.menu-star:nth-child(3) { top: 50%; left: 10%; animation-delay: 2s; }
.menu-star:nth-child(4) { top: 70%; left: 90%; animation-delay: 3s; }
.menu-star:nth-child(5) { top: 15%; left: 60%; animation-delay: 0.5s; }
.menu-star:nth-child(6) { top: 85%; left: 40%; animation-delay: 1.5s; }
.menu-star:nth-child(7) { top: 40%; left: 30%; animation-delay: 2.5s; }
.menu-star:nth-child(8) { top: 60%; left: 70%; animation-delay: 3.5s; }
.menu-star:nth-child(9) { top: 25%; left: 45%; animation-delay: 4s; }
.menu-star:nth-child(10) { top: 75%; left: 25%; animation-delay: 4.5s; }

@keyframes menuTwinkle {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.8); }
}

/* Floating particles in main menu */
.menu-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.menu-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: menuFloat 12s ease-in-out infinite;
}

.menu-particle:nth-child(1) {
    top: 40%;
    left: 20%;
    animation-delay: 0s;
    background: rgba(255, 215, 0, 0.8);
}

.menu-particle:nth-child(2) {
    top: 60%;
    left: 75%;
    animation-delay: 3s;
    background: rgba(138, 43, 226, 0.6);
}

.menu-particle:nth-child(3) {
    top: 25%;
    left: 50%;
    animation-delay: 6s;
    background: rgba(30, 144, 255, 0.7);
}

.menu-particle:nth-child(4) {
    top: 80%;
    left: 30%;
    animation-delay: 9s;
    background: rgba(255, 20, 147, 0.6);
}

@keyframes menuFloat {
    0%, 100% {
        transform: translateY(0px) translateX(0px) rotate(0deg);
        opacity: 0.3;
    }
    25% {
        transform: translateY(-20px) translateX(10px) rotate(90deg);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-40px) translateX(-10px) rotate(180deg);
        opacity: 0.5;
    }
    75% {
        transform: translateY(-20px) translateX(-5px) rotate(270deg);
        opacity: 0.7;
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }

    .menu-button {
        font-size: 1.2rem;
        padding: 0.75rem 1.5rem;
    }

    .math-problem {
        font-size: 2rem;
    }

    .answer-input {
        font-size: 1.5rem;
    }

    .boutique-tabs {
        flex-direction: column;
        align-items: center;
    }
}
