/* ==========================================
   1. REGULAR & LAYOUT UTAMA
   ========================================== */
body {
    margin: 0;
    padding: 0;
    background-color: #222;
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    color: white;
}

#game-container {
    position: relative;
    width: 95vmin; 
    height: 95vmin; /* Samakan agar kotak sempurna 1:1 */
    max-width: 800px; 
    max-height: 800px;
    margin: auto;
    background: #000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    touch-action: none;
    border: 2px solid #444;
}

#gameCanvas, canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ==========================================
   2. TIAP SCREEN / LAYAR (UI OVERLAY)
   ========================================== */
/* Gabungkan pengaturan untuk semua layar menu */
#ui-menu, #ui-gameover, #ui-selection {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30; /* Pastikan lebih tinggi dari canvas dan stats */
    box-sizing: border-box;
    overflow: hidden;
}

/* Lapisan Khusus Background Animasi pada UI Menu */
#ui-menu {
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}

#ui-menu::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: linear-gradient(rgba(0, 0, 100, 0.6), rgba(0, 0, 100, 0.6)), 
                      url('assets/doraemon_bg.png');
    background-size: cover;
    background-position: center;
    animation: slowZoom 15s infinite alternate ease-in-out;
    z-index: -1;
}

@keyframes slowZoom {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* ==========================================
   3. ELEMEN FORM & PILIHAN KARAKTER
   ========================================== */
.game-title {
    width: 100%;
    text-align: center;
    font-size: 2rem;
    color: #3498db;
    text-shadow: 2px 2px 0px #fff;
    margin-top: 10px;
    margin-bottom: 20px;
    display: block;
}

label {
    font-size: 12px;
    display: block;
    margin-bottom: 3px;
    color: #eee;
}

.level-select {
    display: flex;
    gap: 10px;
    width: 90%;
    max-width: 300px;
    margin: 5px auto;
}

.setting-item {
    flex: 1;
    text-align: left;
}

input#player-name, 
.setting-item select {
    width: 100%;
    padding: 8px;
    font-size: 14px;
    border-radius: 5px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

input#player-name {
    max-width: 300px;
    margin-bottom: 5px;
}

.character-selection {
    margin-top: 5px;
    margin-bottom: 10px;
    text-align: center;
}

.character-selection p {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 14px;
}

.char-options {
    display: flex;
    gap: 5px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px;
    border-radius: 5px;
}

.char-icon {
    width: 40px;
    height: 40px;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 50%;
    transition: transform 0.2s, border-color 0.2s;
    background: white;
}

.char-icon:hover { transform: scale(1.1); }
.char-icon.active {
    border-color: #ffca28;
    box-shadow: 0 0 10px #ffca28;
}

/* ==========================================
   4. STYLING SEMUA TOMBOL (BUTTON & LINK <a>)
   ========================================== */
/* Styling Umum Tombol di Layar Menu & Game Over */
#ui-menu button, 
#ui-selection button,
#ui-menu .btn-secondary,
#ui-gameover button,
#ui-gameover .btn-secondary {
    width: 90%;
    max-width: 300px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: bold;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin: 5px 0;
    transition: transform 0.2s, background 0.2s;
    display: block;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
}

/* Tombol Utama (Mulai / Main Lagi) */
#start-btn, #restart-btn {
    background-color: #2ecc71; /* Hijau */
    color: white;
    box-shadow: 0 4px 0 #27ae60;
}

#start-btn:active, #restart-btn:active, #go-to-selection:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #27ae60;
}

/* Tombol Sekunder (Papan Skor) */
.secondary-btn, #show-lb-btn {
    background-color: #3498db; /* Biru */
    color: white;
    box-shadow: 0 4px 0 #2980b9;
}

.secondary-btn:active, #show-lb-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #2980b9;
}

/* Tombol Khusus Menu Utama (Oranye / Kembali) */
.btn-secondary, #back-to-home {
    background-color: #e67e22 !important; /* Oranye */
    color: white !important;
    box-shadow: 0 4px 0 #d35400 !important;
}

.btn-secondary:active, #back-to-home:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #d35400 !important;
}

/* ==========================================
   5. IN-GAME STATS & HUD
   ========================================== */
#game-stats {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 5px;
    pointer-events: none;
    z-index: 5;
}

#current-question {
    font-size: 24px;
    font-weight: bold;
    color: #ffff00;
    margin-top: 10px;
}

/* ==========================================
   6. LAYAR GAME OVER & LEADERBOARD
   ========================================== */
#ui-gameover {
    background: rgba(0, 0, 0, 0.85);
    text-align: center;
    color: white;
}

#over-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.result-box {
    background: white;
    color: #333;
    padding: 10px 15px;
    border-radius: 15px;
    width: 75%;
    max-width: 280px;
    margin-bottom: 10px;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.4);
}

#res-score {
    font-size: 2rem;
    margin: 5px 0;
    color: #2ecc71;
}

#res-category {
    background: #f1c40f;
    font-size: 0.9rem;
    display: inline-block;
    padding: 3px 12px;
    border-radius: 50px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#res-message {
    font-size: 13px;
    margin: 5px 0;
}

/* Overlay untuk Leaderboard */
#leaderboard-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#leaderboard-content {
    background: white;
    color: #333;
    padding: 20px;
    border-radius: 15px;
    width: 85%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

#close-lb-btn {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

#leaderboard-table th, #leaderboard-table td {
    border-bottom: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

/* ==========================================
   7. MEDIA QUERIES (MOBILE RESPONSIVE)
   ========================================== */
@media screen and (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }
}