/* ================================================
   1. PERUSTYYLIT JA YLEISET ELEMENTIT (VAALEA TEEMA)
   ================================================ */

html {
    /* Varmistaa, että 1rem = 16px */
    font-size: clamp(16px, 1rem + 0.5vw, 19px);
}

/* --- Body / Tausta --- */
body {
    font-family: Arial, sans-serif;
    font-size: 1rem;       /* 16px */
    line-height: 1.6;
    color: #333; /* Tummempi teksti */
    margin: 0;
    padding: 1px;
    background-color: #d8e5f8; /* Hiukan tummempi, sinisävyisempi tausta */
    /* Vaalea tausta: hienovarainen sininen tausta */
    background-image:
        radial-gradient(circle at 25px 25px, rgba(24, 96, 194, 0.1) 2px, transparent 2px), /* Siniset pisteet */
        radial-gradient(circle at 75px 75px, rgba(24, 96, 194, 0.08) 2px, transparent 2px),
        linear-gradient(180deg, #eaf2ff 0%, #d8e5f8 100%); /* Kirkkaampi ylhäältä */
    background-size: 100px 100px, 100px 100px, auto;
    background-attachment: fixed;
}

header {
    background: url('images/banner.webp') center center / 1200px 200px no-repeat;
    min-height: 200px;
    padding: 0px 10px;
    box-sizing: border-box;
	border-radius: 6px;
}

/* Kohdistetaan luokka molempiin elementteihin, jos niillä on sama luokka */
.button, a.button {
    /* --- TÄRKEÄT KORJAUKSET A-TAGILLE --- */
    display: inline-block;     /* Aseta estämään rivin sisäinen näyttö */
    text-decoration: none;     /* Poista alleviivaus */
    text-align: center;        /* Varmista tekstin keskitys */
    cursor: pointer;           /* Varmista, että hiiren osoitin on käsi */

    /* --- Yhteiset ulkoasutyylit --- */
    padding: 10px 18px;
    border: 1px solid #1860c2;
    background-color: #1860c2;
    color: #fff; /* Aseta selkeä teksti/linkin väri */
    border-radius: 6px;
    box-shadow: 0px 4px 8px 2px rgba(0,0,0,0.75);
    -webkit-box-shadow: 0px 4px 8px 2px rgba(0,0,0,0.75);
    -moz-box-shadow: 0px 4px 8px 2px rgba(0,0,0,0.75);
}

a.button {
    padding: 8px;
    font-size: 70%;
    color: white;
}

a.button:hover {
    background-color: #218838;
}

/* --- Pääkontti (#mainDiv) --- */
#mainDiv {
    max-width: 1200px;
    margin: 16px auto;
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    /* Tausta: Läpikuultava kortti */
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.95)); /* Läpinäkyvyys vähenee */
    box-shadow: 0 10px 30px rgba(24, 96, 194, 0.2); /* Sinertävä hehku */
    backdrop-filter: blur(2px) saturate(1.05);
}

/* --- Taulukot (table) --- */
table {
    border-collapse: collapse;
    width: 100%;
    background-color: #fff;
}

th {
    padding: 10px;
    border: 1px solid #ccc;
    text-align: left;
    background: #eee;
}

td {
    padding: 10px;
    border: 1px solid #ccc;
    text-align: left;
}

tr:hover {
    background-color: #c7d8ee; /* SÄILYTETTY: Edelleen kirkas hover */
}

.result-table {
    width: 100%;
    margin-top: 10px;
    font-size: 0.85rem;
}

/* --- Navigointi (nav) --- */
nav {
    background-color: rgba(216, 229, 248, 0.5); /* 50 % läpinäkyvä */
    padding: 5px 10px;
    margin: 20px 20px 0px 20px;
    border-radius: 6px;
    box-shadow: 0px 10px 8px -2px rgba(0,0,0,0.75);
    -webkit-box-shadow: 0px 10px 8px -2px rgba(0,0,0,0.75);
    -moz-box-shadow: 0px 10px 8px -2px rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

nav a {
    margin-right: 15px;
    color: #1860c2; /* Kirkas sininen */
    font-weight: bold;
}

body .danger-button {
    background-color: #b31818; /* Puhtaampi punainen */
    color: #ddd;
}

body .danger-button:hover {
    background-color: #b71c1c;
    color: yellow;
}

.theme-toggle-form {
    margin-left: auto;
}

.theme-toggle-btn {
    background: #1565c0;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.theme-toggle-icon {
    width: 24px;
    height: 24px;
    display: block;
}

/* --- Pitkät tekstimuotoilut --- */
.longText > p {
    padding: 5px 30px;
}

.longText li {
    margin: 0px 25px;
}

/* --- Sivupalkki --- */
.sidebar {
    border-left: 1px solid #ccc;
    padding-left: 20px;
    width: 300px;
    font-size: 0.9em;
}

.sidebar ul {
    list-style: none;
    padding-left: 0;
}

/* --- Tarra/Muistiinpano (.sticky-note) --- */
.sticky-note {
    background-color: #fff9c4;
    border: 1px solid #f0e68c;
    padding: 5px;
    margin: 5px;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    font-family: 'Segoe UI', sans-serif;
    max-width: 300px;
    line-height: 1.5em;
    border-radius: 6px;
}

body.dark .sticky-note {
    background-color: #4c4c2c;
    border-color: #77753b;
    color: #fff9c4;
}

/* --- Pieni apu-teksti --- */
.help {
    font-size: .9em;
    color: #666;
}

.status {
    font-size: 12px;
    color: gray;
    text-align: right;
    float: right;
    padding: 0px 10px;
}


/* ================================================
   2. TUMMA TEEMA (body.dark)
   ================================================ */

/* --- Body / Tausta (Tumma teema) --- */
body.dark {
    background-color: #1a1a1a; /* Syvempi tumma */
    color: #ddd;
    background-image:
        radial-gradient(circle at 25px 25px, rgba(77, 166, 255, 0.1) 2px, transparent 2px), /* Sinertävät pisteet */
        radial-gradient(circle at 75px 75px, rgba(77, 166, 255, 0.08) 2px, transparent 2px),
        linear-gradient(180deg, #1d1e22 0%, #121316 100%);
    background-size: 100px 100px, 100px 100px, auto;
    background-attachment: fixed;
}

/* --- Pääkontti (#mainDiv) (Tumma teema) --- */
body.dark #mainDiv {
    border-color: rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(33,33,33,0.95), rgba(26,26,26,0.90));
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

/* --- Linkit (Tumma teema) --- */
body.dark a {
    color: #4da6ff; /* Kirkkaampi sininen linkeille */
}

/* --- Taulukot (Tumma teema) --- */
body.dark table {
    background-color: #222222; /* Syvempi taulu tausta */
    border-color: #444;
}

body.dark th {
    border: 1px solid #444;
    background: #248;
}

body.dark td {
    border: 1px solid #444;
}

body.dark tr:hover {
    background-color: #363636; /* Hienovarainen hover tummassa */
}

/* --- Navigointi (Tumma teema) --- */
body.dark nav {
    background-color: rgba(42, 42, 42, 0.5);
}

body.dark button {
    background-color: #1860c2; 
    color: #fff;
}

body.dark button:hover {
    background-color: #154c96;
}

body.dark .danger-button {
    background-color: #b31818; /* Puhtaampi punainen */
}

body.dark .danger-button:hover {
    background-color: #b71c1c;
    color: yellow;
}

/* --- Etusivun Pääpainikkeet (Tumma teema) --- */
body.dark main a.button {
    background: #4da6ff;
    color: #1a1a1a;
}

body.dark main a.button:hover {
    background: #1a73e8;
}

/* --- Pieni apu-teksti (Tumma teema) --- */
body.dark .help {
    color: #aaa;
}

/* =========================================================
   AUTOVISA – KOJELAUDAN LED-TEEMA, KOKO QUIZ_START
   Korvaa aiempi quiz_startin LED/CSS-lisäys tällä versiolla.
   ========================================================= */


/* ---------------------------------------------------------
   Yleinen tiivistys
   --------------------------------------------------------- */

.quiz-start--compact .quiz-group {
    margin: 8px 0;
}

.quiz-start--compact .quiz-row {
    gap: 8px;
}

.quiz-start--compact .quiz-actions {
    margin-top: 10px;
}

.quiz-start--compact .help {
    line-height: 1.2;
}


/* ---------------------------------------------------------
   Yhteinen jalopuupaneeli
   --------------------------------------------------------- */

.dashboard-panel {
    min-width: 0;
    margin: 0;
    padding: 9px;

    border: 1px solid rgba(214, 183, 125, 0.68);
    border-radius: 8px;

    background:
        linear-gradient(
            90deg,
            rgba(255,255,255,0.035),
            rgba(0,0,0,0.11) 24%,
            rgba(255,255,255,0.025) 48%,
            rgba(0,0,0,0.13) 76%,
            rgba(255,255,255,0.03)
        ),
        repeating-linear-gradient(
            3deg,
            #3b1f12 0px,
            #4d2918 4px,
            #63351e 9px,
            #4a2717 14px,
            #32190f 20px
        );

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.14),
        inset 0 -2px 4px rgba(0,0,0,0.42),
        0 2px 5px rgba(0,0,0,0.25);
}

.dashboard-panel legend {
    padding: 2px 8px;

    border: 1px solid rgba(210, 182, 128, 0.56);
    border-radius: 5px;

    background: linear-gradient(#3b3b3b, #181818);
    color: #f1e4c5;

    font-size: 0.90rem;
    font-weight: 700;
    letter-spacing: 0.02em;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.10),
        0 1px 2px rgba(0,0,0,0.50);
}


/* ---------------------------------------------------------
   Pelaaja + vuosimallit
   --------------------------------------------------------- */

.dashboard-secondary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    margin: 10px 0;
}

.dashboard-panel--form {
    padding: 9px 11px 10px;
}

.dash-field-label {
    display: block !important;
    margin: 0 0 4px !important;

    color: #eadfc9;
    font-size: 0.78rem;
    font-weight: 600 !important;
}

.dash-field-label small {
    color: #bfb39e;
    font-weight: normal;
}


/*
 * Kojelautaan upotettu tekstikenttä.
 * !important tarvitaan, koska sivuston vanha .quiz-start input -CSS
 * määrittää kenttien leveyttä ja värejä.
 */
.quiz-start--compact .dash-input {
    display: block;
    width: 100% !important;
    box-sizing: border-box;

    height: 34px;
    margin: 0 !important;
    padding: 5px 9px;

    border: 1px solid #0c0c0c !important;
    border-radius: 5px;

    background:
        linear-gradient(
            180deg,
            #121212 0%,
            #20201e 100%
        ) !important;

    color: #f0e5cf !important;

    box-shadow:
        inset 0 2px 5px rgba(0,0,0,0.85),
        inset 0 0 0 1px rgba(255,255,255,0.035),
        0 1px 0 rgba(255,255,255,0.08);

    outline: none;
}

.quiz-start--compact .dash-input::placeholder {
    color: #77736a;
    opacity: 1;
}

.quiz-start--compact .dash-input:focus {
    border-color: #b99145 !important;

    box-shadow:
        inset 0 2px 5px rgba(0,0,0,0.85),
        0 0 0 1px rgba(255,181,45,0.35),
        0 0 7px rgba(255,145,0,0.26);
}

.dash-field-help {
    display: block;
    margin-top: 3px;

    color: #bfb39e;
    font-size: 0.68rem;
}

.dash-year-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}


/* ---------------------------------------------------------
   Kolme pääasetusta
   --------------------------------------------------------- */

.dashboard-settings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.dash-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}


/* ---------------------------------------------------------
   Radio- ja checkbox-kytkimet
   --------------------------------------------------------- */

.dash-radio,
.dash-check {
    position: relative;
    min-width: 0;
}

.dash-radio input[type="radio"],
.dash-check input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.dash-radio__label,
.dash-check__label {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;

    min-width: 0;
    min-height: 34px;
    box-sizing: border-box;
    margin: 0 !important;
    padding: 4px 7px;

    border: 1px solid #111;
    border-radius: 5px;

    background:
        linear-gradient(
            180deg,
            #4a4a47 0%,
            #2b2b29 45%,
            #171716 100%
        );

    color: #e8e2d6 !important;
    cursor: pointer;
    user-select: none;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.12),
        inset 0 -2px 2px rgba(0,0,0,0.50),
        0 1px 2px rgba(0,0,0,0.32);

    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.08s ease;
}

.dash-radio__label:hover,
.dash-check__label:hover {
    background:
        linear-gradient(
            180deg,
            #555550 0%,
            #333330 45%,
            #1c1c1a 100%
        );
}


/* LED */
.dash-led {
    flex: 0 0 auto;

    width: 10px;
    height: 10px;

    border: 2px solid #111;
    border-radius: 50%;

    background:
        radial-gradient(
            circle at 35% 30%,
            #48423a 0%,
            #211e1a 45%,
            #090909 100%
        );

    box-shadow:
        inset 0 1px 1px rgba(255,255,255,0.10),
        0 1px 1px rgba(0,0,0,0.70);
}

.dash-radio__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.05;
}

.dash-radio__text strong {
    color: inherit;
    font-size: 0.84rem;
}

.dash-radio__text small {
    margin-top: 2px;
    color: #bbb4a6;
    font-size: 0.63rem;
    font-weight: normal;
}


/* Valittu tila */
.dash-radio input[type="radio"]:checked + .dash-radio__label,
.dash-check input[type="checkbox"]:checked + .dash-check__label {
    border-color: #b99145;

    background:
        linear-gradient(
            180deg,
            #56534b 0%,
            #36332d 45%,
            #201e1a 100%
        );

    color: #fff4d7 !important;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.16),
        inset 0 -2px 3px rgba(0,0,0,0.50),
        0 0 0 1px rgba(255,176,0,0.13),
        0 1px 3px rgba(0,0,0,0.36);
}


/* Sytytetty meripihkanvärinen LED */
.dash-radio input[type="radio"]:checked + .dash-radio__label .dash-led,
.dash-check input[type="checkbox"]:checked + .dash-check__label .dash-led {
    background:
        radial-gradient(
            circle at 35% 30%,
            #fff2a8 0%,
            #ffc13b 22%,
            #ff9d00 58%,
            #a54d00 100%
        );

    box-shadow:
        inset 0 1px 1px rgba(255,255,255,0.72),
        0 0 3px rgba(255,169,0,0.95),
        0 0 7px rgba(255,140,0,0.65),
        0 0 11px rgba(255,120,0,0.25);
}

.dash-radio input[type="radio"]:focus-visible + .dash-radio__label,
.dash-check input[type="checkbox"]:focus-visible + .dash-check__label {
    outline: 2px solid #ffd36b;
    outline-offset: 2px;
}

.dash-radio__label:active,
.dash-check__label:active {
    transform: translateY(1px);
}


/* ---------------------------------------------------------
   Valmistusmaat
   --------------------------------------------------------- */

.dashboard-panel--countries {
    margin: 10px 0;
    padding-bottom: 8px;
}

.country-dashboard-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;

    box-sizing: border-box;
    padding: 6px 9px;

    border: 1px solid #111;
    border-radius: 5px;

    background: linear-gradient(#484845, #232321);
    color: #eee5d3;

    text-align: left;
    cursor: pointer;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.12),
        0 1px 2px rgba(0,0,0,0.32);
}

.country-dashboard-toggle:hover {
    background: linear-gradient(#53534f, #2c2c29);
}

.country-dashboard-toggle small {
    margin-left: auto;
    color: #c5bca8;
}

.country-dashboard-toggle__arrow {
    margin-left: 2px;
    transition: transform 0.15s ease;
}

.country-dashboard-toggle.open .country-dashboard-toggle__arrow {
    transform: rotate(180deg);
}

.country-panel--dashboard {
    display: none;
    margin-top: 7px;
}

.country-panel--dashboard.open {
    display: block;
}

.country-help {
    margin: 3px 0 7px;
    color: #ddd0b8;
}

.country-grid--dashboard {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
}

.country-grid--dashboard .dash-check__label {
    min-height: 30px;
    padding: 3px 6px;
    font-size: 0.78rem;
}


/* ---------------------------------------------------------
   Aloita peli -painike
   --------------------------------------------------------- */

.dashboard-start-wrap {
    margin-top: 10px !important;
}

.dashboard-start-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    width: min(420px, 90%);
    min-height: 42px;
    padding: 8px 22px;

    border: 1px solid #121212;
    border-radius: 7px;

    background:
        linear-gradient(
            180deg,
            #55534d 0%,
            #302f2b 50%,
            #181817 100%
        );

    color: #f5ead5;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.025em;

    cursor: pointer;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.17),
        inset 0 -2px 3px rgba(0,0,0,0.58),
        0 2px 5px rgba(0,0,0,0.35);
}

.dashboard-start-button:hover {
    border-color: #b99145;

    background:
        linear-gradient(
            180deg,
            #646057 0%,
            #3a3731 50%,
            #1d1c19 100%
        );
}

.dashboard-start-button:active {
    transform: translateY(1px);
}

.dashboard-start-led {
    width: 11px;
    height: 11px;

    border: 2px solid #3a2100;
    border-radius: 50%;

    background:
        radial-gradient(
            circle at 35% 30%,
            #fff2a8 0%,
            #ffc13b 22%,
            #ff9d00 58%,
            #a54d00 100%
        );

    box-shadow:
        inset 0 1px 1px rgba(255,255,255,0.72),
        0 0 4px rgba(255,169,0,0.95),
        0 0 9px rgba(255,140,0,0.60);
}


/* ---------------------------------------------------------
   Responsiivisuus
   --------------------------------------------------------- */

@media (max-width: 950px) {
    .dashboard-settings {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-settings .dashboard-panel:last-child {
        grid-column: 1 / -1;
    }

    .dashboard-settings .dashboard-panel:last-child .dash-options {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .country-grid--dashboard {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


@media (max-width: 650px) {
    .dashboard-secondary,
    .dashboard-settings {
        grid-template-columns: 1fr;
    }

    .dashboard-settings .dashboard-panel:last-child {
        grid-column: auto;
    }

    .dashboard-settings .dashboard-panel:last-child .dash-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .country-grid--dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 420px) {
    .dashboard-panel {
        padding: 7px;
    }

    .dash-options {
        gap: 4px;
    }

    .dash-radio__label,
    .dash-check__label {
        min-height: 32px;
        padding: 3px 6px;
    }

    .country-grid--dashboard {
        grid-template-columns: 1fr;
    }

    .dashboard-start-button {
        width: 100%;
    }
}



/* ================================================
   3. HUIPPUPISTEET (ODOMETER)
   ================================================ */

.highscore-odometer {
    display: inline-block;
    padding: 14px 18px 18px;
    background: linear-gradient(180deg, #5a5a5a 0%, #2f2f2f 100%);
    border: 2px solid #1b1b1b;
    border-radius: 10px;
    box-shadow:
        inset 0 2px 2px rgba(255,255,255,0.08),
        inset 0 -3px 6px rgba(0,0,0,0.45),
        0 4px 12px rgba(0,0,0,0.35);
    font-family: "Courier New", Courier, monospace;
}

.odo-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #d8d1b5;
    text-align: center;
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

.odo-display {
    /* Korjattu rikkinäiset kommentit oikeiksi */
    /* display: flex; */
    /* gap: 4px; */
    align-items: center;
    justify-content: center;
}

.odo-display td {
    border: 0 !important;
}

.odo-digit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 48px;
    background: linear-gradient(180deg, #1a1a1a 0%, #111 48%, #000 49%, #181818 100%);
    color: #f3f0e8;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 -1px 0 rgba(0,0,0,0.8),
        0 1px 2px rgba(0,0,0,0.45);
    text-shadow:
        0 0 2px rgba(255,255,255,0.15),
        0 1px 1px rgba(0,0,0,0.75);
    overflow: hidden;
}

.odo-digit::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255,255,255,0.10);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.5);
    transform: translateY(-50%);
}

.odo-digit::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(255,255,255,0.08) 0%,
        rgba(255,255,255,0.02) 25%,
        rgba(0,0,0,0.00) 50%,
        rgba(0,0,0,0.14) 100%
    );
    pointer-events: none;
}


/* ================================================
   4. KUVA/GALLERIA JA AUTOKORTTIKOMPONENTIT
   ================================================ */

/* --- Thumbnail (pienoiskuva) --- */
.thumbnail {
    width: 400px;
    cursor: zoom-in;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* --- Overlay / Kuvankatselu (#overlay) --- */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
}

#overlay img {
    max-width: 90%;
    max-height: 90%;
    border: 4px solid #fff;
    border-radius: 6px;
    cursor: zoom-out;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

/* --- Autokortti (.car-card) --- */
/* Yhdistetty tuplamäärittelyt yhdeksi selkeäksi kokonaisuudeksi */
.car-card {
    max-width: 900px;
    margin: 20px auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

body.dark .car-card {
    background: #2b2b2b;
    border-color: #444;
    box-shadow: 0 6px 24px rgba(0,0,0,.5);
}

.car-card__media {
    position: relative;
    background: #111;
    text-align: center;
}

.car-card__img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: cover;
    position: relative;
    z-index: 1;
}

.car-card__badge {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: rgba(0,0,0,.65);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: .02em;
    font-size: .9rem;
    border: 1px solid rgba(255,255,255,.15);
    z-index: 3;
}

body.dark .car-card__badge { 
    background: rgba(0,0,0,.7); 
}

.car-card__body {
    padding: 16px 18px 20px;
}

.car-card__title {
    margin: 4px 0 12px;
    font-size: 1.5rem; /* Käytetään suurempaa fonttikokoa */
    letter-spacing: .02em;
    color: #1860c2;
}

body.dark .car-card__title { 
    color: #4da6ff; 
}

.car-card__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 8px;
    margin-bottom: 14px;
}

@media (max-width:700px) {
    .car-card__grid { grid-template-columns: 1fr; }
}

.car-card__label {
    font-size: .8rem;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 2px;
}

body.dark .car-card__label { 
    color: #aaa; 
}

.car-card__value {
    font-size: 1.05rem;
}

.car-card__desc {
    background: #0b0b0b0a;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 10px;
}

body.dark .car-card__desc {
    background: #00000026;
    border-color: #444;
}

.car-card__desc > p {
    margin: 4px 0;
    padding-left: 15px;
    font-size: 0.95rem;
    color: #888; /* Hieman tummempi harmaa teksti */
}

.car-card__desc > p strong {
    color: #888;
    min-width: 100px;
    display: inline-block;
}

.car-card__desc h3 {
    margin: 10px 0 5px;
    padding-left: 15px;
    font-size: 1.15rem;
    color: #1860c2;
    font-weight: 700;
}

.car-card__descTitle {
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 6px;
    color: #1860c2;
    letter-spacing: .05em;
}

body.dark .car-card__descTitle {
    color: #4da6ff;
}

.car-card__actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.car-card__overlay {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 100%;
    height: auto;
    z-index: 2;
    display: block;
}

.media-gate__skeleton {
    position: absolute;
    inset: 0;
    z-index: 0;
}


/* ================================================
   5. KOMMENTIT
   ================================================ */

.comments-wrap {
    max-width: 900px;
    margin: 16px auto 32px;
}

.comments-title {
    margin: 8px 0 12px;
    font-size: 1.3rem;
}

.comment-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* --- Yksittäinen kommentti (.comment-note) --- */
.comment-note {
    background: #fffbe6;
    border: 1px solid rgba(0,0,0,.08);
    border-left: 6px solid #f2c14e;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,.06);
}

.comment-empty {
    background: #f7f7f7;
    border-left-color: #bbb;
}

body.dark .comment-note {
    background: #2c2a20;
    color: #e8e1cf;
    border-color: rgba(255,255,255,.08);
    border-left-color: #d2a94d;
    box-shadow: 0 4px 14px rgba(0,0,0,.45);
}

body.dark .comment-empty {
    background: #2a2a2a;
    color: #ccc;
    border-left-color: #777;
}

/* --- Kommentin Sisältö --- */
.comment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .95rem;
    margin-bottom: 6px;
    color: #333;
}

body.dark .comment-head {
    color: #e8e1cf;
}

.comment-date {
    opacity: .8;
    font-size: .85rem;
}

.comment-body {
    line-height: 1.45;
    white-space: pre-wrap;
}


/* ================================================
   6. VISA-KOMPONENTIT
   ================================================ */

/* --- Ajastin / Palkki --- */
#countdown-bar {
    width: 600px;
    max-width: 600px;
    height: 10px;
    background-color: #28a745;
    margin: 10px auto;
    transition: width 0.5s linear;
    text-align: center;
    border-radius: 5px;
}

/* --- Kuvan Kääre --- */
#image-wrapper {
    position: relative;
    width: 600px;
    margin: 0 auto;
    border: 2px solid #ddd;
    display: none;
}

body.dark #image-wrapper {
    border-color: #444;
}

/* --- Lomakekortti (.quiz-start) --- */
.quiz-start {
    width: 95%;
    margin: 30px auto;
    color: #222;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 18px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.1);
}

.quiz-start h2 {
    margin: 0 0 10px;
    font-size: 1.3rem;
    color: #1860c2; 
}

body.dark .quiz-start {
    color: #ddd;
    border-color: #444;
}

body.dark .quiz-start h2 {
    color: #4da6ff;
}

.quiz-start .button {
    font-size: 1.1rem;
    padding: 12px 30px;
    border-radius: 25px;
    border: none;
    color: #fff;
    text-decoration: none;
    display: inline-block;
    transition:
        background-color 0.2s ease,
        transform 0.8s ease,
        box-shadow 0.8s ease;
}

.quiz-start .button:hover {
    background-color: #23913d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.quiz-start .button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

/* --- Lomakekentät --- */
.quiz-start textarea,
.quiz-start .file-input,
.quiz-start input[type="text"],
.quiz-start input[type="number"],
.quiz-start select {
    width: 100%; 
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fafafa;
}

.quiz-start textarea {
    min-height: 140px;
    resize: vertical;
}

/* Yksittäiset leveyskorjaukset */
.quiz-start input[type="text"],
.quiz-start input[type="number"],
.quiz-start select {
    width: 80%;
}

/* Lomakekentät (Tumma teema) */
body.dark .quiz-start textarea,
body.dark .quiz-start .file-input,
body.dark .quiz-start input[type="text"],
body.dark .quiz-start input[type="number"],
body.dark .quiz-start select {
    background: #1e1e1e;
    border-color: #555;
    color: #ddd;
}

/* --- Lomakkeen Asettelu --- */
.quiz-group {
    margin: 15px 0px;
}

.quiz-group label {
    font-weight: 600;
    display: inline-block;
    margin-bottom: 6px;
}

.quiz-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.quiz-row > div {
    flex: 1 1 0%; 
    min-width: 100px; 
}

/* --- Maavalitsin/Grid --- */
.country-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px 14px;
    max-height: 220px;
    overflow: auto;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fafafa;
}

body.dark .country-grid {
    background: #1e1e1e;
    border-color: #555;
}

.country-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

/* --- Lomaketoiminnot --- */
.quiz-actions {
    text-align: center;
    margin-top: 18px;
}

.quiz-actions .button {
    padding: 10px 18px;
    border-radius: 6px;
}


/* ================================================
   7. TEKSTIVISA KOMPONENTIT
   ================================================ */

#options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-top: 15px;
}

#options-container .button {
    flex: 1 1 calc(50% - 12px); 
    min-width: 120px;
    text-align: center;
}


/* ================================================
   8. VISAN LOPPUNÄYTTÖ (.quiz-end)
   ================================================ */

.quiz-end {
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 20px;
}

.quiz-end h2 {
    font-size: 2.2rem;
    color: #1860c2; 
    margin: 0 0 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid #c7d8ee; 
    font-weight: 800;
    letter-spacing: 0.05em;
}

.quiz-end p {
    font-size: 1.4rem;
    color: #333;
    margin: 0 0 25px;
}

.quiz-end p strong {
    font-size: 1.8rem;
    font-weight: 900;
    color: #007bff; 
    display: block; 
    margin-top: 5px;
}

/* Uusi peli -painike */
.quiz-end .button {
    font-size: 1.1rem;
    padding: 12px 30px;
    border-radius: 25px;
    background-color: #28a745; 
    border: none;
    transition: background-color 0.2s ease;
}

.quiz-end .button:hover {
    background-color: #218838;
    border-radius: 50px;
}

/* --- Footer --- */
footer {
    font-weight: bold;
    border-top: 2px solid #1860c2;
    margin-top: 5px;
    padding-top: 2px;
    color: #888;
}


/* ================================================
   9. CACHE-LISTAUS
   ================================================ */

.car-list-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.car-list-table th,
.car-list-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #ccc;
    text-align: left;
    vertical-align: middle;
}

.car-list-table th {
    font-weight: bold;
}

.car-list-thumb {
    width: 90px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.car-list-table tr:hover {
    background: rgba(255, 255, 255, 0.06);
}


/* ================================================
   10. ERILLISET HTML-SIVUTYYLIT (OPAS JA SIVUT)
   ================================================ */

.guide-page .info-hero {
    border-top-color: #28a745;
}

.guide-steps {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.guide-step {
    background: rgba(24, 96, 194, 0.05);
    border: 1px solid rgba(24, 96, 194, 0.12);
    border-radius: 10px;
    padding: 14px 16px;
}

.guide-step h3 {
    margin: 0 0 8px;
    color: #1860c2;
}

.guide-step p {
    margin-bottom: 8px;
}

.guide-step ul,
.guide-tip ul,
.guide-list {
    margin: 8px 0 0;
    padding-left: 1.4rem;
}

.guide-step li,
.guide-tip li,
.guide-list li {
    margin: 6px 0;
}

.guide-note {
    max-width: none;
    margin: 18px 0 0;
    padding: 14px 16px;
}

.guide-answer-grid {
    grid-template-columns: repeat(2, 1fr);
}

.guide-tip {
    margin-top: 16px;
    padding: 14px 16px;
    border-left: 5px solid #1860c2;
    background: rgba(24, 96, 194, 0.06);
    border-radius: 8px;
}

.guide-tip h3 {
    margin-top: 0;
    color: #1860c2;
}

.guide-score-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.guide-score-card {
    background: rgba(255,255,255,0.8);
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0,0,0,.06);
}

.guide-score-card strong {
    display: block;
    color: #1860c2;
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.guide-score-card span {
    display: block;
    font-size: .88rem;
    color: #666;
}

.guide-final {
    text-align: center;
    margin: 26px auto;
    padding: 18px;
}

.guide-final h2 {
    color: #1860c2;
    margin-bottom: 4px;
}

.guide-final p {
    color: #666;
    margin-top: 0;
}

/* --- Opas (Tumma teema) --- */
body.dark .guide-step {
    background: rgba(77,166,255,0.08);
    border-color: rgba(77,166,255,0.18);
}

body.dark .guide-step h3,
body.dark .guide-tip h3,
body.dark .guide-score-card strong,
body.dark .guide-final h2 {
    color: #4da6ff;
}

body.dark .guide-tip {
    background: rgba(77,166,255,0.08);
    border-left-color: #4da6ff;
}

body.dark .guide-score-card {
    background: rgba(43,43,43,0.85);
    border-color: #444;
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

body.dark .guide-score-card span,
body.dark .guide-final p {
    color: #aaa;
}


/* ================================================
   11. TIETOA-SIVU / LEIPÄTEKSTI
   ================================================ */

.info-page {
    max-width: 960px;
    margin: 0 auto;
}

.info-page p {
    font-size: 1rem;
    line-height: 1.75;
}

.info-page h1,
.info-page h2,
.info-page h3 {
    line-height: 1.25;
}

.info-hero {
    border-top: 5px solid #1860c2;
}

.info-kicker {
    margin: 0 0 4px;
    color: #666;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .8rem;
}

.info-lead {
    font-size: 1.18rem;
    font-weight: 500;
    color: #444;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin: 18px auto;
}

.info-box {
    background: rgba(255,255,255,0.75);
    border: 1px solid #ddd;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
}

.info-box h2 {
    margin-top: 0;
    color: #1860c2;
}

.info-section {
    margin-top: 20px;
}

.info-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.info-timeline li {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.info-timeline li:last-child {
    border-bottom: 0;
}

.info-date {
    font-weight: 800;
    color: #1860c2;
    white-space: nowrap;
}

.info-thanks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 12px;
}

.info-thanks > div {
    background: rgba(24, 96, 194, 0.06);
    border: 1px solid rgba(24, 96, 194, 0.14);
    border-radius: 10px;
    padding: 12px 14px;
}

.info-thanks h3 {
    margin-top: 0;
    color: #1860c2;
}

.info-contact {
    max-width: none;
    margin: 22px auto;
    padding: 18px 20px;
}

.info-version {
    font-size: .82rem;
    color: #777;
    text-align: center;
    margin: 20px 0 6px;
}

/* --- Tietoa-sivu (Tumma teema) --- */
body.dark .info-kicker {
    color: #aaa;
}

body.dark .info-lead {
    color: #ddd;
}

body.dark .info-box {
    background: rgba(43,43,43,0.85);
    border-color: #444;
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

body.dark .info-box h2,
body.dark .info-date,
body.dark .info-thanks h3 {
    color: #4da6ff;
}

body.dark .info-timeline li {
    border-bottom-color: rgba(255,255,255,.10);
}

body.dark .info-thanks > div {
    background: rgba(77,166,255,0.08);
    border-color: rgba(77,166,255,0.18);
}

body.dark .info-version {
    color: #aaa;
}


/* ================================================
   12. TEKSTIVISA SIVUN SISÄLTÖ
   ================================================ */

.textquiz-page {
    max-width: 960px;
    margin: 0 auto;
}

.textquiz-select {
    display: grid; /* Lisätty puuttuva display arvo */
    grid-template-columns: repeat(3, 1fr);
}

.textquiz-card {
    display: block;
    text-decoration: none;
    background: rgba(255,255,255,0.82);
    border: 1px solid #ddd;
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
    transition:
        transform .15s ease,
        box-shadow .15s ease,
        border-color .15s ease;
}

.textquiz-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,.14);
    border-color: #1860c2;
    text-decoration: none;
}

.textquiz-card strong {
    display: block;
    color: #1860c2;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.textquiz-card span:last-child {
    display: block;
    color: #555;
    font-size: .92rem;
}

.textquiz-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
}

.textquiz-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.textquiz-mini-help {
    background: rgba(24, 96, 194, 0.08);
    border: 1px solid rgba(24, 96, 194, 0.16);
    color: #1860c2;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
}

.textquiz-container {
    margin: 0;
    width: auto;
    max-width: none;
    text-align: left;
}

.textquiz-question {
    text-align: left;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.textquiz-image {
    margin-top: 10px;
    text-align: center;
}

.textquiz-image img {
    max-width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,.16);
}

.textquiz-options {
    margin-top: 15px;
}

.textquiz-feedback {
    margin-top: 14px;
    font-weight: 700;
}

.textquiz-explanation {
    margin-top: 12px;
    background: rgba(24, 96, 194, 0.06);
    border-left: 5px solid #1860c2;
    border-radius: 8px;
    padding: 12px 14px;
}

.textquiz-explanation:empty {
    display: none;
}

.textquiz-actions {
    text-align: center;
    margin-top: 18px;
}

.textquiz-result {
    max-width: 760px;
    margin: 22px auto;
}

/* --- Tekstivisa (Tumma teema) --- */
body.dark .textquiz-card {
    background: rgba(43,43,43,0.85);
    border-color: #444;
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

body.dark .textquiz-card:hover {
    border-color: #4da6ff;
}

body.dark .textquiz-card strong {
    color: #4da6ff;
}

body.dark .textquiz-card span:last-child {
    color: #aaa;
}

body.dark .textquiz-mini-help {
    background: rgba(77,166,255,0.08);
    border-color: rgba(77,166,255,0.18);
    color: #4da6ff;
}

body.dark .textquiz-explanation {
    background: rgba(77,166,255,0.08);
    border-left-color: #4da6ff;
}


/* ================================================
   13. ETUSIVU
   ================================================ */

.front-page {
    max-width: 980px;
    margin: 0 auto;
}

.front-hero {
    border-top: 5px solid #1860c2;
}

.front-primary-action {
    text-align: center;
    margin: 22px 0 10px;
}

.front-start-button {
    font-size: 1.15rem;
    padding: 14px 28px;
    border-radius: 999px;
}

.front-dev-note {
    text-align: center;
    margin-top: 12px;
}

.front-link-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 22px auto;
}

.front-link-card {
    display: block;
    text-decoration: none;
    background: rgba(255,255,255,0.82);
    border: 1px solid #ddd;
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
    transition:
        transform .15s ease,
        box-shadow .15s ease,
        border-color .15s ease,
        background .15s ease;
}

.front-link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,.14);
    border-color: #1860c2;
    text-decoration: none;
}

.front-link-card strong {
    display: block;
    color: #1860c2;
    font-size: 1.08rem;
    margin-bottom: 6px;
}

.front-link-card span:last-child {
    display: block;
    color: #555;
    font-size: .92rem;
    line-height: 1.45;
}

.front-link-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
}

.front-link-card--main {
    border-color: rgba(40, 167, 69, 0.35);
    background: linear-gradient(180deg, rgba(232,245,233,0.95), rgba(255,255,255,0.85));
}

.front-link-card--main strong {
    color: #218838;
}

.front-note {
    max-width: none;
    text-align: center;
    font-size: 1.05rem;
    margin: 18px auto 0;
    padding: 14px 16px;
}

/* --- Etusivu (Tumma teema) --- */
body.dark .front-link-card {
    background: rgba(43,43,43,0.85);
    border-color: #444;
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

body.dark .front-link-card:hover {
    border-color: #4da6ff;
}

body.dark .front-link-card strong {
    color: #4da6ff;
}

body.dark .front-link-card span:last-child {
    color: #aaa;
}

body.dark .front-link-card--main {
    background: linear-gradient(180deg, rgba(30,60,38,0.95), rgba(43,43,43,0.85));
    border-color: rgba(76, 175, 80, 0.35);
}

body.dark .front-link-card--main strong {
    color: #76d275;
}


/* ================================================
   14. MEDIA QUERIES (MOBIILILAITTEET JA PIENET NÄYTÖT)
   ================================================ */

@media (max-width: 768px) {
    
    /* --- Yleiset Muutokset --- */
    html {
        font-size: 17px;
    }
   
    body {
        line-height: 1.55; 
    }
    
    #mainDiv {
        margin: 0; 
        padding: 10px; 
        border-radius: 0; 
    }
    
    /* --- Lomakkeet ja Taulukot --- */
    .quiz-row {
        flex-direction: column;
        gap: 0;
    }

    .quiz-row > div {
        flex: 1 1 100%; 
        margin-bottom: 12px;
    }
    
    .quiz-start input[type="text"],
    .quiz-start input[type="number"],
    .quiz-start select {
        width: 100%;
        box-sizing: border-box; 
    }
    
    th, td {
        padding: 8px;
    }
    
    .result-table, .stats-table {
        font-size: 0.9rem;
    }

    /* --- Kommentit ja Loppunäyttö --- */
    #comments div[style*="grid"] {
        grid-template-columns: 1fr; 
    }

    .quiz-end {
        padding: 20px 10px;
    }

    .quiz-end h2 {
        font-size: 1.8rem;
    }
}

@media (max-width: 760px) {
    .guide-answer-grid,
    .guide-score-grid,
    .info-grid,
    .info-thanks,
    .textquiz-select {
        grid-template-columns: 1fr;
    }

    .info-timeline li {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .textquiz-header {
        display: block;
    }

    .textquiz-mini-help {
        display: inline-block;
        margin-top: 8px;
        white-space: normal;
    }
}

@media (max-width: 860px) {
    .front-link-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .front-link-grid {
        grid-template-columns: 1fr;
    }
}