/* Phone enclosure follows the bevelled HP Tetris handheld, with WhiteStone branding. */
.handheld-shell,.screen-rim{display:contents}
.handheld-header,.screen-power,.handheld-footer,.touch-select{display:none}
.handheld-menu-buttons{pointer-events:none}
.handheld-menu-buttons button{pointer-events:auto}
@media(max-width:1024px){
  body.has-touch #arcade{padding:4px 2px;background:radial-gradient(ellipse at 70% 0,#263e62,#081327 75%)}
  body.has-touch .handheld-shell{display:flex;flex-direction:column;position:relative;width:min(100%,460px);height:min(760px,calc(100dvh - 8px));padding:12px 4px 14px;border:1px solid #f6f7ff;border-radius:24px 24px 62px 24px;background:linear-gradient(145deg,#f0f1f4,#cbd0d9 78%);box-shadow:inset 2px 3px #fff,inset -3px -6px #a1a8b6,0 12px 35px #0006;color:#243549}
  body.has-touch .handheld-header{display:flex;align-items:center;gap:10px;flex:none;height:45px;margin:0 6px 10px}
  .handheld-header img{width:56px;height:46px;object-fit:contain}
  .handheld-header strong{display:block;font:bold italic 25px/1.1 Arial,sans-serif;letter-spacing:-1px;color:#21384c}
  .handheld-header span{display:block;font:600 6px/1.8 Arial,sans-serif;letter-spacing:1.3px;margin-top:5px}
  /* Slim sidewalls give the LCD almost the phone's full width, at its native 4:3. */
  body.has-touch .screen-rim{--rim-top:22px;--rim-side:4px;--rim-bottom:10px;display:block;position:relative;flex:none;container-type:inline-size;padding:var(--rim-top) var(--rim-side) var(--rim-bottom);background:linear-gradient(135deg,#38465c,#253247);border:1px solid #98a0af;border-radius:11px 11px 25px 11px;box-shadow:inset 2px 3px 6px #152133aa,0 1px #fff}
  body.has-touch .screen-power{display:flex;align-items:center;gap:4px;position:absolute;top:9px;left:11px;right:11px;font:500 6px/1 Arial,sans-serif;letter-spacing:1px;color:#c5cdd4}
  .screen-power i{width:5px;height:5px;border-radius:50%;background:#a5e798;box-shadow:0 0 5px #a1ff85}
  .screen-power span{margin-left:auto;font-size:5px;letter-spacing:.7px}
  body.has-touch #arcade .handheld-shell .game-frame{width:100%!important;height:auto!important;aspect-ratio:4/3;transform:none!important;box-shadow:0 0 0 2px #0d1729;border-radius:2px;flex:none}
  body.has-touch .touch-controls{display:block;position:relative;inset:auto;width:100%;min-height:195px;max-height:none;flex:1;z-index:25}
  body.has-touch .dpad{left:7px;top:33px;bottom:auto;grid-template-columns:repeat(3,42px);grid-template-rows:repeat(3,42px);filter:drop-shadow(0 3px 2px #0004)}
  body.has-touch .dpad button,body.has-touch .dpad>span{border:0;background:#303947;color:#cbd2dc;font:21px Arial,sans-serif;box-shadow:inset 2px 2px #ffffff19,inset -2px -2px #0005}
  body.has-touch .dpad>span{position:relative;box-shadow:none}
  body.has-touch .dpad>span:after{content:'';width:18px;height:18px;border-radius:50%;background:#202c3d;box-shadow:inset 1px 2px #111b2c}
  body.has-touch .ab-buttons{right:2px;top:60px;bottom:auto;gap:15px;padding:7px;border:1px solid #eef2f6;border-radius:55px;background:linear-gradient(145deg,#a5aebb,#d7dce4);box-shadow:inset 1px 2px 3px #75829555;transform:rotate(-15deg)}
  body.has-touch .ab-buttons button{width:61px;height:61px;border:2px solid #a1a7b4;background:linear-gradient(#a95070,#873d5e);color:#f3eaf0;font:bold 26px Arial,sans-serif;box-shadow:inset 1px 2px #c87a94,inset -2px -3px #66324c,0 3px 3px #59607077}
  body.has-touch .ab-buttons button>small{font:600 7px Arial,sans-serif;letter-spacing:.4px;top:calc(100% + 17px);color:#45526a;transform:translateX(-50%) rotate(15deg)}
  body.has-touch .handheld-menu-buttons{position:absolute;bottom:13px;left:50%;transform:translateX(-50%);display:flex;gap:18px}
  body.has-touch .touch-start,body.has-touch .touch-select{display:block;position:static;transform:none;min-width:68px;min-height:44px;margin:0;border:1px solid #b7bfca;border-radius:7px;background:linear-gradient(#d8dde5,#c8ced9);color:#3c4c64;box-shadow:inset 1px 2px #f6f7fb,0 2px #a3acb9;padding:10px 8px;font:600 8px Arial,sans-serif;letter-spacing:1px}
  body.has-touch .touch-controls button.is-pressed{background:#aab4c2;box-shadow:inset 1px 2px 4px #5a6b7f88;transform:translateY(2px)}
  body.has-touch .ab-buttons button.is-pressed{background:#78364f;color:white}
  body.has-touch .handheld-footer{display:flex;align-items:center;justify-content:space-between;flex:none;min-height:38px;margin:0 5px;font:600 6px Arial,sans-serif;letter-spacing:1px;color:#5c6c7f}
  .handheld-speaker{display:flex;gap:5px;transform:rotate(-20deg);margin-right:12px}
  .handheld-speaker i{width:3px;height:26px;border-radius:3px;background:#98a2b1;box-shadow:inset 1px 1px #6a788b,1px 1px #e9edf1}
  /* Menus use the same 4:3 screen as play. The physical D-pad/A/B operates them. */
  body.has-touch .handheld-shell .title-screen .brand-title{top:2%;height:23%}
  body.has-touch .handheld-shell .title-screen .brand-title img{width:20cqw;height:17cqw}
  body.has-touch .handheld-shell .title-hero{top:26%;height:34%}
  body.has-touch .handheld-shell .title-menu{top:62%;gap:.9cqw}
  body.has-touch .handheld-shell .title-menu .start-button{min-height:0;font-size:2.5cqw;padding:.25cqw}
  body.has-touch .handheld-shell .route-select{min-height:0;gap:2cqw}
  body.has-touch .handheld-shell .route-select button{min-width:0;min-height:0;font-size:1.4cqw;padding:.4cqw 1cqw}
  body.has-touch .handheld-shell #route-choice{min-width:29cqw;max-width:65cqw;font-size:1.4cqw}
  body.has-touch .handheld-shell .title-menu>.text-button{min-height:0;font-size:1.2cqw;padding:.3cqw}
  body.has-touch .handheld-shell .title-options{display:flex;gap:3cqw}
  body.has-touch .handheld-shell .title-options button{min-height:0;min-width:0;font-size:1.1cqw;padding:.3cqw}
  body.has-touch .handheld-shell .title-footer{bottom:3.5%;font-size:.76cqw;gap:1.2cqw}
  body.has-touch .handheld-shell .game-utilities button{min-width:0;min-height:0;width:3.8cqw;height:4cqw;font-size:2.1cqw}
  body.has-touch .handheld-shell .result-brand{top:11%;font-size:1.8cqw}
  body.has-touch .handheld-shell .result-copy{top:22%}
  body.has-touch .handheld-shell .result-copy>p{font-size:1cqw;line-height:1.5;margin:0 0 1.2cqw}
  body.has-touch .handheld-shell .result-copy h2{font-size:4cqw;line-height:1.5;margin-bottom:1cqw}
  body.has-touch .handheld-shell .score-row{font-size:1.4cqw;padding:.8cqw}
  body.has-touch .handheld-shell .result-copy .start-button,body.has-touch .handheld-shell .result-copy .text-button{min-height:0;font-size:1.5cqw;padding:.5cqw;line-height:1.4;margin:.4cqw auto}
  body.has-touch .handheld-shell .scores-screen{padding:4cqw 7cqw}
  body.has-touch .handheld-shell .scores-screen h2{margin-top:0;font-size:3cqw}
  body.has-touch .handheld-shell .scores-table{font-size:1.35cqw}
  body.has-touch .handheld-shell .scores-table td{padding:.55cqw 0}
  body.has-touch .handheld-shell .scores-actions button{min-height:0;font-size:1.2cqw;padding:.7cqw}
  body.has-touch .handheld-shell #score-form{margin:0;padding:.6cqw 0;font-size:1cqw}
  body.has-touch .handheld-shell #score-form label{font-size:1cqw}
  body.has-touch .handheld-shell #score-form input{min-height:0;font-size:2cqw;width:13cqw}
  body.has-touch .handheld-shell #score-form button{min-height:0;font-size:1cqw}
  body.has-touch .handheld-shell .portfolio-controls button{min-height:0;font-size:1.1cqw;padding:.7cqw}
  body.has-touch .screen-rim dialog[open]{position:absolute;inset:var(--rim-top) var(--rim-side) var(--rim-bottom);width:auto!important;max-height:none;height:auto;margin:0;padding:14px 11px;border:2px solid #80b394;box-shadow:none;z-index:60;overflow:auto;overscroll-behavior:contain}
  body.has-touch .screen-rim dialog h2{font-size:10px;line-height:1.5;margin:0 20px 10px 0}
  body.has-touch .screen-rim dialog>p:first-of-type{font-size:5px;margin:0 22px 8px 0}
  body.has-touch .screen-rim .help-copy{font-size:6px;line-height:1.8;margin:8px 0}
  body.has-touch .screen-rim .help-lines{gap:8px;margin:10px 0}
  body.has-touch .screen-rim .help-lines p{font-size:6px;line-height:1.5}
  body.has-touch .screen-rim dialog .start-button{font-size:8px;padding:7px}
  body.has-touch .screen-rim .level-list{grid-template-columns:1fr;gap:7px}
  body.has-touch .screen-rim .level-card{min-height:48px;padding:8px;gap:8px}
  body.has-touch .screen-rim .level-card>b{font-size:12px}
  body.has-touch .screen-rim .level-card strong{font-size:6px}
  body.has-touch .screen-rim .level-card small{font-size:4px;margin-top:3px}
}
@media(max-width:1024px) and (max-height:670px) and (orientation:portrait){
  body.has-touch .handheld-shell{padding:10px 4px 12px}
  body.has-touch .handheld-header{height:39px;margin-bottom:8px}
  .handheld-header img{height:38px;width:46px}
  .handheld-header strong{font-size:22px}
  body.has-touch .touch-controls{min-height:175px}
  body.has-touch .dpad{top:20px;grid-template-columns:repeat(3,38px);grid-template-rows:repeat(3,38px)}
  body.has-touch .ab-buttons{top:34px;gap:10px}
  body.has-touch .ab-buttons button{width:52px;height:52px}
  body.has-touch .handheld-menu-buttons{bottom:0}
  body.has-touch .handheld-footer{min-height:28px}
}
@media(max-width:1024px) and (max-height:550px) and (orientation:landscape){
  body.has-touch #arcade{padding:6px max(6px,env(safe-area-inset-left)) 6px max(6px,env(safe-area-inset-right))}
  body.has-touch .handheld-shell{display:block;width:100%;height:calc(100dvh - 12px);padding:0;border-radius:19px 19px 44px 19px}
  body.has-touch .handheld-header{position:absolute;left:16px;top:13px;height:34px;margin:0;gap:6px}
  .handheld-header img{width:36px;height:31px}
  .handheld-header strong{font-size:18px}
  .handheld-header span{font-size:4px;letter-spacing:.6px}
  body.has-touch .screen-rim{--rim-top:18px;--rim-side:5px;--rim-bottom:8px;position:absolute;width:min(calc((100dvh - 48px)*4/3),calc(100% - 276px));top:8px;left:50%;transform:translateX(-50%)}
  body.has-touch .touch-controls{position:absolute;inset:0;min-height:0;max-height:none;pointer-events:none}
  body.has-touch .dpad{top:auto;bottom:70px;left:15px;grid-template-columns:repeat(3,38px);grid-template-rows:repeat(3,38px)}
  body.has-touch .ab-buttons{top:auto;bottom:101px;right:13px;gap:8px;padding:5px}
  body.has-touch .ab-buttons button{width:48px;height:48px}
  body.has-touch .handheld-menu-buttons{left:17px;right:17px;bottom:17px;transform:none;justify-content:space-between}
  body.has-touch .handheld-footer{position:absolute;top:61px;bottom:auto;left:16px;transform:none;min-height:14px;white-space:nowrap;font-size:5px}
  .handheld-speaker{display:none}
}
@media(max-width:760px) and (max-height:550px) and (orientation:landscape){
  /* Shorter phones still have a clear sidewall between branding and the LCD. */
  body.has-touch .handheld-header{left:13px;gap:4px}
  .handheld-header img{width:28px;height:27px}
  .handheld-header strong{font-size:14px}
  .handheld-header span{font-size:3.5px;letter-spacing:.3px}
}
