/* Deliberately light: opaque panels, limited transforms, no backdrop filters, no canvas. */
#flag-mode{font-family:system-ui,sans-serif;color:#f6f1ff;background:#171324;min-height:100dvh;max-width:1440px;margin:auto;display:flex;flex-direction:column;box-sizing:border-box;overscroll-behavior:none;--flag-panel:#282139;--flag-line:#514663;--flag-accent:#e4f3a9}
#flag-mode[hidden]{display:none}
body.flag-active{background:#171324;overflow:auto}
#flag-mode *{box-sizing:border-box}
#flag-mode button,#flag-mode select{font:inherit;color:inherit;border:1px solid #756486;background:#362b49;border-radius:10px;min-height:44px;padding:8px 12px;cursor:pointer;font-weight:700;touch-action:manipulation}
#flag-mode button:focus-visible,#flag-mode select:focus-visible{outline:3px solid #fff3a6;outline-offset:2px}
#flag-mode button:disabled{cursor:default;opacity:.55}
#flag-mode button[aria-pressed=true],#flag-mode .flag-stage.chosen{border-color:#d4ed9b;background:#4b5639}
#flag-mode button.flag-primary{background:#daed9d;border-color:#f0ffc9;color:#292b20}
.flag-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:space-between;padding:10px 14px;background:#211a2f;border-bottom:1px solid var(--flag-line)}
.flag-brand{display:flex;align-items:center;gap:10px;min-width:140px}
.flag-brand img{width:46px;height:46px;object-fit:contain}
.flag-brand b{font-size:17px;letter-spacing:.025em;color:#dcefa8;display:block}
.flag-brand small{display:block;color:#ddd2ed}
.flag-head-actions{display:flex;gap:7px;flex-wrap:wrap;align-items:center}
.flag-main{flex:1;min-height:0;padding:12px 16px}
.flag-menu{display:grid;gap:14px;grid-template-columns:minmax(0,1.8fr) minmax(280px,1fr)}
.flag-paths,.flag-menu-side,.flag-study{background:var(--flag-panel);border:1px solid var(--flag-line);border-radius:17px;padding:14px}
.flag-paths h2,.flag-menu-side h2,.flag-study h2{font-size:clamp(18px,2.5vw,28px);margin:0 0 6px}
.flag-paths p,.flag-menu-side p{margin:4px 0 10px;color:#e3d7f3}
.flag-region-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.flag-region-grid section{padding:9px;border:1px solid #655578;border-radius:12px;background:#20192d}
.flag-region-grid h3{font-size:17px;margin:0 0 7px;color:#e0eeb2}
.flag-region-grid section>div{display:grid;grid-template-columns:repeat(auto-fit,minmax(92px,1fr));gap:5px}
#flag-mode .flag-stage{position:relative;width:100%;text-align:left;padding:6px 8px;min-height:53px;font-size:14px}
.flag-stage strong,.flag-stage small{display:block;overflow-wrap:anywhere}
.flag-stage small{font-size:11px;color:#d8cce8}
.flag-stage:disabled{opacity:.64}
.flag-final-mark{position:absolute;right:5px;top:5px;font-size:15px}
.flag-menu-side{display:flex;flex-direction:column;align-items:stretch;gap:5px}
.flag-preview{height:clamp(105px,20vh,170px);display:flex;justify-content:center}
.flag-preview img{max-height:100%;max-width:100%;object-fit:contain}
.flag-menu-side fieldset{margin:3px 0;min-inline-size:0;display:flex;gap:5px;flex-wrap:wrap;padding:7px;border:1px solid var(--flag-line);border-radius:8px;color:#e9dff3}
.flag-menu-side legend{font-size:13px;font-weight:700}
.flag-menu-side fieldset button{flex:1;min-height:39px;padding:5px;font-size:13px}
.flag-time-label{display:flex;gap:5px;align-items:center;justify-content:space-between;margin-top:4px}
.flag-time-label select{min-height:39px;color:#f5e9ff;background:#352b49}
.flag-menu-side>small{font-size:12px}
.flag-buttons{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:5px}
.flag-buttons .flag-primary{grid-column:1/-1}
.flag-meter,.flag-clock>div,.flag-hp{height:12px;overflow:hidden;background:#161321;border-radius:7px;border:1px solid #75698a}
.flag-meter i,.flag-clock i,.flag-hp i{display:block;height:100%;background:#a9d375}
.flag-study-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(125px,1fr));gap:9px;margin:12px 0}
.flag-study-grid article{border:1px solid #6b5d7a;border-radius:10px;background:#20192e;padding:8px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:7px;min-height:100px}
.flag-picture{display:block;object-fit:contain;max-width:100%;width:100%;height:100%;user-select:none;-webkit-user-drag:none}
.flag-study-grid .flag-picture{height:66px;max-width:110px}
.flag-study-grid b{text-align:center;font-size:14px;overflow-wrap:anywhere}
.flag-section-title{display:flex;justify-content:space-between;align-items:center;gap:6px}
.flag-play{max-width:1050px;margin:auto;display:grid;gap:8px;grid-template-rows:auto auto auto auto auto}
.flag-play-top{display:grid;grid-template-columns:1fr minmax(90px,200px) auto;align-items:center;gap:10px}
.flag-clock{font-weight:800;font-size:17px;text-align:center}
.flag-clock>div{height:6px}
.flag-clock i{background:#e8da8a}
.flag-arena{height:clamp(118px,25vh,200px);display:grid;grid-template-columns:minmax(0,1fr) minmax(70px,.7fr) minmax(0,1fr);background:#261e36;border:1px solid var(--flag-line);border-radius:13px;padding:7px;gap:8px}
.flag-combatant{display:grid;min-height:0;grid-template-rows:auto minmax(0,1fr);justify-items:center}
.flag-hp{width:min(100%,195px);height:23px;position:relative;text-align:center}
.flag-hp b{position:absolute;z-index:1;width:100%;font-size:13px;top:2px;left:0;color:#fff;text-shadow:0 1px 2px #101010}
.flag-hp i{background:#65ae69}.flag-hp.enemy i{background:#af4264}
.flag-combatant img{width:100%;height:100%;max-height:100%;object-fit:contain}
.flag-enemy-art{transform-origin:center bottom}
.flag-arena-center{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:8px}
.flag-notice{color:#fee89f;font-size:clamp(12px,2vw,22px);font-weight:900}
.flag-arena.ally-attack .flag-dragon-art{animation:flag-lunge-right .4s ease-in-out}
.flag-arena.enemy-attack .flag-enemy-art{animation:flag-lunge-left .4s ease-in-out}
.flag-arena.ally-attack .flag-enemy-art,.flag-arena.enemy-attack .flag-dragon-art{animation:flag-hit .4s ease-in-out}
.flag-arena.flag-won .flag-enemy-art,.flag-arena.flag-lost .flag-dragon-art{transform:rotate(-68deg) scale(.65);opacity:.6}
.flag-arena.flag-won .flag-dragon-art{animation:flag-celebrate .7s ease-in-out 2}
@keyframes flag-lunge-right{50%{transform:translateX(14px) scale(1.07)}}
@keyframes flag-lunge-left{50%{transform:translateX(-14px) scale(1.07)}}
@keyframes flag-hit{50%{opacity:.48;transform:translateY(-5px)}}
@keyframes flag-celebrate{50%{transform:translateY(-12px) scale(1.03)}}
.flag-practice-dragon{height:clamp(80px,16vh,120px);text-align:center}
.flag-practice-dragon img{height:100%;max-width:100%;object-fit:contain}
.flag-question{background:var(--flag-panel);border:1px solid var(--flag-line);border-radius:13px;text-align:center;padding:8px}
.flag-question h2{font-size:clamp(17px,3vw,25px);margin:0 0 6px}
.flag-prompt{position:relative;display:flex;align-items:center;justify-content:center;gap:6px;min-height:82px}
.flag-prompt>.flag-picture,.flag-veil{width:min(230px,70vw);height:clamp(75px,16vh,125px)}
.flag-country-name{font-size:clamp(23px,4vw,42px);overflow-wrap:anywhere}
.flag-veil{position:relative;overflow:hidden}
.flag-veil i{position:absolute;background:#211c36;bottom:0;left:0;width:100%;height:50%}
.flag-veil.fog i{height:100%;background:linear-gradient(20deg,transparent 14%,#c8ccce99 40%,transparent 64%,#a7b1c288)}
.flag-veil.revealed i{display:none}
#flag-mode .flag-reveal{font-size:12px;min-height:36px;padding:4px 8px;max-width:105px}
.flag-choices{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr))}
.flag-choices.six{grid-template-columns:repeat(3,minmax(0,1fr))}
#flag-mode .flag-choices button{width:100%;min-height:clamp(51px,8vh,76px);font-size:clamp(15px,2.5vw,22px);overflow-wrap:anywhere;background:#3b3153;border-color:#847195}
#flag-mode .flag-choices.image button{height:clamp(60px,12vh,100px);padding:5px}
#flag-mode .flag-choices button:disabled{opacity:.62}
#flag-mode .flag-choices button.correct{border-color:#b5e6a8;background:#37583b;opacity:1}
#flag-mode .flag-choices button.wrong{border-color:#f1a1b1;background:#743f55;opacity:1}
.flag-feedback{min-height:44px;display:flex;justify-content:space-between;align-items:center;gap:6px;color:#e4d7f1}
.flag-feedback .good{color:#d8ef98}.flag-feedback .bad{color:#ffc0bd}
.flag-result{text-align:center;padding:20px;background:var(--flag-panel);border-radius:13px}
.flag-result strong{font-size:36px;color:#f9e492}
#flag-mode dialog{max-width:min(92vw,500px);color:#f6f1ff;background:#30263f;border:1px solid #8b7b9d;border-radius:16px;box-shadow:none;padding:18px}
#flag-mode dialog::backdrop{background:#171226b8}
#flag-mode dialog h2{font-size:21px;margin:0 0 12px}
#flag-mode .flag-player-dialog>div{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}
@media(max-width:680px){.flag-menu{grid-template-columns:1fr}.flag-menu-side{grid-row:1}.flag-preview{height:110px}.flag-main{padding:8px}.flag-head{padding:8px}.flag-head-actions{gap:3px}.flag-head-actions button{font-size:12px;padding:5px}.flag-brand b{font-size:15px}.flag-brand img{width:32px;height:32px}.flag-play-top{font-size:12px;grid-template-columns:1fr 70px auto;gap:4px}.flag-region-grid{grid-template-columns:1fr 1fr}.flag-country-name{font-size:26px}.flag-arena{height:125px}.flag-choices.six{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-height:750px) and (min-width:700px){.flag-head{padding:5px 12px}.flag-main{padding:7px 12px}.flag-arena{height:clamp(85px,20vh,145px)}.flag-play{gap:5px}.flag-prompt{min-height:65px}.flag-prompt>.flag-picture,.flag-veil{height:clamp(65px,13vh,95px)}.flag-question{padding:5px}.flag-question h2{font-size:20px}.flag-choices.image button{height:clamp(55px,10vh,78px)}#flag-mode .flag-choices button{min-height:45px}.flag-feedback{min-height:42px}}
@media(prefers-reduced-motion:reduce){#flag-mode *{animation:none!important;transition:none!important}}
.flag-monster-effect{font-size:36px;color:#f8cf83;animation:flag-monster-effect .45s ease-out both;line-height:1;pointer-events:none}
@keyframes flag-monster-effect{0%{opacity:0;transform:translateX(45px) scale(.3)}35%{opacity:1;transform:translateX(0) scale(1.3)}100%{opacity:0;transform:translateX(-55px) scale(.7)}}
/* Use the available presentation area for larger opponents and readable flags. */
.flag-practice-dragon{display:flex;justify-content:center;align-items:center}
.flag-arena{background:radial-gradient(ellipse at 78% 58%,#494054 0%,#2a2338 50%,#211a2e 100%)}
.flag-combatant .flag-enemy-art{width:100%;height:100%;max-height:100%;object-fit:contain}
.flag-head-actions select{max-width:190px}
@media(min-width:700px) and (min-height:650px){.flag-arena{height:clamp(165px,27vh,220px)}.flag-prompt>.flag-picture,.flag-veil{height:clamp(100px,16vh,135px)}.flag-practice-dragon{height:clamp(100px,20vh,150px)}}
@media(prefers-reduced-motion:reduce){.flag-enemy-art{animation:none!important}}
/* Final boss: pre-rendered aura, light transform-based battle animations. */
.earth-arena{position:relative;overflow:hidden;background:radial-gradient(ellipse at 78% 56%,#48304d 0%,#251e34 49%,#20192d 100%)}
.earth-arena .flag-earth{transform-origin:center center}
.flag-arena.earth-spin .flag-earth{animation:earth-spin-attack .85s cubic-bezier(.36,.05,.4,1) both}
.flag-arena.earth-fire .flag-earth{animation:earth-fire-recoil .75s ease-in-out both}
.earth-fireball,.earth-spin-trail{position:absolute;display:block;pointer-events:none;z-index:3;left:72%;top:53%;width:clamp(30px,5vw,65px);height:clamp(30px,5vw,65px);border-radius:50%;opacity:0}
.earth-fireball{background:radial-gradient(circle at 38% 40%,#fffbd1 0 13%,#ffd65b 20%,#ff721b 44%,#ae1e22 64%,transparent 72%);animation:earth-fireball-flight .7s ease-in both}
.earth-fireball::after{content:"";position:absolute;top:19%;left:52%;width:105%;height:62%;background:linear-gradient(90deg,#ff4918a6,#a6315000);border-radius:30% 100% 100% 30%;transform:rotate(-8deg)}
.earth-spin-trail{width:clamp(60px,10vw,120px);height:clamp(60px,10vw,120px);border:5px solid #b660d5aa;animation:earth-spin-wave .85s ease-out both}
@keyframes earth-spin-attack{0%{transform:translateX(0) rotate(0)}25%{transform:translateX(-8%) rotate(-90deg) scale(1.07)}55%{transform:translateX(-105%) rotate(-300deg) scale(1.12)}75%{transform:translateX(-25%) rotate(-340deg)}100%{transform:translateX(0) rotate(-360deg)}}
@keyframes earth-fire-recoil{0%,100%{transform:none}30%{transform:scale(.96) translateX(3%)}45%{transform:scale(1.08) translateX(-3%)}}
@keyframes earth-fireball-flight{0%{left:73%;opacity:0;transform:scale(.35)}22%{left:69%;opacity:1;transform:scale(.85)}78%{left:22%;opacity:1;transform:scale(1.15)}100%{left:17%;opacity:0;transform:scale(1.5)}}
@keyframes earth-spin-wave{0%{opacity:0;transform:scale(.4)}35%{opacity:.9;transform:scale(1.1)}100%{left:20%;opacity:0;transform:scale(1.7)}}
@media(prefers-reduced-motion:reduce){.earth-fireball,.earth-spin-trail{display:none}}
@media(min-width:700px) and (min-height:690px){.earth-arena{height:clamp(210px,32vh,250px)}.earth-arena .flag-dragon-art{max-height:156px;align-self:center}}

/* Eight-choice specials use two rows, including flag-image choices.
   Keep the actual next button in view on short classroom displays. */
.flag-choices.eight{grid-template-columns:repeat(4,minmax(0,1fr))}
.flag-play:has(.flag-choices.eight){gap:5px}
#flag-mode .flag-choices.eight button{min-height:44px;padding:5px 7px;font-size:clamp(13px,2vw,20px)}
#flag-mode .flag-choices.eight.image button{height:clamp(48px,9vh,76px)}
.flag-play:has(.flag-choices.eight) .flag-feedback{min-height:44px;position:sticky;bottom:12px;z-index:4;background:#171324;border-radius:8px}
@media(max-height:820px){
 .flag-play:has(.flag-choices.eight) .flag-arena{height:clamp(82px,19vh,135px)}
 .flag-play:has(.flag-choices.eight) .flag-practice-dragon{height:clamp(65px,13vh,105px)}
 .flag-play:has(.flag-choices.eight) .flag-question{padding:5px}
 .flag-play:has(.flag-choices.eight) .flag-question h2{font-size:clamp(16px,2.4vh,20px);margin:0 0 3px}
 .flag-play:has(.flag-choices.eight) .flag-prompt{min-height:56px}
 .flag-play:has(.flag-choices.eight) .flag-prompt>.flag-picture,.flag-play:has(.flag-choices.eight) .flag-veil{height:clamp(55px,12vh,90px)}
}
@media(max-width:520px){
 .flag-choices.eight.text{grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}
 .flag-choices.eight.image{gap:4px}
 .flag-play:has(.flag-choices.eight) .flag-arena{height:90px}
 .flag-play:has(.flag-choices.eight) .flag-head{padding:4px}
 #flag-mode .flag-choices.eight.text button{min-height:40px;font-size:14px}
}
