/* Vanilla & violet arcade. Area tokens preserve each game's own colour. */
.student-layout .game-device{
 --arcade-accent:var(--game-accent,#6556a0);
 --arcade-soft:var(--game-background,#fff0b3);
 --arcade-ink:#302a3c;
 --arcade-edge:color-mix(in srgb,var(--arcade-accent) 55%,#41384e);
 --arcade-paper:#fffefa;
 border:2px solid var(--arcade-edge);border-radius:0;
 background:var(--arcade-paper);color:var(--arcade-ink);
 box-shadow:6px 6px 0 var(--arcade-soft),8px 8px 0 var(--arcade-edge);
 font-family:"Library Manrope",Manrope,sans-serif;
}
.game-device header.game-hud:after{display:none}
.game-device .game-hud{padding:16px 20px;background:var(--arcade-soft);border-bottom:2px solid var(--arcade-edge)}
.student-layout .game-device .game-hud h1{font:800 clamp(1.2rem,2.8vw,1.75rem)/1.25 "Library Manrope",Manrope,sans-serif;color:var(--arcade-ink);letter-spacing:-.02em;text-transform:none;text-shadow:none}
.game-device .game-hud p{font:500 .85rem/1.5 "Library Manrope",Manrope,sans-serif;color:var(--arcade-ink);letter-spacing:0}
.game-device .game-score{gap:10px}
.game-device .game-score>span{padding:6px 10px;border:1px solid var(--arcade-edge);background:var(--arcade-paper);color:var(--arcade-ink);font-size:.8rem;box-shadow:none}
.game-device .game-score strong{font-size:1.25rem;color:var(--arcade-ink);line-height:1.2}
.game-device .game-progress{padding:12px 20px;gap:14px;background:var(--arcade-paper);color:var(--arcade-ink)}
.game-device .game-progress>span{font-size:.85rem}
.game-device .game-progress progress{appearance:none;border:0;border-radius:0;height:12px;background:var(--arcade-soft);overflow:hidden}
.game-device .game-progress progress::-webkit-progress-bar{background:var(--arcade-soft)}
.game-device .game-progress progress::-webkit-progress-value{background:repeating-linear-gradient(90deg,var(--arcade-accent) 0 15px,transparent 15px 19px)}
.game-device .game-progress progress::-moz-progress-bar{background:repeating-linear-gradient(90deg,var(--arcade-accent) 0 15px,transparent 15px 19px)}
.game-device .game-screen{border:1px solid color-mix(in srgb,var(--arcade-edge) 35%,white);border-radius:0;background:var(--arcade-paper);box-shadow:none;padding:16px 18px}
.game-device .game-paper-note{font-size:.9rem;line-height:1.55;border:1px solid var(--arcade-edge);background:var(--arcade-soft);color:var(--arcade-ink);box-shadow:none}
.game-device .game-paper-note strong{font:700 .95rem/1.5 "Library Manrope",Manrope,sans-serif}
.game-device .game-paper-note p{margin:7px 0 0}
.game-device .game-function h2{font:700 1.1rem/1.5 "Library Manrope",Manrope,sans-serif;color:var(--arcade-ink)}
.game-device .game-challenge{grid-template-columns:210px minmax(0,1fr)}
.student-layout .game-device .game-options .game-option{border:2px solid var(--arcade-edge);border-radius:0 12px 0 0;background:var(--arcade-paper);color:var(--arcade-ink);box-shadow:3px 3px 0 var(--arcade-edge);transition:background-color .15s,transform .15s,box-shadow .15s}
.game-device .game-option-letter{border:1px solid var(--arcade-edge);border-radius:0;background:var(--arcade-soft);color:var(--arcade-ink);font:700 .85rem/1.4 "Library Manrope",Manrope,sans-serif}
.student-layout .game-device .game-options .game-option:hover:not(:disabled){background:var(--arcade-soft);border-color:var(--arcade-edge);transform:translate(-1px,-1px);box-shadow:4px 4px 0 var(--arcade-edge)}
.student-layout .game-device .game-options .game-option:active:not(:disabled){transform:translate(2px,2px);box-shadow:1px 1px 0 var(--arcade-edge)}
.student-layout .game-device .game-options .answer-correct{background:#e6f4e9;border-color:#39734e;color:#244c32;box-shadow:3px 3px 0 #39734e}
.student-layout .game-device .game-options .answer-wrong{background:#fff0e9;border-color:#a1533d;color:#743b2c;box-shadow:3px 3px 0 #a1533d}
.student-layout .game-device .game-options .answer-pending{background:var(--arcade-soft)}
.game-device .game-feedback{border:2px solid currentColor;border-radius:0;font-size:.95rem}
.student-layout .game-console .game-device .level-rules summary{border:1px solid var(--arcade-edge);border-radius:0;background:var(--arcade-soft);color:var(--arcade-ink);box-shadow:2px 2px 0 var(--arcade-edge);font:600 .85rem/1.5 "Library Manrope",Manrope,sans-serif}
.student-layout .game-console .game-device .level-rule-sheet{border:2px solid var(--arcade-edge);border-radius:0;box-shadow:4px 4px 0 var(--arcade-soft);background:var(--arcade-paper);color:var(--arcade-ink)}
.student-layout .game-device :is(.game-next,.dice-primary,.dice-reset){border:2px solid var(--arcade-edge);border-radius:0;background:var(--arcade-soft);color:var(--arcade-ink);box-shadow:3px 3px 0 var(--arcade-edge);transition:transform .15s,box-shadow .15s}
.student-layout .game-device :is(.game-next,.dice-primary,.dice-reset):hover:not(:disabled){background:color-mix(in srgb,var(--arcade-soft) 75%,white);transform:translate(-1px,-1px);border-color:var(--arcade-edge);box-shadow:4px 4px 0 var(--arcade-edge)}
.student-layout .game-device :is(.game-next,.dice-primary,.dice-reset):active:not(:disabled){transform:translate(2px,2px);box-shadow:1px 1px 0 var(--arcade-edge)}
.game-device :is(.game-next,.dice-primary,.dice-reset) svg{shape-rendering:auto}
.game-device .game-footer{color:var(--arcade-ink);font-size:.8rem;letter-spacing:0}
.game-device .game-footer:before{display:none}
.game-device .game-level-up-badge{border:3px solid var(--arcade-edge);border-radius:0;background:var(--arcade-soft);color:var(--arcade-ink);box-shadow:6px 6px 0 var(--arcade-edge)}
.game-device .game-confetti i{border-radius:0}
@media(max-width:600px){.game-device .game-hud{padding:12px;gap:8px}.game-device .game-hud p{font-size:.75rem}.game-device .game-score{gap:7px}.game-device .game-score>span{padding:4px 6px;font-size:.75rem}.game-device .game-score strong{font-size:1rem}.game-device .game-progress{padding:10px 12px}.game-device .game-screen{padding:12px 10px}.game-device .game-challenge{grid-template-columns:125px minmax(0,1fr);gap:12px}.game-device .game-paper-note{font-size:.85rem;padding:9px}.game-device .game-footer{font-size:.75rem}}
@media(prefers-reduced-motion:reduce){.student-layout .game-device .game-options .game-option,.student-layout .game-device :is(.game-next,.dice-primary,.dice-reset){transition:none}.student-layout .game-device .game-options .game-option:hover:not(:disabled),.student-layout .game-device .game-options .game-option:active:not(:disabled),.student-layout .game-device :is(.game-next,.dice-primary,.dice-reset):hover:not(:disabled),.student-layout .game-device :is(.game-next,.dice-primary,.dice-reset):active:not(:disabled){transform:none}}

/* Shared mathematical layouts and celebration behaviour. */
.practice-graph{display:block;width:100%;max-width:400px;height:auto;margin:0 auto}
.game-function>.practice-graph{max-width:270px}
.game-hud:has(+.game-progress) .game-score{flex-shrink:0}
.game-score strong{white-space:nowrap}
.game-option-content:has(.practice-graph){display:block;flex:1;min-width:0}
.game-options:has(.practice-graph){grid-template-columns:repeat(4,minmax(0,1fr))}
.student-layout .game-options .game-option:has(.practice-graph){display:block;padding:8px}
.game-option:has(.practice-graph) .game-option-letter{margin-bottom:3px}
@media(max-width:800px){.game-options:has(.practice-graph){grid-template-columns:repeat(2,minmax(0,1fr))}}
.game-boss .boss-banner{display:flex;align-items:center;gap:12px;padding:10px 20px;background:var(--arcade-soft);color:var(--arcade-ink);font-weight:700;border-bottom:2px solid var(--arcade-edge)}
.boss-banner>span:first-child{font-size:1.8rem}.boss-banner>span:last-child{margin-left:auto;font-size:.85rem}
.game-boss-victory:not([hidden]){position:fixed;inset:0;z-index:1000;background:#183326b8;overflow:hidden}
.game-boss-victory .game-level-up-badge{max-width:calc(100vw - 40px);box-sizing:border-box;background:var(--arcade-soft);border:3px solid var(--arcade-edge);box-shadow:6px 6px 0 var(--arcade-edge);padding:30px;text-align:center;animation:boss-victory 5.2s ease both}
.game-boss-victory .game-level-up-badge strong{font-size:clamp(1.5rem,5vw,3rem);color:var(--arcade-ink);font-family:"Library Manrope",Manrope,sans-serif}
.game-boss-victory .game-level-up-badge .boss-crown{font-size:5rem;color:#aa6818;line-height:1}
.boss-victory-stars{color:#bd7d18;font-size:2rem;letter-spacing:.25em}
.boss-victory-ring{position:absolute;width:260px;height:260px;border:12px solid #ffd17b;border-radius:50%;animation:boss-ring 1.4s ease-out both}
.game-boss-victory .game-confetti i{left:calc(2% + var(--piece)*4%);top:-30px;width:12px;height:20px;animation:boss-confetti 4.6s ease-in both;animation-delay:calc(var(--piece)*20ms)}
@keyframes boss-victory{0%{opacity:0;transform:translateY(40px) scale(.6) rotate(-6deg)}12%{opacity:1;transform:translateY(0) scale(1.06) rotate(2deg)}20%,88%{opacity:1;transform:scale(1) rotate(0)}100%{opacity:0;transform:translateY(-20px)}}
@keyframes boss-ring{0%{opacity:0;transform:scale(.4)}20%{opacity:.8}100%{opacity:0;transform:scale(4)}}
@keyframes boss-confetti{0%{opacity:0;transform:translateY(-30px) rotate(0)}10%,80%{opacity:1}100%{opacity:0;transform:translateY(110vh) rotate(500deg)}}
@media(prefers-reduced-motion:reduce){.game-boss-victory .game-level-up-badge{animation:none}.game-boss-victory .game-confetti,.boss-victory-ring{display:none}}
.game-console .level-formula{line-height:2.5;padding:.35em 0}
.game-parameter-note{margin:5px 0}
/* Compact graph layout, with equal units on both axes. */
.student-layout .student-shell:has(.game-graphs){margin-top:12px}
.game-graphs .game-paper-note{font-size:.8rem;padding:8px}
.student-layout .game-graphs .game-hud{padding:9px 16px}
.student-layout .game-graphs .game-hud h1{font-size:1.1rem;max-width:580px}
.game-graphs .game-challenge{grid-template-columns:180px minmax(0,1fr);gap:15px}
.game-graphs .game-function{display:grid;grid-template-columns:minmax(0,1fr) 200px;align-items:center;column-gap:8px}
.game-graphs .game-function h2{font-size:1rem;align-self:end}
.game-graphs .game-function>strong{align-self:start;font-size:1.1rem;line-height:1.4;margin-top:6px}
.game-graphs .game-function>.practice-graph{grid-column:2;grid-row:1 / 3;width:200px;max-width:100%}
.game-graphs .game-screen{padding:8px 12px}
.game-graphs .game-options{gap:6px}
.student-layout .game-graphs .game-options .game-option{padding:0;position:relative;line-height:1}
.game-graphs .game-option .practice-graph{max-width:190px}
.game-graphs .game-option-letter{position:absolute;top:3px;left:3px;z-index:1}
.game-graphs .level-rules{margin:2px 0 6px}
.game-graphs .game-footer{padding:7px 16px}
@media(max-width:600px){.game-graphs .game-challenge{grid-template-columns:110px minmax(0,1fr);gap:8px}.game-graphs .game-function{display:block}.game-graphs .game-function>.practice-graph{width:155px}.game-graphs .game-function h2{font-size:.85rem}.game-graphs .game-paper-note{padding:6px;font-size:.75rem}.game-graphs .game-hud{flex-wrap:wrap}.game-graphs .game-option .practice-graph{max-width:170px}}
/* Let the plot fill its answer card instead of leaving wide side margins. */
.game-graphs .game-option .practice-graph{max-width:none}
/* Wrap mathematical terms rather than scrolling inside the question. */
.game-console .game-function .level-formula{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 .25em;overflow:visible;max-height:none;font-size:clamp(1.1rem,2.1vw,1.65rem);line-height:1.7}
.game-console .formula-part{display:inline-block;max-width:100%;padding:.25em 0}
.game-ma3 .game-hud h1{font-size:clamp(1.1rem,2.4vw,1.65rem);overflow-wrap:anywhere}
.game-ma3 .game-function h2{font-family:inherit;font-size:1.05rem;line-height:1.45}
.game-ma3 .game-option-content{white-space:normal;overflow-wrap:anywhere;font-size:1rem;line-height:1.4}
.game-ma3 .game-feedback{flex-wrap:wrap}
.game-ma3 .game-feedback>span{max-width:100%;white-space:normal}
.game-console .game-ma3 .game-function .level-formula{column-gap:.8em}
.game-ma3 .algebra-rules .level-rule-sheet{font-size:.9rem;padding:12px}
.game-ma3 .algebra-rules .level-rule-sheet p{margin:8px 0}
.game-ma3 .game-option-content:has(.option-part){display:flex;flex-wrap:wrap;column-gap:.35em;justify-content:center;min-width:0}
.game-ma3 .game-option-content .option-part{display:inline-block}
.practice-unit-circle{display:block;width:320px;max-width:100%;height:auto;margin:4px auto}
.game-feedback .game-explanation{flex-basis:100%;min-width:0;font:inherit}
.game-explanation summary{cursor:pointer;font-size:.95rem}
.game-explanation p{margin:.5rem 0 0;line-height:1.5;font-size:.95rem}

@media(max-width:600px){.game-device:not(.game-graphs) .game-challenge{grid-template-columns:minmax(0,1fr)}.game-device:not(.game-graphs) .game-paper-note{padding:7px 10px}.game-device:not(.game-graphs) .game-paper-note p{margin:3px 0 0}}

/* Keep Ma 1 diagrams beside their data and question on larger screens. */
@media(min-width:760px){
.game-device[data-game^="ma1-"] .game-function:has(>.practice-graph){display:grid;grid-template-columns:minmax(0,1fr) 220px;column-gap:12px;align-items:center}
.game-device[data-game^="ma1-"] .game-function>.practice-graph{grid-column:2;grid-row:1 / span 4;width:220px;max-width:100%}
.game-device[data-game^="ma1-"] .game-function:has(>.practice-graph)>.level-formula,
.game-device[data-game^="ma1-"] .game-function:has(>.practice-graph)>.game-parameter-note,
.game-device[data-game^="ma1-"] .game-function:has(>.practice-graph)>h2{grid-column:1}
}

@media(min-width:760px){.game-device .game-options.game-nine-options{grid-template-columns:repeat(3,minmax(0,1fr))}}

/* A whole root stays together, including its sign and fraction. */
.game-ma3 .game-option-content.game-root-options{display:flex;flex-direction:column;align-items:flex-start;gap:.2rem;overflow-wrap:normal}
.game-ma3 .game-root-options .option-part{display:inline-block;white-space:nowrap;overflow-wrap:normal;max-width:100%}
.game-ma3 .game-root-options .option-part .katex{white-space:nowrap}
@media(max-width:600px){.game-ma3 .game-options:has(.game-root-options){grid-template-columns:minmax(0,1fr)}}
/* Longer chain-rule answers need the full card width on small screens. */
@media(max-width:600px){.game-device[data-game="ma4-chain"] .game-options{grid-template-columns:minmax(0,1fr)}}
/* Fractions need room for the entire numerator and denominator. */
.game-device .game-options:has(.practice-math-expression){grid-template-columns:minmax(0,1fr)}
.game-device .game-option-content:has(>.practice-math-expression){justify-content:flex-start;flex:1;min-width:0}
.practice-math-expression,.practice-math-group-body{display:inline-flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.12em .25em;min-width:0;max-width:100%}
.practice-math-fraction{display:inline-flex;flex-direction:column;align-items:stretch;vertical-align:middle;min-width:0;max-width:100%}
.practice-math-numerator,.practice-math-denominator{display:flex;justify-content:center;min-width:0;padding:.15em .2em}
.practice-math-numerator{border-bottom:1px solid currentColor}
.practice-math-power{display:inline-flex;align-items:flex-start;min-width:0;max-width:100%;gap:.05em}
.practice-math-power>sup{display:inline-flex;flex:0 1 auto;min-width:0;max-width:100%;font-size:.72em;line-height:1;position:static;margin-top:-.25em}
.practice-math-atom{display:inline-block;white-space:nowrap}
.practice-math-group{display:inline-grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.05em;min-width:0;max-width:100%}
.game-device .game-feedback>span:has(>.practice-math-expression){min-width:0;flex:1 1 100%}

/* Pupil games only: keep public activities and printed output at their own size.
   Never clip tall questions or shrink phone text to force a one-screen fit. */
@media screen and (min-width:700px){
 .student-layout .game-console{zoom:.9}
 .student-layout .student-shell:has(.game-console){margin-top:12px}
}
@media screen and (max-height:800px){
 .student-layout .game-console .game-hud{padding:10px 16px;gap:10px}
 .student-layout .game-console .game-progress{padding:6px 16px}
 .student-layout .game-console .game-screen{padding:10px 14px}
 .student-layout .game-console .game-challenge{gap:12px}
 .student-layout .game-console .game-paper-note{padding:8px}
 .student-layout .game-console .level-rules{margin:4px 0 8px}
 .student-layout .game-console .game-options{gap:7px}
 .student-layout .game-console .game-next-form{margin-top:8px}
 .student-layout .game-console .game-footer{padding:6px 16px}
 .student-layout .game-console .game-help{margin:12px 0}
}

.student-layout .game-device .game-options.game-wide-options{grid-template-columns:minmax(0,1fr)}

@media(max-width:440px){.game-device .game-options.game-mobile-stacked-options{grid-template-columns:minmax(0,1fr)}}

/* Draw points and regions at equal scale on the real and imaginary axes. */
.game-device .complex-plane-svg { display:block; width:100%; height:auto; max-width:16rem; margin-inline:auto; }
.game-device .plane-picker { width:min(100%,18rem); position:relative; margin:.5rem auto; }
.game-device .plane-picker svg { max-width:none; }
.game-device .plane-point { position:absolute; transform:translate(-50%,-50%); display:grid; place-items:center; width:13.15%; height:13.15%; min-width:0; min-height:0; padding:0; border:0; box-shadow:none; border-radius:50%; background:transparent; }
.game-device .plane-point span { width:.7rem; aspect-ratio:1; border-radius:50%; }
.game-device .plane-point:is(:hover,:focus-visible):enabled span { background:#624398; }
.game-device .plane-point.correct span { background:#16785a; outline:2px solid #16785a; outline-offset:2px; }
.game-device .plane-point.incorrect span { background:#aa3649; }
/* Nine figures: three across on desktop, with room for each coordinate grid. */
.student-layout .game-device .game-options.plane-figure-options { grid-template-columns:repeat(3,minmax(0,1fr)); gap:.45rem; max-width:50rem; margin-inline:auto; }
.student-layout .game-device .plane-figure-options .game-option { display:grid; grid-template-columns:minmax(0,1fr); justify-items:center; justify-self:center; width:100%; max-width:16.5rem; position:relative; padding:.2rem .1rem; }
.game-device .plane-figure-options .game-option-letter { position:absolute; left:.35rem; top:.35rem; }
.game-device .plane-figure-options .game-option-content { width:100%; }
.game-device .plane-figure-options .complex-plane-svg { width:100%; max-width:16rem; }
@media(max-width:760px) {
  .student-layout .game-device .game-options.plane-figure-options { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:480px) {
  .student-layout .game-device .game-options.plane-figure-options { grid-template-columns:minmax(0,1fr); }
}

/* Givens are part of the question, not subdued help text. Shared by all Arena games. */
.game-device .game-function :is(h2,.game-parameter-note,.game-given-text) {
  font:700 1.1rem/1.5 "Library Manrope",Manrope,sans-serif;
  color:var(--arcade-ink);
}

@media (max-width: 440px) {
    .student-layout .game-device[data-game="ma3-triangle-rules"] .game-options.game-math-options {
        grid-template-columns: minmax(0, 1fr);
    }
}
