:root {
    font-family: "DM Sans", "Segoe UI", Arial, sans-serif;
    color: #20243a;
    background: #f7f8fc;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    --ink: #20243a;
    --muted: #7c8194;
    --purple: #6e58df;
    --green: #329b70;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: radial-gradient(ellipse at 15% 3%, #e4e7ff85, transparent 28rem), #f7f8fc; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.app-shell { width: min(100% - 32px, 940px); margin: 0 auto; padding: 48px 0 64px; }
.student-screen { max-width: 650px; margin: 0 auto; }
.intro { margin: 14px 0 31px; text-align: center; }
.game-emblem { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 19px; border: 7px solid #fff; border-radius: 23px; color: #fff; background: #6374c8; box-shadow: 0 12px 24px #535b9b35; font-size: 39px; font-weight: 800; transform: rotate(-5deg); }
.eyebrow, .round-label { color: #6e61c9; font-size: 10px; font-weight: 800; letter-spacing: 1.45px; }
.intro h1, .result-card h1 { margin: 8px 0; font-size: clamp(31px, 5vw, 43px); letter-spacing: -1.7px; }
.intro-copy { max-width: 510px; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.65; }
.student-panel, .question-card, .result-card { border: 1px solid #e9eaf1; border-radius: 18px; background: #fff; box-shadow: 0 10px 32px #2524430d; }
.student-panel { padding: 28px; }
.student-panel label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 800; }
.id-entry { display: flex; min-height: 54px; align-items: center; gap: 12px; padding: 5px 6px 5px 15px; border: 1px solid #e2e4ed; border-radius: 10px; color: #898da0; }
.id-entry:focus-within { border-color: #8a79e4; box-shadow: 0 0 0 3px #7562de1c; }
.id-entry input { width: 100%; min-width: 0; height: 40px; border: 0; outline: 0; color: var(--ink); }
.id-entry input::placeholder { color: #a6a8b4; }
.button { display: inline-flex; min-height: 45px; align-items: center; justify-content: center; gap: 12px; padding: 0 17px; border: 0; border-radius: 9px; font-size: 13px; font-weight: 800; transition: transform .16s ease, background .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .7; }
.button-primary { color: #fff; background: var(--purple); }
.button-primary:hover:not(:disabled) { background: #5b47c4; }
.button-success { color: #fff; background: var(--green); }
.button-success:hover:not(:disabled) { background: #257d5a; }
.button-quiet { color: #5c6074; background: #f0f1f6; }
.helper-text { margin: 9px 0 0; color: #9498a8; font-size: 11px; }
.error-message { margin: 13px 0 0; color: #b83245; font-size: 13px; line-height: 1.5; }
.student-card { display: flex; align-items: center; gap: 14px; margin-top: 23px; padding-top: 21px; border-top: 1px solid #eceef4; }
.student-photo, .player-photo { flex: 0 0 auto; border: 3px solid #fff; border-radius: 15px; object-fit: cover; background: #e9ebf4; box-shadow: 0 5px 14px #25244317; }
.student-photo { width: 62px; height: 62px; }
.student-details { display: grid; min-width: 0; flex: 1; gap: 3px; }
.welcome-label { color: #8c90a0; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.student-details strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.student-class { color: var(--muted); font-size: 12px; }
.game-screen { max-width: 820px; margin: 0 auto; }
.game-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }
.player { display: flex; align-items: center; gap: 10px; }
.player-photo { width: 48px; height: 48px; }
.player div { display: grid; gap: 3px; }
.player strong { font-size: 13px; }
.player span { color: var(--muted); font-size: 11px; }
.game-main { max-width: 740px; margin: 0 auto; }
.progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.question-count { color: #777d91; font-size: 12px; font-weight: 700; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e7e8f1; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6e58df, #8c7be8); transition: width .25s ease; }
.question-card { margin-top: 20px; padding: clamp(21px, 5vw, 38px); }
.question-meta { display: flex; align-items: center; gap: 12px; }
.question-number { display: grid; place-items: center; width: 41px; height: 41px; border-radius: 13px; color: #6251c9; background: #f0edff; font-size: 15px; font-weight: 800; }
.select-hint { color: #8a8e9e; font-size: 11px; font-weight: 600; }
.question-card h1 { margin: 21px 0 23px; font-size: clamp(21px, 3.5vw, 29px); line-height: 1.35; letter-spacing: -.6px; }
.answer-options { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.answer-option { display: flex; min-height: 54px; align-items: center; gap: 12px; padding: 11px 15px; border: 1px solid #e7e8f0; border-radius: 11px; background: #fff; cursor: pointer; transition: border-color .16s ease, background .16s ease; }
.answer-option:hover { border-color: #b9b0ee; background: #faf9ff; }
.answer-option.is-selected { border-color: #8474df; background: #f6f4ff; }
.answer-option input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: #6e58df; }
.answer-option span { font-size: 14px; line-height: 1.45; }
.answer-option.is-correct { border-color: #49ad80; background: #eef9f3; }
.answer-option.is-incorrect { border-color: #e28a94; background: #fff3f3; }
.answer-option input:disabled { cursor: default; }
.answer-feedback { margin-top: 16px; padding: 13px 15px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.answer-feedback.is-correct { color: #216944; background: #eaf7ef; }
.answer-feedback.is-incorrect { color: #8d4a28; background: #fff4e6; }
.question-actions { display: flex; align-items: center; justify-content: flex-end; gap: 11px; margin-top: 24px; }
.score-label { margin-right: auto; color: var(--muted); font-size: 12px; }
.score-label strong { color: var(--ink); }
.game-note { margin: 14px 0 0; color: #9094a3; font-size: 11px; text-align: center; }
.result-screen { max-width: 600px; margin: 40px auto 0; }
.result-card { padding: clamp(27px, 6vw, 48px); text-align: center; }
.result-badge { display: grid; place-items: center; width: 70px; height: 70px; margin: 0 auto 20px; border-radius: 22px; color: #fff; background: #efb64f; box-shadow: 0 8px 18px #d79d3a42; font-size: 37px; }
.result-card h1 { margin: 9px 0; }
.result-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.final-score { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 24px 0 4px; }
.final-score strong { color: #6352cb; font-size: 58px; letter-spacing: -3px; }
.final-score span { color: var(--muted); font-size: 13px; font-weight: 700; }
.correct-count { margin: 0; font-size: 13px; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Widescreen, no-scroll quiz layout */
body.is-playing { height: 100vh; overflow: hidden; }
body.is-playing .app-shell { display: flex; flex-direction: column; width: min(100% - 48px, 1600px); height: calc(100vh - 68px); padding: 14px 0 18px; }
body.is-playing .game-screen { display: flex; flex: 1; flex-direction: column; width: 100%; max-width: none; min-height: 0; margin: 0; }
.game-header { margin-bottom: 12px; }
.player-photo { width: 40px; height: 40px; }
.game-main { display: flex; flex: 1; flex-direction: column; width: 100%; max-width: none; min-height: 0; margin: 0; }
.question-card { display: flex; flex: 1; flex-direction: column; min-height: 0; margin-top: 14px; padding: clamp(16px, 2.4vh, 30px) clamp(20px, 3vw, 48px); }
.question-meta { gap: 14px; }
.timer { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 12px; }
.timer-track { width: min(360px, 40%); height: 10px; overflow: hidden; border-radius: 999px; background: #e7e8f1; }
.timer-bar { width: 100%; height: 100%; border-radius: inherit; background: var(--green); }
.timer.is-low .timer-bar { background: #d4475a; }
.timer-text { min-width: 3ch; font-size: 22px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.timer.is-low .timer-text { color: #d4475a; }
.question-card h1 { margin: clamp(10px, 2vh, 24px) 0; font-size: clamp(22px, 3.6vh, 38px); }
.answer-options { display: grid; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: clamp(8px, 1.6vh, 16px); min-height: 0; }
.answer-option { width: 100%; min-height: 0; padding: 8px 18px; color: inherit; font: inherit; text-align: left; }
.answer-option b { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #6251c9; background: #f0edff; }
.answer-option span { font-size: clamp(15px, 2.3vh, 22px); }
.answer-option:disabled { cursor: default; }
.answer-option.is-correct b { color: #fff; background: #329b70; }
.answer-option.is-incorrect b { color: #fff; background: #d4475a; }
.answer-feedback { margin-top: clamp(8px, 1.6vh, 16px); padding: 10px 16px; font-size: clamp(14px, 2.2vh, 20px); font-weight: 700; }
.question-actions { margin-top: clamp(8px, 1.6vh, 16px); min-height: 45px; }
.result-screen { max-width: 1100px; margin-top: 12px; }
.result-card { padding: clamp(18px, 3vh, 36px); }
.result-badge { width: 54px; height: 54px; margin-bottom: 10px; font-size: 28px; }
.final-score { margin: 10px 0 2px; }
.final-score strong { font-size: 48px; }
.result-actions { margin-top: 16px; }
.wrong-section { margin-top: 18px; text-align: left; }
.wrong-section h2 { margin: 0 0 10px; font-size: 16px; }
.wrong-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: 42vh; margin: 0; padding: 0 6px 0 0; overflow-y: auto; list-style-position: inside; }
.wrong-list li { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid #f0d4d8; border-radius: 10px; background: #fff8f8; font-size: 13px; line-height: 1.45; }
.wrong-answer { color: #b83245; }
.right-answer { color: #216944; font-weight: 700; }

@media (min-width: 900px) { .result-screen { max-width: 1200px; } }
@media (max-width: 760px) { .answer-options, .wrong-list { grid-template-columns: 1fr; } }

@media (max-width: 560px) {
    .app-shell { width: min(100% - 24px, 940px); padding-top: 29px; }
    .student-panel { padding: 20px; }
    .id-entry { flex-wrap: wrap; padding: 8px; }
    .id-entry input { flex: 1 1 calc(100% - 45px); }
    .id-entry .button { width: 100%; }
    .student-card { align-items: flex-start; flex-wrap: wrap; }
    .student-details { padding-top: 5px; }
    .student-card .button { width: 100%; }
    .game-header { margin-bottom: 26px; }
    .button-quiet { min-height: 39px; padding: 0 11px; font-size: 11px; }
    .question-card { padding: 20px 16px; }
    .question-actions { justify-content: flex-end; flex-wrap: wrap; }
    .score-label { width: 100%; margin: 0 0 3px; }
    .answer-option { padding: 10px 11px; }
    .answer-option span { font-size: 13px; }
}
