/* --- CSS Variables --- */
:root {
    --bg-color: #1a1a2e;
    --card-bg-color: rgba(255, 255, 255, 0.05);
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0c0;
    --accent-color-1: #e94560;
    --accent-color-2: #0f3460;
    --gradient: linear-gradient(135deg, var(--accent-color-1), var(--accent-color-2));
    --font-family: 'Poppins', sans-serif;
}

/* --- Global Styles & Resets --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--primary-text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 2rem 1rem;
    transition: background-color 0.5s ease;
}

.app-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

h2 { font-size: 1.7rem; }
.hidden { display: none !important; }

/* --- Header & Navigation --- */
.app-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.app-header h1 { font-weight: 600; font-size: 1.8rem; color: white; }

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg-color);
    padding: 0.5rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-link {
    color: var(--secondary-text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.nav-link:hover {
    color: var(--primary-text-color);
    background-color: rgba(255, 255, 255, 0.1);
}
.nav-link.active {
    color: white;
    background: var(--accent-color-1);
    font-weight: 600;
}
.nav-profile-pic { width: 28px; height: 28px; border-radius: 50%; }

/* --- Animated Timer & Progress Ring --- */
.timer-wrapper {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.timer-display {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent; /* Ensure it doesn't block the SVG */
}
#time-display { font-size: 5rem; font-weight: 600; color: white; letter-spacing: 2px; }
#timer-mode { font-size: 1rem; font-weight: 300; color: var(--secondary-text-color); margin-top: -10px; }

.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
}
.progress-ring__track {
    stroke: var(--card-bg-color);
}
.progress-ring__indicator {
    stroke: url(#progress-gradient);
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
    stroke-dashoffset: calc(2 * 3.14159 * 140); /* Circumference */
}

/* --- Buttons & Controls --- */
.controls {
    display: flex;
    gap: 1rem;
    width: 100%;
    justify-content: center;
    position: relative; /* THE BUTTON FIX: Part 1 */
    z-index: 10;       /* THE BUTTON FIX: Part 2 - Lift buttons above everything else */
}

.control-btn, .google-btn, .logout-btn, .tab-btn {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent; /* Removes blue tap highlight on mobile */
}
.control-btn:disabled { cursor: not-allowed; opacity: 0.5; }
.control-btn:not(:disabled):active { transform: scale(0.98); }
.control-btn { background: var(--card-bg-color); color: var(--primary-text-color); padding: 0.8rem 1.5rem; }
.control-btn i { margin-right: 0.5rem; }
.control-btn.main-btn { background: var(--accent-color-1); border-color: transparent; color: white; font-weight: 600; }

/* --- Content Cards (Ranking, About, Profile) --- */
.leaderboard-page, .about-page {
    width: 100%;
    background: var(--card-bg-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
}
.leaderboard-page h2, .about-page h2 { text-align: center; margin-bottom: 1.5rem; }

/* --- Ranking & Leaderboard --- */
.ranking-tabs { display: flex; justify-content: center; margin-bottom: 1.5rem; background-color: rgba(0,0,0,0.2); border-radius: 50px; padding: 5px; }
.tab-btn { flex-grow: 1; padding: 0.7rem; border: none; background: transparent; color: var(--secondary-text-color); font-size: 0.9rem; }
.tab-btn.active { background: var(--accent-color-2); color: white; font-weight: 600; }
#leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; min-height: 150px; }
#leaderboard-list li { display: flex; align-items: center; padding: 0.5rem; border-radius: 8px; }
#leaderboard-list li:nth-child(odd) { background-color: rgba(0,0,0,0.1); }
#leaderboard-list li .rank { font-weight: 700; font-size: 1.2rem; width: 40px; text-align: center; color: var(--secondary-text-color); }
#leaderboard-list li .name { flex-grow: 1; margin-left: 1rem; }
#leaderboard-list li .score { font-weight: 600; font-size: 1.1rem; }
#user-rank-display { margin-top: 2rem; padding: 1rem; background-color: rgba(15, 52, 96, 0.5); border: 1px solid var(--accent-color-2); border-radius: 10px; text-align: center; }
#user-rank-display p { font-size: 1.1rem; font-weight: 600; }
#user-rank-display span { color: white; font-size: 1.2rem; }

/* --- Loading Spinner --- */
.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--card-bg-color);
    border-top-color: var(--accent-color-1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Profile & Modal Styles --- */
.form-group { width: 100%; margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--secondary-text-color); }
.form-group input { width: 100%; padding: 0.8rem; background-color: rgba(0,0,0,0.2); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; color: var(--primary-text-color); font-family: inherit; font-size: 1rem; }
#modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
#modal-overlay:not(.hidden) { opacity: 1; pointer-events: auto; }
#modal { background: var(--bg-color); padding: 2rem; border-radius: 15px; border: 1px solid rgba(255, 255, 255, 0.1); text-align: center; width: 90%; max-width: 400px; transform: scale(0.9); transition: transform 0.3s ease; }
#modal-overlay:not(.hidden) #modal { transform: scale(1); }
#modal h2 { margin-bottom: 1rem; } #modal p { color: var(--secondary-text-color); margin-bottom: 2rem; }
.modal-buttons { display: flex; flex-direction: column; gap: 1rem; }


/* --- Mobile Responsiveness --- */
@media (max-width: 600px) {
    body { padding: 1rem 0.5rem; }
    .app-container { gap: 1.5rem; }
    .app-header { flex-direction: column; gap: 1rem; }
    .main-nav { width: 100%; justify-content: center; }
    .nav-link span:not(.nav-profile-pic) { display: none; } /* Hide text, show icon */
    .nav-link { padding: 0.7rem; }
    .nav-link.active { padding: 0.7rem 1.2rem; } /* Give active link more space */
    .nav-link.active span { display: inline; } /* Show text for active link */

    .timer-wrapper { width: 90vw; height: 90vw; max-width: 280px; max-height: 280px; }
    #time-display { font-size: clamp(3.5rem, 15vw, 4.5rem); } /* Responsive font size */

    .controls { flex-direction: column; width: 90%; max-width: 300px; }
    .control-btn { width: 100%; }
    .leaderboard-page, .about-page { padding: 1rem; }
    h2 { font-size: 1.5rem; }
}
