/* --- CSS: Gaya Global dan Warna --- */
:root {
    --color-red: #FF0000; 
    --color-white: #FFFFFF; 
    --color-black: #000000;
    --font-main: 'Futura', 'Arial', sans-serif;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-black); 
    color: var(--color-white); 
    margin: 0;
    padding: 0;
    /* --- OPTIMALISASI CENTERING BOX (Flexbox) --- */
    display: flex;
    justify-content: center; /* Pusat horizontal */
    align-items: center;     /* Pusat vertikal */
    min-height: 100vh;       /* Pastikan body setinggi viewport */
    width: 100vw;
}

/* Membuat semua teks *sangat tebal* (900) agar bisa dibaca! */
body, h1, p, span, button {
    font-weight: 900; 
}

.container {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid var(--color-red);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5); 
    width: 95%;
    max-width: 900px;
    text-align: center;
    /* Menggunakan height yang lebih kecil di awal agar centering vertikal bekerja */
    min-height: auto; 
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; 
    /* Hilangkan margin auto yang tidak perlu di sini karena sudah di-handle oleh body */
}

h1 {
    font-size: 2.5em;
    text-shadow: 2px 2px var(--color-red);
    margin-bottom: 20px;
}

/* --- Animasi Transisi Tampilan --- */
#initialSetup, #activeGameDisplay {
    width: 100%;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
    /* Menggunakan position:relative agar konten tetap pada alirannya,
       tetapi kita akan menggunakan class .setup-hidden/visible untuk animasi */
    position: relative; 
    top: auto; 
    left: auto;
    height: auto;
    display: flex; 
    flex-direction: column;
    justify-content: flex-start; /* Konten di dalam kotak mulai dari atas */
    align-items: center;
    padding: 0; /* Hilangkan padding tambahan di sini */
    box-sizing: border-box; 
    flex-shrink: 0; /* Mencegah elemen menyusut */
}

/* --- Perubahan untuk memastikan animasi tetap di tengah --- */

/* Atur z-index tinggi agar animasi perpindahan terlihat rapi */
#initialSetup {
    z-index: 2;
}
#activeGameDisplay {
    z-index: 1;
}

/* Status awal tersembunyi untuk #activeGameDisplay */
.game-display-hidden {
    opacity: 0;
    transform: translateY(20px); 
    pointer-events: none; 
    /* Karena kita menggunakan display:flex/none di JS, ini perlu disesuaikan */
    display: none !important; 
}

/* Status terlihat untuk #activeGameDisplay */
.game-display-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all; 
    z-index: 3;
    display: flex !important;
}

/* Untuk #initialSetup, saat menghilang */
.setup-hidden {
    opacity: 0;
    transform: translateY(-20px); 
    pointer-events: none;
}

/* --- Area Pengaturan Awal --- */
.time-options button.selected {
    background-color: var(--color-red) !important;
    border-color: var(--color-white) !important;
}

.score-container, .time-options {
    margin-bottom: 20px;
}

.time-options button, #startButton {
    background-color: var(--color-black);
    color: var(--color-white);
    border: 2px solid var(--color-red);
    padding: 10px 20px;
    margin: 5px;
    border-radius: 8px;
    cursor: pointer;
}

#startButton {
    background-color: var(--color-red);
    font-size: 1.5em;
    padding: 15px 40px;
}

/* --- Display Game Aktif --- */
#activeGameDisplay {
    /* Mengisi ruang kontainer saat aktif */
    flex-grow: 1; 
    justify-content: space-between; /* Untuk memisahkan header, area game, dan hasil akhir */
}

.header-panel {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 10px;
    padding-top: 20px;
}

.info-panel {
    margin: 0 5px;
    padding: 10px 15px;
    border-radius: 5px;
    background-color: #333;
    border: 2px solid var(--color-red);
    font-size: 1.1em;
}

/* --- Area Game --- */
#gameArea {
    flex-grow: 1; 
    width: 98%; 
    background-color: #1A1A1A; 
    border: 3px solid var(--color-red);
    border-radius: 10px;
    margin: 10px 0;
    position: relative;
    overflow: hidden; 
    cursor: crosshair;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px; 
}

/* --- Target Lingkaran Merah dan Animasi --- */
.target {
    position: absolute;
    width: 40px; height: 40px;
    background-color: var(--color-red);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px var(--color-red);
}

.target.hit { pointer-events: none; animation: explode-fade 0.3s ease-out forwards; }
@keyframes explode-fade {
    0% { opacity: 1; transform: scale(1); box-shadow: 0 0 10px var(--color-red); }
    100% { opacity: 0; transform: scale(2.5); box-shadow: 0 0 20px var(--color-red); }
}

/* --- Overlay Hitung Mundur --- */
#countdownOverlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none; 
    justify-content: center;
    align-items: center;
    z-index: 10;
}

#countdownText {
    font-size: 10em;
    color: var(--color-red);
    animation: countdown-pulse 1s infinite alternate;
}

/* --- Hasil Akhir dan Tombol Reset --- */
#finalResult {
    font-size: 2em;
    color: var(--color-red);
    margin-top: 20px;
}

#resetButton {
    background-color: var(--color-red);
    border: none;
    padding: 10px 20px;
    margin-top: 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    display: none; 
}