/* responsive.css - tablet, phone, landscape and touch layouts. Keep this file last. */

/* ---------- all sizes ---------- */
.view-switch{display:none}
.dpad{display:none}
.app-body{position:relative}
.out-panel{position:relative}
.game-cv,.cam-cv{height:auto}
.btmbar{padding-bottom:calc(4px + env(safe-area-inset-bottom,0px))}
body{overscroll-behavior:none}
@supports (height:100dvh){body{height:100dvh}}

/* ---------- tablets and small windows: panels float over the editor ---------- */
@media(max-width:900px){
  .main{grid-template-columns:1fr;grid-template-rows:1fr 1fr}
  .editor-panel{border-right:none;border-bottom:1px solid var(--border)}
  .theme-grid{grid-template-columns:1fr}
  .side-panel{position:absolute;left:54px;top:0;bottom:0;z-index:500}
  .side-panel.open{width:260px;box-shadow:6px 0 20px rgba(0,0,0,.18)}
  .side-inner{width:260px}
  .side-panel.open.wide,.side-panel.open.wide .side-inner{width:min(340px,calc(100vw - 70px))}
}

/* ---------- phones in portrait: bottom dock, bottom sheet, Code / Output switch ---------- */
@media(max-width:600px) and (orientation:portrait){
  .topbar{height:56px;padding:0 10px;gap:8px}
  .logo img{height:50px}

  .app-body{flex-direction:column}
  .activity-bar{order:3;width:100%;height:54px;flex-direction:row;border-right:none;border-top:1px solid var(--border);padding:5px 8px;gap:4px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
  .activity-bar::-webkit-scrollbar{display:none}
  .act-spacer{display:none}
  .act-btn{flex:0 0 auto;width:46px;height:44px}
  .act-btn.active::before{left:10px;right:10px;top:0;bottom:auto;width:auto;height:3px;border-radius:0 0 3px 3px}

  .side-panel{left:0;right:0;top:auto;bottom:54px;width:100%;height:0;border-right:none;transition:height .22s ease}
  .side-panel.open,.side-panel.open.wide{width:100%;height:64%;border-top:3px solid var(--brand-dk);box-shadow:0 -10px 28px rgba(0,0,0,.22)}
  .side-inner,.side-panel.open.wide .side-inner{width:100%}

  .view-switch{display:flex;gap:3px;margin:8px 10px;padding:3px;flex-shrink:0;background:var(--panel2);border:1px solid var(--border2);border-radius:99px}
  .vs-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;height:34px;border:0;border-radius:99px;background:transparent;color:var(--text2);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;transition:all .15s}
  .vs-btn.active{background:var(--brand-dk);color:#FFF;box-shadow:0 2px 6px rgba(0,0,0,.2)}

  .main{display:flex;flex-direction:column}
  .editor-panel,.out-panel{flex:1;min-height:0;border:none}
  .main:not(.show-out) .out-panel{display:none}
  .main.show-out .editor-panel{display:none}

  .pbtn.run-pbtn{padding:8px 18px;font-size:13px}
  .btm-l span:nth-child(n+3){display:none}
  .studio-label{display:none}
  .btm-back{padding:5px 12px}
}

/* ---------- short landscape (phones on their side): editor and output side by side ---------- */
@media(max-height:520px) and (orientation:landscape){
  .topbar{height:48px}
  .logo img{height:42px}
  .main{grid-template-columns:1fr 1fr;grid-template-rows:1fr}
  .editor-panel{border-right:1px solid var(--border);border-bottom:none}
  .tab-bar{height:32px}
  .tab{height:32px}
  .activity-bar{width:46px}
  .act-btn{width:38px;height:38px}
  .side-panel{left:46px}
}

/* ---------- touch screens ---------- */
@media(pointer:coarse){
  .act-btn[data-tip]:hover::after{display:none}
  .tc{opacity:.55;width:22px;height:22px}
  .pbtn{min-height:34px}
  .inline-inp,.modal input,.modal textarea,.side-action input{font-size:16px}

  /* on-screen game pad (shown only while a game is running) */
  .dpad:not([hidden]){display:flex;position:absolute;left:0;right:0;bottom:12px;z-index:20;padding:0 14px;justify-content:space-between;align-items:flex-end;pointer-events:none}
  .dp-arrows{display:grid;grid-template-columns:repeat(3,54px);grid-template-rows:repeat(2,54px);gap:6px}
  .dp-up{grid-area:1/2}.dp-left{grid-area:2/1}.dp-down{grid-area:2/2}.dp-right{grid-area:2/3}
  .dpad button{pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;background:rgba(30,30,30,.55);color:#FFF;border:2px solid rgba(255,255,255,.65);border-radius:16px;font-size:20px;line-height:1;backdrop-filter:blur(4px)}
  .dpad button:active{background:var(--brand-dk)}
  .dp-a{width:70px;height:70px;border-radius:50%!important;font-size:22px!important;font-weight:700;background:rgba(109,165,26,.85)!important}
}

@media(prefers-reduced-motion:reduce){*{animation:none !important;transition:none !important}}