/* Generated by art/pixelforge/make-ui.mjs (npm run art:ui) from ui-mobile.mjs. Do not edit.
   The HUD, the windows and the login screen on a phone. Loaded after hud-layout.css and login.css; a desktop window is not touched.
   Lengths are the interface's own pixels (2 per art pixel), before the scale. */

/* ---- every screen ---- */
/* what only a phone uses stays out of the way */
.hud-chat-button, .chat-send, #fullscreen-toggle { display: none; }
/* a finger does not zoom the page (two fingers, or two quick taps), drag it past its edge, or call up the system's menus; a long list still scrolls */
html, body { overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: pan-x pan-y; -webkit-tap-highlight-color: transparent; }
#game, #game > canvas { touch-action: none; }
.ui { -webkit-touch-callout: none; }

/* ---- a phone, either way up ---- */
@media (max-width: 760px), (max-height: 520px) {
  :root { --m: 1; --hot: 1.08;
    --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
    /* the screen, clear of the notch and the rounded corners, in the interface's pixels: --sw for widths and left/right, --sh for heights and top/bottom */
    --sw: calc((100% - var(--safe-l) - var(--safe-r)) / var(--m)); --sh: calc((100% - var(--safe-t) - var(--safe-b)) / var(--m)); }
  .hud { inset: var(--safe-t) auto auto var(--safe-l); width: var(--sw); height: var(--sh); transform: scale(var(--m)); transform-origin: 0 0;
    padding: 6px; display: grid; justify-items: start; align-items: start; }   /* the game itself runs under the notch; the HUD keeps clear of it */
  .hud[data-chat="open"] { z-index: 31; }   /* over the windows (20 to 30) while the chat is open */
  .hud:has(.chat-input:focus) { z-index: 31; }
  .hud-corner { display: contents; }                                 /* its pieces are placed one by one with everything else */

  /* the status panel and what goes with it: each in a row of its own */
  .hud-status { position: static; width: 100%; margin: 0 0 6px; }
  .hud-under { position: static; max-width: none; }
  .hud-buffs { margin-bottom: 6px; }                                 /* on this, not on its row: an empty row takes no room */
  .hud-debug { display: none; }                                      /* the test tools' line (session, map, tile, how many players and monsters): not on a phone — the Owner, 2026-10-06:
                                                                        「手機版面把地圖的怪物數量顯示這些提示把它移除」. Only accounts with the test tools have it; a desktop window keeps it */
  /* the target: its name and its bar are over its head in the world, and on a phone the panel that repeats them is left out (the Owner, 2026-10-06:
     「手機版把怪物顯示名稱跟血條移除，不是頭上的」). What is left of it is the row of states the player's skills have put on the target, with their seconds —
     marked in the enemy's red in front, so that it is not taken for the player's own row just above. With no state there is nothing at all. */
  .hud-target { position: relative; left: auto; right: auto; top: auto; margin: 0; padding: 0; border: 0; border-image: none; background: none; min-height: 0; }
  .hud-target > #target-name, .hud-target > #target-bar { display: none; }
  .hud-target-buffs { position: static; display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 6px; margin: 0 0 6px; }
  .hud-target-buffs::before { content: ''; width: 6px; height: 26px; margin-right: 2px; background: #d8402f; box-shadow: 0 0 0 2px var(--ui-line); }
  .hud-event { position: static; margin: 0 0 6px; pointer-events: none; }   /* a tap on it goes to the game */
  .hud-event-row:nth-child(n+2) { display: none; }                   /* one event; the next one waits its turn */
  .hud-notice { position: static; left: auto; right: auto; top: auto; margin: 0 0 6px; max-width: 100%; }
  .hud-fallen { position: static; left: auto; right: auto; top: auto; margin: 0 0 6px; }
  .hud-mapbox { position: static; }
  /* quests: one line each, what is still to do; the name of the quest is left out */
  .hud-quests { position: static; justify-self: start; align-self: start; width: min(400px, 100%); margin: 0 0 6px; gap: 6px; flex-flow: column nowrap; align-items: flex-start; overflow: visible; }   /* room for the longest line (go back to a town with a long name) */
  .hud-quests::before { content: none; }
  .hud-quest { width: auto; max-width: 100%; pointer-events: none; }      /* the dark strip is as wide as the line, not as the column: less of the world is covered */
  .hud-quest-name, .hud-quest-step[data-done="true"] { display: none; }   /* (a quest ready to hand in keeps its last line: whom to go back to) */
  .hud-quest:not(:has(.hud-quest-step[data-done="false"])) > .hud-quest-step:last-child { display: block; }   /* (nothing left to do and no one to go back to: the last line stays, a card is never empty; a rule of its own, for the browsers without :has()) */
  .hud-quest:nth-child(n+4) { display: none; }

  /* the buttons: bigger, for a thumb, in one row */
  .hud-actions { position: static; width: auto; margin: 0; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 6px; }   /* what does not fit goes to a row above, not below */
  .hud-actions > .ui-button { flex: none; height: 52px; min-width: 52px; }
  .hud-actions > .ui-button.ui-square { width: 52px; }
  .hud-chat-button { display: inline-flex; order: -2; }               /* the row reads: chat, settings, backpack, character, skills, automatic hunting */
  #settings-button { order: -1; }                                     /* the gear stands where the menu button stood */
  #name-button, #class-switch { order: 1; }                           /* what only a guest or a tester has goes last, so it is what moves up a row */
  #auto-hunt { gap: 0; padding: 0 8px; font-size: 0; }               /* its own label is too long for the row: two letters, the lamp and the color say the rest */
  #auto-hunt::before { content: "自動"; font-size: 24px; }
  #ride { padding: 0 8px; }
  /* DS-288: with a mount on, 上車／下車 is a ninth button. ui-entry.mjs holds the eight of an account on one line; the ninth goes to a row of its own
     above them, over 自動 (it comes last), wherever it does not fit beside them — it pushed the chat button half off the Owner's phone */
  .hud .hud-actions:has(> #ride:not([hidden])) { width: auto; flex-wrap: wrap-reverse; row-gap: 6px; }
  .ui-close::after { content: ''; position: absolute; inset: -12px; }   /* the cross is small; this is where a finger may land */
  .hud-hotbar { position: static; margin: 0; zoom: var(--hot); }

  /* chat: a line shows for twelve seconds and goes; the input line waits behind the chat button */
  .hud-chat { position: relative; left: auto; bottom: auto; align-self: end; margin: 0 0 6px; gap: 0; pointer-events: none; }
  .chat-input { position: absolute; left: 0; bottom: 0; width: 48px; opacity: 0; }   /* out of sight and out of the stack, but it can still take the cursor: Enter on a keyboard opens the chat too */
  .chat-channel { display: none; }
  .chat-log { max-height: 112px; justify-content: flex-end; align-items: flex-start; gap: 2px; overflow: hidden; border: 0; border-image: none; }   /* the newest four lines; each line has its own dark strip, so nothing shows when all are gone */
  .chat-line { padding: 0 8px; background: #10121a99; animation: chat-line-fade 12s linear forwards; }
  @keyframes chat-line-fade { 0%, 85% { opacity: 1; max-height: 6em; } 99% { opacity: 0; max-height: 6em; } 100% { opacity: 0; max-height: 0; margin-top: -2px; padding: 0; } }
  .hud[data-chat="open"] .hud-chat { position: absolute; grid-area: auto; top: auto; z-index: 3; margin: 0; gap: 6px; pointer-events: auto; }
  .hud .hud-chat:has(.chat-input:focus) { position: absolute; grid-area: auto; top: auto; z-index: 3; margin: 0; gap: 6px; pointer-events: auto; }   /* (a placed item would be held inside its own row.) The block hangs from its bottom edge, where the line to type in stays put, and is as tall as its lines up to the max-height each way of holding the phone gives it; from there the log scrolls. Never top and bottom together: with the align-self: end of the closed chat some browsers then size the box by its lines and some by the two edges, and fifty lines went up over the status panel and off the screen with nothing to scroll */
  .hud[data-chat="open"] .hud-chat .chat-log { flex: 1; min-height: 0; max-height: none; justify-content: flex-start; overflow-y: auto; border-style: solid; border-color: transparent; border-width: 8px 8px 8px 8px; border-image: url(ghost.png) 8 8 8 8 fill; background: #10121ab8; background-clip: padding-box; scroll-snap-type: y proximity; }
  .hud .hud-chat:has(.chat-input:focus) .chat-log { flex: 1; min-height: 0; max-height: none; justify-content: flex-start; overflow-y: auto; border-style: solid; border-color: transparent; border-width: 8px 8px 8px 8px; border-image: url(ghost.png) 8 8 8 8 fill; background: #10121ab8; background-clip: padding-box; scroll-snap-type: y proximity; }   /* (darker than the ghost alone: the open log lies over the target panel and the quests, and has to be read against them) */
  .hud[data-chat="open"] .hud-chat .chat-line:last-child { scroll-snap-align: end; }
  .hud .hud-chat:has(.chat-input:focus) .chat-line:last-child { scroll-snap-align: end; }   /* a log left at its newest line stays there when its height changes (the phone is turned, a keyboard takes part of the window): the browser snaps again after the layout */
  .hud[data-chat="open"] .hud-chat .chat-line { opacity: 1 !important; max-height: none !important; margin-top: 0 !important; padding: 0 !important; background: none; }
  .hud .hud-chat:has(.chat-input:focus) .chat-line { opacity: 1 !important; max-height: none !important; margin-top: 0 !important; padding: 0 !important; background: none; }   /* every line is back while the chat is open; the lines that had gone are gone again when it closes (the animation is not restarted) */
  .hud[data-chat="open"] .hud-chat .chat-input { position: static; flex: none; width: 100%; height: 48px; padding-left: 68px; padding-right: 60px; opacity: 1; }
  .hud .hud-chat:has(.chat-input:focus) .chat-input { position: static; flex: none; width: 100%; height: 48px; padding-left: 68px; padding-right: 60px; opacity: 1; }
  .hud[data-chat="open"] .hud-chat .chat-channel { display: inline-flex; position: absolute; left: 0; bottom: 0; width: 64px; height: 48px; }
  .hud .hud-chat:has(.chat-input:focus) .chat-channel { display: inline-flex; position: absolute; left: 0; bottom: 0; width: 64px; height: 48px; }
  .hud[data-chat="open"] .hud-chat .chat-send { display: inline-flex; position: absolute; right: 0; bottom: 0; width: 56px; height: 48px; }
  .hud .hud-chat:has(.chat-input:focus) .chat-send { display: inline-flex; position: absolute; right: 0; bottom: 0; width: 56px; height: 48px; }

  /* windows: laid out at their own size, drawn smaller from the corner they hang by; no wider and no higher than the screen; what is long scrolls inside */
  :where(body > .ui-window, body > .npc-dialog) { max-width: calc(var(--sw) - 12px); max-height: calc(var(--sh) - 12px); transform: scale(var(--m)); transform-origin: 0 0; }   /* (:where: any rule of a window's own wins over this) */
  .skill-list, .shop-list, .enchant-list, .camp-cards, .travel-destinations { flex: 1; min-height: 0; max-height: none; }
  /* what a picked thing is, and the tip of a worn piece, scroll when they are longer than their room, their row of buttons held at the bottom.
     A phone shows no scroll bar: while there is more below, the last lines in sight fade into the row of buttons. The fade follows the
     scrolling itself (animation-timeline: scroll()); where a browser cannot do that, or there is nothing more to scroll to, none is drawn. */
  @supports (animation-timeline: scroll()) {
    .bag-detail > .name-row::before, .char-tip > .name-row::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 30px; pointer-events: none; opacity: 0;
      background: linear-gradient(to top, #fff6dc, #fff6dc00); animation: ui-more-below linear both; animation-timeline: scroll(nearest block); }
  }
  @keyframes ui-more-below { 0%, 94% { opacity: 1; } 100% { opacity: 0; } }
  .char-tip > .name-row { position: sticky; bottom: 0; background: #fff6dc; box-shadow: 0 3px 0 #fff6dc; }   /* (the fade hangs from the row: it has to be the row that is held at the bottom, upright too) */
  /* a list in a window — a shop's goods, the skills, what can be enchanted, the stations, the two columns of the character window, the settings —
     scrolls when it is longer than its room, and a phone draws no scroll bar: when the cut falls between two rows nothing showed that there were
     more (the fourth weapon in the enchant window, whole, just under the edge). While there is more below, the bottom of the list fades out; at
     the end, or with nothing to scroll, it does not. As above this follows the scrolling itself, and is left out where a browser cannot. */
  @supports (animation-timeline: scroll()) {
    .skill-list, .shop-list, .enchant-list, .travel-destinations, .char-body, .settings-body { animation: ui-list-more linear both; animation-timeline: scroll(self block); }
  }
  @keyframes ui-list-more {
    0%, 94% { -webkit-mask-image: linear-gradient(#000 calc(100% - 40px), #0000); mask-image: linear-gradient(#000 calc(100% - 40px), #0000); }
    100% { -webkit-mask-image: linear-gradient(#000 100%, #000); mask-image: linear-gradient(#000 100%, #000); }
  }
  /* the enchant window (過爐) is opened from the backpack, and on a desktop the two stand side by side: the player watches the +N on the
     backpack's slots. A phone has room for one of them — upright the window is as wide as the screen, on its side the panel with what the
     picked scroll is would lie between the two, over the window's buttons. So while the enchant window is open the backpack is not drawn.
     It is still open: close the enchant window and it is back, the scroll still picked. Nothing is lost meanwhile — the window's head
     says how many scrolls are left, and every piece in its list carries its +N. (Where :has() is not known both are drawn, the enchant
     window over the backpack.) */
  body:has(> .enchant-window) > .bag-window { display: none; }
  .enchant-head, .enchant-row { flex: none; }                        /* (the list gives way, not its rows: a row squeezed lower than its three lines lets them run out of it) */
  body > .ui-window > .ui-banner, body > .ui-window > .ui-button, .travel-destinations > .ui-button { flex-shrink: 0; }   /* when a window is lower than what is in it, the list gives way and scrolls; the title and the buttons keep their height */
  .char-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ui-line) transparent; }
  .char-gear { flex: 0 1 264px; min-height: 0; overflow-y: auto; }   /* the 裝備 page (DS-301): like the 能力 page, it scrolls inside when the window is lower than it */
  .char-head { flex-wrap: wrap; }
  .char-who { flex: 1 1 calc(100% - 78px); }
  .char-stats { margin-top: 0; }
  :where(body > .ui-window, body > .npc-dialog) .ui-button:not(.ui-mini) { height: 46px; }   /* Use, Buy, an answer to someone in town: what a thumb decides with */
  .npc-dialog-options > .ui-button { min-width: 96px; }
  .ui-button.ui-mini { height: 44px; min-width: 46px; }
  .skill-row:not([data-state="locked"]) .skill-head { padding-right: 52px; }   /* the small button is wider here */
  .skill-row:not([data-state="locked"]) .skill-desc, .skill-row:not([data-state="locked"]) .skill-versus { padding-right: 52px; }   /* the button is 44 px tall, taller than the head: the lines under it keep clear of it */
  .char-row { min-height: 44px; }
  .char-stats > .char-row { min-height: 30px; }
  .auto-row { min-height: 42px; }
  .auto-row > .ui-bar { box-sizing: content-box; border: solid transparent; border-width: 12px 0; }   /* like the volume bars */
  /* the settings window (a first arrangement, by the session that made the window; the phone session takes it from here): where the auto-hunt
     window was — upright over the buttons and as wide as the screen, on its side at the top right. Its own limit is written for a desktop
     window, in real pixels: here it is no higher than the room it has, and what is inside (.settings-body) scrolls. */
  .settings-window { max-height: calc(var(--sh) - 12px); }
  .settings-sound > .ui-bar { box-sizing: content-box; border: solid transparent; border-width: 12px 0; }   /* the volume: the bar looks the same, a finger has 42 pixels to land on */
  .settings-foot > #fullscreen-toggle:not([hidden]) { display: flex; }   /* where the browser can go full screen (an iPhone cannot) */
  .settings-body { animation: none; }   /* its footer stays visible; fade the scrolling content above that footer instead */
  .settings-foot { position: sticky; bottom: 0; z-index: 1; flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; background: #fff6dc; }
  .settings-foot > .ui-button { height: auto; min-height: max(46px, calc(30px / var(--m))); font-size: 20px; line-height: 22px; white-space: normal; }
  .settings-foot > #cookie-settings { display: flex; grid-column: 1 / -1; }
  @supports (animation-timeline: scroll()) {
    .settings-foot::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 30px; pointer-events: none; opacity: 0;
      background: linear-gradient(to top, #fff6dc, #fff6dc00); animation: ui-more-below linear both; animation-timeline: scroll(nearest block); }
  }
  .travel-menu { left: 50%; right: auto; bottom: calc(8px * var(--m) + var(--safe-b)); width: min(440px, calc(var(--sw) - 16px)); max-height: calc(var(--sh) - 16px); margin: 0; transform: translateX(-50%) scale(var(--m)); transform-origin: 50% 100%; }
  .name-window { left: 50%; right: auto; top: calc(8% + var(--safe-t)); width: min(380px, calc(var(--sw) - 16px)); margin: 0; transform: translateX(-50%) scale(var(--m)); transform-origin: 50% 0; }   /* near the top: the keyboard takes the lower half */
  .travel-overlay { inset: 0 auto auto 0; width: calc(100% / var(--m)); height: calc(100% / var(--m)); transform: scale(var(--m)); transform-origin: 0 0; }
  .travel-error { inset: auto auto 20% 0; height: auto; transform-origin: 0 100%; }
  .travel-error > .ui-panel { max-width: calc(100% - 24px); text-align: center; }
  /* its button is one line, and the longest it shows — "跟伺服器的連線斷了，按這裡重新連線", seventeen characters — is wider than a phone of 390 px
     or less: the ends of the button were off the screen at 320 and at 390 wide. Here it is no wider than the screen; the line then breaks in
     two — after the comma, not in the middle of a word: word-break: keep-all lets Chinese break only at punctuation (overflow-wrap is for a
     line with none). And it is as high as a window's button on a phone: it is what a thumb has to hit to get back into the game. */
  .travel-error > .ui-button { max-width: calc(100% - 24px); height: auto; min-height: 46px; padding-block: 3px; white-space: normal; word-break: keep-all; overflow-wrap: anywhere; text-align: center; line-height: 1.25; }

  /* the login screen (nothing measures it, so plain zoom does) */
  .login { zoom: var(--m); }
  .login-head { justify-self: stretch; }
  .login-logo { width: min(584px, 100%); max-width: none; height: auto; aspect-ratio: 584 / 124; background-size: 100% 100%; }   /* the whole title, whatever the width */
  .login-card { width: min(420px, 100%); }
  #character-form { width: min(540px, 100%); }
  .login-foot { white-space: nowrap; }
}

/* ---- how much smaller ---- */
@media (max-width: 519.98px) { :root { --m: 0.9; --hot: 1.08; } }
@media (max-width: 429.98px) { :root { --m: 0.8333; --hot: 1.06; } }
@media (max-width: 389.98px) { :root { --m: 0.75; --hot: 1.06; } }
@media (max-width: 349.98px) { :root { --m: 0.7; --hot: 1.03; } }
@media (max-height: 520px) and (min-width: 560px) and (max-height: 449.98px) { :root { --m: 0.9; } }
@media (max-height: 520px) and (min-width: 560px) and (max-width: 924.98px) { :root { --m: 0.9; } }
@media (max-height: 520px) and (min-width: 560px) and (max-height: 409.98px) { :root { --m: 0.8333; } }
@media (max-height: 520px) and (min-width: 560px) and (max-width: 831.98px) { :root { --m: 0.8333; } }
@media (max-height: 520px) and (min-width: 560px) and (max-height: 369.98px) { :root { --m: 0.75; } }
@media (max-height: 520px) and (min-width: 560px) and (max-width: 770.98px) { :root { --m: 0.75; } }
@media (max-height: 520px) and (min-width: 560px) and (max-height: 329.98px) { :root { --m: 0.7; } }
@media (max-height: 520px) and (min-width: 560px) and (max-width: 693.98px) { :root { --m: 0.7; } }
@media (max-height: 520px) and (min-width: 560px) and (max-width: 647.98px) { :root { --m: 0.65; } }
@media (max-height: 520px) and (min-width: 560px) and (max-height: 289.98px) { :root { --m: 0.6; } }
@media (max-height: 520px) and (min-width: 560px) and (max-width: 600.98px) { :root { --m: 0.6; } }

/* ---- upright: the status panel beside the map; the target and the quests under them on the left; the banners, the event, the chat, the buttons and the hot bar stacked at the bottom.
   Both stacks stop short of the middle of the screen, where the player stands. ---- */
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  .hud { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto minmax(0, auto) minmax(0, 1fr) repeat(4, minmax(0, auto)) auto auto; }   /* when the screen is too short for everything at once, the rows that may shrink run into each other; the hot bar stays on the screen */
  .hud-status { grid-area: 1 / 1; }
  .hud-status > .ui-portrait, #status-exp-text { display: none; }    /* the name and the bars take the width (the thin bar still says how far into the level) */
  .hud-mapbox { grid-area: 1 / 2 / 4 / 3; margin: 0 0 6px 6px; }
  .hud-under { grid-area: 2 / 1; }
  .hud-target { grid-area: 3 / 1; width: min(300px, 100%); }
  .hud-quests { grid-area: 5 / 1 / 6 / -1; }   /* under the board (row 4, ui-election.mjs); the spacer row takes the rest, as before */
  .hud-fallen { grid-area: 6 / 1 / 7 / -1; justify-self: center; }
  .hud-notice { grid-area: 7 / 1 / 8 / -1; justify-self: center; }
  .hud-event { grid-area: 8 / 1 / 9 / -1; width: min(300px, 100%); }
  .hud-chat { grid-area: 9 / 1 / 10 / -1; width: min(100%, 440px); }
  .hud-actions { grid-area: 10 / 1 / 11 / -1; justify-self: end; margin-bottom: 8px; }
  .hud-hotbar { grid-area: 11 / 1 / 12 / -1; justify-self: center; }
  .hud[data-chat="open"] .hud-chat { left: 6px; right: 6px; bottom: 56%; max-height: calc(44% - 130px); width: auto; }
  .hud .hud-chat:has(.chat-input:focus) { left: 6px; right: 6px; bottom: 56%; max-height: calc(44% - 130px); width: auto; }   /* under the status panel, in the upper half: the keyboard never covers the line being typed */
  .hud[data-chat="open"] .hud-quests { visibility: hidden; }             /* the open chat lies right over the quests: half a line of them showed under its edge */
  .hud:has(.chat-input:focus) .hud-quests { visibility: hidden; }
  .char-window, .skill-window, .shop-window, .enchant-window, .camp-window { left: calc(6px * var(--m) + var(--safe-l)); top: calc(130px * var(--m) + var(--safe-t)); width: calc(var(--sw) - 12px); max-height: calc(var(--sh) - 136px); }   /* under the status panel, as wide as the screen */
  /* the three a player keeps open while playing end over the row of buttons, on the line of the settings window and the talk panel: a stall with ten
     rows ran to the bottom of the screen, over the buttons and the hot bar (its list scrolls: two or three rows fewer are in sight). Choosing a class
     at the camp is a screen of its own and keeps the whole height. */
  .char-window, .skill-window, .shop-window, .enchant-window { max-height: calc(var(--sh) - 272px); }
  .camp-cards { grid-template-columns: minmax(0, 1fr); }
  /* the backpack: over the buttons (142: the line the settings window and the talk panel end on — at 128 its edge lay 9 px over the top of the
     buttons), and no higher than the other windows begin: under the status panel. It used to be drawn a tenth bigger and to reach the top of the
     screen when a description was long — with a piece of a set picked it lay over the numbers of health and voice and over the whole map, which
     the character, shop and enchant windows never do. Now it is at the scale of the other windows (a slot is 40 px on the Owner's phone, as in
     those windows) and ends where they begin; what it lost in height its slots give up (two rows at least, below). */
  .bag-window { right: calc(6px * var(--m) + var(--safe-r)); bottom: calc(142px * var(--m) + var(--safe-b)); width: min-content; max-height: calc(var(--sh) - 272px); transform: scale(var(--m)); transform-origin: 100% 100%; }
  /* what the picked item is: under the slots, not beside the window. With the tabs and a piece of gear (its numbers, what is worn in that place) the
     backpack is taller than a small phone has room for: the window keeps to its max-height and it is this description that gives way — it scrolls,
     and its row of buttons stays in sight at the bottom of it (on the tip's own paper, tip.png). Without this the buttons ran out of the window's
     bottom and lay over the row of buttons of the HUD. */
  .bag-window > .ui-banner, .bag-tabs, .bag-foot { flex: none; }
  /* and before the description gives way, the slots do: since the backpack holds 200 things they scroll anyway, and with a piece of a set picked
     (its numbers, what is worn, the set's steps and pieces) the description had 260 px on the Owner's phone and half of it was out of sight,
     with nothing to say so. The slots keep two rows at least (and a little of the next); only then does the description scroll. A short
     description leaves the five rows as they are. (The shrink factors: all of what has to be given up comes off the slots until they are at
     their minimum.) */
  .bag-grid { flex: 0 1000 auto; min-height: 124px; }
  .bag-detail { position: static; width: auto; flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; }
  .bag-detail > * { flex: none; }
  .bag-detail > .name-row { position: sticky; bottom: 0; background: #fff6dc; box-shadow: 0 3px 0 #fff6dc; }   /* (the shadow: drawn at a fraction of its size the row ends a part of a pixel above the clip, and a line of the text scrolled under it showed there) */
  .settings-window, .npc-dialog { left: calc(6px * var(--m) + var(--safe-l)); right: auto; bottom: calc(142px * var(--m) + var(--safe-b)); width: calc(var(--sw) - 12px); margin: 0; transform-origin: 0 100%; }
  .settings-window { max-height: calc(var(--sh) - 148px); }             /* from over the buttons up to the top of the screen */
  /* with a mount on, the row of buttons is a row of 上車／下車 higher, and the windows that end over it end that much higher: a mount bought or put on
     with the shop or the backpack open is ridden without closing them. (214: 上車 reaches 209 over the bottom of the Owner's phone — the hot bar, 8,
     a row of the account's buttons, 58 high in ui-entry.mjs, 6, and its own 58 — and 211 where the hot bar is drawn bigger.) */
  .hud:has(#ride:not([hidden])) ~ :is(.char-window, .skill-window, .shop-window, .enchant-window, .bag-window, .team-window) { max-height: calc(var(--sh) - 344px); }
  .hud:has(#ride:not([hidden])) ~ :is(.bag-window, .settings-window, .npc-dialog) { bottom: calc(214px * var(--m) + var(--safe-b)); }
  .hud:has(#ride:not([hidden])) ~ .settings-window { max-height: calc(var(--sh) - 220px); }
}

/* ---- on its side: the status panel, the target and the map across the top; the quests under the status panel, the event under the map; the hot bar and the buttons in one row at the bottom, the chat over the hot bar ---- */
@media (max-height: 520px) and (min-width: 560px) {
  :root { --hot: 1.08; }
  .hud { grid-template-columns: 400px minmax(0, 1fr) auto; grid-template-rows: auto auto repeat(3, minmax(0, auto)) minmax(0, 1fr) minmax(0, auto) auto; }
  .hud-status { grid-area: 1 / 1; }
  .hud-target { grid-area: 1 / 2 / 2 / -1; width: 280px; margin-left: 8px; }
  .hud-under { grid-area: 2 / 1; }
  .hud-notice { grid-area: 3 / 1 / 4 / 3; }
  .hud-fallen { grid-area: 4 / 1 / 5 / 3; }
  .hud-quests { grid-area: 5 / 1; }
  .hud-quest:nth-child(n+3) { display: none; }
  /* DS-241 (2026-10-27): every player has the peace row under the status panel; on a screen 360 high or lower (740 x 304, 844 x 340) two quests
     under it reached the chat. One quest there; the quest window has them all. */
  @media (max-height: 360px) { .hud-quest:nth-child(n+2) { display: none; } }
  .hud-mapbox { position: absolute; right: 6px; top: 6px; }
  .hud-event { position: absolute; left: auto; right: 6px; top: 180px; width: 280px; }
  .hud-chat { grid-area: 7 / 1 / 8 / 3; width: min(100%, 520px); }
  .chat-log { max-height: 84px; }                                    /* three lines: the screen is low */
  /* DS-241 (2026-10-27): on a screen 320 high or lower (740 x 304) the fallen banner, with the peace row and a notice above it, lay under the
     chat's first line. While the player is down the chat keeps two lines there (opening it shows them all). */
  @media (max-height: 320px) { .hud:has(.hud-fallen:not([hidden])) .chat-log { max-height: 56px; } }
  .hud-hotbar { grid-area: 8 / 1 / 9 / 3; justify-self: center; align-self: end; }
  .hud-actions { grid-area: 8 / 3; align-self: end; max-width: 444px; }   /* seven buttons in the row; an eighth starts a row above */
  .hud[data-chat="open"] .hud-chat { left: 6px; bottom: 60%; max-height: calc(40% - 6px); width: min(560px, calc(100% - 200px)); }
  .hud .hud-chat:has(.chat-input:focus) { left: 6px; bottom: 60%; max-height: calc(40% - 6px); width: min(560px, calc(100% - 200px)); }   /* over the status panel while typing: the keyboard leaves only the top of the screen */
  .hud[data-chat="open"] .hud-chat .chat-log { max-height: none; }
  .hud .hud-chat:has(.chat-input:focus) .chat-log { max-height: none; }
  .char-window, .skill-window, .shop-window, .enchant-window, .camp-window { left: calc(6px * var(--m) + var(--safe-l)); top: calc(6px * var(--m) + var(--safe-t)); max-height: calc(var(--sh) - 96px); }   /* from the top, down to the hot bar */
  .camp-window { width: min(620px, calc(var(--sw) - 12px)); }
  /* the enchant window is wider here than the 448 of a desktop: the screen is low — two rows and a half are in sight — and in a column of
     260 px what a piece gives ("身・防禦 +3、血量上限 +34、閃避 +2") took three lines. The backpack is not drawn meanwhile, so the room is there. */
  .enchant-window { width: min(600px, calc(var(--sw) - 12px)); }
  .bag-window, .settings-window { right: calc(6px * var(--m) + var(--safe-r)); top: calc(6px * var(--m) + var(--safe-t)); bottom: auto; max-height: calc(var(--sh) - 96px); transform-origin: 100% 0; }
  /* the backpack on a low screen: with the row of tabs it was 11 px taller than 844 x 340 has room for and the coins were cut off. The tabs are a
     little lower here than the 46 a window's buttons get on a phone, the rows a little closer; on a screen lower still the slots scroll and the
     coins stay. What the picked item is stays beside the window (the desktop's rule), no taller than the window, its buttons in sight. */
  .bag-window { gap: 4px; max-height: calc(var(--sh) - 80px); }      /* (down to just over the row of buttons, which is lower than the hot bar's row the other windows stop at: sixteen pixels the four rows of slots need at 844 x 340) */
  .bag-window > .ui-banner, .bag-tabs, .bag-foot { flex: none; }
  .bag-tabs > .ui-button { height: 43px; }                           /* (43: still 30 px for a thumb where the screen is drawn at 0.7) */
  .bag-foot > .ui-button, .bag-sell-row > .ui-button { min-height: 43px; }
  .bag-grid { flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; }
  .bag-detail { max-height: 100%; overflow-y: auto; scrollbar-width: none; }
  .bag-detail > * { flex: none; }
  .bag-detail > .name-row, .char-tip > .name-row { position: sticky; bottom: 0; background: #fff6dc; box-shadow: 0 3px 0 #fff6dc; }
  .char-tip > * { flex: none; }
  /* the settings in one column, as upright (DS-316). Before its pages it was two columns 712 wide — sound and the way out of the game on
     the left, automatic hunting on the right — so that all of it showed at once on a screen 340 high; now the way out is on the first
     page, and a page higher than the screen scrolls inside the window, under its tabs. 400 wide is what an account with the test tools
     had then (their strip had the left of the screen), and it leaves the left of the game in sight. */
  .settings-window { width: min(400px, calc(var(--sw) - 12px)); }
  .settings-auto { gap: 4px; }                                        /* (rows a little closer than upright: less of the page below the fold at 340 high) */
  .settings-auto .auto-switches { gap: 14px; }                        /* the two switches a little closer, so that the longest label fits its button in 400: 「跳過 BOSS：開」 ran out of it in the real game */
  .npc-dialog { left: calc(6px * var(--m) + var(--safe-l)); right: auto; bottom: calc(82px * var(--m) + var(--safe-b)); width: min(600px, calc(var(--sw) - 12px)); margin: 0; transform-origin: 0 100%; }
  /* with a mount on: the row stays as wide as the account's eight (ui-entry.mjs: seven of 50 and 自動, 2 apart) and 上車／下車 goes over them — at 520
     the hot bar ran off the two narrowest screens. Its row takes no room from the rows of the grid (57 high in ui-entry.mjs, and 6): it rises into the
     empty column over the buttons, under the election's board — taller, it pushed the chat over the quests at 740 x 304 and 932 x 430. And the two
     windows on the right end over it (it reaches 126 over the bottom at 844 x 340). */
  .hud .hud-actions:has(> #ride:not([hidden])) { max-width: calc(7 * 50px + 88px + 7 * 2px); margin-top: calc(-57px - 6px); }
  .hud:has(#ride:not([hidden])) ~ :is(.bag-window, .settings-window) { max-height: calc(var(--sh) - 140px); }
  .login { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); align-items: center; column-gap: 16px; padding: 12px 16px 40px; }   /* the title on the left, the form on the right */
  .login-head { grid-area: 1 / 1; }
  .login-card { grid-area: 1 / 2; align-self: start; }
}

@media (max-width: 760px), (max-height: 520px) {
  .map-window { left: var(--safe-l); top: var(--safe-t); width: var(--sw); height: var(--sh); max-width: var(--sw); max-height: var(--sh); transform: scale(var(--m)); transform-origin: 0 0; }
  .map-row, .map-filters > .ui-button, .map-tools > .ui-button { min-height: calc(30px / var(--m)); }
  .map-tools > .ui-square { min-width: calc(30px / var(--m)); }
  .map-pin::after { content: ''; position: absolute; width: max(26px, calc(30px / var(--m))); height: max(32px, calc(30px / var(--m))); left: 50%; top: 50%; transform: translate(-50%, -50%); }
  .map-tools { bottom: 10px; left: 10px; }
  .hud-walk { width: 168px; }
}
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  .hud-walk { grid-area: 1 / 2 / 4 / 3; margin: 0 0 6px 6px; }
  .map-body { flex-direction: column; }
  .map-view { flex: 0 1 calc(55dvh / var(--m)); }
  .map-side { width: 100%; flex: 1; min-height: 0; }
  .map-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 520px) and (min-width: 560px) {
  .hud-walk { position: absolute; right: 10px; top: 139px; }
  .map-side { width: 300px; }
}

@media (max-width: 760px), (max-height: 520px) {
  .party-window { left: var(--safe-l); top: var(--safe-t); width: var(--sw); height: var(--sh); max-width: none; max-height: none; transform: scale(var(--m)); transform-origin: 0 0; }
  /* Round upwards before scale: layout quantization must not turn the 30/46 CSS-pixel minimum into 29.99/45.99. */
  .party-window .ui-button { min-height: round(up, calc(30px / var(--m)), 1px); min-width: round(up, calc(30px / var(--m)), 1px); }
  .party-window .ui-close { position: relative; flex: none; }
  .party-window > .ui-banner > .ui-close { position: absolute; }
  .party-window .party-tabs > .ui-button { height: round(up, calc(30px / var(--m)), 1px); }
  .party-window .party-foot > .ui-button { height: auto; min-height: round(up, calc(46px / var(--m)), 1px); }
  .party-window .party-leave-actions > .ui-button { height: auto; min-height: round(up, calc(46px / var(--m)), 1px); }
  .party-window .party-emblem-controls > .ui-button, .party-window .party-emblem-actions > .ui-button, .party-window .party-review-row > .ui-button { height: auto; min-height: round(up, calc(46px / var(--m)), 1px); }
  .party-window .party-war-actions > .ui-button, .party-window .party-war-target > .ui-button { min-height: round(up, calc(46px / var(--m)), 1px); }
  .party-window .party-war-strip { min-height: round(up, calc(46px / var(--m)), 1px); }
  .party-skill .skill-head > .ui-button { min-height: round(up, calc(30px / var(--m)), 1px); }
  .party-card { max-height: calc((100dvh - 24px) / var(--m)); overflow-y: auto; }
  .party-card-actions > .ui-button { height: round(up, calc(46px / var(--m)), 1px); }
  .party-emblems > .party-emblem::after { content: ''; position: absolute; inset: -4px; }
  .party-return { position: fixed; left: var(--safe-l); right: auto; bottom: calc(348px * var(--m) + var(--safe-b)); transform: scale(var(--m)); transform-origin: 0 100%; height: round(up, calc(30px / var(--m)), 1px); }
  body:has(.hud[data-chat="open"]) .party-return { visibility: hidden; }
}
/* the narrow phones: the rally card wraps to more lines and stands higher, so the button goes higher too */
@media (max-width: 390px) {
  .party-return { bottom: calc(420px * var(--m) + var(--safe-b)); }
}
@media (max-height: 520px) and (min-width: 560px) {
  .party-return { top: calc(50% - 15px); bottom: auto; left: var(--safe-l); right: auto; transform: scale(var(--m)); transform-origin: 0 0; height: round(up, calc(30px / var(--m)), 1px); }
}
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  /* a chair has five tabs: on the narrowest upright phones they fit the row only with the gaps and the side padding taken in */
  .party-window .party-tabs { gap: 4px; }
  .party-window .party-tabs > .ui-button { padding-left: 2px; padding-right: 2px; }
  .party-member-head { grid-template-columns: 16px minmax(0, 1fr) auto; }
  .party-member-name { grid-column: 2 / -1; }
  .party-member-class { grid-column: 2; }
  .party-member-status { grid-column: 3; }
  .party-home-head .party-count { flex-basis: 100%; text-align: right; }
  .party-emblems { grid-template-columns: repeat(4, 48px); }
  .party-entry { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; }
  .party-entry-count { grid-column: 2; }
  .party-entry > .ui-button { grid-column: 3; }
  .party-card { left: var(--safe-l); right: auto; top: auto; bottom: calc(142px * var(--m) + var(--safe-b)); width: var(--sw); transform: scale(var(--m)); transform-origin: 0 100%; }
}
@media (max-height: 520px) and (min-width: 560px) {
  .party-card { top: 12px; bottom: auto; width: min(600px, calc(var(--sw) - 24px)); transform: translateX(-50%) scale(var(--m)); transform-origin: 50% 0; }
}

@media (max-width: 760px), (max-height: 520px) {
  .player-menu { transform: scale(var(--m)); transform-origin: 0 0; }
  .player-menu { max-width: calc(100vw / var(--m)); max-height: calc(100dvh / var(--m)); }
  .player-menu > .ui-button { height: round(up, calc(30px / var(--m)), 1px); }
  .player-menu > .player-menu-war { height: auto; min-height: round(up, calc(30px / var(--m)), 1px); }
}

/* DS-113: keep the seven/eight-button phone row on one line when a social entry is visible. */
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  .hud-actions:has(> #team-button:not([hidden])), .hud-actions:has(> #party-button:not([hidden])) { gap: 2px; width: max-content; flex-wrap: nowrap; }
  .hud-actions:has(> #team-button:not([hidden])) > .ui-button, .hud-actions:has(> #party-button:not([hidden])) > .ui-button { min-width: 48px; height: 58px; }
  .hud-actions:has(> #team-button:not([hidden])) > .ui-button.ui-square, .hud-actions:has(> #party-button:not([hidden])) > .ui-button.ui-square { width: 48px; }
}
@media (max-height: 520px) and (min-width: 560px) {
  .hud-actions:has(> #team-button:not([hidden])), .hud-actions:has(> #party-button:not([hidden])) { gap: 2px; width: max-content; max-width: 520px; flex-wrap: nowrap; }
  .hud-actions:has(> #team-button:not([hidden])) > .ui-button, .hud-actions:has(> #party-button:not([hidden])) > .ui-button { min-width: 50px; height: 57px; }
  .hud-actions:has(> #team-button:not([hidden])) > .ui-button.ui-square, .hud-actions:has(> #party-button:not([hidden])) > .ui-button.ui-square { width: 50px; }
}

/* DS-140: the switch and its states share the row under the status panel, and a line that does not fit goes down a row */
@media (max-width: 760px), (max-height: 520px) {
  .hud-under { flex-wrap: wrap; row-gap: 6px; }
  .hud-pvp > .pvp-mode { height: round(up, calc(36px / var(--m)), 1px); min-width: round(up, calc(120px / var(--m)), 1px); }
  .hud-pvp > .pvp-mode .ui-glyph { vertical-align: -2px; }
  .hud-target > .target-party { display: none; }   /* as the name: a phone shows the states of the target, not the target */
  .char-stats[data-poll="true"] { margin-top: 0; gap: 4px; }   /* the two columns scroll here: the rows keep the room they have without the poll */
  .char-poll-note { display: block; }                           /* no tooltip under a thumb: the note stands under its row */
}
/* Upright and narrower than 450: the switch with its safe line beside it is wider than the column left of the minimap, and the line ran under the
   map (350 at first; DS-241, 2026-10-27: the long line of a map with no fighting, where a new player starts, reached the minimap's bottom edge up to
   430 wide, the Owner's 420 x 800 among them). The line stands under the switch there. Not by a width in per cent: the row is capped to a few pixels
   while the debate's shelf shows, and a piece held to 100% of it is crushed. Phones on their side are 560 wide or more and keep the line beside it. */
@media (max-width: 449.98px) {
  .hud-pvp { flex-direction: column; align-items: flex-start; gap: 2px; }
}
/* DS-143: the offer and the yield button, and the label between them, are the height of the switch */
@media (max-width: 760px), (max-height: 520px) {
  .hud-debate > .debate-offer, .hud-debate > .debate-yield, .hud-debate > .debate-label { height: round(up, calc(36px / var(--m)), 1px); }
}
/* DS-143: with a party card on the same screen the debate card steps aside by one card: above it upright, under it on its side (the
   party card's place is ui-party.mjs's, in the same two queries). The selector is the desktop's, so this rule wins by coming later.
   212 and 223 are the tallest party card measured on the phone sizes (unscaled, at 320 x 568 upright and 568 x 320 on its side); a
   shorter card leaves a wider gap, a taller one would reach the debate card. */
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card { top: auto; bottom: calc((142px + 212px + 8px) * var(--m) + var(--safe-b)); }
}
/* On its side there is no room for two whole cards over the hot bar: a 740 x 304 screen is 434 of the interface's pixels high, the party
   card takes 223 of them and the hot bar the last 80. So the debate card under a party card is one row there — the megaphone and who
   asks, the seconds, the two buttons — without its line of detail and without its bar (the seconds stay). */
@media (max-height: 520px) and (min-width: 560px) {
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card { top: calc(12px + (223px + 8px) * var(--m)); width: min(720px, calc(var(--sw) - 24px)); flex-direction: row; align-items: center; gap: 12px; }
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card > .party-card-detail,
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card > .party-countdown > .ui-bar { display: none; }
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card > .party-card-head { flex: 1; min-width: 0; }
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card > .party-countdown,
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])) > .debate-card > .party-card-actions { flex: none; }
}
/* An invitation card lies over the offer to debate where the two meet: on its side always (the card is across the top, the offer on the row under the
   status panel), upright when two cards are stacked (on a short screen the upper one reaches the row). A button half under a card is pressed by mistake
   or not at all, so the offer is not shown until the card is answered or runs out. It keeps its place in the row, so nothing moves; the switch, the
   wait for an answer and a debate under way stay as they are. */
@media (max-height: 520px) and (min-width: 560px) {
  :is(body, .stage):has(> .party-card:not([hidden])) .hud-debate[data-state="offer"] { visibility: hidden; }
}
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  :is(body, .stage):has(> .party-card:not(.debate-card):not([hidden])):has(> .debate-card:not([hidden])) .hud-debate[data-state="offer"] { visibility: hidden; }
}
/* DS-143 (on its side): the shelf says its short words, 邀辯論 / 等回覆 18 / 3 / 2:45, which the row of the switch has the room for. The long words stay in the
   element for a screen reader: font-size 0 hides them, and ::after draws the short ones at the phone's 24. The countdown and the time left get the
   megaphone before the figure, so that a bare number still reads as a debate. The switch goes back to its own width, not the phone's minimum. */
@media (max-height: 520px) and (min-width: 560px) {
  .hud-debate > .debate-offer, .hud-debate > .debate-label { font-size: 0; }
  .hud-debate > .debate-offer::after, .hud-debate > .debate-label::after { content: attr(data-short); font-size: 24px; }
  .hud-debate > .debate-label { padding: 0 8px; }   /* 10 on the desktop: the row with the status icons is 400 wide here, and the 4 pixels it needs are these */
  .hud-debate[data-state="countdown"] > .debate-label::before, .hud-debate[data-state="on"] > .debate-label::before { content: ''; display: inline-block; flex: none; width: 18px; height: 14px; margin-right: 6px;
    background: currentColor; -webkit-mask: url(glyph-megaphone.png) center / 100% 100% no-repeat; mask: url(glyph-megaphone.png) center / 100% 100% no-repeat; }   /* the megaphone's size as make-ui.mjs draws it (9 × 7 art pixels at 2) */
  .hud-under:has(> .hud-debate:not([hidden])) > .hud-pvp > .pvp-mode { min-width: 0; }
  /* the desktop's cap on the row (336 short of the screen) is 64 of the interface's pixels in this 400 column: the row wrapped. The row is as wide as its column here */
  .hud-under:has(> .hud-debate:not([hidden])) { max-width: none; }
  /* one line: the switch, the shelf and the status icons share their top (the icons are taller than the row and would sit lower if centred) */
  .hud-under:has(> .hud-debate:not([hidden])) { align-items: flex-start; }
}

@media (max-width: 760px), (max-height: 520px) {
  .hud .hud-team { pointer-events: none; }
  .hud-team .team-row { pointer-events: none; cursor: default; }
  .team-window, .team-card { transform: scale(var(--m)); transform-origin: 0 0; }
  .team-window .team-list { flex: 1; min-height: 0; }
  .team-window .ui-button { height: round(up, calc(46px / var(--m)), 1px); }
  .team-controls > .ui-button { height: round(up, calc(30px / var(--m)), 1px); }
  .team-card-actions > .ui-button { height: round(up, calc(46px / var(--m)), 1px); }
  /* DS-190 (round 2): on a phone, either way up, the faces are a row of small ones at the far left of the row under the status panel. The room they
     take is the first thing in that row: a placeholder the width of the faces (n faces of 24, n - 1 gaps of 4) at the top of the row, and the row's
     own gap sets the rest apart from it. The switch to fighting and the others follow it, and what does not fit goes down a line. */
  .hud[data-team] .hud-team { position: static; grid-area: 2 / 1; justify-self: start; align-self: start; width: max-content; height: 36px; flex-direction: row; gap: 4px; }
  .hud-team .team-row { display: block; width: 24px; height: 36px; padding: 0; border: 0; border-image: none; }
  .hud-team .team-row .ui-portrait { width: 24px; height: 24px; }
  .hud-team .team-head, .hud-team .team-state, .hud-team .team-mp { display: none; }
  .hud-team .team-row .team-bars { display: block; margin-top: 2px; }
  .hud-team .team-row .team-hp { width: 24px; }
  .hud-team .team-row[data-state="away"] .team-hp { opacity: 0.35; }
  .hud-team .team-row[data-leader="true"]::after { content: ''; position: absolute; left: -2px; top: -2px; width: 12px; height: 10px; background: #ffd43a; mask: url(glyph-crown.png) center / 100% 100% no-repeat; }
  .hud[data-team] .hud-under { grid-area: 2 / 1; justify-self: stretch; }   /* the row is as wide as its column (the grid's justify-items: start would size it by its content); the faces lie over its first piece */
  .hud[data-team="1"] .hud-under::before { content: ''; flex: none; align-self: flex-start; order: -2; width: 24px; height: 36px; }
  .hud[data-team="2"] .hud-under::before { content: ''; flex: none; align-self: flex-start; order: -2; width: 52px; height: 36px; }
  .hud[data-team="3"] .hud-under::before { content: ''; flex: none; align-self: flex-start; order: -2; width: 80px; height: 36px; }
  .hud[data-team="4"] .hud-under::before { content: ''; flex: none; align-self: flex-start; order: -2; width: 108px; height: 36px; }
}
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  .team-window { left: calc(6px * var(--m) + var(--safe-l)); top: calc(130px * var(--m) + var(--safe-t)); width: calc(var(--sw) - 12px); max-height: calc(var(--sh) - 272px); }
  .team-card { left: calc(6px * var(--m) + var(--safe-l)); top: auto; bottom: calc(142px * var(--m) + var(--safe-b)); width: calc(var(--sw) - 12px); transform-origin: 0 100%; }
}
@media (max-height: 520px) and (min-width: 560px) {
  .hud[data-team] .hud-event { top: 180px; }   /* the desktop's rule for the events under a team (teamLayout) would put the card on the actions row: it stays where it is without one */
  /* DS-190 (round 2): the row is 400 wide here. With a debate under way the faces (108), the switch (105) and the shelf (195) with their gaps do not
     share its first line, and the states and the boat's chip went down to a third line under the chat. So the shelf and the states follow the faces
     on the first line, and the switch and the boat's chip are the second. Without a debate the row keeps its order. */
  .hud[data-team] .hud-under:has(> .hud-debate:not([hidden])) > .hud-debate,
  .hud[data-team] .hud-under:has(> .hud-debate:not([hidden])) > #hud-buffs { order: -1; }
  .team-window { left: calc(6px * var(--m) + var(--safe-l)); top: calc(6px * var(--m) + var(--safe-t)); max-height: calc(var(--sh) - 96px); }
  .team-card { left: 50%; top: calc(12px * var(--m) + var(--safe-t)); width: 420px; transform: translateX(-50%) scale(var(--m)); transform-origin: 50% 0; }
}

/* DS-175: the sailing chip on a phone: no wider than the screen, its height that of its line, and the countdown in the one line (cut with an ellipsis if the row is full) */
@media (max-width: 760px), (max-height: 520px) {
  .hud-ferry { max-width: 100%; height: auto; }
  .hud-ferry > .hud-ferry-text > .ferry-short { display: block; overflow: hidden; text-overflow: ellipsis; }
}
/* With the debate's shelf on the row (ui-pvp.mjs) the row is capped 336 short of the screen; upright that leaves a few pixels, the switch and the
   shelf overflow it and each takes a row of its own, and a chip held to 100% of the row was a stub with no text. The chip keeps its own width
   there and takes a row as they do (it is narrower than the narrowest phone, so nothing is cut). */
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  .hud-under:has(> .hud-debate:not([hidden])) > .hud-ferry { max-width: none; }
}

/* DS-188: the election on a phone */
@media (max-width: 760px), (max-height: 520px) {
  .hud-election, .hud-cast { pointer-events: none; }
  .hud-cast { width: min(260px, calc(var(--sw) - 24px)); }
  /* the plant button: as tall as a thumb wants (46 on the screen, whatever the scale); the line under it wraps */
  .hud-plant { pointer-events: none; }
  .hud-plant-button { pointer-events: auto; height: round(up, calc(46px / var(--m)), 1px); }
}
@media (max-width: 760px) and (min-height: 520.02px), (max-width: 559.98px) {
  .hud-plant { bottom: 290px; width: min(260px, calc(var(--sw) - 24px)); }   /* where the cast bar is: over the chat */
  .hud-election { position: static; grid-area: 4 / 1; align-self: start;   /* the board is above the quests (ui-mobile.mjs puts those in the row under it) */ justify-self: start; width: min(300px, 100%); margin: 0 0 6px; padding: 2px 4px; gap: 2px; border: 2px solid var(--ui-line); border-image: none; background: #10121ae6; background-clip: padding-box; }
  .hud-election .election-board-head { font-size: 12px; line-height: 14px; }
  .hud-election .election-sides { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
  /* (gap is set whole: the desktop's side has a gap of 8 between its rows, which would put 8 px between these two) */
  .hud-election .election-side { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; grid-template-rows: 18px 12px; gap: 0 3px; align-items: center; height: auto; min-width: 0; padding: 0 2px; border: 0; outline: 2px solid transparent; outline-offset: -2px; }
  .hud-election .election-side[data-mine="true"] { outline-color: var(--ui-title); }
  .hud-election .election-side > .party-emblem { grid-column: 1; grid-row: 1; width: 18px; height: 18px; border-width: 1px; }
  .hud-election .election-side > .party-emblem > .ui-icon { transform: scale(0.5); }
  .hud-election .election-side-name { grid-column: 2 / 4; grid-row: 1; min-width: 0; font-size: 10px; line-height: 12px; }
  .hud-election .election-side-flag { grid-column: 2; grid-row: 2; justify-self: end; width: 9px; height: 12px; }   /* before the votes, at their left */
  .hud-election .election-side-votes { grid-column: 3; grid-row: 2; justify-self: end; font-size: 12px; line-height: 12px; }
  .hud-election .election-role, .hud-election .election-board-more { font-size: 10px; line-height: 12px; }
  .hud-cast { bottom: 290px; }   /* above the chat log (up to 112 high) that stands over the buttons and the hot bar */
}
@media (max-height: 520px) and (min-width: 560px) {
  /* on its side the screen is 304 to 360 high: the board is one row of six (the emblem over the votes; no names, no line of the role), 44 high at most */
  /* (the map's box ends at about 160 on this screen; the event's line, when there is one, is at 180 and about 34 high: the board goes under it) */
  .hud-election { position: absolute; grid-area: auto; right: 6px; top: 228px; width: 340px;   /* (grid-area: auto: the desktop's grid row would make top count from that row, not from the HUD) */ margin: 0; padding: 0 4px; gap: 0; border: 2px solid var(--ui-line); border-image: none; background: #10121ae6; background-clip: padding-box; }
  .hud-election .election-board-head { font-size: 12px; line-height: 14px; }
  .hud-election .election-sides { display: flex; flex-direction: row; gap: 2px; }
  .hud-election .election-side { flex: 1 1 0; display: grid; grid-template-columns: auto auto; grid-template-rows: 14px 12px; gap: 0 2px; justify-content: center; align-items: center; height: 26px; min-width: 0; padding: 0; border: 0; outline: 2px solid transparent; outline-offset: -2px; }
  .hud-election .election-side[data-mine="true"] { outline-color: var(--ui-title); }
  .hud-election .election-side > .party-emblem { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: 14px; height: 14px; border-width: 1px; }
  .hud-election .election-side > .party-emblem > .ui-icon { transform: scale(0.4); }
  .hud-election .election-side-name { display: none; }
  .hud-election .election-side-flag { grid-column: 1; grid-row: 2; width: 8px; height: 12px; }
  .hud-election .election-side-votes { grid-column: 2; grid-row: 2; font-size: 12px; line-height: 12px; }
  .hud-election .election-role { display: none; }
  /* on its side the bar is one line, held right under the board (the same width, the same right edge): the words, the bar, the seconds; no line of
     advice. It is out of the middle of the screen, where the player stands, and over the right of the screen, clear of the buttons and the hot bar */
  .hud-cast { left: auto; right: 6px; top: 276px; bottom: auto; transform: none; width: 340px; padding: 2px 4px; display: flex; align-items: center; gap: 8px; }
  .hud-cast > .hud-cast-head { flex: none; gap: 6px; }
  .hud-cast > .ui-bar { flex: 1 1 0; min-width: 0; margin: 0; }
  .hud-cast > .hud-cast-hint { display: none; }
  /* the plant button on its side: where the cast bar is (under the board, on the right), as wide as the bar; the line under it wraps */
  .hud-plant { left: auto; right: 6px; top: 276px; bottom: auto; transform: none; width: 260px; align-items: flex-end; }   /* (the line under it on one row: two would reach the buttons on the lowest screen) */
}
