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

body {
    font-family: "Arial", "Helvetica", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #ffd700 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    direction: rtl;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.stars {
    position: fixed;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 0;
}

.stars::before, .stars::after {
    content: "";
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    box-shadow: 
        100px 200px white, 300px 100px white, 500px 300px white,
        700px 150px white, 200px 400px white, 600px 500px white,
        150px 50px white, 450px 250px white, 550px 400px white,
        800px 300px white, 350px 450px white, 650px 150px white;
    animation: twinkle 3s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    animation: bounceIn 1s ease;
}

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

.rainbow-text {
    font-size: 3em;
    background: linear-gradient(90deg, #ff00ff, #ff69b4, #ffb6c1, #ffc0cb, #ff1493);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbowShine 3s linear infinite;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

@keyframes rainbowShine {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.subtitle {
    font-size: 1.5em;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.credits {
    color: white;
    font-size: 1em;
    margin-top: 10px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.credits strong {
    color: #ffd700;
    font-size: 1.1em;
}

.version {
    color: white;
    font-size: 0.9em;
    margin-top: 10px;
    opacity: 0.7;
}

.game-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 12px 25px;
    font-size: 1.1em;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #ff69b4, #ff1493);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
}

.nav-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 105, 180, 0.6);
}

.nav-btn.active {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
}

.game-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    animation: slideIn 0.5s ease;
}

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

h2 {
    text-align: center;
    color: #ff1493;
    font-size: 2em;
    margin-bottom: 20px;
}

.game-instructions {
    text-align: center;
    color: #666;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.piano {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: 200px;
    position: relative;
    margin: 20px 0;
    overflow-x: auto;
}

.key {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    font-weight: bold;
    font-size: 0.9em;
}

.key.white {
    width: 60px;
    height: 180px;
    background: linear-gradient(to top, #ffffff, #f0f0f0);
    border: 2px solid #333;
    border-radius: 8px 8px 0 0;
    color: #333;
    z-index: 1;
}

.key.black {
    width: 40px;
    height: 120px;
    background: linear-gradient(to top, #000, #333);
    border: 2px solid #000;
    border-radius: 5px 5px 0 0;
    color: white;
    margin-left: -20px;
    margin-right: -20px;
    z-index: 2;
    font-size: 0.7em;
}

.key:active,
.key.pressed {
    transform: scale(0.95);
}

.key.white:active,
.key.white.pressed {
    background: linear-gradient(to top, #ff69b4, #ffb6c1);
}

.key.black:active,
.key.black.pressed {
    background: linear-gradient(to top, #ff1493, #ff69b4);
}

.piano-hint {
    text-align: center;
    color: #666;
    margin-top: 15px;
    font-size: 1.1em;
}

.score-board, .rhythm-stats {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: linear-gradient(135deg, #ff69b4, #ff1493);
    border-radius: 15px;
    color: white;
    font-size: 1.2em;
    margin-bottom: 20px;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.memory-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #ffc0cb, #ffb6c1);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.memory-card .card-name {
    font-size: 0.3em;
    margin-top: 5px;
    font-weight: bold;
    color: #333;
}

.memory-card:hover:not(.flipped):not(.matched) {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(255, 105, 180, 0.5);
}

.memory-card.flipped, .memory-card.matched {
    background: white;
}

.memory-card.matched {
    animation: matchPulse 0.5s ease;
}

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

#rhythm-canvas {
    display: block;
    margin: 20px auto;
    background: #222;
    border-radius: 15px;
    max-width: 100%;
}

.rhythm-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.rhythm-btn {
    width: 80px;
    height: 80px;
    font-size: 2em;
    border: none;
    border-radius: 15px;
    background: linear-gradient(135deg, #ff69b4, #ff1493);
    color: white;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.rhythm-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.coloring-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.coloring-option {
    padding: 10px 20px;
    border: none;
    border-radius: 15px;
    background: linear-gradient(135deg, #9370db, #ba55d3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
}

.coloring-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(147, 112, 219, 0.5);
}

.color-palette {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.color-btn {
    width: 50px;
    height: 50px;
    border: 3px solid white;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.selected {
    border-color: #333;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

#coloring-canvas {
    display: block;
    margin: 20px auto;
    background: white;
    border-radius: 15px;
    cursor: crosshair;
    max-width: 100%;
    border: 3px solid #333;
}

.canvas-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.control-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.reset-btn {
    display: block;
    margin: 20px auto 0;
    padding: 15px 40px;
    font-size: 1.2em;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

footer {
    text-align: center;
    margin-top: 30px;
}

.footer-text {
    color: white;
    font-size: 1.3em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
    .rainbow-text {
        font-size: 2em;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .piano {
        transform: scale(0.8);
    }
    
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .memory-card {
        font-size: 2em;
    }
    
    #rhythm-canvas {
        width: 100%;
        height: auto;
    }
    
    .rhythm-btn {
        width: 60px;
        height: 60px;
        font-size: 1.5em;
    }
}

@media (min-width: 769px) {
    .desktop-only {
        display: flex !important;
    }
}