/* Shared application shell: header, board footprint, installed-app safe areas and challenge layout. */
/* iOS Home Screen: solid compositing and visual-viewport anchored navigation. */
html.ios-standalone,html.ios-standalone body{height:100vh;min-height:100vh;overflow:hidden;background:var(--brand-bg,#f6f4fa)}
@media(max-width:999px), (hover:none), (pointer:coarse){
html.ios-standalone body #app-navigation{position:fixed;top:calc(var(--viewport-top,0px) + var(--app-height,100vh) - var(--dock-height,68px) - max(12px,env(safe-area-inset-bottom,0px)));bottom:auto;left:16px;right:16px;transform:none;margin:0 auto;width:min(382px,calc(100% - 32px));z-index:10;display:flex;flex-direction:row;align-items:center;justify-content:space-around;gap:3px;padding:7px;border-radius:29px;isolation:auto;background:#fbf9ff;background-image:none;border:1px solid #d9cdec;box-shadow:inset 0 1px 0 #fff,0 5px 18px #35204e1c;backdrop-filter:none;-webkit-backdrop-filter:none;will-change:auto}
html.ios-standalone body #app-navigation .dock-item{color:#655c74;display:flex;flex-direction:column;align-items:center;justify-content:center;height:51px;padding:5px;gap:4px}
html.ios-standalone body #app-navigation .dock-item.active{background:#e9dff8;color:#6842a7;box-shadow:none}
html.ios-standalone[data-theme="dark"] body #app-navigation{background:#292333;border-color:#78638f85;box-shadow:inset 0 1px 0 #ba9ee523,0 5px 20px #0004}
html.ios-standalone[data-theme="dark"] body #app-navigation .dock-item{color:#c4b7d7}
html.ios-standalone[data-theme="dark"] body #app-navigation .dock-item.active{background:#504067;color:#f1e9ff}
html.ios-standalone.viewport-keyboard body #app-navigation{visibility:hidden;pointer-events:none}
html.ios-standalone body .sheet.app-screen{padding-bottom:max(var(--screen-bottom,116px),calc(var(--dock-height,68px) + env(safe-area-inset-bottom,0px) + 24px))}

}

@media(max-height:480px) and (orientation:landscape){
 html.ios-standalone body #app-navigation{padding:5px}
 html.ios-standalone body #app-navigation .dock-item{height:38px;gap:2px;padding:3px}
 html.ios-standalone body #app-navigation .dock-item svg{width:19px;height:19px}
 html.ios-standalone body #app-navigation .dock-item span{font-size:9px}
 html.ios-standalone body .reels .reel .board-wrap{width:min(100%,max(120px,calc(var(--app-height) - 163px - env(safe-area-inset-bottom,0px))))}
}

/* One shared, original logo; no CSS recreation of the approved wordmark. */
html body .brand{gap:0;line-height:1}
html body .brand-lockup{display:block;width:180px;height:auto;max-width:none;object-fit:contain}
html body .brand-lockup-dark{display:none}
html[data-theme="dark"] body .brand-lockup-light{display:none}
html[data-theme="dark"] body .brand-lockup-dark{display:block}
html body .topbar,html body .topbar *{filter:none!important;-webkit-filter:none!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;will-change:auto!important}
html body .topbar{background:transparent!important;box-shadow:none;opacity:1}
.reel-header-slot{display:none}
html.ios-standalone .sheet::backdrop{backdrop-filter:none;-webkit-backdrop-filter:none;background:#0d091a66}
html.ios-standalone :is(.completion-panel,.milestone-notice,.toast,.install-nudge){backdrop-filter:none;-webkit-backdrop-filter:none}
@media(max-width:999px), (max-height:579px), (hover:none), (pointer:coarse){
 html body .sheet.app-screen:has(>.topbar){padding-top:calc(22px + env(safe-area-inset-top))!important}
 html body .sheet.app-screen>.topbar{position:static!important;inset:auto!important;width:100%;max-width:none;margin:0 auto 28px;transform:none}
 html body .reel-header-slot{display:block;position:absolute;top:max(16px,env(safe-area-inset-top));left:16px;right:16px;z-index:12}
 html body .reel-header-slot>.topbar{position:static!important;inset:auto!important;width:100%;max-width:none;margin:0;transform:none}
 html body .reels .reel{padding-top:calc(max(16px,env(safe-area-inset-top)) + 74px)}
 html body .topbar .brand-lockup{width:170px}
}
@media(max-width:359px){html body .topbar .brand-lockup{width:136px}html body .reels .reel{padding-top:calc(max(16px,env(safe-area-inset-top)) + 64px)}}
@media(max-height:480px) and (orientation:landscape){html body .topbar .brand-lockup{width:140px}html body .reel-header-slot{top:max(8px,env(safe-area-inset-top))}html body .reels .reel{padding-top:calc(max(8px,env(safe-area-inset-top)) + 62px)}}
@media(min-width:1000px) and (min-height:580px) and (hover:hover) and (pointer:fine){html body .topbar .brand-lockup{width:144px}}

/* Installed iOS can draw a native scroll-edge blur below its status area.
   Reserve a real gap above controls rather than trying to filter that OS layer.
   The header still scrolls with its page; no fixed header background is added. */
@media(orientation:portrait){
 html.ios-standalone body .reel-header-slot{top:calc(max(16px,env(safe-area-inset-top)) + 36px)}
 html.ios-standalone body .reels .reel{padding-top:calc(max(16px,env(safe-area-inset-top)) + 110px)}
 html.ios-standalone body .sheet.app-screen:has(>.topbar){padding-top:calc(env(safe-area-inset-top) + 36px)!important}
 html.ios-standalone body .reels .reel .reel-content{max-width:min(700px,max(200px,calc(var(--app-height) - 432px - env(safe-area-inset-top) - env(safe-area-inset-bottom))))}
}
@media(orientation:portrait) and (max-width:359px){
 html.ios-standalone body .reels .reel{padding-top:calc(max(16px,env(safe-area-inset-top)) + 100px)}
}
@media(orientation:portrait) and (min-width:700px){
 html.ios-standalone body .reels .reel .reel-content{max-width:min(700px,max(200px,calc(var(--app-height) - 456px - env(safe-area-inset-top) - env(safe-area-inset-bottom))))}
}

/* Playing a challenge uses the same centered board and shell as training.
   Lobby and results keep their own document layout. */
html body[data-view="challenge"] #challenge-sheet:has(.rush-arena){display:flex;flex-direction:column;padding:calc(max(16px,env(safe-area-inset-top)) + 74px) 16px calc(102px + env(safe-area-inset-bottom))!important;overflow-y:auto}
html body #challenge-sheet:has(.rush-arena)> .topbar{position:absolute!important;inset:max(16px,env(safe-area-inset-top)) 16px auto!important;width:auto!important;max-width:none;margin:0;transform:none}
#challenge-sheet:has(.rush-arena) #challenge-back{display:none}
#challenge-sheet:has(.rush-arena)>.rush-content{width:100%;max-width:none!important;margin:auto;animation:none}
#challenge-sheet .rush-game-layout{display:block}
#challenge-sheet .rush-arena{display:flex;flex-direction:column;gap:0;width:100%;max-width:min(620px,calc(var(--app-height) - 390px));margin:auto;min-width:0}
#challenge-sheet .rush-live-hud{display:flex;align-items:center;justify-content:space-between;gap:14px;min-height:52px;padding:0 0 12px;margin:0 0 12px;border-bottom:1px solid var(--line)}
.rush-live-context{display:flex;flex-direction:column;align-items:flex-start;gap:5px;min-width:0;flex:1}
.rush-live-label{display:inline-flex;align-items:center;color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,transparent);border:1px solid color-mix(in srgb,var(--accent) 20%,transparent);padding:3px 7px;border-radius:6px;font-size:9px;font-weight:650;line-height:1.2;letter-spacing:.5px;text-transform:uppercase}
.rush-live-context>strong{font-size:12px;font-weight:550;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#challenge-sheet .rush-scorebar{display:flex;gap:18px;flex-shrink:0;margin:0;padding:0;position:static;pointer-events:auto;flex-wrap:nowrap}
#challenge-sheet .rush-scorebar>div{gap:5px;align-items:center;min-width:30px}
#challenge-sheet .rush-scorebar>div:first-child{min-width:54px}
#challenge-sheet .rush-scorebar span{font-size:9px;line-height:1.2}
#challenge-sheet .rush-scorebar strong{font-size:21px;font-weight:600;line-height:1.1;letter-spacing:-.5px}
#challenge-sheet .rush-scorebar>div:not(:first-child) strong{font-size:18px}
#challenge-sheet .rush-turn{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:0 0 8px;min-height:26px}
#challenge-sheet .rush-turn .turn-label{font-size:11px;font-weight:550;white-space:nowrap;margin:0;display:flex;align-items:center;gap:7px;line-height:1.3}
#challenge-sheet .rush-turn .turn-dot{width:9px;height:9px;flex-shrink:0}
#challenge-sheet .rush-turn .difficulty-pill{font-size:9px;padding:7px 10px;white-space:nowrap}
#challenge-sheet .rush-arena .board-wrap{width:100%;max-width:none;aspect-ratio:1;flex-shrink:0;border-radius:10px;margin:0;grid-column:auto;grid-row:auto}
#challenge-sheet .rush-arena .feedback{margin:0;padding:7px 0;min-height:30px;font-size:11px;line-height:16px;text-align:center;align-self:stretch;grid-column:auto;grid-row:auto}
#challenge-sheet .rush-game-actions{display:flex;flex-direction:row;align-items:center;gap:8px;margin:0;grid-column:auto;grid-row:auto}
#challenge-sheet .rush-game-actions [data-rush-skip]{flex:1;min-width:0;min-height:44px;margin:0;border-radius:12px;background:var(--rush-card);border:1px solid var(--line);font-size:12px;padding:10px 14px}
#challenge-sheet .rush-game-actions [data-rush-refresh]{min-width:44px;min-height:44px;font-size:22px;border:1px solid var(--line);border-radius:12px;padding:5px;margin:0}
#challenge-sheet .rush-game-actions [data-rush-retry]{flex:1;min-height:44px;margin:0;font-size:12px}
.rush-live-meta{margin:10px 0 0!important;font-size:9px!important;line-height:1.5;color:var(--muted);text-align:center}
@media(orientation:portrait){
 html.ios-standalone body[data-view="challenge"] #challenge-sheet:has(.rush-arena){padding-top:calc(max(16px,env(safe-area-inset-top)) + 110px)!important}
 html.ios-standalone body #challenge-sheet:has(.rush-arena)>.topbar{top:calc(max(16px,env(safe-area-inset-top)) + 36px)!important}
 html.ios-standalone body #challenge-sheet .rush-arena{max-width:min(700px,max(200px,calc(var(--app-height) - 432px - env(safe-area-inset-top) - env(safe-area-inset-bottom))))}
}
@media(orientation:portrait) and (min-width:700px){
 html.ios-standalone body #challenge-sheet .rush-arena{max-width:min(700px,max(200px,calc(var(--app-height) - 456px - env(safe-area-inset-top) - env(safe-area-inset-bottom))))}
}
@media(max-width:359px){
 #challenge-sheet .rush-scorebar{gap:10px}
 #challenge-sheet .rush-live-hud{gap:8px}
 #challenge-sheet .rush-turn .difficulty-pill{font-size:8px;padding:6px 7px}
}
@media(min-width:700px) and (orientation:portrait){
 #challenge-sheet .rush-live-context>strong{font-size:16px}
 #challenge-sheet .rush-live-label{font-size:10px}
 #challenge-sheet .rush-scorebar span{font-size:11px}
 #challenge-sheet .rush-scorebar strong{font-size:27px}
 #challenge-sheet .rush-scorebar>div:not(:first-child) strong{font-size:22px}
 #challenge-sheet .rush-turn .turn-label{font-size:14px}
 #challenge-sheet .rush-turn .difficulty-pill{font-size:11px}
 #challenge-sheet .rush-arena .feedback{font-size:13px;min-height:34px}
 #challenge-sheet .rush-game-actions [data-rush-skip]{font-size:14px;min-height:48px}
 #challenge-sheet .rush-live-meta{font-size:11px!important}
}
@media(max-height:480px) and (orientation:landscape){
 html body[data-view="challenge"] #challenge-sheet:has(.rush-arena){padding:calc(max(8px,env(safe-area-inset-top)) + 62px) 20px calc(60px + env(safe-area-inset-bottom))!important}
 html body #challenge-sheet:has(.rush-arena)>.topbar{top:max(8px,env(safe-area-inset-top))!important}
 #challenge-sheet .rush-arena{display:grid;grid-template-columns:minmax(0,min(420px,max(120px,calc(var(--app-height) - 170px - max(8px,env(safe-area-inset-top)) - env(safe-area-inset-bottom))))) minmax(170px,1fr);column-gap:22px;row-gap:7px;max-width:850px}
 #challenge-sheet .rush-turn{grid-column:1;grid-row:1;margin:0}
 #challenge-sheet .rush-arena .board-wrap{grid-column:1;grid-row:2/6}
 #challenge-sheet .rush-live-hud{grid-column:2;grid-row:2;margin:0;padding-bottom:10px}
 #challenge-sheet .rush-arena .feedback{grid-column:2;grid-row:3;text-align:left;padding:0;min-height:0}
 #challenge-sheet .rush-game-actions{grid-column:2;grid-row:4}
 #challenge-sheet .rush-live-meta{grid-column:2;grid-row:5;text-align:left;margin:0!important}
}
@media(min-width:1000px) and (min-height:580px) and (hover:hover) and (pointer:fine){
 html body[data-view="challenge"] #challenge-sheet:has(.rush-arena){padding:24px 36px!important}
 #challenge-sheet .rush-arena{display:grid;grid-template-columns:minmax(0,min(620px,calc(var(--app-height) - 140px))) minmax(240px,300px);column-gap:36px;row-gap:14px;max-width:1000px;align-items:start;grid-template-rows:auto 76px auto auto 1fr}
 #challenge-sheet .rush-turn{grid-column:1;grid-row:1;margin:0;min-height:32px}
 #challenge-sheet .rush-turn .turn-label{font-size:15px}
 #challenge-sheet .rush-turn .difficulty-pill{font-size:11px}
 #challenge-sheet .rush-arena .board-wrap{grid-column:1;grid-row:2/6}
 #challenge-sheet .rush-live-hud{grid-column:2;grid-row:2;padding:0 0 18px;margin:0;min-height:70px}
 #challenge-sheet .rush-live-context>strong{font-size:14px}
 #challenge-sheet .rush-scorebar strong{font-size:25px}
 #challenge-sheet .rush-arena .feedback{grid-column:2;grid-row:3;align-self:start;text-align:left;font-size:14px;line-height:1.6;padding:0;margin:0}
 #challenge-sheet .rush-game-actions{grid-column:2;grid-row:4;align-self:start}
 #challenge-sheet .rush-live-meta{grid-column:2;grid-row:5;text-align:left;align-self:start;margin:0!important;font-size:11px!important}
}

@media(max-width:359px), (max-height:740px) and (orientation:portrait){
 #challenge-sheet .rush-difficulty-label{display:none}
 #challenge-sheet .rush-turn .difficulty-pill{gap:4px}
}

@media(max-height:740px) and (orientation:portrait){
 html body[data-view="challenge"] #challenge-sheet:has(.rush-arena){padding-bottom:calc(78px + env(safe-area-inset-bottom))!important}
}

/* Shared dimensions for training, challenges and the private notebook. */
:root{--play-width:min(620px,max(240px,calc(var(--app-height) - 390px)))}
@media(orientation:portrait){
 html.ios-standalone{--play-width:min(700px,max(200px,calc(var(--app-height) - 432px - env(safe-area-inset-top) - env(safe-area-inset-bottom))))}
 html body .reels .reel .reel-content,html body #challenge-sheet .rush-arena{max-width:var(--play-width)}
}
@media(orientation:portrait) and (min-width:700px){html.ios-standalone{--play-width:min(700px,max(200px,calc(var(--app-height) - 456px - env(safe-area-inset-top) - env(safe-area-inset-bottom))))}}
@media(max-width:999px), (hover:none), (pointer:coarse){
 html body .reels .reel .puzzle-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
 html body .reels .reel .puzzle-actions .action-separator{display:none}
 html body .reels .reel .puzzle-actions .action-button{min-width:0;min-height:44px;font-size:10px;padding:9px 4px;gap:5px}
 html body .reels .reel .puzzle-actions .action-button svg{width:17px;height:17px;flex-shrink:0}
}
@media(min-width:700px) and (orientation:portrait){html body .reels .reel .puzzle-actions .action-button{min-height:48px;font-size:13px}}
@media(min-width:1000px) and (min-height:580px) and (hover:hover) and (pointer:fine){
 html body .reels .reel .reel-content{max-width:1120px}
 html body #challenge-sheet .rush-arena{max-width:1000px}
}

/* Wide tablets share the two-column playing layout used by training. */
@media(min-width:950px) and (min-height:600px) and (orientation:landscape){
 html body #challenge-sheet .rush-arena{display:grid;grid-template-columns:minmax(0,1fr) 260px;column-gap:44px;row-gap:12px;max-width:1080px;align-items:start;grid-template-rows:auto 76px auto auto 1fr}
 #challenge-sheet .rush-turn{grid-column:1;grid-row:1;width:min(100%,calc(var(--app-height) - 300px),620px);justify-self:center}
 #challenge-sheet .rush-arena .board-wrap{grid-column:1;grid-row:2/6;width:min(100%,calc(var(--app-height) - 300px),620px);justify-self:center}
 #challenge-sheet .rush-live-hud{grid-column:2;grid-row:2;margin:0}
 #challenge-sheet .rush-arena .feedback{grid-column:2;grid-row:3;text-align:left}
 #challenge-sheet .rush-game-actions{grid-column:2;grid-row:4}
 #challenge-sheet .rush-live-meta{grid-column:2;grid-row:5;text-align:left}
}
@media(min-width:1000px) and (min-height:580px) and (hover:hover) and (pointer:fine){
 html body #challenge-sheet .rush-arena{max-width:1000px;grid-template-columns:minmax(0,min(620px,calc(var(--app-height) - 140px))) minmax(240px,300px);column-gap:36px}
 #challenge-sheet .rush-turn,#challenge-sheet .rush-arena .board-wrap{width:100%}
}
