* {
    box-sizing: border-box;
}

:root {
    --bg1: #ffe6f2;
    --bg2: #e8f0ff;
    --bg3: #e8fff7;
    --primary: #7b61ff;
    --primary-2: #49c6ff;
    --secondary: #ff78b2;
    --secondary-2: #ff9f68;
    --text: #2b2f55;
    --muted: #6f7698;
    --card: rgba(255, 255, 255, 0.82);
    --white: #ffffff;
    --shadow: 0 20px 45px rgba(96, 109, 177, 0.18);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 16px;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "Nunito", sans-serif;
    color: var(--text);
}

body {
    background:
        radial-gradient(circle at 0% 0%, #ffd6ea 0, transparent 28%),
        radial-gradient(circle at 100% 0%, #d8e9ff 0, transparent 30%),
        radial-gradient(circle at 100% 100%, #d8fff2 0, transparent 26%),
        linear-gradient(135deg, #fdf3ff 0%, #eef5ff 50%, #f0fff8 100%);
    padding: 24px;
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    filter: blur(12px);
    opacity: 0.45;
    z-index: 0;
    animation: floatBlob 9s ease-in-out infinite;
}

body::before {
    top: 40px;
    left: -70px;
    background: #ffd2ea;
}

body::after {
    right: -70px;
    bottom: 20px;
    background: #cfe8ff;
    animation-delay: 1.5s;
}

@keyframes floatBlob {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-18px); }
}

.hidden {
    display: none !important;
}

#login-container,
#quiz-container,
#result-container,
#welcome-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
}

#login-container,
.result-box,
#welcome-container .result-box {
    max-width: 620px;
    margin: 30px auto;
    background: var(--card);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--radius-xl);
    padding: 34px 28px;
    box-shadow: var(--shadow);
    text-align: center;
}

.logo-header {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.academy-logo {
    width: 200px;
    height: 200px;
    object-fit: contain;
    border-radius: 22px;
    border: 4px solid rgba(255,255,255,0.9);
    background: white;
    box-shadow: 0 12px 24px rgba(122, 130, 187, 0.18);
}

h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text);
}

h2 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

h3 {
    font-size: 24px;
    font-weight: 800;
}

.sub-title {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 16px;
}

.input-group {
    display: grid;
    gap: 14px;
    margin: 20px 0 16px;
}

input[type="text"],
input[type="password"],
input[type="number"],
.fill-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 15px 16px;
    font-size: 16px;
    border-radius: 18px;
    background: rgba(248, 250, 255, 0.96);
    color: var(--text);
    box-shadow: inset 0 0 0 1.5px rgba(128, 141, 210, 0.18);
    transition: 0.22s ease;
}

input::placeholder {
    color: #97a0bf;
}

input:focus,
.fill-input:focus {
    transform: translateY(-1px);
    background: white;
    box-shadow:
        inset 0 0 0 2px rgba(123, 97, 255, 0.35),
        0 10px 20px rgba(115, 118, 217, 0.12);
}

button {
    font-family: "Nunito", sans-serif;
}

#start-btn,
.primary-btn,
.secondary-btn,
.audio-btn,
.word-btn {
    border: none;
    cursor: pointer;
    transition: 0.22s ease;
    font-weight: 800;
}

#start-btn,
.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border-radius: 18px;
    padding: 15px 20px;
    box-shadow: 0 14px 28px rgba(105, 114, 255, 0.25);
}

#start-btn {
    width: 100%;
    font-size: 17px;
    margin-top: 4px;
}

#start-btn:hover,
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(105, 114, 255, 0.28);
}

.secondary-btn {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-2));
    color: white;
    border-radius: 18px;
    padding: 15px 20px;
    box-shadow: 0 14px 26px rgba(255, 132, 173, 0.22);
}

.secondary-btn:hover {
    transform: translateY(-2px);
}

.message {
    min-height: 24px;
    margin-top: 14px;
    font-weight: 700;
    color: #e2548b;
}

#quiz-container {
    background: var(--card);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.72);
    border-radius: var(--radius-xl);
    padding: 26px;
    box-shadow: var(--shadow);
    margin-top: 18px;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(130, 144, 210, 0.16);
}

.header-info p {
    margin: 0;
    color: var(--muted);
}

#timer {
    min-width: 180px;
    text-align: center;
    background: linear-gradient(135deg, #ff83ac, #ff7f5f);
    color: white;
    border-radius: 22px;
    padding: 14px 18px;
    font-weight: 800;
    box-shadow: 0 14px 26px rgba(255, 127, 149, 0.24);
}

#time-left {
    display: block;
    margin-top: 6px;
    font-size: 30px;
    letter-spacing: 1px;
}

#questions-wrapper {
    min-height: 280px;
}

.question-block {
    background: rgba(255,255,255,0.96);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 14px 28px rgba(108, 123, 196, 0.12);
}

.question-text {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.5;
    margin-top: 0;
    margin-bottom: 18px;
    color: #243066;
}

.question-media {
    margin-bottom: 18px;
}

.q-img {
    max-width: 100%;
    border-radius: 18px;
    box-shadow: 0 10px 22px rgba(90, 106, 172, 0.16);
}

.options,
.options-grid {
    display: grid;
    gap: 14px;
}

.options-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.options label,
.option-image-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #ffffff, #f5f8ff);
    box-shadow: inset 0 0 0 1.5px rgba(131, 145, 212, 0.15);
    transition: 0.2s ease;
    cursor: pointer;
}

.options label:hover,
.option-image-box:hover {
    transform: translateY(-2px);
    box-shadow:
        inset 0 0 0 2px rgba(123, 97, 255, 0.18),
        0 10px 18px rgba(111, 122, 207, 0.12);
}

.option-image-box {
    flex-direction: column;
    justify-content: center;
}

.option-image-box img {
    max-width: 100%;
    border-radius: 14px;
}

.audio-box {
    margin-bottom: 14px;
}

.audio-btn {
    background: linear-gradient(135deg, #ffb054, #ff7d8c);
    color: white;
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 12px 22px rgba(255, 145, 124, 0.2);
}

.audio-btn.playing {
    background: linear-gradient(135deg, #7b61ff, #37c9ff);
}

.answer-zone,
.word-bank {
    min-height: 70px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
    border-radius: 18px;
    background: #f7f9ff;
    box-shadow: inset 0 0 0 1.5px rgba(127, 142, 205, 0.14);
}

.rearrange-container,
.arrange-container {
    display: grid;
    gap: 14px;
}

.word-btn {
    background: linear-gradient(135deg, #ffffff, #edf3ff);
    color: #37406f;
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 8px 16px rgba(109, 119, 184, 0.12);
}

.word-btn.selected {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
}

.arrange-item {
    text-align: center;
    padding: 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #ffffff, #f7fbff);
    box-shadow: inset 0 0 0 1.5px rgba(125, 139, 204, 0.12);
}

.arrange-label {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    background: linear-gradient(135deg, #7b61ff, #49c6ff);
    margin-bottom: 10px;
}

.arrange-item img {
    max-width: 100%;
    border-radius: 14px;
    margin: 8px 0 12px;
}

.control-bar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 22px;
}

.result-box {
    position: relative;
}

.result-icon {
    font-size: 54px;
    margin-bottom: 8px;
}

#result-detail {
    color: var(--muted);
    line-height: 1.8;
}

#student-info-box {
    background: linear-gradient(135deg, #ffffff, #f7f9ff);
    border-radius: 20px;
    padding: 18px;
    box-shadow: inset 0 0 0 1.5px rgba(129, 143, 205, 0.12);
}

#welcome-container .primary-btn {
    min-width: 220px;
}

@media (max-width: 768px) {
    body {
        padding: 14px;
    }

    #login-container,
    .result-box,
    #quiz-container,
    #welcome-container .result-box {
        padding: 20px;
        border-radius: 22px;
    }

    .quiz-header,
    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }

    #timer {
        min-width: unset;
    }

    .academy-logo {
        width: 68px;
        height: 68px;
    }

    .question-text {
        font-size: 19px;
    }

    h2 {
        font-size: 25px;
    }
}


.loading-popup {
    position: fixed;
    inset: 0;
    background: rgba(40, 47, 88, 0.35);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-box {
    width: min(90%, 340px);
    background: rgba(255, 255, 255, 0.96);
    border-radius: 24px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 18px 40px rgba(62, 79, 145, 0.22);
    animation: popupFade 0.25s ease;
}

.loading-box h3 {
    margin: 14px 0 8px;
    font-size: 22px;
    color: #2d356b;
}

.loading-box p {
    margin: 0;
    color: #6d769b;
    line-height: 1.6;
    font-weight: 600;
}

.spinner {
    width: 54px;
    height: 54px;
    margin: 0 auto;
    border-radius: 50%;
    border: 6px solid #eadfff;
    border-top: 6px solid #7b61ff;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes popupFade {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}