/* Balance Lab integration: preserve the original app logic and one-screen layout. */
html,body{height:100%;overflow:hidden}
#app{height:calc(100vh - 34px);height:calc(100dvh - 34px);min-height:0}
.site-back{display:inline-flex;align-items:center;gap:3px;padding:6px 8px;border-radius:10px;color:#53648c;text-decoration:none;font-weight:800;font-size:12px;white-space:nowrap;border:1px solid #dfe5f1;background:#ffffffcc}
.site-back:hover,.site-back:focus-visible{color:#5549ce;background:white;border-color:#9b91eb}
.site-back:focus-visible{outline:3px solid #7565e8;outline-offset:2px}
.balance-footer{box-sizing:border-box;width:100%;height:34px;margin:0;padding:5px 15px;border-top:1px solid #e1e7f2;background:#f3f6fb;color:#6b758f;font:600 10px/1.25 ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;display:flex;align-items:center;justify-content:space-between;flex-wrap:nowrap;gap:12px}
.balance-footer a{color:#566589;text-decoration:none}
.balance-footer a:hover,.balance-footer a:focus-visible{color:#5045c2;text-decoration:underline;text-underline-offset:2px}
.balance-footer .chemisode-global-footer__links{display:flex;gap:clamp(6px,1vw,12px);align-items:center;flex-wrap:nowrap}
.balance-footer .chemisode-global-footer__meta{white-space:nowrap;font-size:9px}
.mobile-site-links{display:none}
@media(max-width:1050px){.balance-footer .chemisode-global-footer__brand{display:none}.balance-footer{justify-content:center}}
@media(max-width:740px){
  .topbar{padding-left:10px;padding-right:10px;gap:7px}
  .brand-wrap{gap:8px}
  .site-back{padding:6px 9px}
  .site-back span{display:none}
  .brand{font-size:clamp(15px,4.5vw,19px);gap:6px;letter-spacing:-.5px}
  .brand span small{display:none}
  .brand-mark{width:29px;height:29px}
  .header-tag{display:none}
  .balance-footer .desktop-site-links{display:none}
  .mobile-site-links{display:flex;align-items:center;gap:14px}
  .balance-footer{justify-content:space-between;padding:5px 12px;gap:8px}
  .balance-footer .chemisode-global-footer__meta{font-size:9px}
  .site-info-menu{position:relative}
  .site-info-menu summary{list-style:none;cursor:pointer;white-space:nowrap;color:#5045c2}
  .site-info-menu summary::-webkit-details-marker{display:none}
  .site-info-menu summary::after{content:' ▴'}
  .site-info-menu nav{position:absolute;z-index:25;bottom:calc(100% + 7px);right:-10px;display:flex;flex-direction:column;min-width:190px;padding:7px;background:#fff;border:1px solid #dce2ee;border-radius:12px;box-shadow:0 10px 25px #23365432}
  .site-info-menu nav a{display:block;padding:8px 10px;font-size:12px;border-radius:6px}
  .site-info-menu nav a:hover,.site-info-menu nav a:focus-visible{background:#f1f0ff}
}
@media(max-width:390px){.balance-footer{padding:4px 8px}.balance-footer .chemisode-global-footer__meta{font-size:8px}.mobile-site-links{gap:7px}.site-back{padding:4px 7px}.topbar{min-height:54px;height:54px}.top-actions{gap:5px}.top-actions .icon-button{width:34px;height:34px}}
@media(max-height:520px){.topbar{height:46px;min-height:46px}.balance-footer{height:26px;padding-top:2px;padding-bottom:2px}#app{height:calc(100vh - 26px);height:calc(100dvh - 26px)}}
@media print{.balance-footer{display:none!important}#app{height:auto;overflow:visible}}

/* At phone widths use readable, full-width level rows rather than five narrow columns. */
@media(max-width:620px){
  .home{width:calc(100% - 32px);justify-content:center;gap:8px;padding:8px 0;overflow:hidden}
  .hero{min-height:0;flex:none}
  .hero h1{font-size:clamp(22px,6vw,29px);letter-spacing:-1px;margin:4px 0 7px}
  .hero p{font-size:11px;line-height:1.4}
  .overline{font-size:9px;letter-spacing:1.1px}
  .section-header{min-height:18px;align-items:center}
  .level-grid{grid-template-columns:minmax(0,1fr);gap:6px}
  .level-card{flex-direction:row;align-items:center;gap:10px;min-height:57px;padding:7px 10px;border-radius:13px}
  .level-card:before{width:60px;height:60px;right:-35px;top:-32px}
  .level-card .level-number{flex:none;width:36px;height:36px;font-size:18px;border-radius:11px}
  .level-card strong{flex:1;font-size:13px;line-height:1.2;max-width:none}
  .level-card .card-description,.level-card .level-progress{display:none}
  .level-card .level-bottom{width:auto;flex:none;margin:0;font-size:11px;white-space:nowrap}
  .home-bottom{display:none}
}
@media(max-width:390px){
  .hero h1{font-size:23px}
  .hero p{display:none}
  .level-card{min-height:52px;padding:5px 8px}
  .level-card strong{font-size:12px}
  .level-card .level-number{width:32px;height:32px;font-size:16px}
  .level-card .level-bottom{font-size:10px}
  .game-wrap .status-bar .status-left:not(.is-good):not(.is-bad):not(.is-hint){display:none}
  .game-wrap .status-bar .action-group{width:100%;justify-content:space-between}
  .game-wrap .status-bar .action-group .btn{flex:1;min-width:0;padding-inline:4px}
  .game-wrap .status-bar:has(.status-left.is-good,.status-left.is-bad,.status-left.is-hint){flex-wrap:wrap}
  .game-wrap .status-bar:has(.status-left.is-good,.status-left.is-bad,.status-left.is-hint) .status-left{flex:1 1 100%}
}
/* Short landscape screens: give the workspace priority; the page still does not scroll. */
@media(max-height:520px) and (min-width:621px){
  .game-wrap{padding:2px 0 3px;gap:3px}
  .stage-head{min-height:23px}
  .stage{gap:3px}
  .prompt-card:not(.is-paragraph){min-height:59px;padding:4px 10px;gap:1px;border-radius:13px}
  .prompt-card .formula-term{font-size:24px}
  .status-bar{min-height:40px;padding:3px 8px}
  .status-bar .status-title{font-size:11px}
  .status-bar .status-sub{display:none}
  .status-bar .btn{padding:7px 9px;font-size:10px}
  .work-area{padding:7px;border-radius:12px}
  .decision{padding:7px;gap:5px}
  .decision h2{font-size:18px}
  .choice{min-height:46px;padding:5px}
  .unrevealed h3{margin:2px 0}
}
@media(max-width:390px) and (max-height:640px){
  .level1-layout{grid-template-rows:minmax(114px,.8fr) minmax(0,1fr);gap:5px}
  .level1-layout .decision{padding:5px 6px;gap:4px}
  .level1-layout .decision .panel-heading,.level1-layout .decision p{display:none}
  .level1-layout .decision h2{font-size:18px}
  .level1-layout .choice{min-height:54px;padding:6px 5px}
  .level1-layout .preview-panel{padding:5px;gap:4px}
  .level1-layout .preview-panel .big-icon,.level1-layout .unrevealed h3{display:none}
  .level1-layout .preview-panel p{font-size:10px;line-height:1.2}
  .level1-layout .unrevealed{gap:5px}
}
