/* ==========================================================================
   gloop.live mobile dock + touch polish. Loaded after gloop.css.
   - Phones, and short landscape: the land is the only flexible row, so the
     top bar stays one line and the dock stays two (speed/zoom, then actions).
     Extra icon buttons get their own scrolling line only when some exist.
     Wrapping those rows was leaving a thin strip of land.
   - Touch/narrow: 44px targets, safe-area padding, pressed feedback.
   - #hud-extras: shared slot in the dock for small icon buttons added by other
     scripts (mute, bestiary, boat, build...). Append <button> elements into it.
   Desktop (wide screen + fine pointer) is unchanged; #hud-extras is hidden
   while empty.
   ========================================================================== */

/* Extras slot. Desktop: neutral container only (buttons keep their own
   styles; desktop dock layout is Bob's). Hidden until someone appends. */
.hud-extras { display: flex; align-items: center; gap: 0.35rem; }
.hud-extras:empty { display: none; }
/* touch-only extras (map / trophies from js/mobile.js) */
.hud-extras .mob-only { display: none; }
@media (pointer: coarse) {
  .hud-extras .mob-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.6rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    border-radius: 9px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
    border: 1px solid rgba(236, 230, 218, 0.12);
    cursor: pointer;
  }
  .mob-ico { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
}

/* Narrow: wrap everything in the dock; nothing may push past the viewport. */
@media (max-width: 900px) {
  .dock { flex-wrap: wrap; row-gap: 0.45rem; column-gap: 0.6rem; overflow-x: hidden; }
  .acts { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; }
  .acts button { flex: 1 1 auto; min-width: 0; }
  .hud-extras { flex: 0 1 auto; flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .hud-extras button { min-width: 0; max-width: 100%; }
}

/* Phones, and landscape phones (short and not a desktop window): one-line
   chrome. Rows scroll inside themselves instead of stacking or widening the page. */
@media (max-width: 560px), (max-width: 900px) and (max-height: 520px) {
  html, body { min-width: 0; max-width: 100%; }
  .stage { height: 100vh; height: 100dvh; min-width: 0; max-width: 100%; }
  .stage > * { min-width: 0; max-width: 100%; }

  .topbar {
    flex-wrap: nowrap;
    gap: 0.4rem;
    min-width: 0;
    padding: 0.35rem 0.7rem;
  }
  .mark { flex: 0 0 auto; }
  .vitals {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 0.3rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x;
  }
  .vitals::-webkit-scrollbar { display: none; }

  /* Four need meters on one line. The track shrinks; the word does not. */
  .needs {
    flex-wrap: nowrap;
    min-width: 0;
    gap: 0.35rem 0.45rem;
    padding: 0.28rem 0.65rem 0.32rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .needs::-webkit-scrollbar { display: none; }
  .needs span { flex: 1 1 auto; min-width: max-content; gap: 0.28rem; }
  .needs i { width: 2.4rem; flex: 0 0 2.4rem; min-width: 2.4rem; max-width: 2.8rem; }
  .pack:empty { display: none; }

  .dock {
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    row-gap: 0.3rem;
    column-gap: 0.45rem;
    padding: 0.35rem max(0.55rem, env(safe-area-inset-right)) calc(0.35rem + env(safe-area-inset-bottom)) max(0.55rem, env(safe-area-inset-left));
  }
  .speed {
    flex: 1 1 5.5rem;
    order: 1;
    min-width: 5.5rem;
    gap: 0.35rem;
    white-space: nowrap;
  }
  .speed input[type="range"] { flex: 1 1 auto; width: auto; min-width: 2.2rem; }
  .speed span { min-width: 2rem; }
  .zoom {
    flex: 0 1 auto;
    order: 2;
    min-width: 0;
    /* leave the speed slider a usable track; zoom scrolls only if the row is shorter than that */
    max-width: calc(100% - 6.2rem);
    gap: 0.2rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x;
  }
  .zoom::-webkit-scrollbar { display: none; }
  .zoom span { min-width: 2.2rem; padding-left: 0.15rem; padding-right: 0.15rem; }
  .zoom #zoom-fit, .zoom #cam-roam { padding-left: 0.35rem; padding-right: 0.35rem; }
  .acts {
    flex: 1 1 100%;
    order: 4;
    min-width: 0;
    max-width: 100%;
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    touch-action: pan-x;
  }
  .acts::-webkit-scrollbar { display: none; }
  .acts button {
    flex: 0 0 auto;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    letter-spacing: 0.03em;
    scroll-snap-align: start;
  }
  /* clock/weather/action are already in the topbar chips; give the land the room */
  .hint { display: none; }
  /* icon-first on phones: drop text labels, keep the aria-label */
  .hud-extras .mob-icon-btn { padding: 0; width: 44px; }
  .hud-extras .mob-icon-btn .mob-txt { display: none; }
  /* extras: one row, and only when a script has put a button in it.
     More buttons than fit scroll sideways instead of widening the page. */
  .dock .hud-extras {
    flex: 1 1 auto;
    order: 3;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 0.3rem;
    padding: 3px 0; /* room for the bestiary 'new' dot */
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    touch-action: pan-x;
  }
  .dock .hud-extras:empty { display: none; }
  .dock .hud-extras::-webkit-scrollbar { display: none; }
  .dock .hud-extras > * { flex: 0 0 auto; scroll-snap-align: start; }
}
/* Very narrow phones: the percent takes the last of the row, so Follow was
   clipped. Pinch and the + / − buttons still change the zoom. */
@media (max-width: 340px) {
  #zoom-label { display: none; }
  .needs i { width: 1.5rem; flex-basis: 1.5rem; min-width: 1.5rem; }
}

/* Touch-size targets: >= 44x44 CSS px for every dock/HUD button. */
@media (max-width: 900px) and (pointer: coarse), (max-width: 560px) {
  .acts button, .zoom button, .hud-extras button { min-height: 44px; min-width: 44px; }
  .dock .hud-extras button { min-height: 44px; min-width: 44px; } /* beats per-button min-widths */
  .speed input[type="range"] { height: 44px; margin: 0; }
  .gk-hint { width: 44px; height: 44px; }
}

/* Pressed feedback (touch only). js/mobile.js adds .pressed on pointerdown. */
@media (pointer: coarse) {
  .acts button, .zoom button, .hud-extras button, .gk-hint {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .acts button.pressed, .zoom button.pressed, .hud-extras button.pressed, .gk-hint.pressed,
  .acts button:active, .zoom button:active, .hud-extras button:active {
    transform: scale(0.94);
    opacity: 0.8;
    border-color: rgba(185, 245, 180, 0.7);
    color: var(--glow);
    background: linear-gradient(180deg, rgba(185, 245, 180, 0.18), rgba(185, 245, 180, 0.06));
    transition-duration: 0.05s;
  }
}
/* reduced motion: html.gl-rm is set by js/mobile.js from GloopLand.reducedMotion()
   (falls back to prefers-reduced-motion) */
@media (pointer: coarse) {
  html.gl-rm .acts button.pressed, html.gl-rm .zoom button.pressed, html.gl-rm .hud-extras button.pressed, html.gl-rm .gk-hint.pressed,
  html.gl-rm .acts button:active, html.gl-rm .zoom button:active, html.gl-rm .hud-extras button:active { transform: none; transition: none; }
}

/* Boat/ride controls (created by js/mobile.js; touch only, shown while boating
   or riding). Joystick bottom-left, action bottom-right, inside .field so they
   sit above the dock and never cover it. */
.gl-joy, .gl-action { position: absolute; z-index: 4; touch-action: none; -webkit-user-select: none; user-select: none; }
.gl-joy[hidden], .gl-action[hidden] { display: none; }
.gl-joy {
  left: max(16px, calc(env(safe-area-inset-left) + 12px));
  bottom: 16px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(12, 16, 22, 0.35), rgba(12, 16, 22, 0.62));
  border: 1px solid rgba(236, 230, 218, 0.18);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.gl-joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(185, 245, 180, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: transform 0.12s ease-out;
}
.gl-joy.is-active .gl-joy-knob { transition: none; border-color: rgba(185, 245, 180, 0.85); box-shadow: 0 0 0 4px rgba(185, 245, 180, 0.12), 0 4px 14px rgba(0, 0, 0, 0.4); }
.gl-action {
  right: max(16px, calc(env(safe-area-inset-right) + 12px));
  bottom: 28px;
  width: 76px;
  height: 76px;
  padding: 0;
  border-radius: 50%;
  color: var(--glow);
  background: radial-gradient(circle at 50% 35%, rgba(185, 245, 180, 0.3), rgba(12, 16, 22, 0.7));
  border: 1px solid rgba(185, 245, 180, 0.55);
  box-shadow: 0 0 0 4px rgba(185, 245, 180, 0.08), 0 8px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gl-action::after {
  content: '';
  display: block;
  width: 26px;
  height: 26px;
  margin: auto;
  border-radius: 50%;
  border: 2px solid currentColor;
}
.gl-action.pressed, .gl-action:active { transform: scale(0.92); opacity: 0.85; background: radial-gradient(circle at 50% 35%, rgba(185, 245, 180, 0.45), rgba(12, 16, 22, 0.7)); }
.gl-action:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }
/* keep the thoughts panel clear of the pad while it is showing */
html.has-vehicle-pad .thoughts { bottom: 160px; max-height: 24%; }
/* the log overlays the land: let it scroll, but a pinch there must not zoom the page */
@media (pointer: coarse) { .thoughts { touch-action: pan-y; } }
html.gl-rm .gl-joy-knob { transition: none; }
html.gl-rm .gl-action.pressed, html.gl-rm .gl-action:active { transform: none; }
/* short boating field on phones (css/boat.css v6 .field.boat-short): the one-line strip ends
   ~102px down and the minimap ~168px down, so a smaller pad at the bottom edge clears both */
@media (max-width: 560px) {
  html.has-vehicle-pad .field.boat-on.boat-short .gl-joy { bottom: 8px; width: 112px; height: 112px; }
  html.has-vehicle-pad .field.boat-on.boat-short .gl-joy-knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  html.has-vehicle-pad .field.boat-on.boat-short .gl-action { bottom: 8px; width: 60px; height: 60px; }
}
/* phones, boat or mammoth pad showing (not the short boating field, where css/boat.css parks the log
   in the top row): the log sits at bottom:160px and can climb into the minimap (.mm-wrap: right 0.8rem,
   6.5rem wide), so end it 8px left of the minimap column */
@media (max-width: 560px) {
  html.has-vehicle-pad .field:not(.boat-short) .thoughts { right: calc(0.8rem + 6.5rem + 8px); width: auto; }
}
/* phones: the pack row (gloop.js chips; fruit.js + craft.js add more) stays ONE line and scrolls
   sideways inside itself, so a full pack can't wrap to 5-6 rows and squeeze the game area */
@media (max-width: 560px), (max-width: 900px) and (max-height: 520px) {
  .pack { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; touch-action: pan-x; }
  .pack::-webkit-scrollbar { display: none; }
  .pack > * { flex: 0 0 auto; white-space: nowrap; }
}

/* ==========================================================================
   Phone fit. Desktop never gets html.mob-compact.
   Portrait and short landscape: the land is the only row. Vitals and a
   one-row dock (time, zoom, tools) float on it. Needs, pack and actions
   live in the tools sheet (js/mobile.js) so they don't push the world.
   ========================================================================== */

@media (max-width: 560px), (max-width: 950px) and (max-height: 520px) {
  html, body {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .stage { overflow: hidden; }
  .field, #body {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  /* dialogs and sheets stay tappable and scroll inside themselves */
  .gp-ov, .gl-auth-ov, .gk-overlay, .a11y-panel, .craft-panel, .craft-info,
  .ach-panel, .gb-overlay, .gb-panel, .intro {
    touch-action: pan-y;
    -webkit-user-select: text;
    user-select: text;
  }
}

@media (max-width: 560px) {
  .intro-go { min-height: 44px; }
}

/* auth.css sets a 7-row grid. The extra class wins so the land is the only row. */
html.mob-compact.gl-auth-on .stage,
html.mob-compact .stage { grid-template-rows: minmax(0, 1fr); }
html.mob-compact .stage > .field { grid-row: 1; }
html.mob-compact .gl-auth-bar,
html.mob-compact .topbar,
html.mob-compact .stage > .dock { grid-row: auto; }

html.mob-compact .gl-auth-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  background: rgba(28, 24, 14, 0.84);
}
html.mob-compact .gl-auth-guest,
html.mob-compact .gl-auth-user { flex-wrap: nowrap; min-height: 44px; }
html.mob-compact .gl-auth-msg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.mob-compact .topbar {
  position: absolute;
  top: var(--mob-auth, 0px);
  left: 0;
  right: 0;
  z-index: 7;
  flex-wrap: nowrap;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  background: linear-gradient(180deg, rgba(7, 8, 10, 0.78), rgba(7, 8, 10, 0.28));
  border-bottom: 0;
}
html.mob-compact .mark { letter-spacing: 0.08em; font-size: 0.62rem; }
html.mob-compact .vitals {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  gap: 0.45rem;
  touch-action: pan-x;
}
html.mob-compact .vitals > span { padding: 0.1rem 0; white-space: nowrap; }
html.mob-compact .hint { display: none; }

html.mob-compact .stage > .dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  width: auto;
  max-width: 100%;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.45rem calc(0.22rem + env(safe-area-inset-bottom)) 0.45rem;
  background: linear-gradient(0deg, rgba(7, 8, 10, 0.82), rgba(7, 8, 10, 0.4));
  border-top: 0;
  overflow: hidden;
  justify-content: flex-start;
}
html.mob-compact .dock .speed { flex: 1 1 6.2rem; max-width: 46%; min-width: 0; order: 1; }
html.mob-compact .dock .zoom {
  flex: 1 1 auto;
  order: 2;
  min-width: 0;
  max-width: none;
  overflow-x: auto;
  overflow-y: hidden;
}
html.mob-compact .zoom button,
html.mob-compact .hud-extras button {
  min-height: 44px;
  min-width: 44px;
}
html.mob-compact .speed input[type="range"] { height: 44px; }
html.mob-compact .dock .hud-extras {
  flex: 0 1 auto;
  order: 3;
  max-width: 34%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

html.mob-compact .field > .a11y-open,
html.mob-compact .field > .story-btn,
html.mob-compact .field > .gk-hint,
html.mob-compact .field .xb-btn {
  top: calc(var(--mob-top, 4.2rem) + 0.35rem);
  z-index: 6;
  width: 44px;
  height: 44px;
}
html.mob-compact .field > .story-btn { left: calc(0.8rem + 44px + 8px); }
html.mob-compact .field .ach-toggle { right: calc(0.8rem + 44px + 8px); }
html.mob-compact .field .mm-toggle { right: calc(0.8rem + 2 * (44px + 8px)); }
html.mob-compact .mm-wrap { top: calc(var(--mob-top, 4.2rem) + 0.35rem + 44px + 8px); }
html.mob-compact .field .thoughts {
  bottom: calc(var(--mob-dock, 52px) + 0.45rem);
  max-height: 28%;
}

/* Pack icons: phones only. Desktop chips stay text (no .pack-ico). */
html.mob-compact .pack .pack-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.4rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(236, 230, 218, 0.14);
  font-size: 1.05rem;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
html.mob-compact .pack .pack-ico i { font-style: normal; }
html.mob-compact .pack .pack-ico b {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
}
#pack-tip {
  position: fixed;
  z-index: 80;
  max-width: 70vw;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: #161d27;
  color: var(--ink, #ece6da);
  border: 1px solid rgba(236, 230, 218, 0.16);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}
#pack-tip[hidden] { display: none !important; }

#mob-tools { display: none; }
html.mob-compact #mob-tools {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  order: 5;
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.7rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  border: 1px solid rgba(236, 230, 218, 0.12);
}

#mob-sheet-back {
  position: fixed;
  inset: 0;
  z-index: 69;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
#mob-sheet-back[hidden] { display: none !important; }
#mob-sheet {
  position: fixed;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(70dvh, calc(100dvh - 3.5rem));
  padding: 0.7rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  background: rgba(8, 11, 16, 0.96);
  border-top: 1px solid rgba(236, 230, 218, 0.14);
  overflow: auto;
  touch-action: pan-y;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}
#mob-sheet[hidden] { display: none !important; }
#mob-sheet .needs,
#mob-sheet .pack,
#mob-sheet .skills {
  position: relative;
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  margin: 0;
  background: transparent;
}
#mob-sheet .needs,
#mob-sheet .skills {
  flex-wrap: wrap;
  overflow: visible;
  padding: 0.15rem 0.1rem;
}
#mob-sheet .needs span,
#mob-sheet .skills span { flex: 1 1 7.5rem; min-width: 0; }
#mob-sheet .pack {
  flex-wrap: wrap;
  overflow: visible;
  max-height: none;
  gap: 0.35rem;
  padding: 0.15rem 0.1rem 0.25rem;
  touch-action: manipulation;
}
#mob-sheet .hud-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  order: 0;
}
#mob-sheet .hud-extras:empty { display: none; }
#mob-sheet .acts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  overflow: visible;
  flex: 0 0 auto;
  max-width: none;
  order: 0;
  touch-action: manipulation;
}
#mob-sheet .acts button {
  min-height: 48px;
  min-width: 0;
  width: 100%;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
#mob-sheet-close {
  position: sticky;
  top: 0;
  z-index: 1;
  flex: 0 0 auto;
  min-height: 44px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  border-radius: 10px;
  border: 1px solid rgba(236, 230, 218, 0.16);
  background: #161d27;
}

/* Panels and sheets on a phone: full width, 44px controls, no clipped title. */
@media (max-width: 560px), (max-width: 950px) and (max-height: 520px) {
  .a11y-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-height: min(80dvh, calc(100dvh - 0.5rem));
    border-radius: 14px 14px 0 0;
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
  }
  .a11y-panel select,
  .a11y-panel button,
  .a11y-close,
  .gk-close,
  .gp-x,
  .craft-x,
  .craft-placebar button,
  .craft-recipes button,
  .craft-info button {
    min-height: 44px;
    min-width: 44px;
  }
  .a11y-panel select { font-size: 16px; }
  .gk-overlay { padding: max(0.6rem, env(safe-area-inset-top)) 0.6rem max(0.6rem, env(safe-area-inset-bottom)); align-items: flex-end; }
  .gk-panel { max-height: min(86dvh, calc(100dvh - 1rem)); width: 100%; }
  .gk-body dt { flex-basis: 5.4rem; white-space: normal; }
  .gp-ov { align-items: flex-end; }
  .gp-card { width: 100%; max-height: min(88dvh, calc(100dvh - 0.5rem)); overflow: auto; }
  .craft-panel, .craft-info {
    left: 0.4rem;
    right: 0.4rem;
    top: 0.4rem;
    width: auto;
    max-height: calc(100% - 0.8rem);
  }
  .intro-word { font-size: clamp(2.6rem, 18vw, 6rem); }
}

/* Needs, pack, and the clock stay on the land. Powers live in one drawer. */
html.mob-compact #mob-status {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--mob-top, 2rem);
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 22vh;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 8, 10, 0.78), rgba(7, 8, 10, 0.2) 70%, rgba(7, 8, 10, 0));
}
#mob-status[hidden] { display: none !important; }
html.mob-compact #mob-status .needs,
html.mob-compact #mob-status .pack {
  position: relative;
  pointer-events: auto;
  margin: 0;
  background: transparent;
}
html.mob-compact #mob-status .needs { padding-top: 0.12rem; padding-bottom: 0.12rem; }
html.mob-compact #mob-status .pack { padding-top: 0; padding-bottom: 0.15rem; }
html.mob-compact #mob-status .pack .pack-ico {
  min-height: 40px;
  min-width: 36px;
  padding: 0 0.28rem;
}
html.mob-compact #skills { display: none !important; }
html.mob-compact .mark,
html.mob-compact .vitals > span:nth-child(2),
html.mob-compact .vitals > span:nth-child(5) { display: none; }
html.mob-compact #cam-roam,
html.mob-compact #zoom-label { display: none; }
html.mob-compact .stage > .dock { overflow-x: auto; scrollbar-width: none; }
html.mob-compact .stage > .dock::-webkit-scrollbar { display: none; }
html.mob-compact .dock button,
html.mob-compact .zoom button,
html.mob-compact #mob-tools,
html.mob-compact .acts button,
html.mob-compact .hud-extras button,
html.mob-compact .pack .pack-ico,
html.mob-compact .act-drive {
  min-height: 48px;
  min-width: 48px;
}
html.mob-compact .field .thoughts {
  top: auto;
  bottom: calc(var(--mob-dock, 56px) + 0.35rem);
  max-height: 18%;
}
#mob-sheet-title {
  font-family: var(--mono, ui-monospace, monospace);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--mute, #b7b1a6);
  padding: 0.15rem 0.2rem 0;
}
#mob-sheet .acts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  flex-wrap: wrap;
  overflow: visible;
  max-width: none;
}
#mob-sheet .acts button {
  min-height: 48px;
  white-space: nowrap;
}
#mob-sheet .hud-extras {
  flex-wrap: wrap;
  overflow: visible;
  max-width: none;
}
#mob-sheet .mob-txt { display: inline !important; }
#mob-sheet .hud-extras .mob-icon-btn { width: auto; padding: 0 0.75rem; }
html.mob-compact #act-nearest { display: none !important; }

/* Compact HUD is one column: status, needs, pack, land, dock.
   Nothing is pulled over another row. Corner buttons sit beside the minimap. */
html.mob-compact .stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  grid-template-rows: none;
}
html.mob-compact .gl-auth-bar,
html.mob-compact .topbar,
html.mob-compact #mob-status,
html.mob-compact .stage > .dock {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  flex: 0 0 auto;
  width: 100%;
  max-height: none;
}
html.mob-compact .stage > .field {
  flex: 1 1 auto;
  min-height: 0;
  order: 4;
}
html.mob-compact .topbar {
  order: 1;
  height: 1.6rem;
  max-height: 1.6rem;
  overflow: hidden;
  align-items: center;
  padding: 0 0.5rem;
  background: rgba(7, 8, 10, 0.92);
}
html.mob-compact .vitals {
  overflow: hidden;
  flex-wrap: nowrap;
  gap: 0.45rem;
}
html.mob-compact .vitals > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.mob-compact #mob-status {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.05rem 0 0.15rem;
  background: rgba(7, 8, 10, 0.92);
  pointer-events: none;
}
html.mob-compact #mob-status .needs {
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 0.45rem;
  padding: 0.05rem 0.5rem;
  line-height: 1;
}
html.mob-compact #mob-status .needs span { min-width: 0; flex: 1 1 0; }
html.mob-compact #mob-status .needs i { width: 28px; flex: 0 0 28px; }
html.mob-compact #mob-status .pack {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0.4rem;
  min-height: 0;
}
html.mob-compact #mob-status .pack .pack-ico {
  min-height: 36px;
  min-width: 32px;
  padding: 0 0.22rem;
}
html.mob-compact .stage > .dock {
  order: 5;
  flex-wrap: wrap;
  overflow: visible;
  align-items: center;
  justify-content: flex-start;
  column-gap: 0.28rem;
  row-gap: 0.18rem;
  padding: 0.16rem 0.35rem calc(0.16rem + env(safe-area-inset-bottom));
  background: rgba(7, 8, 10, 0.94);
}
html.mob-compact .dock .speed {
  flex: 1 1 7.5rem;
  order: 1;
  max-width: none;
  min-width: 0;
}
html.mob-compact .dock .speed input[type="range"] {
  width: auto;
  flex: 1 1 2.4rem;
  min-width: 2.2rem;
  max-width: 6.5rem;
  height: 36px;
}
html.mob-compact .dock .zoom {
  flex: 0 0 auto;
  order: 2;
  overflow: visible;
  min-width: 0;
  max-width: none;
  flex-wrap: nowrap;
}
html.mob-compact .zoom #zoom-out,
html.mob-compact .zoom #zoom-in {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  flex: 0 0 36px;
}
html.mob-compact .zoom #zoom-fit,
html.mob-compact #act-drive,
html.mob-compact #act-home,
html.mob-compact #mob-tools {
  width: auto;
  min-width: max-content;
  max-width: none;
  height: 36px;
  min-height: 36px;
  padding: 0 0.45rem;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  flex: 0 0 auto;
}
html.mob-compact #act-drive { order: 3; font-size: 0.62rem; }
html.mob-compact #act-home { order: 3; font-size: 0.62rem; padding: 0 0.4rem; }
html.mob-compact #mob-tools { order: 4; font-size: 0.62rem; padding: 0 0.5rem; }
html.mob-compact .field > .a11y-open,
html.mob-compact .field > .story-btn,
html.mob-compact .field > .gk-hint,
html.mob-compact .field .xb-btn {
  left: auto;
  right: calc(0.4rem + 6.5rem + 0.35rem);
  width: 40px;
  height: 40px;
  top: 0.3rem;
  z-index: 6;
}
html.mob-compact .field > .story-btn { top: calc(0.3rem + 44px); }
html.mob-compact .field .mm-toggle { top: calc(0.3rem + 88px); }
html.mob-compact .field .ach-toggle { top: calc(0.3rem + 132px); }
html.mob-compact .field > .gk-hint {
  top: calc(0.3rem + 176px);
  z-index: 8;
  opacity: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  color: #fff8e8;
  background: rgba(12, 16, 22, 0.94);
  border-color: rgba(255, 248, 232, 0.55);
}
html.mob-compact .mm-wrap {
  top: 0.3rem;
  right: 0.4rem;
  width: 6.5rem;
  height: 6.5rem;
}
html.mob-compact .field .gb-toast {
  top: 0.35rem;
  left: 0.45rem;
  right: auto;
  max-width: calc(100% - 6.5rem - 40px - 1.8rem);
  z-index: 6;
}
html.mob-compact .field .thoughts {
  top: auto;
  bottom: 0.35rem;
  max-height: 22%;
}
@media (max-height: 520px) {
  html.mob-compact .gl-auth-bar { padding: 0.08rem 0.4rem; }
  html.mob-compact .gl-auth-guest,
  html.mob-compact .gl-auth-user { min-height: 0; gap: 0.25rem; }
  html.mob-compact .gl-auth-btn { min-height: 22px; min-width: max-content; padding: 0.05rem 0.45rem; font-size: 0.68rem; }
  html.mob-compact .topbar { height: 1.15rem; max-height: 1.15rem; }
  html.mob-compact .vitals { max-height: 1.15rem; overflow: hidden; align-items: center; }
  html.mob-compact .vitals > span { padding: 0; line-height: 1.15rem; }
  html.mob-compact #mob-status { padding-bottom: 0.05rem; }
  html.mob-compact #mob-status .needs { padding-top: 0; padding-bottom: 0; }
  html.mob-compact #mob-status .pack .pack-ico { min-height: 22px; min-width: 20px; font-size: 0.8rem; }
  html.mob-compact .stage > .dock { flex-wrap: nowrap; padding-top: 0.04rem; padding-bottom: 0.04rem; }
  html.mob-compact .zoom #zoom-fit,
  html.mob-compact #act-drive,
  html.mob-compact #act-home,
  html.mob-compact #mob-tools,
  html.mob-compact .zoom #zoom-out,
  html.mob-compact .zoom #zoom-in { height: 32px; min-height: 32px; }
  html.mob-compact .field > .a11y-open,
  html.mob-compact .field > .story-btn,
  html.mob-compact .field > .gk-hint,
  html.mob-compact .field .xb-btn { width: 34px; height: 34px; }
  html.mob-compact .field > .story-btn { top: calc(0.25rem + 36px); }
  html.mob-compact .field .mm-toggle { top: calc(0.25rem + 72px); }
  html.mob-compact .field .ach-toggle { top: calc(0.25rem + 108px); }
  html.mob-compact .field > .gk-hint { top: calc(0.25rem + 144px); }
  html.mob-compact .mm-wrap { width: 5.2rem; height: 5.2rem; }
  html.mob-compact .field > .a11y-open,
  html.mob-compact .field > .story-btn,
  html.mob-compact .field > .gk-hint,
  html.mob-compact .field .xb-btn { right: calc(0.3rem + 5.2rem + 0.25rem); }
}

/* Stick showing (ride or Take control): the log sits above the 128px pad,
   which is 16px off the floor of the field. The dock stays below the field.
   The short boat strip keeps its own place. */
html.mob-compact.has-vehicle-pad .field:not(.boat-short) .thoughts {
  bottom: calc(16px + 128px + 10px);
  left: 0.5rem;
  right: 0.5rem;
  width: auto;
  max-height: 4.8rem;
}
@media (max-height: 520px) {
  html.mob-compact.has-vehicle-pad .field:not(.boat-short) .thoughts {
    right: calc(0.3rem + 5.2rem + 0.25rem + 34px + 0.45rem);
    max-height: 3.4rem;
  }
}
