:root {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #374151;
    --text-muted: #9ca3af;
    --accent: #4b5563;
    --accent-hover: #1f2937;
    --gold: #d97706;
    --gold-bg: #fffbeb;
    --silver: #475569;
    --silver-bg: #f8fafc;
    --fire: #ef4444;
    --success-bg: #f0fdf4;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --neutral-bg: #f3f4f6;
    --neutral-text: #4b5563;
    --border-radius: 8px; /* Veidi ümaram moodsamaks ilmele */
    --cut-size: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Keskjoondatud vaated (Login/Register) */
.container-center {
    min-height: 85vh; /* Hoiab sisu ekraani keskel */
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 450px; /* Kitsam vaade sisselogimiseks */
}

/* NAVIGATSIOON */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
}

/* KAARDID JA ELEMENTID */
.card {
    background: var(--card-bg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden; /* Hoiab sisu kaardi sees */
}

.card-silver { border: 2px solid var(--silver); box-shadow: 0 4px 15px rgba(100, 116, 139, 0.2); }
.card-gold { border: 2px solid var(--gold); box-shadow: 0 4px 15px rgba(217, 119, 6, 0.2); }

.special-badge {
    position: absolute; top: 0; right: 0;
    padding: 5px 15px; font-size: 0.7rem; font-weight: bold; text-transform: uppercase;
    color: white; border-bottom-left-radius: 10px;
}
.badge-silver { background-color: var(--silver); }
.badge-gold { background-color: var(--gold); }

/* TEKSTID JA NUPUD */
h1, h2, h3, h4 { font-weight: 600; color: var(--text-main); margin-bottom: 1rem; }
.stat-number { font-size: 2.5rem; font-weight: 700; color: var(--accent); }
.text-small { font-size: 0.875rem; color: var(--text-muted); }
.text-small a {
    color: var(--accent);
    text-decoration: none;
}
.text-small a:hover {
    text-decoration: underline;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--accent);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border-radius: 4px; /* Mobiilisõbralikum kui clip-path nurgad */
    transition: background-color 0.2s;
}
.btn:hover { background-color: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-outline { background-color: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-danger { background-color: #ef4444; border: none; color: white; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }

/* VORMID */
input[type="text"], input[type="number"], input[type="password"], input[type="email"], input[type="file"], select, textarea {
    width: 100%; padding: 0.75rem; margin-bottom: 1rem;
    border: 1px solid #d1d5db; background: #f9fafb; color: var(--text-main);
    outline: none; font-size: 1rem; border-radius: 4px;
}

/* Vormi grid (Punktid, Aeg, Tüüp) */
.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* TABELID (Admin & Leaderboard) */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* Tekitab kerimise kui tabel ei mahu ära */
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}
.admin-table { width: 100%; border-collapse: collapse; min-width: 500px; /* Sunnib tabelit olema laiem, et scroll tekiks */ }
.admin-table th, .admin-table td { text-align: left; padding: 1rem; border-bottom: 1px solid #e5e7eb; }

/* QUIZ UI */
.quiz-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0; /* Neutraalne taust tühimike jaoks */
    margin-bottom: 1.5rem;
    border-radius: 4px;
    overflow: hidden;
}
.quiz-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.timer-container { width: 100%; height: 6px; background-color: #e5e7eb; border-radius: 10px; overflow: hidden; margin-bottom: 1.5rem; }
.timer-bar { height: 100%; background-color: var(--accent); width: 100%; transition: width 0.1s linear; }
.timer-bar.danger { background-color: #ef4444; }

.options-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.option-label { display: flex; align-items: center; padding: 1rem; background: #f3f4f6; cursor: pointer; border-radius: 4px; transition: background 0.2s; }
.option-label:hover { background: #e5e7eb; }
.option-label input { margin-right: 15px; width: auto; margin-bottom: 0; }

.answer-row { display: grid; grid-template-columns: 40px 1fr 40px; gap: 10px; align-items: center; margin-bottom: 10px; }
.correct-radio { width: 20px; height: 20px; cursor: pointer; accent-color: var(--accent); margin-bottom: 0 !important;}

/* SÕNUMID */
.msg-box { padding: 1rem; border-radius: 4px; margin-bottom: 1rem; text-align: center; font-weight: bold; }
.msg-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-text); }
.msg-error { background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-text); }
.result-box { padding: 2rem; border-radius: 8px; margin-bottom: 2rem; }
.result-success { background-color: var(--success-bg); border: 2px solid var(--success-text); color: var(--success-text); }
.result-fail { background-color: var(--error-bg); border: 2px solid var(--error-text); color: var(--error-text); }
.result-neutral { background-color: var(--neutral-bg); border: 2px solid var(--neutral-text); color: var(--neutral-text); }

.benefits-box { background-color: var(--success-bg); border: 1px solid #bbf7d0; padding: 1.5rem; border-radius: 4px; margin-top: 2rem; text-align: left; }
.benefits-list { list-style: none; margin-top: 1rem; }
.benefits-list li { margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; color: var(--success-text); }
.icon { width: 20px; height: 20px; }

/* --- RESPONSIVE (MOBIIL) --- */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
        margin-top: 0 !important; /* Eemaldab igasuguse hardcoded margin-top'i */
    }
    
    /* Navigatsioon üksteise alla */
    .nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .nav-links {
        justify-content: center;
        flex-wrap: wrap;
        width: 100%;
        gap: 15px;
    }

    .card { padding: 1.25rem; }
    
    /* Vormi veerud üksteise alla */
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    h1 { font-size: 1.75rem; }
    .stat-number { font-size: 2rem; }

    /* Nupud täislaiuses */
    .btn { width: 100%; margin-bottom: 0.5rem; }
    
    .answer-row {
        grid-template-columns: 30px 1fr 40px;
    }

    /* Tabeli font väiksemaks */
    .admin-table th, .admin-table td { padding: 0.75rem; font-size: 0.9rem; }
}

/* --- Uued stiilid jagamise funktsionaalsuse jaoks --- */
.button-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}
.btn-icon {
    flex-shrink: 0;
    width: 44px; /* Fikseeritud laius, et oleks ruudukujuline */
    padding: 0.5rem;
    background-color: #e5e7eb;
    color: var(--text-main);
    border: 1px solid #d1d5db;
}
.btn-icon:hover {
    background-color: #d1d5db;
}

.toast {
    visibility: hidden;
    min-width: 150px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 12px;
    position: fixed;
    z-index: 10;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}



.toast.show {

    visibility: visible;

    opacity: 1;

}



/* --- INTRO OVERLAY --- */

.intro-overlay {

    position: fixed;

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

    z-index: 100;

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    text-align: center;

    color: white;

    padding: 2rem;

    animation: fadeOut 2.5s forwards;

}



.intro-gold {

    background-color: rgba(217, 119, 6, 0.9); /* var(--gold) with alpha */

}



.intro-silver {

    background-color: rgba(71, 85, 105, 0.9); /* var(--silver) with alpha */

}



.intro-title {

    font-size: 2.5rem;

    font-weight: bold;

    display: flex;

    align-items: center;

    gap: 1rem;

    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);

}



.intro-title svg {

    width: 48px;

    height: 48px;

}



.intro-points {

    font-size: 1.5rem;

    margin-top: 1rem;

    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);

}



@keyframes fadeOut {

    0% { opacity: 1; transform: scale(1); }

    80% { opacity: 1; transform: scale(1.05); }

    100% { opacity: 0; transform: scale(1.1); visibility: hidden; }

}
