:root {
    --lgbgc: linear-gradient(135deg, #0332ff, #00136c, #4785ff);
}
html {
    font-size: 20px;
    font-family: sans-serif;
    background-color: rgb(255, 255, 255);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    overscroll-behavior-y: contain;
    width: 100%;
}
body {
    background: url("../imgs/iqroyale_logo2.png") no-repeat center/fixed;
    position: relative;
}
.snap {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    min-height: 32rem;  /* never smaller than smallest viewport */
    height: 100svh;      /* track address bar show/hide */
    max-height: 100lvh;  /* never exceed largest viewport */
    padding: 1vw 2vw;
    background-image: linear-gradient(aliceblue, #001031de);
}
/*  */
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
/*  */
    button { 
        touch-action: manipulation; 
    }
    button:disabled {
        opacity: 0.5;
        pointer-events: none;
        cursor: not-allowed;
    }
    button:not(:disabled):hover {
        opacity: 0.8;
    }
/*  */
/* header - START */
    header {
        background: var(--lgbgc);
        width: fit-content;
        padding: 0.6rem 0.3rem;
        height: 3vh;
        top:0;
        left:0;
        display: flex;
        align-items: center;    
        justify-content: center;
        position: absolute;
        border-bottom-right-radius: 0.2rem;
        z-index: 3;
    }
    header p {
        color: white;
        font-size: 0.6rem;
        letter-spacing: 0.1rem;
    }
/* header - END */

/* random - START */
    #status_p {
        display: block;
        position: absolute;
        top: 0;
        left: 50%;
        transition: transform 700ms ease-out;
        max-width: 20rem;
        box-shadow: 0 0.1rem 0.2rem #00052ba8;
        font-size: 1rem;
        height: 1.5rem;
        display: grid;
        place-items: center;
        border-radius: 0 0 0.3rem 0.3rem;
        background-image: linear-gradient(to bottom right, #2f3341, #222731);
        border: 0.05rem double gray;
        border-top: none;
        font-size: 0.8rem;
        text-align: center;
        width: 55vw;
        color: #ffffff;
    }
    .game-sec {
        padding-top: 1.5rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
/* random - END */

/* error message slider - START */
    #err_div {
        position: fixed;
        top: 0;
        left: 100vw;
        text-align: center;
        width: 100vw;
        background-color: rgba(255, 0, 0, 0.867);
        color: white;
        padding: 5rem 1rem;
        font-size: 1rem;
        font-weight: bold;
        box-shadow: 0 0.3rem 0.3rem rgb(0, 0, 0);
        transition: left 0.5s ease-in-out;
        z-index: 1000;
    }
/* error message slider - END */

/* initial_view - START */
    #initial_view {
        background-color: white;
        padding: 2rem 0;
        border-radius: 1rem;
        flex-direction: column; align-items: center; justify-content: center;
        gap: 1rem;
        font-size: 1rem;
        width: 100%;
        margin-bottom: 2rem;
        max-width: 25rem;
        box-shadow: 0 0 0.3rem rgb(0 0 0 / 74%);
    }   
    .intro-p {
        color: blue;
        font-size: 0.8rem;
    }
    h1 {
        line-height: 2rem;
        color: #44495c;
        font-size: 1.4rem;
        border-bottom: 0.2rem dashed orange;
    }
    .game-idea-p {
        font-family: 'Segoe UI', Tahoma, sans-serif;
        font-size: 1.1rem;
        line-height: 1.6;
        color: rgb(95, 95, 95);
        margin: 1.5rem auto;
        text-align: center;
    }
    #start_form {
        display: flex;
        width: 80%;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        border: 0.2rem dashed rgb(97 104 142);
        padding: 1rem;
        border-radius: 1rem;
        background-color: #fffffff1;
    }
    #start_form label {
        color: rgb(0, 6, 61);
        text-align: center;
        font-size: 0.9rem;
    }
    #start_form input {
        width: 100%;
        padding: 0.5rem 0.3rem;
        font-size: 1rem;
        font-family: inherit;
        color: #333;
        border: 0.2rem solid orange;
        border-radius: 0.5rem;
        text-align: center;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    #start_form input::placeholder {
        color: #aaa;
    }
    #start_form input:focus {
        border-color: blue;
        box-shadow: 0 0 1rem rgb(0, 0, 0);
        outline: none;
    }
    #start_btn {
        display: grid;
        background: var(--lgbgc);
        color: white;
        border: none;
        place-items: center;
        height: 3.5rem;
        border: 0.05rem solid green;
        width: 100%;
        font-size: 1.2rem;
        font-weight: bold;
        border-radius: 0.6rem;
        cursor: pointer;
        border: 0.2rem ridge rgb(21, 74, 32);
    }
/* initial_view - END */

/* lobby_view - START */
    #lobby_view {
        height: 100%;
        flex-direction: column;
        justify-content: space-evenly; /* IMPORTNAT (CAN BE changed later) */
        align-items: center;
        width: 100%;
        max-width: 30rem;
        position: relative;
        max-height: 35rem;
    }
    #info_span {
        display: block;
        position: absolute;
        margin-right: 0.1rem;
        top: 0;
        right: 0;
        margin-top: 0.2rem;
        margin-right: 0.45rem;
        font-size: 0.7rem;
    }
    #info_span {  
        color: gray;
    }
    #mode_vote_div {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;    
        width: 100%;
        max-width: 20rem;
        background-color: #1e243c36;
        padding: 0.2rem;
        border-radius: 0.5rem;
        border: 0.05rem solid #838da5;
    }
    .vote-hint {
        font-size: 0.9rem;
        border-top-left-radius: 0.5rem;
        border-top-right-radius: 0.5rem;
        width: 100%;
        color: white;
        text-align: center;
        background: var(--lgbgc);
        padding: 0.3rem 0;
    }
    #mode_vote_div div {
        display: flex;
        gap: 0.2rem;
        width: 100%;
    }
    /* vote mode button - START */
        .mode-btn {    
            background-color: white;
            display: flex;
            width: 100%;
            align-items: center;
            justify-content: space-between;
            padding: 0 0.5rem;
            border-radius: 0.3rem;
            height: 3rem;
            border: 0.05rem outset rgb(169, 189, 168);
        }
        .mode-btn:active .vote-box {
            background-color: orange;
        }
        .mode-btn p:first-child {
            color:#39415b;
            text-align: start;
            font-weight: bold;
            font-size: 0.8rem;
            width: 4.6rem;
            border-right: 0.1rem solid orange;  
        }
        .vote-count {
            font-size: 0.8rem;
            color: rgb(0, 0, 0);
        }
        .vote-box {
            height: 55%;
            aspect-ratio: 1;
            border: 0.05rem solid gray;
            border-radius: 0.2rem;
            display: grid;
            place-items: center;
        }
    /* vote mode button - END */

    .lobby-slot-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        justify-content: center;
        width: 100%;
    }
    .lobby-slot {
        display: flex;
        justify-content: space-between;
        border: 0.05rem outset #495261ab;
        background-color: #ffcc7075;
        align-items: center;
        border-radius: 0.4rem;
        height: 2rem;
        padding: 0 0.4rem;
        width: 100%;
        color: #14151d;
    }   
    .player-name {
        width: 6rem;
        letter-spacing: 0.05rem;
        font-style: italic;
    }
    .player-points-p {
        width: 5rem;
        font-size: 0.8rem;
    }
    .player-points-p::before {
        content: 'Points: ';
    }
    .player-time-p {
        width: 5rem;
        display: flex;
        justify-content: start;
        gap: 0.4rem;
        font-size: 0.8rem;
    }
    .player-time-p::before {
        content: 'Time: ';
    }
    .ready-indicator-div {
        height: 50%;
        aspect-ratio: 1;
        border-radius: 50%;
        border: 0.05rem solid #464646;
        background-color: #e1e2e5;
    }
    #lobby_controls_div {
        display: flex;
        width: 100%;
        min-height: 2rem;
        max-height: 4rem;
        height: 100%;
        justify-content: center;    
        gap: 1rem;
        padding: 0.5rem;
        background-color: rgba(173, 177, 197, 0.29);
        border-radius: 0.2rem;
    }
    #lobby_controls_div button {
        height: 100%;
        width: 50%;
        border-radius: 0.3rem;
        font-size: 0.8rem;
        border: 0.05rem solid rgb(159, 164, 187);
    }
    #call_start_btn {
        display: grid;
        place-items: center;
        background-color: #0080ff;
        color: #ffffff;
    }
    #chat_btn {
        background-color: #ffffff;
        color: rgb(0, 0, 0);
    }
    #round_timer {
        background: linear-gradient(135deg, #0331ff44, #00146c62, #4784ff59);
        box-shadow: 0 0 0.3rem #1b2333;
        position: relative;
        width: 100%;
        height: 0.5rem;
        border-radius: 1rem;
        overflow: hidden;
    }
    #round_timer_fill {
        display: flex;
        position: absolute;
        height: 100%;
        width: 100%;
        background-image: linear-gradient(to right, rgb(43, 255, 0), rgb(17, 146, 0));
        transform-origin: left center;
    }
    #play_area {    
        display: flex;
        position: relative;
        width: 100%;
        flex-direction: column;
        background-color: white;
        border-radius: 0.3rem;
        box-shadow: 0 0 0.2rem #000a21e8;
        padding: 0.1rem;
    }
    #question_div {
        font-size: 0.9rem;
        padding: 0.25rem;
        color: rgb(41 53 65);
        user-select: none;    
        pointer-events: none; 
        text-align: center;
        position: relative;
    }
    .border-div {
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 3rem;
        border-radius: 0.2rem;
        border: 0.05rem dashed orange;
    }
    #question_placeholder {
        justify-content: center;
        gap: 0.5rem;
    }
    #answer_div {
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    .answer-container {
        width: 100%;
        height: 3rem;
        display: flex;
        gap: 0.1rem;
        padding: 0.1rem 0;
    }
    #answer_display {
        background-color: gainsboro;
        width: 50%;
        display: grid;
        place-items: center;
        overflow: auto;
        color: #000933;
        letter-spacing: 0.1rem;
        height: 100%;
        border: 0.05rem solid #8d8d8d;
        border-radius: 0.2rem;
    }
    #submit_answer_btn {
        all: unset;
        display: grid;
        place-items: center;
        font-size: 0.9rem;
        width: 25%;
        height: 100%;
        background-color: #0080ff;
        color: white;
        border-radius: 0.2rem;
    }
    #remove_number_btn {
        all: unset;
        display: grid;
        place-items: center;
        color: #ffffff;
        width: 25%;
        background: #be1919;
        height: 100%;
        border-radius: 0.2rem;
    }
    #numpad {
        display: flex;
        width: 100%;
        height: 3rem;
        gap: 0.05rem;
    }
    #numpad button {
        all: unset;
        display: grid;
        place-items: center;
        width: 10%;
        border-radius: 0.2rem;
        height: 100%;
        color: rgb(255 255 255);
        background-image: linear-gradient(to bottom right, #2f3341, #222731);
    }
    #numpad button:hover {
        opacity: 0.9;
    }
    #numpad button:active {
        background-image: linear-gradient(to bottom right, #1b1d25, #101318);
    }
    #submit_answer_btn:active {
        background-color: #021e3b;
    }
    #remove_number_btn:active {
        background-color:#330000;
    }
/* lobby_view - END */

/* match_view - START */
    #match_view {
        height: 100%;
        flex-direction: column;
        justify-content: space-evenly; 
        align-items: center;
        width: 100%;
        max-width: 30rem;
        position: relative;
        max-height: 35rem;
    }
    #match_slot_container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        justify-content: center;
        width: 100%;
    }
    .match-slot {
        display: flex;
        justify-content: space-between;
        background-color: #311b06ad;
        align-items: center;
        border-radius: 0.4rem;
        height: 2rem;
        padding: 0 0.4rem;
        width: 100%;
        color: #edf8ff;
    }   
/* match_view - END */

/* mode-explained-sec - START */
    .mode-explained-sec {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-evenly;
    }
    .mode-explained-sec h2 {
        color: #44495c;
        font-size: 1.2rem;
    }
    /* --- Stacked 3D carousel --- */
    .mode-explained-sec .carousel.stacked {
        position: relative;
        max-width: 34rem;
        width: 100%;
        height: 50vh;
        margin: 0 auto;
        perspective: 20rem;
        transform-style: preserve-3d;
        overflow: visible;
        scrollbar-width: none;
    }
    .mode-explained-sec .carousel.stacked::-webkit-scrollbar { 
        display:none; 
    }
    .mode-explained-sec .carousel.stacked .slide {
        user-select: none; 
        position: absolute;
        left: 50%;
        top: 50%;
        width: clamp(18rem, 90%, 28rem);
        height: 18rem;
        transform-origin: center;
        border-radius: 0.5rem;
        border: 0.05rem solid gainsboro;
        background-image: linear-gradient(to bottom right, rgba(255,255,255,0.7), rgba(255,255,255,0.15));
        backdrop-filter: blur(1rem);
        box-shadow: 0 0 2rem rgba(0,0,0,0.18);
        transition:
            transform 100ms ease-in-out,
            filter 100ms ease,
            opacity 100ms ease,
            z-index 0s step-end;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        align-items: center;
        padding: 1rem;
        padding-top: 2.5rem;
    }
    .mode-explained-sec .carousel .slide h3 {
        color: #ffffff;
        position: absolute;
        top: 0;
        left: 0;
        border: 0.05rem ridge gainsboro;
        background: linear-gradient(135deg, #0332ff , #00136c, #4785ff);
        border-radius: 0.5rem 0 0.5rem 0;
        border-left: none;
        border-top: none;
        padding: 0.5rem;
        font-size: 1rem;
        font-weight: normal;
    }
    .mode-explained-sec .carousel .slide h3::before {
        font-weight: bold;
        color: orange;
    }
    .mode-explained-sec .carousel .slide:nth-of-type(1) h3::before { content: "Mode 1: "; }
    .mode-explained-sec .carousel .slide:nth-of-type(2) h3::before { content: "Mode 2: "; }
    .mode-explained-sec .carousel .slide:nth-of-type(3) h3::before { content: "Mode 3: "; }
    .mode-explained-sec .carousel .slide:nth-of-type(4) h3::before { content: "Mode 4: "; }

    /* Pack tilt while dragging (JS sets --tilt from -1 to 1) */
    .mode-explained-sec .carousel.stacked {
        --tilt: 0; /* -1 … 1 */
        --tilt-deg: calc(var(--tilt) * 6deg);
        transform: rotateY(var(--tilt-deg));
    }
    /* Positions relative to the active index */
    .slide.pos-0 {  /* FRONT */
        z-index: 5;
        opacity: 1;
        filter: none;
        transform: translate(-50%, -50%) translateZ(0) rotateY(0deg) scale(1);
    }
    .slide.pos-1 { /* RIGHT, slightly behind */
        z-index: 4;
        opacity: 0.95;
        filter: saturate(0.95) brightness(0.98);
        transform: translate(calc(-50% + 170px), -50%)
                    translateZ(-130px) rotateY(-12deg) scale(0.94);
    }
    .slide.pos-2 { /* RIGHT BACK (peek) */
        z-index: 3;
        opacity: 0.85;
        filter: blur(0.2px) brightness(0.95);
        transform: translate(calc(-50% + 280px), -50%)
                    translateZ(-260px) rotateY(-16deg) scale(0.9);
    }

    .slide.pos--1 { /* LEFT, slightly behind */
        z-index: 4;
        opacity: 0.95;
        filter: saturate(0.95) brightness(0.98);
        transform: translate(calc(-50% - 170px), -50%)
                    translateZ(-130px) rotateY(12deg) scale(0.94);
    }
    .slide.pos--2 { /* LEFT BACK (peek) */
        z-index: 3;
        opacity: 0.85;
        filter: blur(0.2px) brightness(0.95);
        transform: translate(calc(-50% - 280px), -50%)
                    translateZ(-260px) rotateY(16deg) scale(0.9);
    }
    .mode-explained-sec .slide ul {
        margin-inline-start: 0.4em;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    .mode-explained-sec .slide ul li {
        color: #44495c;
    }
    /* Optional: tiny bounce when becoming front */
    .slide.becoming-front {
        transition: transform 320ms cubic-bezier(.2,1,.2,1), filter 320ms, opacity 320ms;
    }
    /* --- Dots --- */
    .slide-indicator {
        display: flex;
        justify-content: center;
        gap: 0.6rem;
        margin-top: 1rem;
        user-select: none;
    }
    .slide-indicator span {
        width: 0.6rem;
        height: 0.6rem;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.445);
        display: inline-block;
        opacity: 0.5;
        transform: scale(1);
        transition: transform 0.2s ease, opacity 0.2s ease;
        cursor: pointer;
    }
    .slide-indicator span.active {
        opacity: 1;
        transform: scale(1.2);
        background: rgb(255, 255, 255);
    }
/* mode-explained-sec - end */

/* footer - START */
    footer {
        width: 100%;
        display: flex;  
        flex-direction: column;
        justify-content: space-evenly;
        align-items: center;
    }
    footer p {
        color: #44495c;
        font-weight: bold;
        font-size: 1.2rem;  
    }
    footer em {
        color: #ffffff;
    }
    footer ul {
        list-style: none;
        width: 100%;
        display: flex;
        gap: 0.2rem;
        flex-direction: column;
        align-items: center;
    }
    footer li a {
        display: block;
        text-decoration: none;
        color: #ebf3ff;
        padding: 0.5rem;
        border-radius: 0.3rem;
        border: 0.05rem solid gray;
        background-color: #00071ca8;
    }
/* footer - END */

@media (max-width: 600px) {
    header {
        display: none;
    }
    #initial_view {
        background-color: rgba(0, 0, 0, 0);
        box-shadow: none;
    }
    h1 {
        text-align: center;
        color: rgb(64 75 102);
        font-size: 1.2rem;
    }
    .game-idea-p {
        color: rgb(64 75 102);
        width: 15rem;
    }
    #start_form input {
        border: 0.2rem solid orange;
    }
}
@media (max-height: 670px) {
    html {
        font-size: 3vh;
    }
}
@media (max-width: 400px) {
    html {
        font-size: 5vw;
    }
}