* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #ecebe7;
}

.fade-slide {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-slide.show {
  opacity: 1;
  transform: translateY(0);
}
#name_img{
    width: 64px;
}
#step_count {
    border: 3px solid #c9c2b7;
    background: white;
    border-radius: 14px;
    padding: 6px;
    font-size: 14px;
}

.wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.info {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #A37AA6;
    color: white;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tooltip {
    position: absolute;
    z-index: 1000;
    top: 120%;
    left: 0;
    background: #d7d2c8;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    /*white-space: nowrap;*/
    white-space: pre-line; /* rivinvaihdot vain br-tageista ja rivinvaihdoista lähdetekstissä */
    overflow-wrap: normal; /* älä pakota sanoja riville */
    max-width: 100vw;
}

.info:hover + .tooltip,
.info:focus + .tooltip {
    opacity: 1;
    pointer-events: auto;
}


#title img#logo {
    max-width: 30%; /* enintään puolet headerin leveydestä */
    width: 80vw; /* skaalautuu myös pienillä näytöillä */
    height: auto; /* säilyttää kuvasuhteen */
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- OTSIKKO ---------- */
#title {
    padding: 10px;
    text-align: center;
    font-size: 22px;
    /*font-weight: bold;*/
}

/* ---------- LAYOUT ---------- */
#layout {
    flex: 1;
    display: flex;
    flex-direction: row;
}

/* ---------- PELI ---------- */
#game {
    flex: 1;
    padding: 15px;
}

#questionBox {
    background: #FAF9F6;
    border: 3px solid #c9c2b7;
    border-radius: 16px;
    padding: 20px;
    display: none; /*box-shadow: 0 4px 12px rgba(245, 248, 246, 0.35);*/
}

#question {
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
    margin-bottom: 20px;
}

#answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.answerBtn {
    color: black;
    background: #F1F3EE;
    border: 3px solid #c9c2b7; /* pehmeä keltainen, puoliläpinäkyvä */
    border-radius: 14px;
    padding: 14px;
    font-size: 16px;
    min-height: 48px;
    cursor: pointer;
    position: relative;
}

.enemyChoiceIcon {
    width: 40px;
    position: absolute;
    top: 0;
    right: -20px;
}
.myChoiceIcon{
    width: 40px;
    position: absolute;
    top: 0;
    left: -20px;
}

#timer {
    margin-top: 12px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: black;
    margin-top: 16px;
    padding-top: 6px;
}

#startB {
    background: #A37AA6;
    border: 3px solid #F5A835;
    color: #f1f3ee;
    border-radius: 14px;
    padding: 14px;
    font-size: 16px;
    min-height: 48px;
    cursor: pointer;
    margin-top: 16px;

}

.label {
    /*font-size: 1.17em; *//* sama kuin h3 */
    /*font-weight: bold;*/
    /*margin: 1em 0;*/
    font-weight: normal;
    font-size: 16px;
}

.user_name {
    margin: 10px;
    font-weight: bold;
    font-size: 1.17em;
}


/* ---------- TIKKAAT ---------- */
#ladderArea {
    width: 400px;
    height: 500px;
    background: #d7d2c8;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

#ladderArea::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    pointer-events: none;
    background-image: radial-gradient(rgba(241, 243, 238, 0.25) 15%, transparent 15%), radial-gradient(rgba(241, 243, 238, 0.25) 10%, transparent 10%), radial-gradient(rgba(241, 243, 238, 0.25) 12%, transparent 12%);
    background-size: 50px 50px, 70px 70px, 40px 40px;
    background-position: 0 0, 20px 30px, 15px 10px;
}


#ladder {
    position: relative;
    width: 280px;
    height: 90%;
    background: url("assets/ladder.png") center top / contain no-repeat;
}

/* ---------- PELAAJAT ---------- */
#p1_name,
#p2_name {
    padding: 4px 4px;
    font-weight: 600;
    position: relative;
}

#p1_name:not(:empty) {
    position: absolute;
    top: -25px;
    left: 1px;
    z-index: 5;
    border-left: 3px solid #F5A835;
}

#p1_name:not(:empty)::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(
            to right,
            #F5A835 0%,
            rgba(245, 168, 53, 0.6) 40%,
            rgba(245, 168, 53, 0.0) 100%
    );
}

#p2_name {
    position: absolute;
    bottom: -25px;
    right: 1px;
    z-index: 5;
    border-right: 3px solid #A37AA6;
}

#p2_name:not(:empty)::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(
            to left, /* liila täysi oikeassa, häivytys vasempaan */ #A37AA6 0%, /* täysi liila oikealla */ rgba(163, 122, 166, 0.6) 40%,
            rgba(163, 122, 166, 0.0) 100% /* häivytys vasempaan */
    );
}

.player {
    position: absolute;
    width: 240px;
    bottom: 0;
    transition: bottom 0.45s ease;
    height: 5%;
}

#player1Img {
    left: -10px;
    position: absolute;
    bottom: 0;
    transition: bottom 0.4s ease;
    display: block;
    z-index: 2;
}
#p1_stairs {
    left: -10px;
    position: absolute;
    bottom: 0;
    transition: bottom 0.4s ease;
    display: block;
    z-index: 1;
}
#reward1, #reward2, #reward3 {
    left: -10px;
    position: absolute;
    bottom: 0;
    transition: bottom 0.4s ease;
    display: block;
    z-index: 0;
}
#player2Img {
    display: block;
    left: 70px;
    position: absolute;
    bottom: 0;
    transition: bottom 0.4s ease;
    z-index: 1;
}
#p2_stairs {
    display: block;
    left: 70px;
    position: absolute;
    bottom: 0;
    transition: bottom 0.4s ease;
    z-index: 0;
}

.player img {
    width: 100%;
    display: block;
    z-index: 1;
}

.name {
    text-align: center;
    font-size: 14px;
    font-weight: bold;

}
#p1_stairs, #p2_stairs{
    opacity: 1;
    transition: opacity 0.4s ease;
}

#p1_stairs.hidden,  #p2_stairs.hidden  {
    opacity: 0;
}
.player .name {
    position: absolute;
    top: -24px;
    color: black;
    pointer-events: none;
    z-index: 10;
    width: 50px; /* max leveys pelaajan nimen laatikolle */
    /* Rivinvaihto vain väliviivasta */
    white-space: normal;
    overflow-wrap: normal; /* ei rivitä muuten */
    word-break: normal;
    hyphens: auto; /* mahdollistaa rivinvaihdon väliviivasta */
}

#player1 .name {
    /*right: 100%;  */ /* työnnä kokonaan ulos pelaajasta */
    margin-right: 6px; /* pieni väli */
    text-align: center;
}

#player2 .name {
    left: 100%; /*työnnä kokonaan ulos pelaajasta */
    margin-left: 6px;
    text-align: center;
}

#p1_streak1,
#p1_streak2 {
    left: -10px;
    position: absolute;
    bottom: 0;
    z-index: 2;
    display: none;
}

#p2_streak1,
#p2_streak2 {
    left: 70px;
    position: absolute;
    bottom: 0;
    z-index: 1;
    display: none;
}

.username_box input {
    border: 3px solid #c9c2b7; /* sama ruskea kuin muissa */
    border-radius: 12px; /* pyöristetyt kulmat */
    padding: 8px 12px; /* vähän sisäistä tilaa tekstille */
    font-size: 16px;
    outline: none; /* poistaa oletusarvoisen kehystysvärin klikattaessa */
    width: 165px; /* venyy divin leveyteen, halutessasi voi olla esim. 250px */
    box-sizing: border-box; /* varmistaa, että padding ei riko leveyttä */
}

.friend_box input {
    border: 3px solid #c9c2b7; /* sama ruskea kuin muissa */
    border-radius: 12px; /* pyöristetyt kulmat */
    padding: 8px 12px; /* vähän sisäistä tilaa tekstille */
    font-size: 16px;
    outline: none; /* poistaa oletusarvoisen kehystysvärin klikattaessa */
    width: 300px; /* samanlainen leveys kuin oma nimerkkiboxi */
    box-sizing: border-box; /* varmistaa, että padding ei riko leveyttä */
}

input[type="radio"] {
    accent-color: #A37AA6; /* haluamasi väri */
    width: 20px;
    height: 20px;
}

:root {
    --purple: #A37AA6; /* sun murrettu violetti */
}

.subject {
    position: relative;
    border: 3px solid #A37AA6; /* liila reuna */
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease; /* vain reunan muutos */
    width: 85px;
    aspect-ratio: 1 / 1; /* pitää kortin neliönä */
}

.subject img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* kuvat eivät veny, täyttää kortin */
    display: block;
}

.subjects {
    display: grid;
    /*grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));*/
    grid-template-columns: repeat(3, 1fr); /* aina 2 saraketta */
    gap: 16px;
    padding: 8px;
}

.subject .overlay-text {
    position: absolute;
    bottom: 4px; /* alareunassa */
    left: 50%;
    transform: translateX(-50%);
    color: black;
    z-index: 2;
}


/* valittu */
.subject .tick {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #A3CC74;
    color: white;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 2;
    pointer-events: none;
}

.subject.active .tick {
    opacity: 1;
}


/* ---------- MOBIILI: OIKEALLA, KAVENNETTU ---------- */ /* ---------- MOBIILI: TIKKAAT YLÄOSASSA, KAVENNETTU ---------- */
@media (max-width: 480px) {
    #overlay {
        align-items: flex-start;
        /*padding-top: 80px;*/
    }
    .name {
        font-size: 12px;
    }

    /*.subject {
        width: 50px;
    }*/
    .subject .overlay-text {
        font-size: 12px;
    }

    #title img#logo {
        max-width: 60%; /* sallii logon olla isompi pienellä näytöllä */
        width: auto; /* käytä max-width:ää pikemminkin kuin vw:tä */
    }

    /* Ladder alue kaventuu ja on yläosassa */
    #ladderArea {
        width: 120px;
        align-items: flex-start; /* ladder ylös */
        padding-top: 10px;
        position: relative;
        height: 500px; /* tai sopiva kiinteä korkeus */
        align-items: flex-end; /* pohjaan */
    }

    /* Ladder skaalautuu ylhäältä */
    #ladder {
        transform: scale(0.90);
        transform-origin: top center;
    }

    /* Pelaajat pienemmiksi ja alapäähän */
    .player {
        width: 120px;
        bottom: 0; /* pysyy alapäässä tikkaiden juuressa */
        top: auto; /* ei vaikuta */
        position: absolute;
    }

    .player img {
        width: 135px;
        display: block;
        transition: bottom 0.05s linear; /* smooth animaatio */
    }

    /* Pelaajien erikoispaikat */
    #player1 {
        /*transform: translateX(-40%);*/
        left: -10px;
    }

    #player2 {
        left: -45px;
        /*transform: translateX(-40%);*/
    }

    /* Vastausalueen grid yhdelle sarakkeelle mobiilissa */
    /*#answers {
        grid-template-columns: 1fr;
    }*/
}

/* mobiili päättyy */

/* ---------- OVERLAY ILMOITUKSET ---------- */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.2); /* tummentaa taustan */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
    overflow-y: auto; /* tärkeä mobiilissa */
}

#overlay.active {
    opacity: 1;
    pointer-events: all;
}

#notification {
    background: #d7d2c8;
    border: 3px solid #ecebe7;
    border-radius: 18px;
    padding: 30px 40px;
    width: 320px;
    text-align: center;
    font-size: 18px;
    animation: popIn 0.3s ease;
}

.notification-close {
    display: inline-flex; /* TÄRKEÄ */
    align-items: center;
    justify-content: center;

    background-color: #A37AA6;
    color: #F1F3EE;
    border: 3px solid #F5A835;
    border-radius: 12px;

    padding: 6px 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;

    transition: background-color 0.2s ease,
    transform 0.1s ease,
    box-shadow 0.1s ease;
}


@keyframes popIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}


/* Pienillä näytöillä pienennetään fonttia */


@media (max-width: 1200px) {
    #answers {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .answerBtn {
        color: black;
        font-size: 14px;
        padding: 10px;
        min-height: 36px;
    }
}


