/* The app owns exactly its viewport, also when that viewport is an iframe. */
html{height:100%;overflow:hidden}
body,body.playing,body:not(.playing){margin:0;min-height:0;height:100%;overflow:hidden;overscroll-behavior:none}
body .app,body.playing .app,body:not(.playing) .app{display:flex;flex-direction:column;width:100%;height:100dvh;min-height:0;max-width:none;padding:0;margin:0}
body .topbar{flex:none;height:58px;margin:0;padding:4px 24px}
body main,body .stage-wrap,body.playing main,body.playing .stage-wrap{display:flex;flex:1;min-height:0;width:100%;height:auto;padding:0;border:0;border-radius:0;box-shadow:none}
body .stage-wrap{flex-direction:column}
body .stage,body.playing .stage,body:not(.playing) .stage{flex:1;width:100%;height:100%;min-height:0;aspect-ratio:auto;border:0;border-radius:0;padding:0}
body #game,body.playing .stage #game{position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto}
body .stage-bottom,body .below-stage,body .app>footer{display:none}
body.playing .topbar{display:none}
body .scene-caption{bottom:14px}
body:not(.playing) .menu{display:flex;flex-direction:column;top:5%;bottom:4%;justify-content:center}
body .menu .title-lockup{margin:0;width:100%;max-height:26dvh}
body .menu .logo{max-height:26dvh;object-fit:contain}
body .menu>.eyebrow{margin:0 0 8px}
body .menu .menu-tagline{margin:8px 0 14px}
body .menu>.play-btn{flex:none;height:52px;min-height:44px;margin:0 0 10px}
body .menu-secondary{gap:7px}
body .menu-secondary button{height:46px;min-height:44px}
body .menu-links{margin-top:4px;gap:8px}
body .menu .how-link,body .menu-kit-link{min-height:44px}

/* Dialogs keep their actions visible and page whole cards when space is tight. */
body .modal-backdrop,body.playing .modal-backdrop,body:not(.playing) .modal-backdrop{padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));align-items:center}
body .modal.fitted-panel,body.playing .modal.fitted-panel,body:not(.playing) .modal.fitted-panel{display:flex;flex-direction:column;gap:10px;width:460px;max-width:100%;max-height:100%;padding:20px 24px;overflow:visible}
.fitted-panel [hidden]{display:none!important}
.panel-head,.panel-foot,.panel-nav{flex:none;min-width:0}
.panel-head:empty,.panel-foot:empty{display:none}
.panel-body{flex:none;min-height:0;display:flex;flex-direction:column;gap:8px;outline:none}
.panel-block{display:flow-root;flex:none;min-width:0}
body .modal.fitted-panel .panel-block>*{margin-top:0!important;margin-bottom:0!important}
body .modal.fitted-panel h2{font-size:28px;margin:4px 22px 0;line-height:1.15}
body .modal.fitted-panel .eyebrow{font-size:9px;margin:0;line-height:1.4}
body .modal.fitted-panel p{font-size:13px;line-height:1.5}
body .modal.fitted-panel .closet-tabs{margin:12px 0 0}
body .modal.fitted-panel .play-btn{width:100%;height:48px;min-height:44px;margin:0;font-size:12px}
body .modal.fitted-panel .secondary-btn{min-height:44px;margin:0;font-size:11px;padding:7px}
.panel-foot{display:flex;flex-wrap:wrap;gap:6px}
.panel-foot>.play-btn{flex:1}
.panel-foot>.result-actions{flex-basis:100%}
.panel-nav{display:flex;align-items:center;justify-content:space-between;gap:8px;border-top:1px solid #edc78d26;padding-top:4px}
.panel-nav>span{color:#cbb89c;font-size:12px;white-space:nowrap}
body .panel-nav button{min-width:85px}
body .modal.fitted-panel .result-actions{display:grid;grid-template-columns:1fr 1fr 1.2fr;gap:6px;margin:0}
body .modal.fitted-panel .share-score{width:auto;line-height:1.3;letter-spacing:0}
body .modal.fitted-panel .characters{margin:0;gap:10px}
body .modal.fitted-panel .character-card{min-height:150px;padding:12px 7px;gap:7px}
body .modal.fitted-panel .character-card b{font-size:12px}
body .modal.fitted-panel .character-card small{font-size:10px}
body .modal.fitted-panel .character-kit-link{font-size:11px}
body .modal.fitted-panel .wardrobe-preview{min-height:0;padding:0;gap:10px}
body .modal.fitted-panel .wardrobe-preview .toy-portrait{width:90px!important;height:90px!important}
body .modal.fitted-panel .wardrobe-preview p{margin:4px 0!important}
body .modal.fitted-panel .wardrobe-grid{grid-template-columns:repeat(5,minmax(0,1fr));gap:5px}
body .modal.fitted-panel .wardrobe-card{min-height:64px;padding:6px 2px;justify-content:center}
body .modal.fitted-panel .wardrobe-card img{width:38px;height:30px}
body .modal.fitted-panel .wardrobe-card b{display:none}
body .modal.fitted-panel .wardrobe-card small{font-size:8px;letter-spacing:0}
body .modal.fitted-panel .wardrobe-note,body .modal.fitted-panel .upgrade-note{font-size:11px!important;line-height:1.4!important}
body .modal.fitted-panel .wallet{margin:0;padding:6px 10px;font-size:12px}
body .modal.fitted-panel .upgrade-card{padding:12px;margin:0}
body .modal.fitted-panel .upgrade-card p{font-size:12px;margin:7px 0}
body .modal.fitted-panel .buy-btn{min-height:44px;height:auto;font-size:11px;padding:8px;line-height:1.4}
body .modal.fitted-panel .quick-upgrades{padding:7px}
body .modal.fitted-panel .scores-table{width:100%;table-layout:fixed;font-size:13px}
body .modal.fitted-panel .scores-table th{font-size:9px;padding:0 6px 3px}
body .modal.fitted-panel .scores-table td{padding:6px}
.panel-block:has(.scores-table)+.panel-block:has(.scores-table) thead{visibility:collapse}
body .modal.fitted-panel .tutorial-demo{float:left;width:70px;height:62px;margin:0 4px 0 0}
body .modal.fitted-panel .tutorial-art{width:60px;height:60px;margin:0}
body .modal.fitted-panel .demo-arrow{right:0;top:12px;font-size:25px}
body .modal.fitted-panel .demo-stick{width:26px;height:26px;left:0;bottom:0}
body .modal.fitted-panel .demo-stick i{inset:6px}
body .modal.fitted-panel .tutorial-head{margin:0 0 6px}
body .modal.fitted-panel .tutorial-head .eyebrow{padding-right:6px}
body .modal.fitted-panel .tutorial-skip{min-height:44px}
body .modal.fitted-panel .tutorial-note{font-size:12px;padding:10px;line-height:1.4}
body .modal.fitted-panel .tutorial-dots{display:none}
body .modal.fitted-panel .tutorial-back{flex:none}
body .modal.fitted-panel .progression-cards{margin:0}
body .modal.fitted-panel .progression-cards>div{padding:10px}
body .modal.fitted-panel .progression-cards h3{font-size:15px}
body .modal.fitted-panel .progression-cards p{font-size:12px!important}
body .modal.fitted-panel .result-scores{padding:9px 0}
body .modal.fitted-panel .big-score{font-size:40px;margin:0}
body .modal.fitted-panel .personal-best strong{font-size:22px;margin-top:4px}
body .modal.fitted-panel .run-stats{row-gap:7px}
body .modal.fitted-panel .run-stats>div:last-child{padding-top:7px}
body .modal.fitted-panel .kit-card{padding:12px;gap:12px}
body .modal.fitted-panel .kit-card p{font-size:12px}
body .modal.fitted-panel .share-text{min-height:110px;resize:none}

@media(min-width:761px) and (pointer:fine){
  body.playing .stage #game,body.playing .stage:is(:fullscreen,:-webkit-full-screen) #game{top:86px;height:calc(100% - 86px);width:100%}
  body.playing .stage:is(:fullscreen,:-webkit-full-screen){padding:0;min-height:0;height:100%;width:100%}
}
@media(max-width:760px),(pointer:coarse){
  body:not(.playing) .topbar{padding:0;left:16px;right:16px;top:calc(env(safe-area-inset-top) + 10px);height:44px}
  body:not(.playing) .menu{top:calc(env(safe-area-inset-top) + 64px);bottom:calc(env(safe-area-inset-bottom) + 8px);left:50%;width:calc(100% - 32px);max-width:400px;justify-content:flex-start}
  body .menu .title-lockup{max-width:330px}
  body .menu .logo{max-height:22dvh}
  body .menu .menu-tagline{margin:5px 0}
  body .menu-vignette{display:block;flex:1;min-height:64px;margin:0 0 8px}
  body .menu .menu-secondary{grid-template-columns:1fr 1fr;gap:6px}
  body .menu .menu-secondary button,body .menu #character-btn{height:44px}
  body .menu #character-btn{grid-column:1/-1}
  body .menu .how-link{padding:8px 0}
  body .menu-kit-link{font-size:10px}
}
@media(max-height:650px){
  body .menu>.eyebrow{display:none}
  body .menu .logo{max-height:19dvh}
  body .menu .menu-tagline{margin:4px 0;font-size:12px}
  body .scene-caption{display:none}
  body .modal.fitted-panel,body.playing .modal.fitted-panel,body:not(.playing) .modal.fitted-panel{padding:14px 16px;gap:8px}
  body .modal.fitted-panel h2{font-size:24px}
}
@media(max-height:500px) and (min-width:560px){
  body .modal.fitted-panel,body.playing .modal.fitted-panel,body:not(.playing) .modal.fitted-panel{width:660px;padding:10px 18px;gap:6px}
  body .modal.fitted-panel .panel-head>.eyebrow{display:none}
  body .modal.fitted-panel h2{font-size:23px}
  body .modal.fitted-panel .closet-tabs{margin-top:6px}
  body .modal.fitted-panel .character-card{min-height:90px;display:grid;grid-template-columns:auto 1fr;padding:6px 10px;gap:3px 8px}
  body .modal.fitted-panel .character-comparison{grid-row:1/3;width:auto}
  body .modal.fitted-panel .character-card .toy-portrait{width:48px;height:48px}
  body .modal.fitted-panel .character-card img.real-toy{width:42px;height:53px}
  body .modal.fitted-panel .character-kit-link{min-height:38px}
  body .modal.fitted-panel .tutorial-demo{width:50px;height:40px}
  body .modal.fitted-panel .tutorial-art{width:40px;height:40px}
  body .modal.fitted-panel .tutorial-head{margin:0}
  body .modal.fitted-panel .kit-card img.kit-photo{width:64px;height:80px}
}
@media(max-height:500px) and (min-width:761px) and (pointer:fine){
  body .topbar{height:48px}
  body:not(.playing) .menu{top:10px;bottom:10px;width:40%;max-width:440px}
  body .menu .title-lockup,body .menu .logo{max-height:70px}
  body .menu .menu-secondary{display:grid;grid-template-columns:1fr 1fr}
  body .menu #character-btn{grid-column:1/-1}
  body .menu .menu-tagline{margin:2px 0 6px}
}
@media(max-height:500px) and (max-width:760px) and (orientation:landscape){
  body:not(.playing) .menu{left:18px;right:18px;transform:none;width:auto;max-width:none;justify-content:center;align-items:flex-end}
  body .menu>.play-btn,body .menu>.menu-secondary,body .menu>.menu-links{width:50%}
  body .menu .title-lockup{position:absolute;left:0;top:0;width:44%;max-height:85px}
  body .menu .logo{max-height:85px}
  body .menu .menu-tagline{display:none}
  body .menu-vignette{position:absolute;left:0;top:80px;bottom:0;width:46%;min-height:0}
  body .menu .menu-secondary .menu-icon{display:none}
}

/* Leaderboard: sign-up form, results card and board rows. */
.join-form{display:grid;gap:8px;text-align:left}
.join-form label{display:grid;gap:4px;font-size:11px;letter-spacing:.3px;color:#d9c6a6}
.join-form input:not([type=checkbox]){width:100%;height:42px;padding:0 12px;border:1px solid #9c7550;border-radius:8px;background:#2d201c;color:#fff1d2;font:inherit;font-size:16px;letter-spacing:0}
.join-form input::placeholder{color:transparent}
.join-form input:focus-visible,.join-form .join-check input:focus-visible{outline:3px solid #f5bc4d;outline-offset:2px}
.join-form .join-check{display:flex;align-items:flex-start;gap:10px;font-size:12px;line-height:1.4;letter-spacing:0}
.join-form .join-check input{flex:none;width:22px;height:22px;margin:0;accent-color:#f5b747}
.join-trap{position:absolute;left:-9999px;width:1px;height:1px;opacity:0;pointer-events:none}
.join-privacy{justify-self:start;font-size:11px;color:#c7b08b;text-underline-offset:3px}
.panel-status{min-height:0;margin:0;font-size:12px;line-height:1.4;color:#ffb8a0;text-align:center;flex-basis:100%}
.panel-status:empty{display:none}
body .modal.fitted-panel .panel-skip{width:auto;flex:0 0 36%}
.join-card{display:grid;gap:5px;padding:10px 12px;border:1px solid #edc78d55;border-radius:10px;background:#2d201c88;text-align:left}
.join-card b{font-size:13px;letter-spacing:.3px;color:#ffd98f}
.join-card p{margin:0;font-size:12px;line-height:1.45;color:#cfbca0}
.join-card .secondary-btn{margin-top:4px}
.board-status{margin:0;text-align:center;font-size:12px;letter-spacing:.3px;color:#f6c870}
.board-you{margin:0;text-align:center;font-size:13px;color:#ffd180}
.scores-table tr.me td{background:#f5b74724;color:#ffe3a6}
.board-you,.scores-table td:nth-child(2){overflow-wrap:anywhere}
/* Short screens: field names move into the fields, and in landscape the form uses two columns. */
@media (max-height:700px){
  .join-form{gap:6px}
  .join-form label:not(.join-check){font-size:0;gap:0}
  .join-form input:not([type=checkbox]){height:38px}
  .join-form input::placeholder{color:#a8977c}
  .join-form .join-check{font-size:11.5px;line-height:1.3}
  body .modal.fitted-panel .join-lead{font-size:12px}
}
@media (max-height:520px) and (orientation:landscape){
  body .modal.fitted-panel[data-panel=join]{width:min(640px,100%);padding:14px 20px}
  .join-form{grid-template-columns:1fr 1fr;grid-auto-flow:column;grid-template-rows:repeat(3,auto);column-gap:14px}
  .join-form .join-check:nth-of-type(1){grid-column:2;grid-row:1}
  .join-form .join-check:nth-of-type(2){grid-column:2;grid-row:2}
  .join-form .join-privacy{grid-column:2;grid-row:3}
  body .modal.fitted-panel[data-panel=join] .join-lead,body .modal.fitted-panel[data-panel=join] .eyebrow{display:none}
  body .modal.fitted-panel[data-panel=join] h2{font-size:20px;margin:0}
}
/* Very short landscape screens (about 320px tall): tighter dialogs so nothing is cut off. */
@media (max-height:340px){
  body .modal-backdrop,body.playing .modal-backdrop,body:not(.playing) .modal-backdrop{padding-top:6px;padding-bottom:6px}
  body .modal.fitted-panel,body.playing .modal.fitted-panel,body:not(.playing) .modal.fitted-panel{padding:10px 18px;gap:6px}
  .panel-foot{gap:4px}
  body .modal.fitted-panel .play-btn{height:40px;min-height:40px}
  body .modal.fitted-panel .secondary-btn{min-height:36px}
  body .modal.fitted-panel h2{font-size:22px;margin-top:0}
  .panel-nav{padding-top:2px}
}
