/* =========================================================
   MATHS LEARNING SUITE
   Complete Responsive Stylesheet
========================================================= */


/* =========================================================
   GLOBAL APP
========================================================= */

#mls-app {
    font-family: "Trebuchet MS", Arial, sans-serif;
    background: linear-gradient(145deg, #32108d 0%, #6426c5 55%, #7900d4 100%);
    color: #ffffff;
    width: 100%;
    max-width: 1400px;
    min-height: 700px;
    margin: 0 auto;
    border-radius: 18px;
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

#mls-app *,
#mls-app *::before,
#mls-app *::after {
    box-sizing: border-box;
}


/* Remove unwanted default button styles */

#mls-app button {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   GLOBAL CLOSE BUTTON — TOP RIGHT
========================================================= */

#mls-app .mls-close {
    position: absolute;
    top: 32px;
    right: 16px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    background: #ffffff;
    color: #44345b;
    font-family: Arial, sans-serif;
    font-size: 30px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 0 rgba(35, 10, 80, 0.2);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#mls-app .mls-close:hover {
    background: #ffe45c;
    color: #32108d;
    transform: rotate(90deg) scale(1.06);
    box-shadow: 0 6px 0 rgba(35, 10, 80, 0.25);
}

#mls-app .mls-close:active {
    transform: scale(0.94);
}

#mls-app .mls-close:focus-visible {
    outline: 4px solid #ffd43b;
    outline-offset: 3px;
}


/* =========================================================
   SCREENS
========================================================= */

#mls-app .mls-screen {
    display: none;
    padding: 30px;
    min-height: 700px;
    position: relative;
}

#mls-app .mls-screen.active {
    display: block;
}


/* =========================================================
   HOME HERO
========================================================= */

#mls-app .mls-hero {
    text-align: center;
    padding: 38px 10px 18px;
}

#mls-app .mls-brand {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 5px;
    color: #ffffff;
}

#mls-app .mls-brand span {
    color: #ffd43b;
}

#mls-app .mls-hero h1 {
    font-size: clamp(42px, 7vw, 82px);
    font-weight: 900;
    color: #ff8b00;
    text-shadow: 3px 4px #ffffff, 7px 8px #24105c;
    margin: 20px 0;
    line-height: 1.05;
    transform: rotate(-3deg);
}

#mls-app .mls-hero p {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
}


/* =========================================================
   GAME GRID
========================================================= */

#mls-app .mls-game-grid {
    width: 100%;
    max-width: 980px;
    margin: 35px auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}


/* =========================================================
   GAME CARDS
========================================================= */

#mls-app .mls-game-card {
    position: relative;
    width: 100%;
    min-height: 185px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    border: 5px solid #ffffff;
    border-radius: 26px;
    color: #21102e;
    cursor: pointer;
    box-shadow: 0 8px 0 #210b58;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

#mls-app .mls-game-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 0 #210b58;
    filter: brightness(1.04);
}

#mls-app .mls-game-card:active {
    transform: translateY(3px);
    box-shadow: 0 4px 0 #210b58;
}

#mls-app .mls-game-card:focus-visible {
    outline: 4px solid #ffffff;
    outline-offset: 4px;
}


/* Card icon */

#mls-app .mls-game-card i {
    font-style: normal;
    width: 65px;
    height: 65px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.45);
    border: 4px solid #ffffff;
    border-radius: 50%;
    font-size: 30px;
    font-weight: 900;
    line-height: 1;
}


/* Card title */

#mls-app .mls-game-card b {
    font-size: 26px;
    font-weight: 900;
    line-height: 1.05;
    text-align: center;
}


/* Card description */

#mls-app .mls-game-card small {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}


/* =========================================================
   GAME CARD COLOURS
========================================================= */

#mls-app .green {
    background: #57e56b;
}

#mls-app .yellow {
    background: #ffe34f;
}

#mls-app .orange {
    background: #ffb23e;
}

#mls-app .red {
    background: #ff6868;
}

#mls-app .blue {
    background: #66c5ff;
}

#mls-app .purple {
    background: #c19bff;
}


/* =========================================================
   HOME FOOTER
========================================================= */

#mls-app .mls-footer-label {
    text-align: center;
    font-size: 16px;
    font-weight: 800;
    margin-top: 25px;
    color: #ffffff;
}


/* =========================================================
   GAME TOPBAR
========================================================= */

#mls-app .mls-topbar {
    display: grid;
    grid-template-columns: 70px 1fr 70px;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 1150px;
    margin: 0 auto 30px;
    position: relative;
}


/* Game title */

#mls-app .mls-topbar h2 {
    font-size: clamp(34px, 5vw, 64px);
    font-weight: 900;
    color: #ff9a00;
    text-shadow: 2px 3px #ffffff;
    text-align: center;
    line-height: 1.1;
    margin: 0;
}


/* =========================================================
   HOME BUTTON
   Matches .mls-home-btn in PHP
========================================================= */

#mls-app .mls-home-btn {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 4px solid #ffffff;
    border-radius: 50%;
    background: #ff8c18;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 34px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(35, 10, 80, 0.3);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#mls-app .mls-home-btn:hover {
    background: #ffd43b;
    color: #32108d;
    transform: translateY(-3px);
    box-shadow: 0 7px 0 rgba(35, 10, 80, 0.3);
}

#mls-app .mls-home-btn:active {
    transform: scale(0.94);
}

#mls-app .mls-home-btn:focus-visible {
    outline: 4px solid #ffffff;
    outline-offset: 3px;
}


/* Empty right column maintains centered title */

#mls-app .mls-topbar::after {
    content: "";
    display: block;
    width: 58px;
    height: 58px;
}


/* =========================================================
   GAME LAYOUT
========================================================= */

#mls-app .mls-layout {
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 25px;
}


/* =========================================================
   LEVEL SIDEBAR
========================================================= */

#mls-app .mls-layout aside {
    background: #ffffff;
    color: #29104f;
    border-radius: 22px;
    padding: 22px;
    min-width: 0;
}

#mls-app .mls-layout aside h3 {
    font-size: 25px;
    font-weight: 500;
    line-height: 1.2;
    margin: 5px 0 20px;
}


/* Level buttons */

#mls-app .mls-level-btn {
    width: 100%;
    padding: 14px 10px;
    margin: 7px 0;
    border: 0;
    border-radius: 10px;
    background: #eee4ff;
    color: #32108d;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

#mls-app .mls-level-btn:hover {
    background: #e1caff;
    transform: translateX(3px);
}

#mls-app .mls-level-btn.active {
    background: #ffbd24;
    color: #29104f;
}


/* =========================================================
   GAME MAIN PANEL
========================================================= */

#mls-app .mls-layout main {
    min-width: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 3px solid rgba(255, 255, 255, 0.55);
    border-radius: 22px;
    padding: 25px;
    text-align: center;
}


/* =========================================================
   SCORE + TIME
========================================================= */

#mls-app .mls-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

#mls-app .mls-stats div {
    min-width: 100px;
    background: #291064;
    border-radius: 12px;
    padding: 12px 25px;
    font-size: 14px;
    font-weight: 700;
}

#mls-app .mls-stats b {
    display: block;
    color: #ffd33d;
    font-size: 32px;
    line-height: 1.2;
    margin-top: 4px;
}


/* =========================================================
   QUESTION BOX
========================================================= */

#mls-app .mls-question {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 165px;
    background: #ffffff;
    color: #28104f;
    border-radius: 18px;
    padding: 30px;
    margin: 25px 0;
    font-size: clamp(38px, 6vw, 70px);
    font-weight: 900;
    line-height: 1.1;
}


/* =========================================================
   ANSWERS
========================================================= */

#mls-app .mls-answers {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

#mls-app .mls-answers button {
    min-height: 80px;
    border: 4px solid #ffffff;
    border-radius: 15px;
    background: #ffbd24;
    color: #29104f;
    font-size: 32px;
    font-weight: 900;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

#mls-app .mls-answers button:hover {
    background: #7ef28c;
    transform: translateY(-3px);
}

#mls-app .mls-answers button:active {
    transform: scale(0.97);
}


/* =========================================================
   FEEDBACK
========================================================= */

#mls-app .mls-layout main p {
    min-height: 25px;
    margin: 20px 0 15px;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.5;
}


/* =========================================================
   START GAME BUTTON
========================================================= */

#mls-app .mls-layout main>button {
    border: 0;
    border-radius: 12px;
    background: #55e36b;
    color: #173d20;
    padding: 15px 32px;
    font-size: 19px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#mls-app .mls-layout main>button:hover {
    background: #7ef28c;
    transform: translateY(-3px);
    box-shadow: 0 5px 0 rgba(35, 10, 80, 0.3);
}

#mls-app .mls-layout main>button:active {
    transform: scale(0.96);
}


/* =========================================================
   TABLET — UP TO 1024px
========================================================= */

@media (max-width: 1024px) {
    #mls-app .mls-screen {
        padding: 25px;
    }
    #mls-app .mls-game-grid {
        max-width: 850px;
        gap: 18px;
    }
    #mls-app .mls-game-card {
        min-height: 170px;
    }
    #mls-app .mls-layout {
        grid-template-columns: 220px 1fr;
        gap: 18px;
    }
    #mls-app .mls-layout main {
        padding: 20px;
    }
}


/* =========================================================
   MOBILE / TABLET — UP TO 800px
========================================================= */

@media (max-width: 800px) {
    #mls-app {
        border-radius: 14px;
    }
    #mls-app .mls-screen {
        padding: 18px;
        min-height: 650px;
    }
    /* Home */
    #mls-app .mls-hero {
        padding: 35px 5px 15px;
    }
    #mls-app .mls-brand {
        font-size: 13px;
        letter-spacing: 3px;
    }
    #mls-app .mls-hero h1 {
        font-size: clamp(38px, 9vw, 58px);
        margin: 18px 0;
    }
    #mls-app .mls-hero p {
        font-size: 16px;
    }
    #mls-app .mls-game-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        margin: 28px auto;
    }
    #mls-app .mls-game-card {
        min-height: 155px;
        padding: 15px 8px;
        border-width: 4px;
        border-radius: 20px;
        box-shadow: 0 6px 0 #210b58;
    }
    #mls-app .mls-game-card i {
        width: 54px;
        height: 54px;
        font-size: 25px;
        border-width: 3px;
    }
    #mls-app .mls-game-card b {
        font-size: 21px;
    }
    #mls-app .mls-game-card small {
        font-size: 11px;
    }
    /* Game topbar */
    #mls-app .mls-topbar {
        grid-template-columns: 50px 1fr 50px;
        gap: 8px;
        margin-bottom: 22px;
    }
    #mls-app .mls-topbar h2 {
        font-size: 30px;
    }
    #mls-app .mls-home-btn {
        width: 46px;
        height: 46px;
        font-size: 27px;
        border-width: 3px;
    }
    #mls-app .mls-topbar::after {
        width: 46px;
        height: 46px;
    }
    /* Layout */
    #mls-app .mls-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    #mls-app .mls-layout aside {
        padding: 18px;
        border-radius: 18px;
        text-align: center;
    }
    #mls-app .mls-layout aside h3 {
        font-size: 22px;
        margin-bottom: 12px;
    }
    #mls-app .mls-level-btn {
        width: calc(50% - 10px);
        margin: 5px;
    }
    #mls-app .mls-layout main {
        padding: 18px;
        border-radius: 18px;
    }
    #mls-app .mls-question {
        min-height: 130px;
        padding: 25px 15px;
        margin: 20px 0;
    }
    #mls-app .mls-answers {
        gap: 10px;
    }
    #mls-app .mls-answers button {
        min-height: 70px;
        font-size: 28px;
    }
}


/* =========================================================
   SMALL MOBILE — UP TO 480px
========================================================= */

@media (max-width: 480px) {
    #mls-app .mls-close {
        top: 10px;
        right: 10px;
        width: 42px;
        height: 42px;
        font-size: 26px;
    }
    #mls-app .mls-screen {
        padding: 14px;
    }
    #mls-app .mls-hero {
        padding-top: 35px;
    }
    #mls-app .mls-hero h1 {
        font-size: 37px;
        text-shadow: 2px 3px #ffffff, 5px 6px #24105c;
    }
    #mls-app .mls-game-grid {
        gap: 10px;
    }
    #mls-app .mls-game-card {
        min-height: 140px;
        border-radius: 17px;
        padding: 12px 5px;
    }
    #mls-app .mls-game-card i {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
    #mls-app .mls-game-card b {
        font-size: 18px;
    }
    #mls-app .mls-game-card small {
        font-size: 10px;
    }
    #mls-app .mls-topbar h2 {
        font-size: 25px;
    }
    #mls-app .mls-stats {
        gap: 10px;
    }
    #mls-app .mls-stats div {
        min-width: 85px;
        padding: 10px 15px;
        font-size: 12px;
    }
    #mls-app .mls-stats b {
        font-size: 28px;
    }
    #mls-app .mls-question {
        min-height: 115px;
        font-size: 42px;
    }
    #mls-app .mls-answers button {
        min-height: 62px;
        font-size: 25px;
    }
    #mls-app .mls-layout main>button {
        width: 100%;
        padding: 14px 20px;
    }
}


/* =========================================================
   ACCESSIBILITY
========================================================= */

@media (prefers-reduced-motion: reduce) {
    #mls-app *,
    #mls-app *::before,
    #mls-app *::after {
        transition: none !important;
        animation: none !important;
    }
}