/* PWA shell and phone play area. Safe areas accommodate notches and gesture bars. */
:root{--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px)}
/* Contain the previous canvas size during rotation so it cannot widen Safari's
   layout viewport before Phaser has received the new container dimensions. */
#game{overflow:hidden}
body:not([data-game-screen="play"]) #touch-controls{display:none!important}
.touch-instructions,.touch-mission-toggle{display:none}
.pwa-menu-status{font-size:10px;line-height:1.6;color:#b4cbb3;margin-top:9px;max-width:360px}
.pwa-menu-status>span{display:block}.pwa-menu-status [hidden]{display:none!important}
#kka-root .pwa-menu-status .g-button{padding:6px 0;font-size:10px;text-align:left}
.pwa-panel{max-width:530px}.pwa-app-icon{display:block;border-radius:20px;margin-bottom:22px}
.pwa-panel h2{margin:10px 0 22px!important}.pwa-panel li{line-height:1.8;margin:13px 0;padding-left:5px}.pwa-panel ol{padding-left:24px}
.pwa-panel p{font-size:13px}.pwa-panel .pwa-offline-status{padding:12px 15px;border:1px solid #91af7655;border-radius:6px;color:#d6dfa9!important;background:#79904d12}
.pwa-site{display:inline-block;color:#dfc383;font-size:13px;margin:12px 0;overflow-wrap:anywhere}
.pwa-panel footer{display:flex;flex-wrap:wrap;gap:12px;margin-top:20px}
.pwa-panel a,.pwa-panel button{touch-action:manipulation}
.g-title-screen{padding-top:var(--safe-top)}
.g-title-copy{padding-bottom:125px}
.g-title-footer{bottom:calc(18px + var(--safe-bottom))}
.g-title-top{top:calc(24px + var(--safe-top));left:max(4%,var(--safe-left));right:max(4%,var(--safe-right))}
.g-overlay,.k-overlay{padding-top:max(16px,var(--safe-top));padding-right:max(16px,var(--safe-right));padding-bottom:max(16px,var(--safe-bottom));padding-left:max(16px,var(--safe-left))}
.g-lab-shell{margin-top:var(--safe-top);margin-bottom:var(--safe-bottom);max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px)}
.g-codex{max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px)}
.g-expedition{padding:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left)}
.g-lab-layout,.g-codex-body,.g-codex-page,.g-overlay,.k-overlay,.g-title-screen{overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.touch-device #game,.touch-device #touch-controls{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.touch-device .glass,.touch-device .k-play-bar,.touch-device .g-overlay,.touch-device .k-overlay{backdrop-filter:none}
.touch-device .keyboard-instructions{display:none!important}
.touch-device .touch-mission-toggle{display:inline-flex;align-items:center;justify-content:center;min-width:48px;min-height:34px;background:transparent;color:#efdab0;font-size:11px;border:1px solid #e6cf9d40;border-radius:5px;margin-left:auto;pointer-events:auto}
.touch-device .k-play-objective.expanded .touch-instructions{display:block;font-size:10px;line-height:1.5;letter-spacing:0;margin-top:8px}
.touch-device .k-play-objective strong{display:none}.touch-device .k-play-objective.expanded strong{display:block}
.touch-device .k-play-objective .k-quest-steps{align-items:center;gap:7px;font-size:9px;margin-bottom:4px}
.touch-device .k-play-objective{width:230px;max-width:calc(100vw - 150px);padding:6px 10px;top:calc(76px + var(--safe-top));right:calc(12px + var(--safe-right));background:#102a23e8}
.touch-device .k-stamina{font-size:7px;margin-top:4px;gap:6px}.touch-device .k-stamina>span{white-space:nowrap}.touch-device .k-distance{font-size:7px;line-height:1.5}
.touch-device .k-play-bar{top:calc(8px + var(--safe-top));left:calc(10px + var(--safe-left));right:calc(10px + var(--safe-right));padding:6px 8px;gap:8px;border-radius:8px}
.touch-device .k-play-bar>div{gap:8px;min-width:0}.touch-device .k-play-bar strong{font-size:12px;line-height:1.3;max-width:150px}.touch-device .k-play-bar small{display:none}.touch-device .k-pill{font-size:12px;padding:7px}
.touch-device .k-play-bar nav{gap:5px;max-width:none;flex-wrap:nowrap;align-items:center;min-width:0;overflow-x:auto;justify-content:flex-start;scrollbar-width:none}
.touch-device .k-play-bar nav>*{flex-shrink:0}
#kka-root .pwa-fullscreen{min-width:44px;width:44px;min-height:44px}
.touch-device #kka-root .k-play-bar .k-btn{min-height:44px!important;font-size:11px!important;padding:8px!important;white-space:nowrap}
.touch-device #kka-root .k-play-bar .k-square{min-width:44px;width:44px}
.touch-device.kka-mode #hud{top:calc(78px + var(--safe-top));left:calc(12px + var(--safe-left));right:auto;flex-wrap:nowrap}
.touch-device.kka-mode .hero-hud{width:116px;padding:6px;gap:0;background:#102a23e8}.touch-device .hero-hud .avatar{display:none}.touch-device .hero-name{font-size:13px}.touch-device .hero-name span{display:none}.touch-device #hearts .icon{width:15px;height:15px}.touch-device #hearts{gap:3px}.touch-device .health-track{height:3px}
.touch-device.kka-mode #power-status{top:calc(140px + var(--safe-top));left:calc(12px + var(--safe-left));font-size:8px}
.touch-device.kka-mode #boss-bar{top:calc(78px + var(--safe-top));left:47%;width:clamp(130px,22vw,210px);padding:7px;transform:translateX(-50%);border-radius:7px}.touch-device #boss-bar .boss-bar-head{font-size:9px;gap:5px}.touch-device #boss-name{font-size:10px}
.touch-device .action-controls{display:grid;grid-template-columns:66px 76px;grid-template-rows:64px 72px;gap:10px 12px;width:154px;right:calc(16px + var(--safe-right));bottom:calc(16px + var(--safe-bottom));opacity:.93;align-items:center;justify-items:center}
.touch-device .action-controls .action-button{position:relative!important;left:auto!important;right:auto!important;bottom:auto!important;top:auto!important;width:64px!important;height:64px!important;min-height:64px;margin:0!important;transform:none!important;align-self:center;background:linear-gradient(145deg,#315345eb,#122a26eb);border-color:#f1d29aaa;box-shadow:0 3px 12px #001d1466,inset 0 0 0 4px #e7dfb610}
.touch-device .action-controls .action-button:active{transform:scale(.96)!important}
.touch-device .action-controls .guard-button{grid-column:1;grid-row:1}.touch-device .action-controls .dash-button{grid-column:2;grid-row:1;width:58px!important;height:58px!important;min-height:58px}
.touch-device .action-controls .attack-button{grid-column:1;grid-row:2}.touch-device .action-controls .jump-button{grid-column:2;grid-row:2;width:76px!important;height:76px!important;background:linear-gradient(145deg,#ac9255da,#2e4632f0);border-color:#ffe2a3}
.touch-device .action-controls .action-button span{font-size:8px;letter-spacing:.5px}.touch-device .action-controls .action-button kbd{display:none}.touch-device .action-controls .action-button .icon{width:25px;height:25px}.touch-device .guard-button{font-size:23px!important}
.touch-device .joystick-wrap{left:calc(18px + var(--safe-left));bottom:calc(27px + var(--safe-bottom));opacity:.9}
.touch-device #joystick{width:116px;height:116px;background:radial-gradient(circle,#e8edc612 36%,#17372fbb 39%,#102e2bdd 68%,#d4dab780 70%);border-color:#e9e0bcb3}
.touch-device .stick-nub{left:36px;top:36px;width:42px;height:42px;background:linear-gradient(145deg,#f0e3bdb3,#839b83cc)}.touch-device .stick-arrow{top:37px;font-size:31px}.touch-device .stick-dot{left:55px}.touch-device .control-caption{display:none}
.touch-device #kka-root input:not([type=radio]):not([type=checkbox]),.touch-device #kka-root textarea,.touch-device #kka-root select{font-size:16px!important;min-height:44px}
.touch-device #kka-root .g-button,.touch-device #kka-root .g-codex-index nav button{min-height:44px!important}
.touch-device #kka-root .g-answers label{min-height:58px;font-size:14px}
.touch-device #kka-root .g-seals button{width:38px;height:38px}
.touch-device #toast{max-width:calc(100% - 40px);pointer-events:none}
@media(max-width:540px){
  .g-title-copy{padding-top:calc(95px + var(--safe-top));padding-bottom:115px}
  .g-title-copy h1{font-size:clamp(51px,14vw,72px)!important}.g-title-copy>p{font-size:11px!important}
  .g-title-menu{margin-top:24px;gap:7px}.g-title-menu .g-button{min-height:44px!important}
  .g-title-hero{top:235px;height:115px}.g-title-hero>img{width:100px}
  .g-save-indicator{margin-top:15px}.pwa-menu-status{font-size:9px;max-width:90%}
  .g-title-footer{position:relative;bottom:auto;left:auto;right:auto;margin:-80px 6% 0;padding-bottom:calc(20px + var(--safe-bottom))}
  .g-overlay,.k-overlay{padding: max(9px,var(--safe-top)) max(9px,var(--safe-right)) max(9px,var(--safe-bottom)) max(9px,var(--safe-left))}
  .pwa-panel{padding:23px 20px}.pwa-panel li{font-size:14px}.pwa-panel footer .g-button{width:100%}
  .g-codex{max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 18px)}
  .g-lab-shell{max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 18px)}
  .touch-device .k-play-bar{display:grid;grid-template-columns:1fr;gap:5px;padding:6px 8px}
  .touch-device .k-play-bar>div{justify-content:flex-start}.touch-device .k-play-bar strong{max-width:none}
  .touch-device .k-play-bar nav{overflow-x:auto;justify-content:flex-start;scrollbar-width:none}
  .touch-device .k-play-bar nav>*{flex-shrink:0}
  .touch-device.kka-mode #hud{top:calc(110px + var(--safe-top))}
  .touch-device .k-play-objective{top:calc(108px + var(--safe-top));width:218px;max-width:calc(100vw - 145px);right:calc(10px + var(--safe-right));padding:6px 8px}
  .touch-device .k-play-objective .k-quest-steps{gap:4px;font-size:8px;flex-wrap:wrap}.touch-device .touch-mission-toggle{min-height:30px;min-width:44px;font-size:10px}
  .touch-device.kka-mode #power-status{top:calc(172px + var(--safe-top))}
  .touch-device.kka-mode #boss-bar{top:calc(214px + var(--safe-top));left:50%;width:65%}
  .touch-device .g-lab-shell .k-command-bank .k-btn{width:46px;height:46px;min-height:46px}
}
@media(max-height:500px) and (orientation:landscape){
  .g-title-copy{padding-top:65px;width:55%;padding-bottom:75px}.g-title-copy h1{font-size:44px!important;letter-spacing:2px;margin:10px 0!important}
  .g-title-copy>.g-overline,.g-title-copy>p,.g-title-subtitle,.g-save-indicator{display:none}
  .g-title-menu{margin-top:15px;gap:6px;max-width:340px;grid-template-columns:1fr 1fr}
  #kka-root .g-title-menu .g-button{min-height:44px;padding:8px 12px!important;font-size:9px;letter-spacing:.4px}
  .g-title-menu .g-primary{grid-column:1/-1}.g-title-hero{top:20%;height:65%}.g-title-hero>img{max-height:185px;width:auto}
  .g-hero-caption strong{font-size:21px}.g-hero-caption>span{font-size:6px}.g-title-footer{font-size:6px}
  .touch-device .k-play-objective{width:195px;top:calc(67px + var(--safe-top));padding:4px 8px}
  .touch-device .k-play-objective .k-quest-steps{font-size:8px;gap:4px}.touch-device .touch-mission-toggle{font-size:9px;min-width:40px;min-height:28px}
  .touch-device.kka-mode #hud{top:calc(68px + var(--safe-top))}.touch-device.kka-mode #boss-bar{top:calc(69px + var(--safe-top));left:45%;width:clamp(120px,20vw,180px)}
  .touch-device.kka-mode #power-status{top:calc(125px + var(--safe-top))}
  .touch-device .k-distance{display:none}.touch-device .k-play-objective.expanded .k-distance{display:block}
  .touch-device .action-controls{grid-template-columns:60px 70px;grid-template-rows:54px 65px;gap:7px 10px;width:142px;bottom:calc(12px + var(--safe-bottom));right:calc(14px + var(--safe-right))}
  .touch-device .action-controls .action-button{width:58px!important;height:58px!important;min-height:58px}
  .touch-device .action-controls .jump-button{width:70px!important;height:70px!important}.touch-device .action-controls .dash-button{width:52px!important;height:52px!important;min-height:52px}
  .touch-device .joystick-wrap{bottom:calc(16px + var(--safe-bottom));left:calc(20px + var(--safe-left))}
  .touch-device #joystick{width:104px;height:104px}.touch-device .stick-nub{left:31px;top:31px}.touch-device .stick-arrow{top:31px}.touch-device .stick-dot{left:49px}
  .g-codex{height:calc(100dvh - 20px)}.g-codex-top{padding:8px 15px}.g-codex-foot{padding:7px 12px}
  .g-lab-shell{max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 18px)}
}
@media(prefers-reduced-motion:reduce){.pwa-app-icon{animation:none}}

/* Compact play HUD. Secondary actions live in the paused menu on touch screens. */
.touch-device #kka-root .k-play-bar .mobile-secondary{display:none!important}
.touch-device .k-play-bar{display:flex;align-items:center;top:calc(6px + var(--safe-top));left:max(10px,var(--safe-left));right:max(10px,var(--safe-right));padding:0;gap:8px;background:none;border:0;box-shadow:none;backdrop-filter:none;pointer-events:none}
.touch-device .k-play-bar>div{min-width:0;gap:7px;padding:5px 9px 5px 5px;border:1px solid #d6c79755;border-radius:10px;background:#102b27df;max-width:calc(100% - 118px);height:46px}
.touch-device .k-play-bar strong{font-size:12px;max-width:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.touch-device .k-play-bar>div>span:nth-child(2){min-width:0}
.touch-device .k-play-bar .k-pill{font-size:11px;line-height:1;padding:10px 7px;flex-shrink:0}
.touch-device .k-play-bar nav{pointer-events:auto;overflow:visible;gap:5px;flex-shrink:0;max-width:none;background:#102b27ed;border:1px solid #d6c79755;border-radius:10px;padding:0 3px}
.touch-device #kka-root .k-play-bar .k-btn{border:0;background:transparent;min-height:44px!important;padding:6px 8px!important;font-size:11px!important;border-radius:7px}
.touch-device #kka-root .k-play-bar [data-act="pause"]{font-size:21px!important}
.touch-device.kka-mode #hud{top:calc(59px + var(--safe-top));left:max(10px,var(--safe-left))}
.touch-device.kka-mode .hero-hud{width:139px;padding:6px 8px;border-radius:9px}
.touch-device .hero-info{display:flex;align-items:center;justify-content:space-between;gap:6px}
.touch-device .hero-name{font-size:9px;letter-spacing:.3px}
.touch-device.kka-mode #hearts{margin:0;gap:2px}
.touch-device.kka-mode #hearts .icon{width:15px;height:15px}
.touch-device .health-track{display:none}
.touch-device .k-play-objective{top:calc(57px + var(--safe-top));right:max(10px,var(--safe-right));width:154px;max-width:calc(100vw - 169px - var(--safe-left) - var(--safe-right));padding:0 8px 5px;background:#102b27d9;border-radius:9px;pointer-events:auto}
.touch-device .k-play-objective .k-quest-steps{margin:0;gap:0;justify-content:flex-end}
.touch-device .k-play-objective:not(.expanded) .k-quest-steps>span,.touch-device .k-play-objective:not(.expanded) .k-travel,.touch-device .k-play-objective:not(.expanded) .k-distance{display:none}
.touch-device .k-play-objective:not(.expanded){display:grid;grid-template-columns:1fr 44px;align-items:center;gap:8px;padding:0 8px}
.touch-device .k-play-objective:not(.expanded) .k-quest-steps{grid-column:2;grid-row:1}
.touch-device .k-play-objective:not(.expanded) .k-stamina{grid-column:1;grid-row:1;flex-direction:column;align-items:stretch;gap:3px}
.touch-device .k-play-objective:not(.expanded) .k-stamina meter{flex:none;width:100%}
.touch-device .touch-mission-toggle{min-height:44px;min-width:44px;font-size:11px;padding:4px 0;border:0;margin:0}
.touch-device .k-play-objective .k-stamina{margin:0;font-size:7px;gap:5px;position:relative}
.touch-device .k-play-objective .k-stamina meter{height:7px;min-width:0;flex:1;appearance:none;-webkit-appearance:none;border:0;border-radius:4px;background:#304c41}
.touch-device .k-stamina meter::-webkit-meter-bar{height:7px;border:0;background:#304c41;border-radius:4px}
.touch-device .k-stamina meter::-webkit-meter-optimum-value{background:#d4bc7c;border-radius:4px}
.touch-device .k-stamina meter::-moz-meter-bar{background:#d4bc7c;border-radius:4px}
.touch-device .k-play-objective.expanded{width:300px;max-width:calc(100vw - 20px - var(--safe-left) - var(--safe-right));padding:0 12px 10px;background:#102b27f5;z-index:4}
.touch-device .k-play-objective.expanded .k-quest-steps{gap:8px;font-size:10px;flex-wrap:nowrap}
.touch-device .k-play-objective.expanded .touch-mission-toggle{margin-left:auto;flex-shrink:0}
.touch-device .k-play-objective.expanded strong{font-size:12px;line-height:1.5;margin:0 0 8px}
.touch-device .k-play-objective.expanded .k-distance{display:block;font-size:10px}
.touch-device.kka-mode #power-status{top:calc(95px + var(--safe-top));left:max(10px,var(--safe-left));font-size:8px}
.touch-device.kka-mode #boss-bar{top:calc(123px + var(--safe-top));left:50%;width:clamp(160px,45vw,280px);padding:5px 8px}
.touch-device.kka-mode #toast{top:calc(123px + var(--safe-top));padding:9px 12px;gap:8px;width:max-content;max-width:calc(100% - 28px - var(--safe-left) - var(--safe-right));border-radius:9px}
.touch-device #toast .icon{width:18px;height:18px}.touch-device #toast strong{font-size:10px;letter-spacing:.7px}.touch-device #toast span{font-size:11px;line-height:1.4}
.touch-device .action-controls{grid-template-columns:60px 68px;grid-template-rows:54px 66px;gap:8px;width:136px;right:max(12px,var(--safe-right));bottom:calc(12px + var(--safe-bottom))}
.touch-device .action-controls .action-button{width:58px!important;height:58px!important;min-height:58px;background:#173c33b8;box-shadow:inset 0 0 0 3px #e7dfb60a;border-color:#f1d29a88}
.touch-device .action-controls .dash-button,.touch-device .action-controls .guard-button{width:52px!important;height:52px!important;min-height:52px}
.touch-device .action-controls .jump-button{width:68px!important;height:68px!important;min-height:68px;background:#997e45b8}
.touch-device .action-controls .action-button .icon{width:23px;height:23px}
.touch-device .action-controls .action-button span{font-size:8px}
.touch-device .joystick-wrap{left:max(16px,var(--safe-left));bottom:calc(18px + var(--safe-bottom))}
.touch-device #joystick{width:100px;height:100px;background:radial-gradient(circle,#e8edc608 36%,#17372f66 39%,#102e2b9c 68%,#d4dab760 70%)}
.touch-device .stick-nub{left:31px;top:31px;width:38px;height:38px}.touch-device .stick-arrow{top:31px;font-size:28px}.touch-device .stick-dot{left:47px}
.touch-device #kka-root .mobile-pause-menu{display:grid;grid-template-columns:1fr 1fr;gap:8px;width:min(480px,100%);padding:18px;max-height:calc(100dvh - 20px - var(--safe-top) - var(--safe-bottom));overflow-y:auto}
.touch-device .mobile-pause-menu>.k-eyebrow,.touch-device .mobile-pause-menu>h2,.touch-device .mobile-pause-menu>[data-act="resume"],.touch-device .mobile-menu-learning{grid-column:1/-1}
.touch-device #kka-root .mobile-pause-menu>h2{margin:4px 0 10px;font-size:26px}.touch-device .mobile-pause-menu>p{display:none}
.touch-device #kka-root .mobile-pause-menu button{width:100%;min-height:44px;margin:0!important;padding:10px;font-size:12px;border:1px solid #d6c79755;border-radius:8px;background:#25483c;color:#f5e4bd}
.touch-device #kka-root .mobile-pause-menu [data-act="resume"]{background:#ddc38d;color:#17382d}
.touch-device .mobile-menu-learning{display:flex;gap:8px}.touch-device .mobile-menu-learning>*{flex:1;min-width:0}
.touch-device .mobile-pause-menu [data-act="game-fullscreen"] svg{display:inline-block;vertical-align:middle;width:16px;height:16px;margin-right:5px}
@media(orientation:landscape) and (max-height:500px){
  .touch-device.kka-mode #boss-bar{top:calc(62px + var(--safe-top));left:50%;width:clamp(130px,24vw,250px)}
  .touch-device.kka-mode #toast{top:calc(120px + var(--safe-top));max-width:55vw}
}
