/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #ffd6e7 0%, #e2f0ff 100%);
    color: #5a5a5a;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffb6c1' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffd6e7 0%, #c1e1ff 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.8s ease;
}

.loading-screen.active {
    opacity: 1;
    visibility: visible;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
}

.loading-heart {
    font-size: 4rem;
    color: #ff6b9d;
    margin-bottom: 1.5rem;
    animation: heartbeat 1.5s infinite ease-in-out;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.loading-title {
    font-family: 'Dancing Script', cursive;
    font-size: 3.5rem;
    color: #ff6b9d;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.loading-subtitle {
    font-size: 1.2rem;
    color: #8a6fa8;
    margin-bottom: 2rem;
}

.loading-bar {
    width: 100%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff9ec0, #8a6fa8);
    border-radius: 10px;
    animation: loading 3s ease-in-out forwards;
}

@keyframes loading {
    0% { width: 0%; }
    100% { width: 100%; }
}

.loading-sparkles span {
    display: inline-block;
    font-size: 2rem;
    margin: 0 0.5rem;
    animation: sparkle 2s infinite ease-in-out;
}

.loading-sparkles span:nth-child(2) { animation-delay: 0.2s; }
.loading-sparkles span:nth-child(3) { animation-delay: 0.4s; }
.loading-sparkles span:nth-child(4) { animation-delay: 0.6s; }
.loading-sparkles span:nth-child(5) { animation-delay: 0.8s; }

@keyframes sparkle {
    0%, 100% { opacity: 0.3; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Game Container */
.game-container {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    transition: opacity 0.5s ease;
}

.game-container.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
}

.game-title {
    font-family: 'Dancing Script', cursive;
    font-size: 2.2rem;
    color: #ff6b9d;
    margin-right: 2rem;
}

.game-title i {
    margin-right: 0.5rem;
}

.level-info {
    background: linear-gradient(135deg, #ff9ec0, #8a6fa8);
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(138, 111, 168, 0.3);
}

.level-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.level-number {
    font-size: 1.5rem;
    margin: 0 0.3rem;
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.stat-item {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.stat-item i {
    color: #ff6b9d;
    margin-right: 0.5rem;
    font-size: 1.2rem;
}

.stat-item span {
    font-weight: 700;
    font-size: 1.2rem;
    color: #8a6fa8;
}

/* Game Main */
.game-main {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.game-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

.level-category {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(135deg, #c1e1ff, #ffd6e7);
    border-radius: 50px;
    font-weight: 700;
    color: #8a6fa8;
    margin-bottom: 0.5rem;
}

.game-instructions p {
    font-size: 1.1rem;
    color: #8a6fa8;
}

.game-instructions i {
    color: #ff6b9d;
    margin-left: 0.3rem;
}

/* Game Board */
.game-board {
    display: grid;
    grid-gap: 0.8rem;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 1rem;
}

/* Grid configuration for different levels */
.grid-4 { grid-template-columns: repeat(2, 1fr); max-width: 400px; margin: 0 auto; }
.grid-6 { grid-template-columns: repeat(3, 1fr); max-width: 500px; margin: 0 auto; }
.grid-8 { grid-template-columns: repeat(4, 1fr); max-width: 600px; margin: 0 auto; }
.grid-12 { grid-template-columns: repeat(4, 1fr); max-width: 700px; margin: 0 auto; }
.grid-16 { grid-template-columns: repeat(4, 1fr); max-width: 700px; margin: 0 auto; }
.grid-20 { grid-template-columns: repeat(5, 1fr); max-width: 800px; margin: 0 auto; }
.grid-24 { grid-template-columns: repeat(6, 1fr); max-width: 900px; margin: 0 auto; }

.card {
    aspect-ratio: 1/1;
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    transform: rotateY(180deg);
    cursor: default;
    box-shadow: 0 0 15px rgba(255, 107, 157, 0.5);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
}

.card-back {
    background: linear-gradient(135deg, #ff9ec0, #8a6fa8);
    color: white;
}

.card-front {
    background: white;
    transform: rotateY(180deg);
    color: #ff6b9d;
    border: 3px solid #ffd6e7;
}

.card.matched .card-front {
    background: linear-gradient(135deg, #e7ffc1, #c1ffd6);
    border-color: #a8ffc1;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-control {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #ff9ec0, #8a6fa8);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 10px rgba(138, 111, 168, 0.3);
}

.btn-control:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(138, 111, 168, 0.4);
}

.btn-control:active {
    transform: translateY(0);
}

.btn-control:disabled, .btn-control.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Audio Controls */
.audio-controls {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.7rem 1rem;
    border-radius: 50px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.audio-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9ec0, #8a6fa8);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.audio-btn:hover {
    transform: scale(1.1);
}

.volume-slider-container {
    width: 100px;
}

#volume-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, #ff9ec0, #8a6fa8);
    border-radius: 3px;
    outline: none;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ff6b9d;
    cursor: pointer;
}

#volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ff6b9d;
    cursor: pointer;
}

/* Progress Controls */
.progress-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.progress-btn {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #c1e1ff, #ffd6e7);
    color: #8a6fa8;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.progress-btn:hover {
    background: linear-gradient(135deg, #a8d1ff, #ffc1e7);
    transform: translateY(-2px);
}

/* Win Popup */
.win-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.win-popup.active {
    opacity: 1;
    visibility: visible;
}

.win-content {
    background: linear-gradient(135deg, #ffd6e7, #c1e1ff);
    width: 90%;
    max-width: 500px;
    padding: 2.5rem;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.win-content::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 0;
    animation: float 20s linear infinite;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-5%, -5%) rotate(360deg); }
}

.win-content > * {
    position: relative;
    z-index: 1;
}

.win-icon {
    font-size: 4rem;
    color: #ff6b9d;
    margin-bottom: 1rem;
    animation: bounce 1s ease infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-15px); }
}

.win-title {
    font-family: 'Dancing Script', cursive;
    font-size: 2.8rem;
    color: #ff6b9d;
    margin-bottom: 0.5rem;
}

.win-level {
    font-size: 1.2rem;
    color: #8a6fa8;
    margin-bottom: 1.5rem;
}

.romantic-message {
    background-color: rgba(255, 255, 255, 0.7);
    padding: 1.5rem;
    border-radius: 15px;
    margin: 1.5rem 0;
    border-left: 5px solid #ff6b9d;
}

#romantic-text {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    color: #8a6fa8;
    line-height: 1.4;
}

.win-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem 0;
}

.win-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.win-stat i {
    font-size: 1.8rem;
    color: #ff6b9d;
    margin-bottom: 0.5rem;
}

.win-btn {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #ff9ec0, #8a6fa8);
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto;
    box-shadow: 0 6px 15px rgba(138, 111, 168, 0.4);
}

.win-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(138, 111, 168, 0.5);
}

/* Music Playlist */
.music-playlist {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffd6e7, #c1e1ff);
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.music-playlist.active {
    opacity: 1;
    visibility: visible;
}

.playlist-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(138, 111, 168, 0.2);
    flex-shrink: 0;
}

.playlist-header h3 {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    color: #ff6b9d;
    margin-bottom: 0.5rem;
}

.playlist-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#now-playing {
    font-size: 0.9rem;
    color: #8a6fa8;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.close-playlist {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #8a6fa8;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.2rem;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-playlist:hover {
    background-color: rgba(255, 107, 157, 0.1);
    color: #ff6b9d;
    transform: rotate(90deg);
}

/* Scrollable playlist container */
.playlist-scroll-container {
    flex: 1;
    overflow-y: auto;
    max-height: calc(80vh - 150px);
    padding: 0 1rem;
}

.playlist-content {
    padding: 0.5rem 0;
}

.playlist-item {
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.playlist-item:hover {
    background-color: rgba(255, 255, 255, 0.8);
    transform: translateX(5px);
}

.playlist-item.active {
    background-color: rgba(255, 107, 157, 0.2);
    border-left: 4px solid #ff6b9d;
}

.playlist-item.active::after {
    content: '';
    position: absolute;
    right: 1rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff6b9d;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.playlist-item i {
    margin-right: 1rem;
    color: #ff6b9d;
    font-size: 1.2rem;
    min-width: 20px;
}

.playlist-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item .duration {
    font-size: 0.8rem;
    color: #8a6fa8;
    margin-left: 1rem;
    opacity: 0.7;
}

.playlist-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(138, 111, 168, 0.2);
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
    background-color: rgba(255, 255, 255, 0.3);
}

.playlist-control-btn {
    flex: 1;
    padding: 0.7rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff9ec0, #8a6fa8);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.playlist-control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(138, 111, 168, 0.3);
}

.playlist-control-btn.active {
    background: linear-gradient(135deg, #ff6b9d, #6a4a8a);
    box-shadow: 0 4px 8px rgba(255, 107, 157, 0.3);
}

/* Custom scrollbar for playlist */
.playlist-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.playlist-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.playlist-scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #ff9ec0, #8a6fa8);
    border-radius: 3px;
}

.playlist-scroll-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #ff6b9d, #6a4a8a);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .header-left, .header-right {
        width: 100%;
        justify-content: center;
    }
    
    .game-title {
        font-size: 1.8rem;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .stats {
        gap: 1rem;
    }
    
    .stat-item {
        padding: 0.4rem 0.8rem;
    }
    
    .loading-title {
        font-size: 2.5rem;
    }
    
    .grid-20 { grid-template-columns: repeat(4, 1fr); }
    .grid-24 { grid-template-columns: repeat(4, 1fr); }
    
    .audio-controls {
        bottom: 1rem;
        right: 1rem;
        padding: 0.5rem 0.8rem;
    }
    
    .audio-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .volume-slider-container {
        width: 80px;
    }
    
    .win-content {
        padding: 1.5rem;
    }
    
    .win-title {
        font-size: 2.2rem;
    }
    
    #romantic-text {
        font-size: 1.5rem;
    }
    
    .win-stats {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .grid-12 { grid-template-columns: repeat(3, 1fr); }
    .grid-16 { grid-template-columns: repeat(4, 1fr); }
    .grid-20 { grid-template-columns: repeat(4, 1fr); }
    .grid-24 { grid-template-columns: repeat(4, 1fr); }
    
    .btn-control, .progress-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .loading-title {
        font-size: 2rem;
    }
    
    .loading-heart {
        font-size: 3rem;
    }
    
    .music-playlist {
        max-width: 95%;
        max-height: 85vh;
    }
    
    .playlist-scroll-container {
        max-height: calc(85vh - 150px);
    }
    
    .playlist-header {
        padding: 1rem;
    }
    
    .playlist-header h3 {
        font-size: 1.5rem;
    }
    
    .playlist-item {
        padding: 0.8rem;
    }
    
    .playlist-footer {
        padding: 0.8rem 1rem;
    }
}

/* Copyright Footer */
.copyright-footer {
    text-align: center;
    padding: 1.5rem;
    color: #8a6fa8;
    font-size: 0.9rem;
    margin-top: 2rem;
    position: relative;
    z-index: 1;
}

.copyright-footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ff9ec0, transparent);
}

.copyright-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

.copyright-content p {
    margin: 0.5rem 0;
}

.copyright-sub {
    font-style: italic;
    color: #ff6b9d;
    font-size: 0.85rem;
    margin: 0.8rem 0;
}

.copyright-version {
    font-size: 0.8rem;
    opacity: 0.7;
    color: #8a6fa8;
}

/* Responsive copyright */
@media (max-width: 768px) {
    .copyright-footer {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .copyright-sub {
        font-size: 0.75rem;
    }
    
    .copyright-version {
        font-size: 0.7rem;
    }
}