:root {
    --qz-blue: #2563eb;
    --qz-blue-dark: #1d4ed8;
    --qz-purple: #7c3aed;
    --qz-card: #ffffff;
    --qz-text: #14213d;
    --qz-muted: #6b7280;
    --qz-line: #dbe4f1;
    --qz-soft: #f3f6ff;
    --qz-shadow: 0 16px 42px rgba(49, 76, 123, .13);
}

.qz-manager-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.qz-manager-head h2 {
    margin: 4px 0;
}

.qz-manager-head p {
    max-width: 720px;
    margin: 5px 0;
    color: var(--qz-muted);
}

.qz-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.qz-summary-grid article {
    padding: 16px;
    border: 1px solid var(--qz-line);
    border-radius: 15px;
    background: var(--qz-card);
}

.qz-summary-grid span,
.qz-summary-grid small {
    display: block;
    color: var(--qz-muted);
}

.qz-summary-grid span {
    font-size: 12px;
    font-weight: 700;
}

.qz-summary-grid strong {
    display: block;
    margin: 7px 0;
    color: var(--qz-blue);
    font-size: 25px;
}

.qz-summary-grid small {
    line-height: 1.45;
}

.qz-manager-search {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.qz-manager-search input {
    width: min(470px, 100%);
    padding: 11px 13px;
    border: 1px solid var(--qz-line);
    border-radius: 12px;
    background: #ffffff;
}

.qz-set-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 16px;
}

.qz-set-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 18px;
    border: 1px solid var(--qz-line);
    border-radius: 17px;
    background: var(--qz-card);
    box-shadow: 0 6px 20px rgba(49, 76, 123, .06);
}

.qz-set-card-icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border-radius: 15px;
    background: #f1ecff;
    font-size: 27px;
}

.qz-set-card-copy {
    min-width: 0;
}

.qz-set-card h3 {
    margin: 0 0 5px;
}

.qz-set-card p {
    min-height: 38px;
    margin: 0 0 10px;
    overflow: hidden;
    color: var(--qz-muted);
    font-size: 13px;
    line-height: 1.45;
}

.qz-set-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.qz-set-meta span {
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--qz-blue);
    background: var(--qz-soft);
    font-size: 11px;
    font-weight: 700;
}

.qz-set-card > .button {
    grid-column: 1 / -1;
    width: 100%;
}

.qz-empty {
    grid-column: 1 / -1;
    padding: 50px 24px;
    border: 1px solid var(--qz-line);
    border-radius: 18px;
    background: #ffffff;
    text-align: center;
}

.qz-empty-icon {
    font-size: 50px;
}

.qz-empty h3 {
    margin: 10px 0 7px;
}

.qz-empty p {
    margin: 0 auto 18px;
    max-width: 520px;
    color: var(--qz-muted);
    line-height: 1.6;
}

.qz-part-one {
    max-width: 760px;
    margin: 20px auto;
    padding: 30px;
    border: 1px solid var(--qz-line);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: var(--qz-shadow);
    text-align: center;
}

.qz-part-one-icon {
    display: grid;
    width: 76px;
    height: 76px;
    place-items: center;
    margin: 0 auto 14px;
    border-radius: 22px;
    background: #f1ecff;
    font-size: 40px;
}

.qz-part-one h2 {
    margin: 7px 0;
}

.qz-part-one > p {
    color: var(--qz-muted);
}

.qz-ready-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 24px 0;
    text-align: left;
}

.qz-ready-list div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px;
    border-radius: 13px;
    background: var(--qz-soft);
}

.qz-ready-list span {
    font-size: 23px;
}

.qz-part-one-notice {
    padding: 14px;
    border-radius: 13px;
    color: #5b21b6;
    background: #f5f0ff;
    font-size: 13px;
    line-height: 1.55;
}

.qz-part-one-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
}

.qz-part-one-actions button:disabled {
    cursor: not-allowed;
    opacity: .6;
}

@media (max-width: 760px) {
    .qz-manager-head {
        flex-direction: column;
    }

    .qz-summary-grid {
        grid-template-columns: 1fr;
    }

    .qz-ready-list {
        grid-template-columns: 1fr;
    }

    .qz-part-one-actions {
        flex-direction: column;
    }

    .qz-part-one-actions .button {
        width: 100%;
    }
}

@media (max-width: 430px) {
    .qz-set-grid {
        grid-template-columns: 1fr;
    }

    .qz-part-one {
        padding: 22px 15px;
    }
}


/* Quiz Challenge — gameplay */

.qz-play-body {
    min-height: 100vh;
    margin: 0;
    color: var(--qz-text);
    background:
        radial-gradient(circle at top, #ffffff 0, transparent 28rem),
        #eef4ff;
    font-family: Arial, sans-serif;
}

.qz-game-shell {
    width: min(580px, 100%);
    min-height: 100dvh;
    margin: 0 auto;
    padding: 14px 14px 24px;
}

.qz-game-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 13px;
}

.qz-game-header span {
    display: block;
    margin-bottom: 4px;
    color: #52627c;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.qz-game-header h1 {
    margin: 0;
    font-size: 24px;
}

.qz-game-header > a {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--qz-line);
    border-radius: 11px;
    color: #334155;
    background: #ffffff;
    font-weight: 800;
    text-decoration: none;
}

.qz-statusbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.qz-statusbar > div {
    padding: 9px 7px;
    border: 1px solid var(--qz-line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .9);
    text-align: center;
}

.qz-statusbar small {
    display: block;
    margin-bottom: 3px;
    color: var(--qz-muted);
    font-size: 10px;
}

.qz-statusbar strong {
    font-size: 17px;
}

.qz-game-progress {
    height: 7px;
    margin-bottom: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #dbe5f4;
}

.qz-game-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--qz-purple), var(--qz-blue));
    transition: width .25s ease;
}

.qz-question-card {
    min-height: calc(100dvh - 190px);
    padding: 18px;
    border: 1px solid var(--qz-line);
    border-radius: 23px;
    background: #ffffff;
    box-shadow: var(--qz-shadow);
}

.qz-question-badge {
    width: fit-content;
    margin: 0 auto 8px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #5b21b6;
    background: #f3edff;
    font-size: 11px;
    font-weight: 800;
}

.qz-question-card > h2 {
    margin: 0 0 13px;
    font-size: 19px;
    text-align: center;
}

.qz-image-prompt {
    display: grid;
    height: min(31dvh, 270px);
    place-items: center;
    margin-bottom: 14px;
    overflow: hidden;
    border-radius: 17px;
    background: #f8fbff;
}

.qz-image-prompt img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qz-audio-prompt {
    display: grid;
    width: min(220px, 70%);
    min-height: 150px;
    place-items: center;
    margin: 7px auto 17px;
    border: 0;
    border-radius: 28px;
    color: #ffffff;
    background:
        radial-gradient(circle at 30% 20%, #8b5cf6, transparent 55%),
        var(--qz-blue);
    box-shadow: 0 17px 34px rgba(37, 99, 235, .25);
    cursor: pointer;
}

.qz-audio-prompt span {
    display: block;
    font-size: 62px;
}

.qz-audio-prompt strong {
    display: block;
    margin-top: -26px;
    font-size: 18px;
}

.qz-text-prompt {
    display: grid;
    min-height: 145px;
    place-items: center;
    margin: 7px 0 17px;
    padding: 18px;
    border-radius: 18px;
    color: #172554;
    background: #f4f7ff;
    text-align: center;
    cursor: pointer;
}

.qz-text-prompt strong {
    display: block;
    font-size: clamp(34px, 10vw, 54px);
    line-height: 1.1;
}

.qz-text-prompt small {
    display: block;
    margin-top: 10px;
    color: var(--qz-blue);
    font-size: 18px;
}

.qz-answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.qz-answer-button {
    min-height: 64px;
    padding: 11px;
    border: 2px solid var(--qz-line);
    border-radius: 14px;
    color: #1e293b;
    background: #ffffff;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.3;
    cursor: pointer;
    transition:
        border-color .16s ease,
        background .16s ease,
        transform .16s ease;
}

.qz-answer-button:hover:not(:disabled) {
    border-color: #9cb4e9;
    background: #f8fbff;
    transform: translateY(-1px);
}

.qz-answer-button.correct {
    border-color: #22c55e;
    color: #166534;
    background: #dcfce7;
}

.qz-answer-button.wrong {
    border-color: #ef4444;
    color: #991b1b;
    background: #fee2e2;
    animation: qz-shake .25s linear 2;
}

.qz-answer-button:disabled {
    cursor: default;
}

.qz-feedback {
    min-height: 23px;
    margin: 12px 0 0;
    color: var(--qz-muted);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.qz-feedback.correct {
    color: #15803d;
}

.qz-feedback.wrong {
    color: #b91c1c;
}

.qz-next-button {
    width: 100%;
    min-height: 49px;
    margin-top: 11px;
    border: 0;
    border-radius: 13px;
    color: #ffffff;
    background: var(--qz-blue);
    font-weight: 800;
    cursor: pointer;
}

.qz-result-panel {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    padding: 18px;
    place-items: center;
    background: rgba(20, 33, 61, .55);
    backdrop-filter: blur(7px);
}

.qz-result-panel[hidden] {
    display: none;
}

.qz-result-card {
    width: min(430px, 100%);
    padding: 28px 20px;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 30px 90px rgba(15, 23, 42, .28);
    text-align: center;
}

.qz-result-icon {
    font-size: 56px;
}

.qz-result-card h2 {
    margin: 8px 0;
    font-size: 30px;
}

.qz-result-card > p {
    color: var(--qz-muted);
}

.qz-result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 20px 0;
}

.qz-result-stats span {
    padding: 11px 5px;
    border-radius: 13px;
    background: var(--qz-soft);
}

.qz-result-stats small,
.qz-result-stats strong {
    display: block;
}

.qz-result-stats small {
    margin-bottom: 4px;
    color: var(--qz-muted);
    font-size: 10px;
}

.qz-result-stats strong {
    color: var(--qz-blue);
    font-size: 19px;
}

.qz-result-card button {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 13px;
    color: #ffffff;
    background: var(--qz-blue);
    font-weight: 800;
    cursor: pointer;
}

.qz-result-card > a {
    display: inline-block;
    margin-top: 15px;
    color: #5b21b6;
}

.qz-game-empty {
    padding: 50px 22px;
    border-radius: 20px;
    background: #ffffff;
    text-align: center;
}

.qz-game-empty > div {
    font-size: 50px;
}

@keyframes qz-shake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@media (max-width: 430px) {
    .qz-game-shell {
        padding: 10px 10px 18px;
    }

    .qz-question-card {
        min-height: calc(100dvh - 174px);
        padding: 14px;
        border-radius: 20px;
    }

    .qz-answer-button {
        min-height: 59px;
        padding: 8px;
        font-size: 16px;
    }

    .qz-image-prompt {
        height: min(29dvh, 240px);
    }

    .qz-audio-prompt {
        min-height: 135px;
    }
}


/* Quiz Challenge — Part 3 */

.qz-statusbar {
    grid-template-columns: repeat(5, 1fr);
}

.qz-wrong-review {
    margin: 18px 0;
    padding: 14px;
    border-radius: 15px;
    background: #fff7ed;
    text-align: left;
}

.qz-wrong-review h3 {
    margin: 0 0 10px;
    color: #9a3412;
    font-size: 15px;
    text-align: center;
}

#wrongReviewList {
    display: grid;
    gap: 7px;
}

.qz-wrong-item {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 11px;
    border: 1px solid #fed7aa;
    border-radius: 11px;
    color: #7c2d12;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
}

.qz-wrong-item span {
    min-width: 0;
}

.qz-wrong-item strong,
.qz-wrong-item small {
    display: block;
}

.qz-wrong-item small {
    margin-top: 2px;
    overflow: hidden;
    color: #9a3412;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qz-wrong-item b {
    flex: 0 0 auto;
    font-size: 18px;
}

.qz-result-stats {
    grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 520px) {
    .qz-statusbar {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 5px;
    }

    .qz-statusbar > div {
        padding: 8px 2px;
    }

    .qz-statusbar small {
        font-size: 9px;
    }

    .qz-statusbar strong {
        font-size: 14px;
    }

    .qz-result-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* Quiz Challenge — Part 4 */

.qz-image-prompt,
.qz-text-prompt {
    cursor: pointer;
}

.qz-text-prompt em {
    display: block;
    margin-top: 12px;
    color: #64748b;
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
}

.qz-result-stars {
    min-height: 28px;
    margin-top: 2px;
    color: #f59e0b;
    font-size: 22px;
    letter-spacing: 2px;
}

.qz-achievements {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: -4px 0 16px;
}

.qz-achievements article {
    padding: 11px 7px;
    border-radius: 13px;
    background: #f8fafc;
}

.qz-achievements span,
.qz-achievements small,
.qz-achievements strong {
    display: block;
}

.qz-achievements span {
    margin-bottom: 3px;
    font-size: 22px;
}

.qz-achievements small {
    color: #64748b;
    font-size: 10px;
}

.qz-achievements strong {
    margin-top: 4px;
    color: #1e3a8a;
    font-size: 16px;
}

.qz-wrong-review > p {
    margin: -4px 0 10px;
    color: #9a3412;
    font-size: 11px;
    text-align: center;
}

.qz-practice-wrong-button {
    width: 100%;
    min-height: 50px;
    margin-bottom: 9px;
    border: 0;
    border-radius: 13px;
    color: #ffffff;
    background: #f97316;
    font-weight: 800;
    cursor: pointer;
}

.qz-practice-wrong-button:hover {
    background: #ea580c;
}

.qz-result-card {
    max-height: calc(100dvh - 30px);
    overflow-y: auto;
}

@media (max-width: 430px) {
    .qz-result-panel {
        padding: 8px;
        align-items: end;
    }

    .qz-result-card {
        width: 100%;
        max-height: calc(100dvh - 16px);
        padding: 20px 14px 16px;
        border-radius: 24px 24px 12px 12px;
    }

    .qz-result-card h2 {
        font-size: 25px;
    }

    .qz-result-icon {
        font-size: 46px;
    }

    .qz-result-stars {
        font-size: 18px;
    }

    .qz-answer-button {
        min-height: 64px;
    }
}


/* Quiz display correction:
   Author display rules must not override the HTML hidden attribute. */
.qz-audio-prompt[hidden],
.qz-image-prompt[hidden],
.qz-text-prompt[hidden],
.qz-next-button[hidden] {
    display: none !important;
}

/* Text questions should stay compact and centered. */
.qz-text-prompt {
    min-height: 135px;
    margin-bottom: 14px;
}

/* Remove obsolete help text styling from Part 4. */
.qz-text-prompt em {
    display: none !important;
}


/* Quiz image / answer balance correction */
.qz-question-card {
    min-height: auto;
    padding: 16px;
}

.qz-image-prompt {
    width: 100%;
    height: clamp(180px, 27dvh, 235px);
    margin: 0 0 18px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #e6edf7;
    border-radius: 17px;
    background: #ffffff;
}

.qz-image-prompt img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}

.qz-answer-grid {
    position: relative;
    z-index: 2;
    margin-top: 0;
    gap: 10px;
    background: #ffffff;
}

.qz-answer-button {
    min-height: 58px;
    padding: 10px 12px;
}

.qz-feedback {
    margin-top: 10px;
}

@media (max-width: 430px) {
    .qz-question-card {
        padding: 13px;
    }

    .qz-question-card > h2 {
        margin-bottom: 10px;
        font-size: 17px;
        line-height: 1.3;
    }

    .qz-image-prompt {
        height: clamp(165px, 25dvh, 205px);
        margin-bottom: 14px;
        padding: 8px;
    }

    .qz-answer-grid {
        gap: 8px;
    }

    .qz-answer-button {
        min-height: 54px;
        padding: 8px;
        font-size: 15px;
    }
}


/* Final Quiz layout correction — keep image fully visible and move answers lower */
.qz-question-card {
    display: flex;
    flex-direction: column;
    min-height: auto;
    padding: 16px;
}

.qz-image-prompt {
    flex: 0 0 auto;
    width: 100%;
    height: clamp(230px, 34dvh, 310px);
    margin: 0 0 24px;
    padding: 10px;
    overflow: hidden;
    border: 1px solid #e6edf7;
    border-radius: 18px;
    background: #ffffff;
}

.qz-image-prompt img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
}

.qz-answer-grid {
    flex: 0 0 auto;
    width: 100%;
    margin-top: 0;
    padding-top: 0;
    gap: 10px;
    background: #ffffff;
}

.qz-answer-button {
    min-height: 58px;
}

@media (max-width: 430px) {
    .qz-question-card {
        padding: 13px;
    }

    .qz-image-prompt {
        height: clamp(210px, 31dvh, 260px);
        margin-bottom: 20px;
        padding: 8px;
    }

    .qz-answer-grid {
        gap: 8px;
    }

    .qz-answer-button {
        min-height: 54px;
    }
}


/* ===== Portrait image layout fix v10 ===== */
.qz-image-prompt{
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
}

.qz-image-prompt img{
    width:auto !important;
    height:auto !important;
    max-width:78% !important;
    max-height:78% !important;
    object-fit:contain !important;
}

.qz-image-prompt.is-portrait{
    min-height:420px !important;
    padding:24px 20px 60px !important; /* extra bottom space */
}

.qz-image-prompt.is-portrait img{
    max-width:72% !important;
    max-height:72% !important;
}

.qz-answer-grid{
    margin-top:26px !important;
}

@media (max-width:430px){
    .qz-image-prompt.is-portrait{
        min-height:360px !important;
        padding:18px 14px 56px !important;
    }
    .qz-image-prompt.is-portrait img{
        max-width:68% !important;
        max-height:68% !important;
    }
    .qz-answer-grid{
        margin-top:22px !important;
    }
}
