/* V27 — UI layer. Native controls, responsive layout, no dependencies. */
:root{--ui-bg:#101c2c;--ui-panel:#1c2a3b;--ui-edge:#677a8f;--ui-gold:#f0d7a1;--ui-text:#f8f2e4;--ui-muted:#c6d5e0;--ui-accent:#a8e8c9;--ink:var(--ui-text);--muted:var(--ui-muted);--mint:var(--ui-accent)}
body{background:radial-gradient(ellipse at 50% 0%,#3f505f 0%,#19283a 43%,#101c2c 80%);font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
body[data-campaign="pyramides"]{--ui-accent:#f0d29a;background:radial-gradient(ellipse at 50% 0%,#665545,#263445 43%,#111d2b 82%)}
body[data-campaign="litteral"]{--ui-accent:#c9b9f5;background:radial-gradient(ellipse at 50% 0%,#4c436b,#272f47 43%,#111b2d 82%)}
main{max-width:1180px;padding:clamp(10px,2vw,24px)}
header{padding:10px 0 15px;border-bottom:1px solid #e8d4a833;margin-bottom:16px}
header h1{font-family:Georgia,serif;font-weight:700;color:var(--ui-gold);letter-spacing:-.025em}
.kicker{color:var(--ui-accent);letter-spacing:.11em}
button,a.btn{border:1px solid #8094a6;background:linear-gradient(180deg,#394c61,#223247);color:var(--ui-text);border-radius:11px;min-height:44px}
button:focus-visible,a:focus-visible,summary:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #ffe6aa;outline-offset:3px}
button.primary{background:linear-gradient(180deg,#e1f4dd,var(--ui-accent));color:#192e3d;border:1px solid #f1f8d7;box-shadow:0 3px 0 #111c2c77}
button:not(:disabled):active,a.btn:active{translate:0 1px}
.panel{background:linear-gradient(145deg,#2c3b4e,#1a293c);border-color:#9cacc16b;box-shadow:0 16px 50px #090f1d60;border-radius:20px}
.intro{gap:15px;padding:clamp(12px,2.4vw,25px)}
.intro h2,.finish h2,.storycopy h2{color:var(--ui-gold);font-family:Georgia,serif}
.introart{border-color:#aab8c45b;max-height:210px;background:#1a293b}
.introart svg{width:100%;height:auto;max-height:210px;object-fit:cover}
.identity,.custompanel{background:#152538;border:1px solid #a7b5ca50;border-radius:14px}
.identity h3{margin:0;color:var(--ui-gold);font-size:18px}
.identity input,.identity select,.customfields select{background:#101f31;border-color:#879ab2;color:#fff4df}
.authfields{grid-template-columns:repeat(2,minmax(0,1fr));align-items:center;gap:8px 14px}
.authfields>label{font-weight:600}.authfields>input,.authfields>select{max-width:none;width:100%}
.authfields>.importline,.authfields>.authbuttons,.authfields>small{grid-column:1/-1}
.authfields .importline{font-weight:400}.authfields .importline input{width:auto}
#authConnected{padding:4px 0}#connectedName{color:var(--ui-accent);font-size:18px}
.ui-section{display:grid;gap:12px;padding:clamp(12px,2vw,20px);background:#14223690;border:1px solid #a8b8ce48;border-radius:16px;min-width:0}
.ui-heading{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.ui-heading>div{flex:1;min-width:150px}.ui-heading h3{font:700 clamp(20px,3vw,27px)/1.2 Georgia,serif;color:var(--ui-gold);margin:0 0 4px}
.ui-heading p{font-size:13px;color:var(--ui-muted)}
.ui-step{display:inline-grid;place-items:center;flex:0 0 35px;height:35px;border:1px solid #ead2a388;background:#e8c88b19;color:var(--ui-gold);font-weight:800;border-radius:50%}
.worldselect{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.worldcard,.worldcard:last-child{position:relative;display:grid;gap:6px;grid-template-columns:1fr;grid-column:auto;border:1px solid #899caf80;border-radius:13px;background:linear-gradient(145deg,#2d3f53,#172539);padding:0 0 10px;overflow:hidden;text-align:left;align-content:start;min-width:0;box-shadow:0 4px 10px #0002}
.worldcard[aria-pressed=true],.worldcard:last-child[aria-pressed=true]{border:2px solid var(--accent);box-shadow:0 0 0 2px #e4efd424;background:linear-gradient(145deg,#3b4e5e,#202e41)}
.worldcard .worldthumb{display:block;width:100%;aspect-ratio:3/1;object-fit:cover;border-bottom:1px solid #e8d8ae33;pointer-events:none}
.worldcard .worldnumber{position:absolute;top:7px;left:8px;display:grid;place-items:center;width:25px;height:25px;background:#152034e8;border:1px solid var(--accent);border-radius:50%;font-size:13px;color:white}
.worldcard strong,.worldcard small,.worldcard .worldstatus{margin:0 10px;display:block;overflow-wrap:anywhere;white-space:normal}
.worldcard strong{font-size:clamp(14px,1.8vw,18px);line-height:1.2}
.worldcard small{font-size:13px;color:var(--ui-muted);line-height:1.3}
.worldstatus{font-size:12px;color:#edce95;font-weight:750}
.worldcard[aria-pressed=true] .worldstatus{color:var(--ui-accent)}
#selectedWorld{border-left:3px solid var(--ui-accent);padding:9px 12px;background:#2e4257;border-radius:6px;font-size:14px;color:#f8f1df}
.levels{gap:9px;grid-template-columns:repeat(3,minmax(0,1fr))}
.levels button{align-items:flex-start;justify-content:center;text-align:left;min-height:80px;padding:10px 12px;gap:4px;line-height:1.3}
.levels button small{color:#d8e4ef;font-size:12px;white-space:normal}
.levels button.primary small{color:#243d42!important}
details.ui-fold{border:1px solid #a0b0c454;border-radius:14px;background:#152538;padding:0;overflow:hidden}
details.ui-fold summary{display:flex;align-items:center;justify-content:space-between;gap:10px;cursor:pointer;padding:14px 16px;list-style:none;color:var(--ui-gold);font-weight:800;min-height:52px}
details.ui-fold summary::-webkit-details-marker{display:none}details.ui-fold summary::after{content:"＋";font-size:20px;color:var(--ui-accent)}details.ui-fold[open] summary::after{content:"−"}
details.ui-fold[open] summary{border-bottom:1px solid #a0b0c444}
.ui-foldbody{padding:14px;display:grid;gap:12px}
.charactergrid{gap:9px}.character{background:linear-gradient(#2c3e55,#1a293d);border-color:#8097ab80;border-radius:12px}.character[aria-pressed=true]{border-color:#ffe0a6;background:#384c59}
.character small{color:#d2dfeb}.avatarpreview{border-radius:10px;overflow:hidden}
.mapspells{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.spellentry{position:relative;display:grid;align-content:start;justify-items:start;text-align:left;min-width:0;padding:11px;border:1px solid color-mix(in srgb,var(--spell) 60%,#475b70);border-top:3px solid var(--spell);border-radius:10px;background:linear-gradient(145deg,#2b3c50,#182a3e);gap:5px}
.spellentry strong{font-size:14px;color:var(--spell);white-space:normal;overflow-wrap:anywhere}.spellentry small{font-size:12px;line-height:1.4;color:#d2deea}
.spellentry.locked,.spellentry:disabled{opacity:.68}
.spellentry[aria-pressed=true]{outline:2px solid var(--spell);outline-offset:-2px;background:#3a4b60}
.spellchoice{border:1px solid var(--spell);color:var(--spell);min-height:44px;border-radius:9px;background:#203349;font-size:13px}
.spellchoice[aria-pressed=true]{background:#40536a;box-shadow:inset 0 -3px var(--spell)}
#equipPanel{background:#15263af5;border:1px solid #a5b7cd;max-height:min(65dvh,350px)}
.equipheading{color:var(--ui-gold)}.bossclue{background:#25384c;color:#ffe4ac;line-height:1.45}
.hud{background:#142337;border:1px solid #7e94ae75;border-radius:12px;padding:8px!important;margin-bottom:6px;gap:8px}.hud>div:first-child{min-width:110px}.hud #sector{color:var(--ui-gold)}.stats{background:#1b2b40;border-color:#7a8ea45e}.health{color:#ffa3a7}
.progress{background:#0d192b;border:1px solid #607c8b70;height:9px}.progress i{background:linear-gradient(90deg,#7ac7ba,#e4f2ac)}
.screen{border-color:#9aafc299;background:#182a3e;box-shadow:0 8px 30px #0004}
.screen .control{background:#1c314beb;border:2px solid #d5e4f0a0;border-radius:15px;box-shadow:0 4px 0 #101b2c99;font-weight:900;color:#fff8e9;backdrop-filter:none}
.screen .control.jump{background:#a4e4c9e8;color:#173248}.screen .control.cast{background:#7865bde8;color:#fff}
.screen .control.pressed{background:#f1d59b;color:#213247}
.screen .overlay{background:#091322d9}
.screen .dialog{border:1px solid #c9d2e3a8;border-top:4px solid var(--ui-accent);background:linear-gradient(145deg,#2a3d54,#15263c);width:min(100%,760px);padding:clamp(10px,2vw,20px);gap:10px;border-radius:14px;box-shadow:0 18px 50px #0009}
.dialog h2{font-family:Georgia,serif;color:var(--ui-gold);font-size:clamp(19px,3vw,26px)}
.dialog .kicker{font-size:12px}
.equation,.equation.longcalc,.geometryPrompt{background:#101e31;border:1px solid #7289a3;border-radius:11px;padding:clamp(10px,2vw,18px);font-size:clamp(20px,3vw,32px);line-height:1.45;overflow-wrap:anywhere}
.equation.longcalc,.equation.geometryPrompt{font-size:clamp(17px,2.5vw,25px)}
.answers{gap:8px;grid-template-columns:repeat(2,minmax(0,1fr))}
.answers button{min-height:58px;background:linear-gradient(155deg,#3c5069,#24374c);border:1px solid #9aacc2;line-height:1.4;padding:10px;font-size:clamp(16px,2.3vw,22px);white-space:normal;overflow-wrap:anywhere}
.answers button.bad{background:#72414d;color:#fff0e8;opacity:.85;border-color:#ffb5a7}
.answers button.correct{background:#27604d;color:#e3ffdc;border-color:#a2e3c2;opacity:1}
.answers button:disabled:not(.correct):not(.bad){opacity:.58}
.answers.figurechoices button{padding:6px;gap:4px}.figurechoices svg{max-height:105px;border-radius:6px}
.questionfigure{max-width:280px}.questionfigure svg{max-height:170px}
.feedback{border-left:3px solid #afc0d7;color:#e3edf6;background:#24374c;font-size:14px}
.feedback.success{border-color:#a4e4bf;background:#244d42;color:#d9ffe8}.feedback.retry{border-color:#f6cb90;background:#543c42;color:#ffe7c0}
.remediation{background:#1b2e43;border:1px solid #e8cb93}.rempart{background:#12243a}.remediation h3{color:#ffe0a4}
.dialogcontrols button{min-height:44px}
.finish .spellreward{width:min(100%,660px);background:#1b2d42;border-color:#e4cc9b;color:#ffe8b7}.finish .stars{letter-spacing:.1em;color:#ffe2a1;text-shadow:0 2px 6px #0007}.finish .victoryart{border-color:#d6c49c}
.ui-runedots{display:flex;gap:5px;flex-wrap:wrap;align-items:center}.ui-runedots i{width:18px;height:7px;border-radius:5px;background:#60748b;border:1px solid #8da3bc}.ui-runedots i.past{background:#a8e8bd;border-color:#c5f7cc}.ui-runedots i.current{background:#f5d69c;border-color:#ffe8b9}
@media(min-width:700px){.answers.figurechoices{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-width:700px){.worldselect{grid-template-columns:repeat(2,minmax(0,1fr))}.mapspells{grid-template-columns:repeat(2,minmax(0,1fr))}.authfields{grid-template-columns:1fr}.authfields>*{grid-column:1}.authfields>.importline input{width:auto}.worldcard strong{font-size:15px}.levels button{min-height:72px}}
@media(max-width:460px){.levels{grid-template-columns:1fr}.levels button{min-height:58px}.worldcard small{font-size:12px}.ui-section{padding:10px}.ui-foldbody{padding:10px}.screen .control{min-height:44px;min-width:44px}.answers button{font-size:16px;min-height:52px}}
/* Questions should use the entire viewport on narrow portrait screens outside fullscreen. */
@media(max-width:700px) and (orientation:portrait){.play:not(.gamefull) .screen #dialog,.play:not(.gamefull) .screen #pause{position:fixed!important;inset:0!important;padding:12px;z-index:1000;overflow:auto;place-items:center}.play:not(.gamefull) .screen .dialog{max-height:calc(100dvh - 24px);width:100%}.screen .dialog{gap:8px}}
@media(max-height:500px) and (orientation:landscape){.play.gamefull .hud{padding:2px 4px!important;gap:3px}.screen .dialog{padding:8px;gap:5px}.screen .dialog h2{font-size:18px}.screen .equation{padding:6px;font-size:19px}.screen .equation.geometryPrompt,.screen .equation.longcalc{font-size:16px}.answers button{min-height:40px;padding:5px;font-size:15px}.questionfigure svg{max-height:100px}.figurechoices svg{max-height:80px}.feedback{padding:5px;font-size:12px}.dialogcontrols button{min-height:36px;font-size:13px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;transition:none!important}}
