/* =============== LEVEL SELECTION SCREEN - KIDS FRIENDLY =============== */
#levelScreen {
    background: white; /* Ubah background menjadi putih */
    color: #333; /* Ubah warna teks untuk kontras dengan background putih */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Hapus animated background sebelumnya karena background putih */
#levelScreen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(200, 200, 200, 0.1) 0%, transparent 30%), /* Ubah menjadi abu-abu ringan */
        radial-gradient(circle at 90% 30%, rgba(200, 200, 200, 0.08) 0%, transparent 30%),
        radial-gradient(circle at 20% 80%, rgba(200, 200, 200, 0.05) 0%, transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(200, 200, 200, 0.05) 0%, transparent 30%);
    animation: bgFloat 15s infinite alternate ease-in-out;
    pointer-events: none;
}

@keyframes bgFloat {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(20px, 10px) scale(1.05);
    }
}

/* HEADER */
.level-header {
    text-align: center;
    padding: 20px 25px 15px;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    background: linear-gradient(145deg, #4D96FF, #6BCBFF);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid rgba(0, 0, 0, 0.1); /* Ubah border menjadi gelap */
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.05);
}

.level-header h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 900;
    margin-bottom: 8px;
    background: white;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none; /* Hapus text shadow */
    letter-spacing: -0.5px;
    animation: titleGlow 3s infinite alternate ease-in-out;
}

@keyframes titleGlow {
    0% {
        filter: drop-shadow(0 2px 5px rgba(255, 107, 107, 0.3));
    }
    50% {
        filter: drop-shadow(0 2px 8px rgba(255, 217, 61, 0.4));
    }
    100% {
        filter: drop-shadow(0 2px 5px rgba(107, 207, 127, 0.3));
    }
}

/* LEVELS CONTAINER */
.levels-container {
    flex: 1;
    padding: 20px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 15px;
    flex: 1;
    min-height: 0;
}

/* LEVEL CARDS - COLORFUL & FUN */
.level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 20px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 4px solid transparent;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.1),
        inset 0 0 0 2px rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    animation: cardFloat 3s infinite ease-in-out;
    animation-delay: calc(var(--card-index, 0) * 0.1s);
}

/* Different colors for each level */
.level-card:nth-child(1) { 
    background: linear-gradient(145deg, #FF6B6B, #FF8E8E);
    border-color: rgba(255, 107, 107, 0.6);
    --card-index: 1;
}
.level-card:nth-child(2) { 
    background: linear-gradient(145deg, #FFD93D, #FFE566);
    border-color: rgba(255, 217, 61, 0.6);
    --card-index: 2;
}
.level-card:nth-child(3) { 
    background: linear-gradient(145deg, #6BCF7F, #8DE99E);
    border-color: rgba(107, 207, 127, 0.6);
    --card-index: 3;
}
.level-card:nth-child(4) { 
    background: linear-gradient(145deg, #4D96FF, #6BCBFF);
    border-color: rgba(77, 150, 255, 0.6);
    --card-index: 4;
}
.level-card:nth-child(5) { 
    background: linear-gradient(145deg, #9D4BFF, #B88CFF);
    border-color: rgba(157, 75, 255, 0.6);
    --card-index: 5;
}
.level-card:nth-child(6) { 
    background: linear-gradient(145deg, #FF6B9D, #FF8EBB);
    border-color: rgba(255, 107, 157, 0.6);
    --card-index: 6;
}
.level-card:nth-child(7) { 
    background: linear-gradient(145deg, #FFB347, #FFCC66);
    border-color: rgba(255, 179, 71, 0.6);
    --card-index: 7;
}
.level-card:nth-child(8) { 
    background: linear-gradient(145deg, #00D4AA, #5CE6C4);
    border-color: rgba(0, 212, 170, 0.6);
    --card-index: 8;
}
.level-card:nth-child(9) { 
    background: linear-gradient(145deg, #667eea, #8A9CFF);
    border-color: rgba(102, 126, 234, 0.6);
    --card-index: 9;
}
.level-card:nth-child(10) { 
    background: linear-gradient(145deg, #FF6B6B, #FFD93D, #6BCF7F);
    border-color: rgba(255, 107, 107, 0.6);
    --card-index: 10;
}

@keyframes cardFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Ganti efek hover - lebih sederhana */
.level-card:hover {
    transform: translateY(-10px) scale(1.05) rotate(1deg);
    color: #000000 !important;
    text-shadow: 
        1px 1px 0 #FFFFFF,
        -1px -1px 0 #FFFFFF,
        1px -1px 0 #FFFFFF,
        -1px 1px 0 #FFFFFF,
        0 0 20px var(--card-glow-color, rgba(255, 217, 61, 0.7)) !important;
    font-weight: 900 !important;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.3),
        0 0 40px var(--card-glow-color, rgba(255, 255, 255, 0.4)),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
    z-index: 100;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: brightness(1.1) contrast(1.05);
}

/* Selected Level */
.level-card.selected {
    border: 3px solid #4D96FF;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.3),
        0 0 30px rgba(77, 150, 255, 0.4);
    transform: scale(1.12);
    z-index: 200;
    transition: all 0.3s ease;
}

@keyframes selectedBounce {
    0%, 100% {
        transform: translateY(-5px) scale(1.04);
    }
    50% {
        transform: translateY(-8px) scale(1.04);
    }
}

/* Level Number */
.level-number {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 900;
    color: white;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 2px;
}

/* Level Range */
.level-range {
    font-size: clamp(0.8rem, 1.8vw, 1rem);
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* FOOTER - BACK BUTTON CENTERED */
.level-footer {
    flex-shrink: 0;
    padding: 15px 25px 20px;
    position: relative;
    z-index: 2;
    text-align: center;
    background: white; /* Ubah menjadi putih */
    border-top: 3px solid rgba(0, 0, 0, 0.1); /* Ubah border menjadi gelap */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    min-height: 80px; /* Tambah tinggi minimal untuk footer */
}

/* Back Button - Simple and Clean */
.back-button {
    background: linear-gradient(45deg, 
        rgba(255, 107, 107, 0.95), 
        rgba(255, 217, 61, 0.95));
    border: 3px solid rgba(0, 0, 0, 0.1);
    color: white;
    padding: 12px 35px;
    border-radius: 25px;
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 
        0 6px 15px rgba(0, 0, 0, 0.1);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    position: relative;
    overflow: hidden;
}

.back-button::before {
    content: '←';
    font-size: 1.3rem;
    font-weight: 800;
}

.back-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent);
    transition: 0.5s;
}

/* Ganti efek hover back button */
.back-button:hover {
    background: linear-gradient(45deg, 
        rgba(255, 107, 107, 1), 
        rgba(255, 217, 61, 1));
    transform: translateY(-3px);
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.2);
}

.back-button:hover::after {
    left: 100%;
}

.back-button:active {
    transform: translateY(-1px);
}

/* Untuk 5 level */
.levels-grid.five-levels {
    grid-template-columns: repeat(5, 1fr);
    max-width: 800px;
    margin: 0 auto;
    gap: 15px;
}

/* Untuk 10 level */
.levels-grid.ten-levels {
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .levels-grid.five-levels {
        grid-template-columns: repeat(3, 1fr);
        max-width: 500px;
    }
    
    .levels-grid.ten-levels {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .levels-grid.five-levels {
        grid-template-columns: repeat(2, 1fr);
        max-width: 300px;
    }
    
    .levels-grid.ten-levels {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =============== RESPONSIVE LEVEL SCREEN =============== */

/* Tablet */
@media (max-width: 1024px) {
    .level-header {
        padding: 15px 20px 10px;
    }
    
    .levels-container {
        padding: 15px;
    }
    
    .levels-grid {
        gap: 12px;
    }
    
    .level-card {
        padding: 18px 12px;
        border-radius: 18px;
    }
    
    .level-footer {
        padding: 12px 20px 15px;
    }
    
    .back-button {
        padding: 10px 30px;
        min-width: 160px;
    }
}

/* Mobile Portrait */
@media (max-width: 768px) {
    .level-header {
        padding: 12px 15px 8px;
    }
    
    .level-header h2 {
        font-size: 1.6rem;
    }
    
    .levels-container {
        padding: 12px;
    }
    
    .levels-grid {
        gap: 10px;
    }
    
    .level-card {
        padding: 15px 10px;
        border-radius: 16px;
        gap: 6px;
    }
    
    .level-number {
        font-size: 1.4rem;
    }
    
    .level-range {
        font-size: 0.85rem;
        padding: 3px 8px;
    }
    
    .level-footer {
        padding: 10px 15px 12px;
        min-height: 70px;
    }
    
    .back-button {
        padding: 10px 25px;
        min-width: 150px;
        font-size: 1rem;
    }
}

/* Mobile Landscape */
@media (max-width: 768px) and (orientation: landscape) {
    .level-header {
        padding: 10px 12px 6px;
    }
    
    .level-header h2 {
        font-size: 1.4rem;
    }
    
    .levels-container {
        padding: 8px;
    }
    
    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
        gap: 8px;
    }
    
    .level-card {
        padding: 10px 8px;
        gap: 4px;
    }
    
    .level-number {
        font-size: 1.2rem;
    }
    
    .level-range {
        font-size: 0.75rem;
    }
    
    .level-footer {
        padding: 8px 12px 10px;
        min-height: 60px;
    }
    
    .back-button {
        padding: 8px 20px;
        min-width: 140px;
        font-size: 0.9rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .levels-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(5, 1fr);
        gap: 8px;
    }
    
    .level-card {
        padding: 12px 8px;
        border-radius: 14px;
    }
    
    .back-button {
        padding: 10px 20px;
        min-width: 140px;
        font-size: 0.95rem;
    }
}

/* Very Small Height */
@media (max-height: 600px) {
    .level-header {
        padding: 10px 15px 6px;
    }
    
    .levels-container {
        padding: 8px;
    }
    
    .levels-grid {
        gap: 6px;
    }
    
    .level-card {
        padding: 10px 6px;
        gap: 4px;
    }
    
    .level-footer {
        padding: 8px 15px 10px;
        min-height: 60px;
    }
    
    .back-button {
        padding: 8px 20px;
        min-width: 130px;
        font-size: 0.9rem;
    }
}

/* Loading Animation for Cards */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.level-card {
    animation: fadeInUp 0.5s ease forwards, cardFloat 3s infinite ease-in-out;
    animation-delay: calc(var(--card-index, 0) * 0.05s), calc(var(--card-index, 0) * 0.1s);
    opacity: 0;
}