/* =========================================
   PERUSASETUKSET
========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html,
body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Arial, Helvetica, sans-serif;
    color: #f4e7c1;
    background:
        linear-gradient(rgba(5, 12, 30, 0.82), rgba(5, 12, 30, 0.92)),
        url("tausta.png") center center / cover fixed;
}

.background {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: url("tausta.png") center / cover no-repeat;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(
        120deg,
        rgba(5, 12, 30, 0.82),
        rgba(5, 12, 30, 0.58)
    );
}

/* =========================================
   YLÄPALKKI
========================================= */

.header {
    height: 78px;
    padding: 0 7%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, #08152d, #142b50);
    border-bottom: 2px solid #c9a44c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.logo {
    font-size: 25px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #f5d783;
    text-decoration: none;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.9;
}

.logo span {
    color: #f5d783;
}

nav {
    display: flex;
    gap: 28px;
    align-items: center;
}

nav a {
    color: #f4e7c1;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}

nav a:hover {
    color: #ffc75c;
}

/* =========================================
   PÄÄALUE
========================================= */

.main {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.computer-wrapper {
    width: 100%;
    min-width: 0;
    margin: 0 auto;
}

.computer {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    background: #050b18;
    border: 2px solid #c9a44c;
    border-radius: 12px;
    box-shadow:
        0 0 0 4px rgba(201, 164, 76, 0.12),
        0 12px 35px rgba(0, 0, 0, 0.55);
}

/* =========================================
   PELIN OTSIKKO
========================================= */

.game-timeline-title {
    width: 100%;
    padding: 13px 18px;
    color: #f5d783;
    background: linear-gradient(90deg, #102344, #1c3965);
    border-bottom: 1px solid #c9a44c;
    text-align: center;
    font-size: 18px;
    letter-spacing: 0.4px;
}

.game-timeline-title strong {
    font-weight: bold;
}

/* =========================================
   EMULAATTORIN NÄYTTÖ
========================================= */

#screen_container {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#screen_container canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    margin: auto !important;
}

.computer.image-stretched #screen_container canvas {
    object-fit: fill !important;
}

.screen-text {
    position: absolute;
    inset: 0;
    pointer-events: none;
    color: #f5d783;
}

/* =========================================
   TALLENNUSILMOITUS (TOAST)
========================================= */

.save-toast {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);

    padding: 10px 20px;
    border-radius: 8px;

    background: linear-gradient(135deg, rgba(8, 21, 45, 0.95), rgba(20, 43, 80, 0.95));
    border: 1px solid #c9a44c;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 10px rgba(201, 164, 76, 0.35);

    color: #f5d783;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
    max-width: 90%;

    opacity: 0;
    pointer-events: none;
    z-index: 1000;

    transition: opacity 0.3s ease, transform 0.3s ease;
}

.save-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =========================================
   PELIEN VALINTAPALKKI
========================================= */

.game-timeline {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;

    width: 100%;
    min-width: 0;
    max-width: 100%;

    padding: 10px 14px;

    color: #f5d783;
    background: linear-gradient(90deg, #0b1933, #172e52);
    border-top: 1px solid #c9a44c;

    overflow: hidden;
}

.game-timeline-settings {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 8px;

    width: auto;
    min-width: 0;
    max-width: 100%;
    margin-left: auto;
}

/* =========================================
   ASETUSPAINIKKEET
========================================= */

.game-timeline button,
.game-timeline select {
    min-width: 0;
    max-width: 100%;
    padding: 8px 11px;

    color: #f5d783;
    background: #142b50;
    border: 1px solid #c9a44c;
    border-radius: 6px;

    font-size: 13px;
    font-weight: bold;
    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.game-timeline button:hover,
.game-timeline select:hover {
    color: #08152d;
    background: #f5d783;
    border-color: #ffe7a0;
    transform: scale(1.04);
}

.game-timeline button:focus-visible,
.game-timeline select:focus-visible {
    outline: 2px solid #ffe7a0;
    outline-offset: 2px;
}

/* =========================================
   RESOLUUTIOASETUS
========================================= */

.resolution-control {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

#resolution {
    width: auto;
    max-width: 150px;
}

/* =========================================
   ÄÄNENVOIMAKKUUS
========================================= */

.volume-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
}

#volumeIcon {
    color: #f5d783;
    font-size: 17px;
}

#volumeSlider {
    width: 85px;
    max-width: 85px;
    min-width: 45px;
    accent-color: #c9a44c;
    cursor: pointer;
}

#volumeValue {
    min-width: 30px;
    color: #f5d783;
    font-size: 12px;
    text-align: center;
}

#muteBtn {
    white-space: nowrap;
}

/* =========================================
   VENYTYS-, TALLENNUS- JA KOKO NÄYTÖN PAINIKKEET
========================================= */

#stretchBtn,
#fullscreenBtn,
.fullscreen-save-btn {
    white-space: nowrap;
}

/* Koko näytön tallennusnappi näkyy vain koko näytössä */
.fullscreen-save-btn {
    display: none;
}

.computer:fullscreen .fullscreen-save-btn {
    display: inline-flex;
}

/* =========================================
   ISOT TOIMINTOPAINIKKEET (NORMAALITILASSA)
========================================= */

.save-actions-wrapper {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
    margin: 0;
}

.large-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    width: 100%;
    min-height: 52px;
    padding: 14px 22px;

    color: #f5d783;
    background: linear-gradient(145deg, #102344, #183561);
    border: 2px solid #c9a44c;
    border-radius: 10px;

    font-size: 17px;
    font-weight: 900;
    letter-spacing: 0.8px;
    cursor: pointer;

    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(201, 164, 76, 0.2);

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.large-action-btn:hover {
    color: #08152d;
    background: linear-gradient(145deg, #f5d783, #ffc75c);
    border-color: #ffe7a0;
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.55),
        0 0 12px rgba(245, 215, 131, 0.45);
}

.large-action-btn:active {
    transform: translateY(0) scale(0.99);
}

.large-action-btn:focus-visible {
    outline: 2px solid #ffe7a0;
    outline-offset: 2px;
}

/* Koti-painike piilossa normaalitilassa */

#homeBtn {
    display: none;
}

/* Koti-painike näkyy koko näytössä */

.computer:fullscreen #homeBtn {
    display: inline-flex;
}

/* =========================================
   PALKKIEN SULKEMINEN
========================================= */

.close-timeline {
    display: none;
}

.timeline-reopen {
    display: none;
}

/* =========================================
   KOKO NÄYTÖN TILA
   Alkuperäinen v86-asettelu säilytetty
========================================= */

.computer:fullscreen {
    position: relative;

    width: 100vw;
    height: 100vh;

    max-width: none;
    min-width: 0;

    overflow: hidden;

    border: 0;
    border-radius: 0;
}

/* Otsikko pois koko näytössä */

.computer:fullscreen > .game-timeline-title {
    display: none !important;
}

/* Näyttö keskelle koko näytön tilassa */

.computer:fullscreen #screen_container {
    position: absolute;

    left: 50%;
    top: 50%;

    max-width: 100vw;
    max-height: 100vh;

    transform: translate(-50%, -50%);

    aspect-ratio: auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Koko näytön asetuspalkki */

.computer:fullscreen .game-timeline {
    position: absolute;

    top: 12px;
    right: 12px;
    left: auto;

    width: auto;
    max-width: calc(100vw - 24px);
    min-width: 0;

    justify-content: flex-end;
    flex-wrap: nowrap;

    padding: 10px 14px;

    overflow: visible;

    border: 1px solid #c9a44c;
    border-radius: 8px;

    z-index: 100;
}

/* Koko näytön asetukset */

.computer:fullscreen .game-timeline-settings {
    display: flex;

    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;

    margin-left: auto;

    justify-content: flex-end;
    flex-wrap: nowrap;
}

/* Sulkemispainike näkyviin koko näytössä */

.computer:fullscreen .close-timeline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: static;
    transform: none;
    margin-left: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    color: #f5d783;
    background: #142b50;
    border: 1px solid #c9a44c;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.computer:fullscreen .close-timeline:hover {
    color: #08152d;
    background: #f5d783;
    border-color: #ffe7a0;
    transform: scale(1.08);
}

/* =========================================
   KOKO NÄYTÖN TILA – PALKKI SULJETTU
========================================= */

.computer:fullscreen.timeline-closed .game-timeline {
    display: none !important;
}

.computer:fullscreen.timeline-closed .timeline-reopen {
    display: inline-flex;

    position: absolute;
    top: 12px;
    right: 12px;

    align-items: center;
    justify-content: center;

    padding: 9px 14px;

    color: #f5d783;
    background: #142b50;
    border: 1px solid #c9a44c;
    border-radius: 7px;

    font-weight: bold;
    cursor: pointer;

    z-index: 100;
}

.computer:fullscreen.timeline-closed .timeline-reopen:hover {
    color: #08152d;
    background: #f5d783;
}

/* =========================================
   PELIN KLIKKAUKSELLA PIILOTTAMA PALKKI
========================================= */

.computer.timeline-hidden-by-game-click .game-timeline,
.computer.timeline-hidden-by-game-click .timeline-reopen {
    display: none !important;
}

/* =========================================
   OHJETEKSTI JA ALAPALKIT
========================================= */

.game-controls-container {
    width: 100%;
    max-width: 100%;
    margin: 14px auto 0 auto;
    display: flex;
    flex-direction: column;
}

.help {
    width: 100%;
    margin: 0 0 12px 0;
    padding: 12px 18px;
    color: #f5d783;
    background: linear-gradient(90deg, #102344, #1c3965);
    border: 1px solid #c9a44c;
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 0.4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.computer:fullscreen ~ .game-controls-container,
.computer:fullscreen .help {
    display: none;
}

/* =========================================
   ALATUNNISTE
========================================= */

footer,
.footer {
    width: 100%;
    margin-top: auto;
    padding: 25px 15px;

    color: #c9b783;
    background: rgba(5, 13, 29, 0.92);

    border-top: 1px solid #8f7134;

    text-align: center;
    font-size: 12px;
    letter-spacing: 2px;
}

/* =========================================
   MOBIILINÄKYMÄ
========================================= */

@media (max-width: 700px) {
    .header {
        padding: 10px 14px;
    }

    .logo {
        font-size: 16px;
    }

    .main {
        padding: 10px;
    }

    .save-actions-wrapper {
        grid-template-columns: 1fr;
        gap: 10px;
        margin: 0;
    }

    .large-action-btn {
        min-height: 46px;
        padding: 12px 16px;
        font-size: 15px;
    }

    .game-timeline-title {
        padding: 11px;
        font-size: 15px;
    }

    .game-timeline {
        justify-content: flex-end;
        padding: 9px;
    }

    .game-timeline-settings {
        width: 100%;
        flex: 1 1 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 7px;
    }

    .game-timeline button,
    .game-timeline select {
        padding: 7px 9px;
        font-size: 12px;
    }

    #volumeSlider {
        width: 65px;
        max-width: 65px;
    }

    /* Mobiilin koko näytön palkki */

    .computer:fullscreen .game-timeline {
        top: 8px;
        right: 8px;

        width: auto;
        max-width: calc(100vw - 16px);

        flex-wrap: wrap;
        justify-content: flex-end;

        padding: 8px;
    }

    .computer:fullscreen .game-timeline-settings {
        width: auto;
        max-width: 100%;

        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .computer:fullscreen .close-timeline {
        position: static;
        transform: none;
        margin-left: 6px;
    }
}

/* =========================================
   ERITTÄIN PIENET NÄYTÖT
========================================= */

@media (max-width: 400px) {
    .game-timeline-settings {
        gap: 5px;
    }

    .game-timeline button,
    .game-timeline select {
        padding: 6px 7px;
        font-size: 11px;
    }

    #volumeSlider {
        width: 50px;
        max-width: 50px;
    }

    #volumeValue {
        min-width: 25px;
        font-size: 11px;
    }
}
/* =========================================
   TIETOKONEEN KOKO ALUE KESKELLE
========================================= */

.computer-wrapper {
    display: flex;
    justify-content: center;

    width: 100%;
    max-width: 1500px;

    margin-left: auto;
    margin-right: auto;
}

.computer {
    width: 100%;
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
}

.main {
    flex: 1;
}