/* --- Google Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

/* --- CSS Variables for easy theme management --- */
:root {
    --primary-color: #4a90e2; /* A nice blue */
    --primary-hover-color: #357ABD;
    --background-color: #f4f7f6;
    --card-background-color: #ffffff;
    --text-color: #333333;
    --light-text-color: #777777;
    --border-color: #dddddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* --- General Body & Typography Styles --- */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2 {
    font-weight: 600;
}

/* --- Header Styles --- */
header {
    background-color: var(--card-background-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

header nav div[role="button"] {
    cursor: pointer;
    color: var(--light-text-color);
    transition: color 0.3s ease;
}

header nav div[role="button"]:hover {
    color: var(--primary-color);
}

/* --- Main Content Layout --- */
main {
    flex-grow: 1;
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
    box-sizing: border-box;
}

/* --- The Big Button Section --- */
#button-section {
    text-align: center;
    margin-bottom: 3rem;
}

#main-button {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(74, 144, 226, 0.4);
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent; /* Removes blue tap highlight on mobile */
}

#main-button:hover:not(:disabled) {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px rgba(74, 144, 226, 0.5);
    background-color: var(--primary-hover-color);
}

#main-button:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 5px 10px rgba(74, 144, 226, 0.4);
}

#main-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

#timer-display {
    margin-top: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--light-text-color);
    height: 2rem; /* Reserve space to prevent layout shift */
}

/* --- Stats Section --- */
#stats-section {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.stat-item {
    background: var(--card-background-color);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow-color);
    text-align: center;
    flex: 1;
    min-width: 200px; /* Minimum width for each stat item */
}

.stat-item h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--light-text-color);
}

.stat-item p {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* --- Leaderboards Section --- */
#leaderboards-section {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.leaderboard {
    background: var(--card-background-color);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow-color);
    flex: 1;
    min-width: 250px;
}

.leaderboard h2 {
    text-align: center;
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.leaderboard ol {
    padding-left: 1.5rem;
    margin: 0;
}

.leaderboard li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.leaderboard li:last-child {
    border-bottom: none;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 2rem;
    background-color: var(--card-background-color);
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--light-text-color);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}


/* --- Rules Modal Styles --- */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
}

/* When modal is visible */
.modal.visible {
    display: flex;
}

.modal-content {
    background-color: var(--card-background-color);
    margin: auto;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    #leaderboards-section {
        flex-direction: column;
    }

    #stats-section {
        flex-direction: column;
    }

    header {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* --- Settings Modal Styles --- */
.settings-form {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.settings-divider {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 2rem 0;
}

.danger-section {
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: 8px;
    padding: 1.5rem;
}

.danger-section h3 {
    color: #e74c3c;
    margin-top: 0;
}

.button-group {
    display: flex;
    justify-content: flex-start;
    margin-top: 1rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary-btn:hover {
    background-color: var(--primary-hover-color);
}

.danger-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.danger-btn:hover {
    background-color: #c0392b;
}

.pulse-animation {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

/* Add styling for the secondary button */
.secondary-btn {
    background-color: #f0f0f0;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.secondary-btn:hover {
    background-color: #e0e0e0;
}

/* --- Custom Alert Styles --- */
.custom-alert {
    position: fixed;
    z-index: 1100;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90%;
    width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.custom-alert.visible {
    opacity: 1;
    pointer-events: auto;
}

.custom-alert.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.custom-alert.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

.alert-content {
    padding: 1rem 2rem 1rem 1rem;
    position: relative;
}

.alert-content p {
    margin: 0;
    font-weight: 500;
}

.success .alert-content p {
    color: #155724;
}

.error .alert-content p {
    color: #721c24;
}

.alert-close-button {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.alert-close-button:hover {
    opacity: 1;
}
