/* Phones and tablets (2026-12-03, Vova: "the mobile version looks a catastrophe"). The ONE mobile stylesheet for all pages
   (game index.html, cabinet.html; each <body> has data-page; the landing has its own phone rules in landing.css). Desktop (1265x650 and up, mouse) is never
   matched: menus use size queries (narrow OR short screens), the fight HUD uses body.touch (js/touch.js: primary pointer
   coarse / first real touch / ?touch=1). Breakpoints:
     narrow portrait = (max-width: 700px) and (orientation: portrait)      — phones upright, foldables
     short landscape = (max-height: 500px) and (orientation: landscape)    — phones on their side
   Safe areas (notch / home bar) come from env(safe-area-inset-*) (viewport-fit=cover). */
:root { --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); }

/* ============================== every touch device: no page zoom / pull-to-refresh / selection ============================== */
html.touch, html.touch body { overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
html.touch body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
html.touch input, html.touch textarea { -webkit-user-select: text; user-select: text; }
html.touch canvas#c, body.touch #hud, body.touch #tUi { touch-action: none; }
#tUi { display: none; }
body:not(.touch) #fsBtn { display: none; }   /* fullscreen knob: touch screens only, the desktop corner stays as it was */
body.touch #tUi { display: block; }

/* ============================== game menus: lobby, server list, map picker, waiting, help ============================== */
@media (max-width: 700px), (max-height: 500px) {
  [data-page=game] #lobby { padding: calc(64px + var(--st)) calc(14px + var(--sr)) calc(14px + var(--sb)) calc(14px + var(--sl)); overflow-y: auto; align-items: safe center; }
  [data-page=game] #lobby .res { gap: 10px; }
  [data-page=game] #cabBtn { top: calc(10px + var(--st)); right: calc(12px + var(--sr)); min-height: 44px; display: grid; place-items: center; padding: 0 18px; }
  body.menu[data-page=game] #hrLocFixed { top: calc(12px + var(--st)); left: calc(12px + var(--sl)); width: 44px; height: 44px; }
  #logoImg { height: clamp(70px, 22vh, 170px); }
  #tagline { font-size: 15px; margin-top: -4px; }
  #lobby input { padding: 8px 14px; min-height: 46px; font-size: 16px; }   /* 16px: iOS does not zoom into the field */
  /* mode buttons: compact cards, the drawn scene on the left, the words on the right */
  #createBlock { margin-top: 8px; gap: 12px; flex-wrap: nowrap; width: 100%; }
  button.mode { flex: 1; min-width: 0; width: auto; padding: 8px 10px 8px 6px; display: grid; grid-template-columns: 74px minmax(0, 1fr); grid-template-rows: auto auto;
    column-gap: 8px; align-items: center; text-align: left; border-radius: 20px; }
  button.mode img { position: static; transform: none; grid-row: 1 / 3; width: 74px; height: 62px; max-height: none; margin-top: -16px; object-position: center bottom; }
  button.mode b { font-size: 21px; align-self: end; }
  button.mode small { align-self: start; font-size: 12px; line-height: 1.15; }
  #joinBlock button { font-size: 19px; padding: 10px 26px; }

  /* server list: header wraps, rows become two-line tiles */
  #servers .card { height: 100%; padding: 12px 14px; gap: 8px; border-radius: 22px; }
  .sHead { flex-wrap: wrap; gap: 8px; }
  .sHead h2 { font-size: 24px; }
  .sHead .grow { display: none; }
  #sClose { width: 44px; height: 44px; }
  #servers .card #sNick { flex: 1 1 150px; width: auto; min-height: 44px; font-size: 16px; }
  #sCreate { min-height: 44px; font-size: 15px; padding: 6px 16px; }
  body:has(#servers:not(.hidden)) #hrLocFixed, body:has(#picker:not(.hidden)) #hrLocFixed { display: none; }   /* the knob would sit on the card */
  .sFilters { flex-wrap: wrap; gap: 6px 12px; }
  #sMap { min-height: 44px; font-size: 15px; }
  .sFree { min-height: 44px; }
  .sFree input { width: 24px; height: 24px; }
  .sCols { display: none; }
  #sList { padding: 6px; gap: 6px; border-radius: 16px; }
  .srow { grid-template-columns: minmax(0, 1fr) auto auto 96px; grid-template-areas: "map map map map" "br pl st go"; gap: 4px 10px; padding: 8px 10px; }
  .srow > :nth-child(1) { grid-area: map; } .srow > :nth-child(2) { grid-area: br; font-size: 13px; } .srow > :nth-child(3) { grid-area: pl; }
  .srow > :nth-child(4) { grid-area: st; } .srow > :nth-child(5) { grid-area: go; }
  .sMapC img { width: 64px; height: 40px; }
  .srow button { min-height: 44px; }
  .sEmpty img { height: 80px; }
  .sEmpty button { min-height: 44px; }

  /* map window: small map cards scroll, the buttons always stay visible at the bottom */
  #picker .card { max-height: 100%; overflow: hidden; padding: 12px 14px; gap: 8px; border-radius: 22px; }
  #picker h2 { font-size: 21px; }
  #pickMaps { flex: 1 1 auto; min-height: 0; overflow-y: auto; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 2px 2px 6px; }
  button.mapb { padding: 4px 4px 5px; border-radius: 14px; }
  button.mapb img { height: clamp(48px, 13vh, 92px); border-radius: 10px; margin-bottom: 2px; }
  button.mapb b { font-size: 15px; }
  button.mapb small { font-size: 10.5px; }
  #pickTeamRow { min-height: 44px; flex-wrap: wrap; gap: 6px; }
  #pickTeams button { width: 44px; height: 44px; }
  .pickBtns { flex: none; }
  .pickBtns button { min-height: 44px; }

  /* waiting room, help, result */
  .overlay { padding: calc(10px + var(--st)) calc(10px + var(--sr)) calc(10px + var(--sb)) calc(10px + var(--sl)); }
  .card { padding: 14px 16px; border-radius: 22px; }
  #waiting .card button, #helpClose, #againBtn, #coachOk { min-height: 44px; }
  #help .keys tbody { grid-template-columns: 1fr; }
  #help .keys td:first-child { width: 110px; }
  #resArt { height: clamp(70px, 26vh, 220px); }
  #resTitle { font-size: clamp(40px, min(11vw, 12vh), 90px); -webkit-text-stroke-width: 9px; }
  #resText { font-size: 16px; }
  #resStats { flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 94vw; }
  #resStats .st { padding: 5px 12px; }
  #resStats .st b { font-size: 20px; }
}
/* narrow portrait: everything in one column */
@media (max-width: 700px) and (orientation: portrait) {
  #createBlock { flex-direction: column; gap: 22px; margin-top: 18px; width: min(420px, 100%); }
  button.mode { grid-template-columns: 96px minmax(0, 1fr); padding: 10px 16px 10px 8px; }
  button.mode img { width: 96px; height: 76px; margin-top: -26px; }
  button.mode b { font-size: 24px; }
  #pickMaps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  button.mapb img { height: clamp(60px, 12vh, 92px); }
}
/* wide but short upright screens (foldables ~580x640): the three mode signs stand in a row, as on desktop */
@media (min-width: 520px) and (max-width: 700px) and (max-height: 760px) and (orientation: portrait) {
  #createBlock { flex-direction: row; gap: 10px; width: 100%; margin-top: 10px; }
  button.mode { grid-template-columns: 1fr; padding: 8px 6px 34px; text-align: center; }
  button.mode img { width: 100%; height: 70px; margin: -22px 0 0; object-fit: contain; }
  button.mode b { font-size: 19px; }
  button.mode small { font-size: 11px; }
  #logoImg { height: clamp(70px, 20vh, 130px); }
}
@media (max-width: 420px) and (orientation: portrait) {
  .srow { grid-template-columns: minmax(0, 1fr) auto 88px; grid-template-areas: "map map map" "pl st go"; }
  .srow > :nth-child(2) { display: none; }
}
/* short landscape: logo smaller, map cards 4 in a row */
@media (max-height: 500px) and (orientation: landscape) {
  [data-page=game] #lobby { padding-top: calc(10px + var(--st)); }
  #logoImg { height: clamp(60px, 22vh, 110px); }
  #createBlock { margin-top: 14px; max-width: 760px; }
  #picker .card { width: min(860px, 100%); height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr) auto; }
  #picker h2, #pickMaps { grid-column: 1 / -1; }
  #pickTeamRow { justify-content: flex-start; }
  .sEmpty img { display: none; }
}

/* any finger-first screen (tablets too): small controls get a 44 px tap size */
@media (pointer: coarse) {
  #servers .card #sNick, #sMap, #sCreate, #pickTeams button, .pickBtns button, .srow button { min-height: 44px; }
  #sClose, body.menu[data-page=game] #hrLocFixed { width: 44px; height: 44px; }
  .sFree { min-height: 44px; }
  [data-page=cabinet] .authLoc .hr-loc, [data-page=cabinet] .knob, [data-page=cabinet] .stat .plus { width: 44px; height: 44px; }
  [data-page=cabinet] .back { display: inline-block; padding: 13px 8px; }
  [data-page=cabinet] button, [data-page=cabinet] #top .hr-loc { min-height: 44px; }
  [data-page=cabinet] #top .logo { display: flex; align-items: center; min-height: 44px; min-width: 44px; }
  [data-page=cabinet] #pigCard .name input { min-height: 44px; }
  [data-page=cabinet] #pigCard .clsPick button { min-width: 44px; }
}

/* ============================== the fight on a touch screen (body.touch) ============================== */
/* top-left: whose turn, compact; the knobs (chat, help, music, graphics, fullscreen) in a row under it */
body.touch #turnbox { top: calc(6px + var(--st)); left: calc(8px + var(--sl)); padding: 3px 10px 8px 3px; gap: 7px; max-width: min(300px, 40vw); border-width: 3px; border-radius: 16px; }
body.touch #timer { width: 42px; height: 42px; font-size: 18px; }
body.touch #turnTeam { font-size: 14px; }
body.touch #turnPig { font-size: 11px; }
body.touch #teams { display: none; }
body.touch #turnbox { padding: 3px 14px 3px 3px; }   /* right: clear of the board's corner nails (Vova 2026-12-05) */
body.touch #skipBtn { position: static; flex: none; height: 44px; padding: 0 12px; font-size: 12px; }
body.touch #corner { top: calc(72px + var(--st)); left: calc(60px + var(--sl)); right: auto; flex-direction: row; gap: 6px; }
body.touch #corner .knob, body.touch #gfxBtn { width: 44px; height: 44px; font-size: 17px; border-width: 3px; }
body.touch #corner #tutBtn { display: none; }   /* the coach tips talk about the mouse */
body.touch #fsBtn svg { width: 20px; height: 20px; display: block; margin: auto; }
body.touch #gfxBtn { position: static; }   /* js/touch.js moves the gear into #corner */
body.touch #gfxBox { top: calc(124px + var(--st)); left: calc(8px + var(--sl)); right: auto; width: 290px; }
body.touch .gfxRow button { min-height: 44px; }
body.touch #chat { left: calc(8px + var(--sl)); top: calc(72px + var(--st)); bottom: auto; width: min(300px, 42vw); display: flex; flex-direction: column-reverse; }
body.touch #chatLog { margin: 8px 0 0; }
body.touch #chatPad { bottom: auto; top: 52px; width: min(540px, calc(100vw - 30px)); z-index: 3; padding: 8px; gap: 6px; }
body.touch #chatPad .cp-ph { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.touch #chatPad .cp-em { justify-content: flex-start; gap: 6px; }
body.touch #chatPad .cp-em button { font-size: 20px; }
body.touch #chatWrite { position: absolute; right: 8px; bottom: 8px; padding: 0 16px; }
body.touch #chatPad .cp-ph button, body.touch #chatWrite { min-height: 44px; }
body.touch #chatPad .cp-em button { width: 44px; height: 44px; }
body.touch #chat .cm { font-size: 12px; }
body.touch #chatIn { height: 44px; font-size: 16px; }
body.touch #chat.typing { width: min(420px, 70vw); z-index: 45; }
/* top-right: wind, weather, language */
body.touch #windbox { top: calc(6px + var(--st)); right: calc(8px + var(--sr)); width: 52px; height: 52px; border-width: 3px; }
body.touch #windArrow { font-size: 21px; }
body.touch #windVal { font-size: 10px; }
body.touch #hrLocFixed { top: calc(10px + var(--st)) !important; right: calc(68px + var(--sr)) !important; width: 44px; height: 44px; }
/* waiting room: no turn box, no wind yet - chat top-left and language top-right on one line (Vova 2026-12-05: "they live their own life") */
body.touch.waitroom #chat { top: calc(10px + var(--st)); }
body.touch.waitroom #hrLocFixed { right: calc(10px + var(--sr)) !important; }
body.touch #wxbox { top: calc(10px + var(--st)); right: calc(120px + var(--sr)); height: 44px; padding: 0 8px; font-size: 19px; }
/* the hint line and the power bar: low in the middle, above the weapon strip (the arc stays free) */
body.touch #stepbar { top: auto; bottom: calc(66px + var(--sb)); max-width: 52vw; }
body.touch #stepText { font-size: 13px; white-space: normal; line-height: 1.2; }
body.touch #keys, body.touch #lockHint, body.touch #ctrl { display: none !important; }
/* the power bar: right under the brigades strip (#teamBar), centred on it, the text written on the bar, so it stays
   above the knob row (2026-12-05) */
body.touch #aimHud { top: calc(var(--tbH, 52px) + 24px + var(--st)); left: calc((min(300px, 40vw) + 18px + var(--sl) + 100vw - 236px - var(--sr)) / 2); }
body.touch #aimHud .pbar { width: 150px; left: -75px; height: 16px; }
body.touch #aimHud .ptxt { font-size: 12px; top: -16px; line-height: 16px; }
body.touch #toast { top: calc(var(--tbH, 52px) + 52px + var(--st)); max-width: 70vw; text-align: center; font-size: 13px; }
body.touch #banner { font-size: 30px; -webkit-text-stroke-width: 5px; }
body.touch .lbl { font-size: 11px; }
body.touch .lbl .hp { width: 40px; height: 6px; }
/* the dock falls apart into thumb zones: weapons + powers strip bottom-centre, jump + FIRE bottom-right */
body.touch #bottom { display: contents; }
body.touch #weapons { position: fixed; left: 50%; bottom: calc(8px + var(--sb)); transform: translateX(-50%); gap: 4px; padding: 4px; border-radius: 18px;
  background: rgba(255,246,220,.82); box-shadow: 0 3px 0 rgba(90,40,18,.45), 0 6px 14px rgba(0,0,0,.2); z-index: 6; }
body.touch #weapons .wbtn { width: 46px; height: 46px; border-radius: 13px; border-width: 2.5px; box-shadow: 0 3px 0 var(--brown); padding: 0; }
body.touch #weapons .wbtn img { top: 4px; height: 30px; max-width: 38px; }
body.touch #weapons .wbtn span { display: none; }
body.touch #weapons .wbtn small { font-size: 9px; margin-bottom: 0; }
body.touch #weapons .wbtn .am { top: -6px; right: -6px; }
body.touch #powers { position: fixed; right: calc(10px + var(--sr)); bottom: calc(112px + var(--sb)); flex-direction: column-reverse; gap: 6px; z-index: 6; }
body.touch #powers .pw { width: 50px; min-width: 0; height: 50px; padding: 0; border-radius: 14px; border-width: 2.5px; }
body.touch #powers .pw svg { top: 5px; width: 26px; height: 26px; }
body.touch #powers .pw span { display: none; }
body.touch #powers .pw small { font-size: 9px; }
body.touch #jumpBtn { position: fixed; right: calc(108px + var(--sr)); bottom: calc(14px + var(--sb)); width: 60px; height: 60px; border-radius: 50%; z-index: 6; }
body.touch #jumpBtn img { top: 7px; height: 30px; }
body.touch #jumpBtn span { font-size: 10px; margin-bottom: 7px; }
body.touch #jumpBtn small { display: none; }
body.touch #fireBtn { position: fixed; right: calc(14px + var(--sr)); bottom: calc(12px + var(--sb)); width: 86px; height: 86px; margin: 0; z-index: 6; }
body.touch #fireBtn .fb { font-size: 14px; }
body.touch:not(.t-mine) #weapons, body.touch:not(.t-mine) #powers, body.touch:not(.t-mine) #jumpBtn, body.touch:not(.t-mine) #fireBtn { opacity: .5; }
/* joystick: a soft ring bottom-left (it jumps under the thumb when touched) */
#tJoy { position: fixed; left: calc(28px + var(--sl)); bottom: calc(22px + var(--sb)); width: 112px; height: 112px; border-radius: 50%; pointer-events: none; z-index: 5;
  background: radial-gradient(circle, rgba(255,246,220,.18) 0 55%, rgba(255,246,220,.5) 56% 62%, rgba(255,246,220,.12) 63%); opacity: .75; }
#tJoy.on { margin: -56px 0 0 -56px; bottom: auto; opacity: 1; }
#tJoy i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px; border-radius: 50%; background: linear-gradient(180deg, #fffaf0, #ffe7a8); border: 3px solid var(--brown); box-shadow: 0 4px 0 var(--brown); }
body:not(.t-mine) #tJoy { display: none; }
/* look / scope zoom / plane course: a small row above jump */
#tTools { position: fixed; right: calc(108px + var(--sr)); bottom: calc(84px + var(--sb)); display: flex; flex-direction: row-reverse; gap: 6px; z-index: 6; }
.tbtn { width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 20px; display: grid; place-items: center; border-width: 2.5px; touch-action: none; }
.tbtn svg { width: 24px; height: 24px; }
.tbtn.on { background: var(--orange); }
.tbtn.tsn, .tbtn.tpl { display: none; }
body.t-sniper .tbtn.tsn, body.t-plane .tbtn.tpl { display: grid; }
body:not(.t-mine) #tTools { display: none; }
/* every brigade at a glance (2026-12-05, Vova): top centre between the turn box and the wind / weather / language
   group; chips wrap into a 2nd row with many brigades; the bar itself lets taps through, only the strip takes them.
   The power bar and the toasts sit under it (--tbH = the strip height, set by game.js) */
#teamBar { display: none; }
body.touch #teamBar { display: flex; position: fixed; top: calc(6px + var(--st)); left: calc(min(300px, 40vw) + 18px + var(--sl)); right: calc(236px + var(--sr));
  justify-content: center; align-items: flex-start; pointer-events: none; z-index: 7; }
body.touch #teamStrip { pointer-events: auto; display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; max-width: 100%;
  min-height: 44px; min-width: 44px; padding: 4px 6px; margin: 0; border-radius: 14px; touch-action: manipulation; }
body.touch #teamPanel { pointer-events: auto; position: fixed; top: calc(var(--tbH, 52px) + 12px + var(--st)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px - var(--sl) - var(--sr));
  max-height: calc(100vh - var(--tbH, 52px) - 24px - var(--st) - var(--sb)); overflow-y: auto; overscroll-behavior: contain; padding: 14px 56px 14px 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 300px)); gap: 10px 12px; z-index: 30; }   /* columns: game.js */
body.touch #teamPanel.hidden { display: none; }
/* portraits (2026-12-05, Vova: "the faces of my pigs with their energy"): my brigade = a face per pig with its HP bar,
   the pig on turn bigger in a gold ring; other brigades = a colour disc with the number alive + their HP line */
#teamStrip .tc { display: inline-flex; border-radius: 9px; }
#teamStrip .tc.me { gap: 4px; padding: 3px 5px 4px; align-items: flex-end; }
#teamStrip .pf { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 30px; }
#teamStrip .pf i { display: block; width: 28px; height: 4px; border-radius: 2px; }
#teamStrip .tc.foe { flex-direction: column; align-items: center; gap: 3px; padding: 4px 4px 5px; width: 32px; }
#teamStrip .tc.foe b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; line-height: 1; }
#teamStrip .tc.foe em { display: block; width: 24px; height: 4px; border-radius: 2px; }
#teamStrip .foes { display: flex; gap: 4px; }
#teamStrip .foes.mini { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows), auto); gap: 4px 3px; }
#teamStrip .foes.mini .tc.foe { width: 21px; height: 21px; padding: 0; border-radius: 50%; display: grid; place-items: center; }   /* the HP ring: skin.css */
#teamStrip .foes.mini .tc.foe b { width: 15px; height: 15px; font-size: 10px; }
#teamStrip .foes.mini .tc.foe em { display: none; }
/* a phone held upright (the fight asks to turn it, but the bar must not sit on the knobs meanwhile): a row of its own
   under the knob row */
@media (orientation: portrait) and (max-width: 700px) {
  body.touch #teamBar { top: calc(124px + var(--st)); left: calc(12px + var(--sl)); right: calc(12px + var(--sr)); }
  body.touch #teamPanel { top: calc(var(--tbH, 52px) + 130px + var(--st)); max-height: calc(100vh - var(--tbH, 52px) - 142px - var(--st) - var(--sb)); }
  body.touch #aimHud { top: calc(var(--tbH, 52px) + 142px + var(--st)); left: 50%; }
}
.fc { position: relative; display: block; width: 30px; height: 30px; border-radius: 50%; flex: none; }
.fc img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; pointer-events: none; }
.fc .clsb { position: absolute; right: -4px; bottom: -3px; width: 13px; height: 13px; }
.fc .clsb svg { width: 9px; height: 9px; }
#teamStrip .pf.on .fc { transform: scale(1.14); transform-origin: 50% 100%; }
/* the scoreboard: a block per brigade, a row per pig */
#teamPanel .sbX { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 18px; line-height: 1; min-height: 0; }
#teamPanel .tp { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 6px 8px 7px; border-radius: 10px; }
#teamPanel .tph { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; min-width: 0; min-height: 22px; }
#teamPanel .tph b { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#teamPanel .tph i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
#teamPanel .tph .nk { font-size: 11px; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
#teamPanel .tph .you, #teamPanel .tph .turn { flex: none; }
#teamPanel .tph .sum { margin-left: auto; padding-left: 6px; font-size: 12px; flex: none; }
#teamPanel .pg { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 78px) 44px 24px; align-items: center; gap: 6px; font-size: 12px; min-height: 30px; padding: 0 2px; border-radius: 7px; }
#teamPanel .pg .fc { width: 26px; height: 26px; }
#teamPanel .pg .fc .clsb { width: 12px; height: 12px; right: -3px; bottom: -2px; }
#teamPanel .pg .fc .clsb svg { width: 8px; height: 8px; }
#teamPanel .pg > span:not(.fc) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#teamPanel .pg .cl { font-size: 11px; }
#teamPanel .pg i { height: 7px; border-radius: 4px; }
#teamPanel .pg b { text-align: right; font-variant-numeric: tabular-nums; }
/* turn the phone: only during a fight, only upright */
#tRotate { display: none; position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 40%, rgba(255,200,110,.3), rgba(15,30,55,.85) 75%), #20324d; }
#tRotate > div { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#tRotate svg { width: 110px; height: 110px; animation: tRot 2.4s ease-in-out infinite; }
#tRotate b { font-size: 22px; color: #fff; text-shadow: var(--outline); }
#tRotate span { color: #ffe7a8; font-size: 15px; }
@keyframes tRot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 900px) { body.touch.infight #tRotate { display: flex; } }
/* small phones on their side: a bit tighter still */
@media (max-height: 500px) {   /* phones: the hint goes up under the power bar, the pig's head stays free */
  body.touch #stepbar { bottom: auto; top: calc(var(--tbH, 52px) + 32px + var(--st));   /* under the power bar */  left: auto; right: calc(12px + var(--sr)); transform: none; max-width: 40vw; text-align: right; }
  body.touch #toast { top: 30%; }
}
@media (max-height: 400px) {
  body.touch #weapons .wbtn { width: 44px; height: 44px; }
  body.touch #powers { bottom: calc(104px + var(--sb)); }
  body.touch #powers .pw { width: 46px; height: 46px; }
  body.touch #fireBtn { width: 80px; height: 80px; }
}

/* ============================== cabinet ============================== */
@media (max-width: 700px), (max-height: 500px) {
  [data-page=cabinet] { overflow-y: auto; height: auto; }
  html:has(body[data-page=cabinet]) { height: auto; }
  [data-page=cabinet] #auth { position: relative; min-height: 100vh; min-height: 100dvh; padding: calc(14px + var(--st)) calc(14px + var(--sr)) calc(14px + var(--sb)) calc(14px + var(--sl)); }
  [data-page=cabinet] .authLogo { height: clamp(80px, 24vh, 200px); }
  [data-page=cabinet] #authForm input { min-height: 46px; font-size: 16px; }
  [data-page=cabinet] .authBtns button { min-height: 46px; }
  [data-page=cabinet] .back { display: inline-block; padding: 13px 8px; }
  [data-page=cabinet] .authLoc { top: calc(12px + var(--st)); right: calc(12px + var(--sr)); }
  [data-page=cabinet] .authLoc .hr-loc { width: 44px; height: 44px; }
  [data-page=cabinet] #app { height: auto; min-height: 100vh; padding: calc(10px + var(--st)) calc(10px + var(--sr)) calc(16px + var(--sb)) calc(10px + var(--sl)); }
  [data-page=cabinet] #top { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 8px; border-radius: 20px; }
  [data-page=cabinet] #top .logo img { height: 46px; margin: -4px 0; }
  [data-page=cabinet] .who .nick { font-size: 17px; max-width: 46vw; }
  [data-page=cabinet] .xpbar { width: 80px; }
  [data-page=cabinet] #tXpTxt { display: none; }
  [data-page=cabinet] .stat { height: 44px; }
  [data-page=cabinet] .stat img { width: 30px; height: 30px; }
  [data-page=cabinet] .stat b { font-size: 17px; }
  [data-page=cabinet] .stat .plus, [data-page=cabinet] .knob { width: 44px; height: 44px; }
  [data-page=cabinet] #top .hr-loc, [data-page=cabinet] #logoutBtn { min-height: 44px; }
  [data-page=cabinet] main { display: flex; flex-direction: column; }
  [data-page=cabinet] #left { min-height: 0; }
  [data-page=cabinet] #tabs button { min-height: 44px; flex: 1; padding: 6px 8px; font-size: 15px; }
  body.skin-cab[data-page=cabinet] #tabs { padding-left: 0; }   /* the skin's folder-tab indent does not fit a phone */
  [data-page=cabinet] #pigGrid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); grid-template-rows: none; grid-auto-rows: 150px; }
  [data-page=cabinet] .tile.locked button, [data-page=cabinet] .item button { min-height: 44px; }
  [data-page=cabinet] .foot { flex-direction: column; align-items: flex-start; gap: 4px; }
  [data-page=cabinet] .shopGrid { display: flex; flex-direction: column; }
  [data-page=cabinet] .box { min-height: 220px; }
  [data-page=cabinet] .items { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); grid-auto-columns: auto; grid-auto-rows: 150px; }
  [data-page=cabinet] .look .row { grid-template-columns: 54px repeat(4, minmax(0, 1fr)); min-height: 120px; }
  [data-page=cabinet] #tab-rating { overflow-x: auto; }
  [data-page=cabinet] #right { min-height: 0; }
  [data-page=cabinet] #pigCard { min-height: 360px; }
  [data-page=cabinet] #pigCard button, [data-page=cabinet] #pigCard .clsPick button { min-height: 44px; min-width: 44px; }
  [data-page=cabinet] a.go { height: 64px; font-size: 26px; }
  [data-page=cabinet] #packs { grid-template-columns: repeat(2, 1fr); }
  [data-page=cabinet] .card button, [data-page=cabinet] .custom input { min-height: 44px; }
  [data-page=cabinet] #toast { bottom: calc(16px + var(--sb)); max-width: 90vw; text-align: center; }
}
/* phone on its side: the login card goes into two columns (logo | form) */
@media (max-height: 500px) and (orientation: landscape) {
  [data-page=cabinet] .authCard { width: min(760px, 100%); display: grid; grid-template-columns: 1fr 1.1fr; column-gap: 24px; align-items: center; }
  [data-page=cabinet] .authLogo { grid-column: 1; grid-row: 1; height: clamp(80px, 40vh, 170px); margin: 0 auto; }
  [data-page=cabinet] .authCard h1 { grid-column: 1; grid-row: 2; font-size: 20px; }
  [data-page=cabinet] #authForm { grid-column: 2; grid-row: 1 / 4; }
  [data-page=cabinet] .back { grid-column: 1; grid-row: 3; }
  [data-page=cabinet] main { display: grid; grid-template-columns: minmax(0, 1fr) 260px; }
}

