/* Shared by the portal, React games, and all five iframe worlds. Never intercept
   input; reserve a small corner instead of covering a HUD or touch control. */
.avid-ip{box-sizing:border-box;width:114px;display:flex;align-items:center;flex-direction:column;gap:2px;pointer-events:none;user-select:none;line-height:1.25;text-align:center;color:#e7f4ff;font-family:Arial,sans-serif;filter:drop-shadow(0 2px 3px #061329);opacity:.86}
.avid-ip-site{position:fixed;right:max(16px,env(safe-area-inset-right));bottom:max(14px,env(safe-area-inset-bottom));z-index:50}
/* The fixed game library sits above the ordinary portal layer. */
body:has(.avid-game-library)>.avid-ip-site{z-index:107}
.avid-ip-game{position:absolute;right:max(14px,env(safe-area-inset-right));bottom:max(10px,env(safe-area-inset-bottom));z-index:12}
.avid-ip-seal{position:relative;width:68px;height:68px;display:block;border-radius:50%;background:#f3f9ffe8;box-shadow:0 0 0 1px #bceaff70,0 2px 18px #02081955}
.avid-ip-seal img{width:100%;height:100%;object-fit:contain;display:block}
.avid-ip-seal sup{position:absolute;right:-9px;top:2px;font-size:13px;font-weight:700;color:#ffe17b;text-shadow:0 1px 3px #061329}
.avid-ip-trademark{font-size:9px;letter-spacing:.07em;font-weight:700;color:#ffe28b}
.avid-ip small{font-size:9px;white-space:nowrap;color:#d0e7f9}
body:has(.avid-ip-game)>.avid-ip-site,body:has(iframe[title*="Avidian Squad"])>.avid-ip-site,body:has(iframe[src^="/game-runtime/tori?embedded=1&bridge=2&"])>.avid-ip-site{display:none}
/* TORI's mark is a sibling of the full-screen shade, so it stays sharp above
   pause, quiz/SUCCESS, retry, victory and results. Settings keep their z15. */
#shell:has(> .screen:not(.menu-screen):not([hidden])) > [data-brand-game="alien"]{z-index:12;opacity:1}
/* The menu's five world buttons occupy the bottom edge in every aspect ratio. */
#shell:has(> .menu-screen:not([hidden])) > [data-brand-game="alien"]{top:calc(max(20px,env(safe-area-inset-top)) + 56px);bottom:auto}
/* Wide layouts leave the mark to the right of action buttons. */
@media(min-height:541px) and (min-width:900px){
 .wise-root:has(.avid-ip-game) .wise-skills{right:142px!important}
 .relic-root:has(.avid-ip-game) .relic-toolbar{right:142px!important}
}
@media(max-width:899px),(max-height:540px){
 .avid-ip{width:96px;gap:1px}.avid-ip-seal{width:44px;height:44px}.avid-ip-seal sup{font-size:11px;right:-8px}.avid-ip-trademark,.avid-ip small{font-size:8px}
 .avid-ip-game{right:max(10px,env(safe-area-inset-right));bottom:max(7px,env(safe-area-inset-bottom))}
 .wise-root:has(.avid-ip-game) .wise-skills{bottom:max(79px,calc(env(safe-area-inset-bottom) + 70px))!important}
 .relic-root:has(.avid-ip-game) .relic-toolbar{bottom:max(79px,calc(env(safe-area-inset-bottom) + 70px))!important}
 .flight-game [data-brand-game="flight"]{top:82px;bottom:auto}
 #shell:has(.avid-ip-game) #touch-controls .touch-actions{transform:translateY(-70px)}
}
/* A separate top-left corner keeps the overlay mark out of quiz options and
   the fixed bottom results actions, including intermediate tablet widths.
   Only TORI overlay stages use this compact layout. */
 #shell:has(> .screen:not(.menu-screen):not([hidden])) > [data-brand-game="alien"]{
  top:max(8px,env(safe-area-inset-top));left:max(14px,env(safe-area-inset-left));right:auto;bottom:auto;
  width:154px;display:grid;grid-template-columns:32px 1fr;grid-template-rows:auto auto;column-gap:8px;row-gap:0;text-align:left;
 }
 #shell:has(> .screen:not(.menu-screen):not([hidden])) > [data-brand-game="alien"] .avid-ip-seal{grid-row:1/3;width:32px;height:32px}
 #shell:has(> .screen:not(.menu-screen):not([hidden])) > [data-brand-game="alien"] .avid-ip-seal sup{right:-6px;top:0;font-size:9px}
 #shell:has(> .screen:not(.menu-screen):not([hidden])) > [data-brand-game="alien"] .avid-ip-trademark{font-size:9px;white-space:nowrap}
 #shell:has(> .screen:not(.menu-screen):not([hidden])) > [data-brand-game="alien"] small{font-size:8px}
 #shell:has(> [data-brand-game="alien"]) > .screen.shaded{
  padding-top:calc(max(8px,env(safe-area-inset-top)) + 44px);padding-bottom:max(10px,env(safe-area-inset-bottom));
 }
 #shell:has(> [data-brand-game="alien"]) > .screen.shaded > :is(.dialog,.quiz-panel){
  max-height:calc(100dvh - max(8px,env(safe-area-inset-top)) - 44px - max(10px,env(safe-area-inset-bottom)));
 }
@media(orientation:landscape) and (max-height:540px){
 #shell:has(> .menu-screen:not([hidden])) > [data-brand-game="alien"]{top:calc(max(6px,env(safe-area-inset-top)) + 52px)}
}
@media(orientation:portrait) and (max-width:650px){
 #shell:has(> .menu-screen:not([hidden])) > [data-brand-game="alien"]{top:calc(14vh + max(42px,env(safe-area-inset-top)))}
}
@media(prefers-reduced-motion:reduce){.avid-ip{transition:none}}


/* TORI alone: keep the existing motion preference reachable below its HUD.
   The iframe keeps its own watermark; no game controls or physics change. */
@media(orientation:landscape) and (max-height:540px){
 body:has(iframe[src^="/game-runtime/tori?embedded=1&bridge=2&"])>.motion-switch{top:calc(max(6px,env(safe-area-inset-top)) + 52px);right:calc(max(12px,env(safe-area-inset-right)) + 216px);bottom:auto;z-index:101;min-height:44px;max-width:90px;padding:4px 8px;gap:4px;font-size:11px;line-height:1.2}
 body:has(iframe[src^="/game-runtime/tori?embedded=1&bridge=2&"])>.motion-switch svg{width:14px;height:14px;flex-shrink:0}
 body:has(iframe[src^="/game-runtime/tori?embedded=1&bridge=2&"])>.motion-switch span{white-space:nowrap}
}


/* Student portal only: two document-scrolling header slots, never over task CTAs.
   R=max(12px,safe-right); brand96 + gap12 + motion<=100 + gap12
   reserves R+220px. Game dialogs and TORI's iframe rules remain unchanged. */
@media(orientation:landscape) and (max-height:540px){
 body:has(.app-root.role-student):not(:has(.flight-dialog,[data-slot="dialog-content"][data-open]))>.avid-ip-site{position:absolute;top:max(14px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));bottom:auto;width:96px;transform:none}
 body:has(.app-root.role-student):not(:has(.flight-dialog,[data-slot="dialog-content"][data-open]))>.motion-switch{position:absolute;top:max(14px,env(safe-area-inset-top));right:calc(max(12px,env(safe-area-inset-right)) + 108px);bottom:auto;box-sizing:border-box;min-height:44px;min-width:76px;max-width:100px;padding:6px 10px;gap:6px;white-space:nowrap}
 body:has(.app-root.role-student):not(:has(.flight-dialog,[data-slot="dialog-content"][data-open]))>.motion-switch span{white-space:nowrap}
 body:has(.app-root.role-student):not(:has(.flight-dialog,[data-slot="dialog-content"][data-open])) .app-root.role-student>.role-topbar{min-height:calc(max(14px,env(safe-area-inset-top)) + 70px);height:auto;padding-inline-end:calc(max(12px,env(safe-area-inset-right)) + 220px)}
}
