.home-mode-bar{grid-template-columns:repeat(2,minmax(0,1fr))}
#theoryModal{z-index:15;padding:0;background:var(--panel);backdrop-filter:none}
.theory-box{width:100%;max-width:none;height:100svh;max-height:100svh;border:0;border-radius:0;padding:calc(16px + env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));overscroll-behavior:contain;position:relative}.theory-box>header,.theory-box>section,.theory-box>div,.theory-box>p{max-width:640px;margin-left:auto;margin-right:auto}
.theory-heading{position:sticky;top:0;z-index:2;background:var(--panel);padding:8px 0;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}
.theory-heading h2{font-size:23px;margin:0}
.theory-heading button{flex:0 0 auto;min-height:44px;min-width:44px}
.theory-box .subtitle{margin:12px 0;font-size:14px}
.theory-box select{width:100%;min-height:48px;padding:10px;background:var(--bg);color:var(--ink);border:1px solid var(--line);border-radius:12px;font-size:15px;margin:8px 0 14px}
.theory-box label[for]{font-size:14px;color:var(--muted)}
.theory-count{font-size:12px;color:var(--lime);margin:0 0 8px}
.theory-theme{font-size:12px;color:var(--muted);margin-bottom:12px}
.theory-box fieldset{padding:0;margin:0;border:0;min-width:0}
.theory-box legend{font-size:20px;line-height:1.45;font-weight:800;margin-bottom:16px;width:100%;overflow-wrap:anywhere}
.theory-choice{display:flex;align-items:center;gap:12px;min-height:52px;border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:8px;cursor:pointer;font-size:15px;line-height:1.4}
.theory-choice input{width:20px;height:20px;accent-color:var(--lime);flex-shrink:0}
.theory-choice:has(input:checked){border-color:var(--lime);background:#cffa570c}
.theory-feedback{background:#ffcf6212;border:1px solid #ffcf6244;border-radius:12px;padding:16px;font-size:15px;line-height:1.6;margin:16px 0}
.theory-feedback.correct{background:#cffa5712;border-color:#cffa5744}
.theory-feedback p{margin:8px 0 0}
.theory-course{display:block;min-height:44px;padding:12px 0;color:var(--lime);font-size:13px}
.theory-mascot{display:flex;align-items:center;justify-content:center;height:180px;margin:12px auto 16px;overflow:visible}
#theoryPet{scale:1;transform:rotate(0);animation:theory-idle 4s ease-in-out infinite;flex-shrink:0}
#theoryPet .companion-body,#theoryPet .pet-paw{display:none!important}
#theoryPet[data-emotion=laughing]{animation:theory-bounce .6s ease-in-out infinite}
@keyframes theory-bounce{50%{translate:0 -8px;rotate:3deg}}
#theoryResult{text-align:center}#theoryResultTitle{font-size:23px}#theoryScore{font-size:16px;color:var(--lime);line-height:1.6;margin:14px 0}
#theorySave,#theoryProgress{font-size:12px;color:var(--muted);line-height:1.6;margin:12px 0 0}
@media(max-width:430px){.theory-box{padding:calc(10px + env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left))}.theory-mascot{height:160px}.theory-heading h2{font-size:20px}.theory-box legend{font-size:18px}.theory-box .primary,.theory-box .secondary{min-height:48px;padding:12px;font-size:14px}}
@media(prefers-reduced-motion:reduce){#theoryPet[data-emotion]{animation:none}}

#theoryStart{margin-bottom:18px}#theoryLength{margin-bottom:0}

@keyframes theory-idle{0%,100%{transform:translateY(0) rotate(0)}35%{transform:translateY(-5px) rotate(-1deg)}70%{transform:translateY(-2px) rotate(1deg)}}
#theoryPet[data-emotion=whistling]{animation:theory-idle 1.2s ease-in-out infinite}

@media(prefers-reduced-motion:reduce){#theoryPet,#theoryPet[data-emotion]{animation:none!important}}

.theory-tools{display:flex;align-items:center;gap:8px;flex:0 0 auto}.theory-tools .icon{padding:0 10px;font-size:12px}

/* Keep the next question reachable while reading the correction. */
#theoryNext{position:fixed;bottom:calc(12px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:min(640px,calc(100% - 36px - env(safe-area-inset-left) - env(safe-area-inset-right)));margin:0;min-height:48px;background:var(--lime);color:var(--bg);z-index:4;box-shadow:0 0 0 8px var(--panel),0 -8px 24px #0004}
#theoryQuestion:has(#theoryNext:not([hidden])){padding-bottom:80px}
