/* iPhone & Mobile Touch PWA stylesheet (activated only when html.mobile is set; TV 1920x1080 stays 100% untouched). */

html.mobile, html.mobile body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html.mobile #stage {
  position: fixed;
  inset: 0;
  width: 100% !important;
  height: 100dvh !important;
  transform: none !important;
  overflow: hidden;
}

html.mobile .bg {
  width: 100%;
  height: 46dvh;
  opacity: 0;
}
html.mobile .bg.on { opacity: .34; }
html.mobile .scrim, html.mobile [dir=rtl] .scrim {
  background: linear-gradient(180deg, rgba(20,19,24,.55) 0%, var(--surface) 44%, var(--surface) 100%);
}

/* ---------- Library View (Portrait & Landscape) ---------- */
html.mobile #library {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 76px);
}

html.mobile .top {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  height: auto;
  flex-wrap: wrap;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 12px) + 8px) calc(env(safe-area-inset-right, 0px) + 16px) 10px calc(env(safe-area-inset-left, 0px) + 16px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  backdrop-filter: blur(22px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

html.mobile .brand { font-size: 19px; gap: 9px; }
html.mobile .brand i { width: 32px; height: 32px; border-radius: 9px; }
html.mobile .brand i svg { width: 18px; height: 18px; }
html.mobile .status, html.mobile .hints, html.mobile .ibtn .tip { display: none !important; }
html.mobile .topTools { margin-inline-start: auto; gap: 6px; }
html.mobile .ibtn { width: 38px; height: 38px; border-radius: 19px; background: var(--sc-high); }
html.mobile .ibtn svg { width: 20px; height: 20px; }

html.mobile #tabs {
  order: 3;
  flex: 1 1 100%;
  width: 100%;
  gap: 6px;
  padding: 2px 0;
  margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

html.mobile .tab {
  height: 34px;
  padding: 0 14px !important;
  font-size: 14px !important;
  border-radius: 17px;
  background: color-mix(in srgb, var(--sc-high) 70%, transparent);
}
html.mobile .tab.sel {
  background: var(--primary);
  color: var(--on-primary);
}
html.mobile .tab.sel::before { display: none; }
html.mobile .tab.focus, html.mobile .btn.focus, html.mobile .card.focus .box, html.mobile .row.focus, html.mobile .ni.focus {
  outline: none;
  transform: none;
}

/* ---------- Hero Spotlight ---------- */
html.mobile .hero {
  position: relative;
  top: auto;
  inset-inline-start: auto;
  width: 100%;
  padding: 18px 18px 8px;
}
html.mobile .hero .sys { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
html.mobile .hero h1 { font-size: 30px; line-height: 35px; letter-spacing: -.4px; margin-top: 4px; }
html.mobile .hero .sub { font-size: 14px; min-height: 0; margin-top: 4px; }
html.mobile .chips { flex-wrap: wrap; gap: 6px; margin-top: 10px; }
html.mobile .chip { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; border-width: 1px; gap: 5px; }
html.mobile .chip svg { width: 14px; height: 14px; }
html.mobile .actions { flex-wrap: wrap; gap: 10px; margin-top: 14px; }
html.mobile .btn { height: 44px; padding-inline: 18px 20px; border-radius: 22px; font-size: 15px; gap: 8px; }
html.mobile .btn svg { width: 20px; height: 20px; }

html.mobile .message {
  position: relative;
  top: auto;
  inset-inline-start: auto;
  width: 100%;
  padding: 36px 20px;
}
html.mobile .message h1 { font-size: 26px; line-height: 32px; }
html.mobile .message p { font-size: 15px; line-height: 23px; margin-top: 10px; }

/* ---------- Shelves & Cards ---------- */
html.mobile .shelves {
  position: relative;
  top: auto;
  height: auto;
  overflow: visible;
  margin-top: 8px;
}
html.mobile .track { transform: none !important; display: flex; flex-direction: column; gap: 18px; }
html.mobile .shelf {
  height: auto;
  padding: 0;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}
html.mobile .shelf h2 {
  font-size: 17px;
  height: auto;
  padding: 0 18px 8px;
}
html.mobile .shelf h2 span { font-size: 13px; margin-inline-start: 6px; }
html.mobile .strip {
  transform: none !important;
  gap: 12px;
  padding: 4px 18px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
html.mobile .strip::-webkit-scrollbar { display: none; }
html.mobile .card { width: 136px; }
html.mobile .box { width: 136px; height: 188px; border-radius: 12px; }
html.mobile .card .t { font-size: 13px; margin-top: 6px !important; color: var(--on-surface); }
html.mobile .ph.styled { padding: 12px; }
html.mobile .ph.styled .phSys { font-size: 10px; padding: 3px 6px; }
html.mobile .ph.styled .phIcon svg { width: 42px; height: 42px; }
html.mobile .ph.styled .phTitle { font-size: 14px; line-height: 18px; }
html.mobile .box .fav, html.mobile .box .pin { width: 26px; height: 26px; top: 6px; }
html.mobile .box .fav svg, html.mobile .box .pin svg { width: 14px; height: 14px; }
html.mobile .box .dbdg { font-size: 11px; padding: 2px 7px; bottom: 6px; border-radius: 6px; }

/* ---------- iOS Add-to-Home-Screen Banner ---------- */
.mInstallBar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 8px) + 10px);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--sc-high) 92%, #000);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 12px 32px rgba(0,0,0,.55);
}
.mInstallBar img { border-radius: 9px; flex: none; }
.mInstallTxt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mInstallTxt b { font-size: 13px; font-weight: 600; color: var(--on-surface); }
.mInstallTxt span { font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.mInstallX {
  width: 28px; height: 28px; border-radius: 14px; border: 0;
  background: rgba(255,255,255,.1); color: var(--on-surface); font-size: 13px;
}

/* ---------- Detail Sheet ---------- */
html.mobile #detail {
  flex-direction: column;
  gap: 18px;
  padding: calc(env(safe-area-inset-top, 14px) + 16px) 18px calc(env(safe-area-inset-bottom, 16px) + 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
}
html.mobile .dLeft { width: 100%; display: flex; flex-direction: column; align-items: center; }
html.mobile .dCover { width: 180px; height: 244px; border-radius: 16px; }
html.mobile .shots { width: 100%; overflow-x: auto; justify-content: center; margin-top: 12px; gap: 10px; }
html.mobile .shot { width: 156px; height: 112px; border-radius: 10px; flex: none; }
html.mobile .shot i { font-size: 11px; padding: 3px 8px; }
html.mobile .dRight { width: 100%; }
html.mobile #detail .dSys { font-size: 13px; }
html.mobile #detail h2 { font-size: 26px; line-height: 31px; margin-top: 4px; }
html.mobile #detail .sub { font-size: 14px; margin-top: 4px; }
html.mobile .dStats { gap: 10px; margin-top: 14px; flex-wrap: wrap; }
html.mobile .dStat { padding: 10px 12px; border-radius: 12px; min-width: 100px; flex: 1; }
html.mobile .dStat b { font-size: 15px; }
html.mobile .dStat span { font-size: 11px; }
html.mobile #detail h3 { font-size: 14px; margin-top: 18px; }
html.mobile .saveRow { flex-direction: column; gap: 8px; margin-top: 8px; }
html.mobile .saveSlot { height: 58px; border-radius: 12px; padding: 6px 12px; font-size: 14px; }
html.mobile .saveSlot .thumb { width: 62px; height: 44px; border-radius: 6px; }

/* ---------- Search, Dialogs, Link, Loading, Pause ---------- */
html.mobile #search {
  left: 12px;
  right: 12px;
  top: calc(env(safe-area-inset-top, 12px) + 10px);
  width: auto;
  transform: none;
  padding: 14px 16px;
  border-radius: 18px;
  outline-width: 2px;
}
html.mobile #sInput { height: 38px; font-size: 17px; }
html.mobile #search .scount { font-size: 12px; margin-top: 8px; gap: 8px; flex-wrap: wrap; }
.mSearchBtn {
  height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--outline);
  background: transparent; color: var(--on-surface); font-size: 12px; font-weight: 500;
}
.mSearchBtn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

html.mobile #loading { padding: 24px; gap: 16px; }
html.mobile #loading .cov { width: 150px; height: 206px; border-radius: 14px; }
html.mobile #loading .l1 { font-size: 22px; text-align: center; }
html.mobile .prog { width: min(320px, 84vw); height: 6px; }
html.mobile #loading .l2 { font-size: 14px; }
html.mobile #loading .tip { font-size: 13px; padding: 10px 14px; border-radius: 10px; }

html.mobile #pause {
  width: min(340px, 88vw);
  padding: calc(env(safe-area-inset-top, 16px) + 16px) 18px calc(env(safe-area-inset-bottom, 16px) + 16px);
  overflow-y: auto;
}
html.mobile #pause .l { font-size: 12px; }
html.mobile #pause h2 { font-size: 22px; line-height: 26px; }
html.mobile #pause .meta { font-size: 12px; margin-bottom: 14px; }
html.mobile .pHead { font-size: 14px; padding: 10px 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
html.mobile .pi { min-height: 50px; padding: 8px 14px; border-radius: 14px; font-size: 15px; gap: 12px; margin-bottom: 4px; }
html.mobile .pi svg { width: 20px; height: 20px; }
html.mobile .pi.slot .thumb { width: 56px; height: 40px; border-radius: 6px; }

html.mobile #dialog .dlg, html.mobile #exit .dlg {
  width: min(380px, 92vw);
  padding: 22px 20px;
  border-radius: 22px;
}
html.mobile #dialog h2, html.mobile #exit h2 { font-size: 22px; line-height: 28px; }
html.mobile #dialog p, html.mobile #exit p { font-size: 14px; line-height: 21px; margin-top: 8px; }
html.mobile #dialog .actions, html.mobile #exit .actions { margin-top: 18px; }
html.mobile #dialog .lic div { font-size: 13px; padding: 8px 0; }

html.mobile #link {
  padding: calc(env(safe-area-inset-top, 16px) + 20px) 20px calc(env(safe-area-inset-bottom, 16px) + 20px);
  overflow-y: auto;
}
html.mobile #lkTitle { font-size: 26px !important; line-height: 32px !important; }
html.mobile #lkBody, html.mobile #lkNote, html.mobile #lkLeft { font-size: 14px !important; line-height: 21px !important; }
html.mobile #lkCode { flex-direction: column; gap: 16px !important; align-items: flex-start !important; }
html.mobile #lkQr { width: 148px !important; height: 148px !important; }
html.mobile #lkDigits { font-size: 36px !important; }

/* ---------- Settings & Remap Mobile Layout ---------- */
html.mobile #settings, html.mobile #remap {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
html.mobile .sHead {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  height: auto;
  padding: calc(env(safe-area-inset-top, 12px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.mClose {
  width: 36px; height: 36px; border-radius: 18px; border: 0;
  background: var(--sc-high); color: var(--on-surface);
  display: grid; place-items: center; margin-inline-start: 8px; flex: none;
}
html.mobile .sClock { font-size: 13px; }
html.mobile .sBody {
  position: relative;
  top: auto; bottom: auto; left: auto; right: auto;
  flex-direction: column;
  gap: 14px;
  padding: 8px 16px calc(env(safe-area-inset-bottom, 16px) + 28px);
}
html.mobile .nav {
  width: 100%;
  flex-direction: row;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
html.mobile .nav::-webkit-scrollbar { display: none; }
html.mobile .nav .sep { display: none; }
html.mobile .ni {
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  font-size: 14px;
  gap: 7px;
  flex: none;
  background: var(--sc-low);
}
html.mobile .ni svg { width: 18px; height: 18px; }
html.mobile .list { width: 100%; overflow: visible; -webkit-mask-image: none; mask-image: none; }
html.mobile .strack { padding: 0; transform: none !important; }
html.mobile .catT { font-size: 24px; line-height: 30px; padding: 4px 4px 0; }
html.mobile .catD { font-size: 13px; padding: 0 4px; margin: 4px 0 10px; }
html.mobile .subh { font-size: 12px; padding: 14px 4px 6px; }
html.mobile .row { min-height: 62px; padding: 10px 14px; border-radius: 16px; gap: 12px; background: var(--sc-low); }
html.mobile .row .rt { font-size: 15px; white-space: normal; }
html.mobile .row .rs { font-size: 12px; white-space: normal; }
html.mobile .row .lead { width: 36px; height: 36px; border-radius: 10px; }
html.mobile .row .lead svg { width: 20px; height: 20px; }
html.mobile .val { font-size: 14px; }
html.mobile .sw { width: 52px; height: 30px; border-radius: 15px; border-width: 2px; }
html.mobile .sw i { width: 16px; height: 16px; margin-top: -8px; inset-inline-start: 5px; }
html.mobile .sw.on i { width: 22px; height: 22px; margin-top: -11px; inset-inline-start: 24px; }
html.mobile .sl .bar { width: 110px; height: 10px; }
html.mobile .sl .bar b { height: 24px; top: -7px; width: 6px; }
html.mobile .sl .n { width: 42px; font-size: 14px; }
html.mobile .pv, html.mobile .foot { display: none !important; }

html.mobile .snack {
  inset-inline-start: 16px;
  inset-inline-end: 16px;
  bottom: calc(env(safe-area-inset-bottom, 12px) + 14px);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
}

.mSetupForm { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.mSetupForm label { font-size: 12px; color: var(--on-surface-variant); }
.mSetupForm input {
  height: 40px; border-radius: 10px; border: 1px solid var(--outline);
  background: var(--sc-low); color: var(--on-surface); padding: 0 12px; font-size: 14px;
}
.mSetupForm .mPinBox {
  height: 54px; font-size: 28px; font-weight: 600; text-align: center;
  letter-spacing: 8px; border: 2px solid var(--primary); border-radius: 14px;
}
.mManualFold { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.mManualFold summary { font-size: 12px; color: var(--on-surface-variant); cursor: pointer; padding: 4px 0; }

/* ---------- Touch Gamepad & In-Game HUD (#touchui) ---------- */
#touchui {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body:not(.playing) #touchui { display: none !important; }

.thud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 8px) + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 20px;
  background: rgba(20, 19, 24, .86);
  border: 1px solid rgba(255,255,255,.14);
  pointer-events: auto;
}
.thudBtn {
  height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.88);
  font: 500 12px Roboto, 'Noto Sans Arabic', sans-serif;
  display: flex;
  align-items: center;
  gap: 5px;
}
.thudBtn.on { background: var(--primary); color: var(--on-primary); }

#touchui.padHidden .tpad { display: none; }

.tpad {
  position: absolute;
  left: env(safe-area-inset-left, 10px);
  right: env(safe-area-inset-right, 10px);
  bottom: calc(env(safe-area-inset-bottom, 8px) + 8px);
  top: 48dvh;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 8px 10px;
}

@media (orientation: landscape) {
  .tpad { top: auto; height: 76dvh; padding: 4px 12px; }
}

.tleft, .tright {
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
}
.tleft { align-items: flex-start; }
.tright { align-items: flex-end; }

.tshoulders { display: flex; gap: 8px; pointer-events: auto; }
.tcenter {
  display: flex;
  gap: 10px;
  align-self: flex-end;
  margin-bottom: 4px;
  pointer-events: auto;
}

.tbtn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.92);
  background: rgba(34, 32, 42, .82);
  border: 1.5px solid rgba(255,255,255,.18);
  font: 600 16px Roboto, sans-serif;
}
.tbtn.on {
  background: color-mix(in srgb, var(--primary) 55%, rgba(255,255,255,.25));
  border-color: #fff;
  transform: scale(.93);
}

.tbtn.sh {
  min-width: 56px;
  height: 34px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
}
.tbtn.pill {
  height: 28px;
  padding: 0 13px;
  border-radius: 14px;
  font-size: 11px;
  letter-spacing: .4px;
  text-transform: uppercase;
  background: rgba(30, 29, 36, .72);
}

/* 8-Way Tactile Cross D-Pad */
.tdpad {
  position: relative;
  width: 146px;
  height: 146px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  pointer-events: auto;
}
.tdpad i {
  position: absolute;
  font-style: normal;
  display: grid;
  place-items: center;
  background: rgba(38, 36, 46, .74);
  border: 1px solid rgba(255,255,255,.16);
  color: rgba(255,255,255,.75);
  font-size: 14px;
}
.tdpad .up    { left: 49px; top: 6px; width: 48px; height: 48px; border-radius: 12px 12px 4px 4px; }
.tdpad .down  { left: 49px; bottom: 6px; width: 48px; height: 48px; border-radius: 4px 4px 12px 12px; }
.tdpad .left  { left: 6px; top: 49px; width: 48px; height: 48px; border-radius: 12px 4px 4px 12px; }
.tdpad .right { right: 6px; top: 49px; width: 48px; height: 48px; border-radius: 4px 12px 12px 4px; }
.tdpad .center { left: 49px; top: 49px; width: 48px; height: 48px; background: rgba(38, 36, 46, .74); border: 0; }
.tdpad .arm.on { background: color-mix(in srgb, var(--primary) 60%, #fff); color: #141318; }

/* Face button geometries */
.tface.face-diamond { position: relative; width: 152px; height: 152px; }
.tface.face-diamond .act { position: absolute; width: 54px; height: 54px; border-radius: 50%; font-size: 20px; }
.tface.face-diamond .act.top    { left: 49px; top: 0; }
.tface.face-diamond .act.bottom { left: 49px; bottom: 0; }
.tface.face-diamond .act.left   { left: 0; top: 49px; }
.tface.face-diamond .act.right  { right: 0; top: 49px; }

.ps-tri { color: #5fd6ac; } .ps-cir { color: #ff8c94; } .ps-x { color: #8fb3ff; } .ps-sq { color: #f3a6d6; }

.tface.face-pair { position: relative; width: 144px; height: 110px; }
.tface.face-pair .act { position: absolute; width: 62px; height: 62px; border-radius: 50%; font-size: 20px; }
.tface.face-pair .act.b { left: 4px; bottom: 4px; }
.tface.face-pair .act.a { right: 4px; top: 8px; }

.tface.face-six {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 8px;
}
.tface.face-six .act.sm { width: 46px; height: 40px; border-radius: 20px; font-size: 14px; opacity: .88; }
.tface.face-six .act.lg { width: 50px; height: 50px; border-radius: 50%; font-size: 17px; }

.tface.face-single .atari-fire {
  width: 84px; height: 84px; border-radius: 50%;
  background: rgba(198, 45, 45, .78);
  border-color: rgba(255, 160, 160, .45);
  font-size: 16px; letter-spacing: .8px;
}
