/*
 * hyd-mobile-desktop.css
 *
 * Pocket desktop and window chrome. On phones hyd-desktop.js adds the mobile-desktop class to #web-desktop, and
 * this file turns the desktop into one absolutely positioned stage: title block on top, a grid of shortcut
 * icons, windows positioned from the --wx and --wy variables (also set by hyd-desktop.js) and a scrolling dock
 * at the bottom. For wider screens it caps the dock and windows to the visible work area and lays the shortcut
 * icons out in columns. Later sections draw the paired window controls (close and minimise discs) for the
 * desktop, solitaire and pinball windows, the compact road-question sheet, and the scroll and stacking rules
 * for phones. div.desktop-window-body, the wrapper hyd-desktop.js adds inside each window, has no box of its
 * own (display: contents) until a rule below makes it a scroller.
 */

/* A pocket desktop: the same windows, icons and souvenirs share one stage. */
.desktop-window-body {
  display: contents;
}

/*
 * Pocket desktop: phones, 620px and below. It only applies while hyd-desktop.js has added mobile-desktop to the
 * stage.
 */
@media (max-width: 620px) {
  /* --- Stage --- */
  html[data-theme] #world #home .portal-collage {
    padding: 0;
    overflow: visible;
  }

  html[data-theme] #world #home .portal-collage #web-desktop.mobile-desktop {
    display: block;
    position: relative;
    width: 100%;
    height: 100svh;
    min-height: 0;
    /*
     * !important: several earlier phone rules pad .web-desktop (for example hyd-desktop.css, hyd-personal-web.css,
     * hyd-aqua.css, hyd-time-machine.css, hyd-mac-windows.css, hyd-classic-desktop.css and hyd-object-controls.css).
     * The pocket desktop places everything itself and needs no padding. This selector (three ids) already
     * out-ranks all of them, so the !important is insurance: removing it changed nothing in Chrome at 320 and
     * 390 px (6 Oct 2026).
     */
    padding: 0 !important;
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
    --mobile-icons-top: 146px;
    --mobile-window-height: 360px;
  }

  /* --- Title block and road-question odometer --- */
  html[data-theme] #world #home .mobile-desktop .portal-brand {
    top: 12px;
    left: 8px;
    right: 8px;
    width: auto;
    padding: 0;
    z-index: 20;
    pointer-events: none;
  }

  html[data-theme] #world #home .mobile-desktop .portal-brand :is(button, #home-uturns) {
    pointer-events: auto;
  }

  html[data-theme] #world #home .mobile-desktop .portal-brand h1 {
    font-size: clamp(25px, 7vw, 36px);
    line-height: 1.1;
  }

  html[data-theme] #world #home .mobile-desktop .portal-brand > span:first-child {
    font-size: 10px;
    letter-spacing: 2px;
  }

  html[data-theme] #world #home .mobile-desktop #home-uturns {
    margin-top: 8px;
  }

  html[data-theme] #world #home .mobile-desktop #home-uturns .uturn-odometer {
    padding: 5px 7px;
    gap: 7px;
  }

  html[data-theme] #world #home .mobile-desktop #home-uturns .uturn-stat {
    min-width: 35px;
  }

  /* --- Shortcut icon grid --- */
  html[data-theme] #world #home .mobile-desktop .desktop-icons {
    position: absolute;
    left: 5px;
    right: 5px;
    /*
     * !important: the icon grid always starts at the measured bottom of the title block (--mobile-icons-top,
     * set by hyd-desktop.js), whatever other .desktop-icons rules say.
     */
    top: var(--mobile-icons-top) !important;
    bottom: auto;
    width: auto;
    /* min-height, not height: a definite height would cap the rows that bigger text grows. */
    height: auto;
    min-height: var(--mobile-icons-height,224px);
    display: grid;
    grid-template-columns: repeat(var(--mobile-icon-columns,5),minmax(0,1fr));
    /* max-content rows (52px from the shortcuts’ min-height) grow with bigger text, also while the grid scrolls;
       hyd-desktop.js measures the grid and keeps the windows below it. */
    grid-auto-rows: max-content;
    align-items: start;
    align-content: start;
    justify-items: center;
    gap: 4px 6px;
    padding: 0 3px 4px;
    z-index: 9;
    overflow: visible;
    touch-action: manipulation;
    box-sizing: border-box;
  }

  /* Bigger text grew the grid past the room above the window band (hyd-desktop.js): it scrolls there. */
  html[data-theme] #world #home .mobile-desktop .desktop-icons.is-crowded {
    height: var(--mobile-icons-height);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-icons > button {
    display: grid;
    grid-template-rows: 26px minmax(calc(22 * var(--px)), auto);
    align-content: start;
    align-items: end;
    justify-items: center;
    width: 100%;
    max-width: 82px;
    height: auto;
    min-height: 52px;
    padding: 0;
    gap: 2px;
    justify-content: normal;
    translate: none;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-icons > button > :is(img, svg, span) {
    width: 26px;
    height: 26px;
    min-height: 0;
    margin: 0;
    object-fit: contain;
    flex: none;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-icons > button > .folder-art {
    height: 20px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-icons > button > b {
    align-self: start;
    margin: 0;
    font: calc(10 * var(--px))/calc(11 * var(--px)) var(--desktop-label-font);
    max-width: 100%;
    padding: 0 1px;
    min-height: calc(22 * var(--px));
    box-sizing: border-box;
    text-wrap: balance;
    /* A long word in bigger text breaks, at a hyphen where it can, rather than running into the next shortcut
       (anywhere, not break-word: the label sits in an auto grid track, which would otherwise widen to the whole
       word). */
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  /* --- Windows: placed at --wx and --wy, with a scrolling body --- */
  html[data-theme] #world #home .mobile-desktop .desktop-window {
    position: absolute;
    left: 0;
    top: 0;
    right: auto;
    bottom: auto;
    width: min(292px, calc(100% - 30px));
    max-width: calc(100% - 12px);
    max-height: var(--mobile-window-height);
    height: auto;
    min-height: 0;
    margin: 0;
    box-sizing: border-box;
    /*
     * !important: hyd-desktop.css and hyd-personal-web.css set transform: none !important on windows at phone
     * widths. The pocket desktop positions windows with a transform (from --wx and --wy, set by
     * hyd-desktop.js), so it has to be !important as well, and more specific.
     */
    transform: translate(var(--wx,6px),var(--wy,232px)) !important;
    rotate: 0deg;
    overflow: hidden;
    touch-action: auto;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-window:not([hidden]) {
    display: flex;
    flex-direction: column;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-window-body {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    touch-action: pan-y pinch-zoom;
  }

  html[data-theme] #world #home .mobile-desktop #desk-entry {
    width: min(332px, calc(100% - 26px));
  }

  html[data-theme] #world #home .mobile-desktop #desk-view {
    width: min(232px, calc(100% - 58px));
    overflow: hidden;
  }

  html[data-theme] #world #home .mobile-desktop #desk-view:not([hidden]) {
    display: flex;
    flex-direction: column;
  }

  html[data-theme]
    #world
    #home
    .mobile-desktop
    #desk-view
    > :is(.desktop-titlebar, .desktop-photo-tools) {
    flex: 0 0 auto;
  }

  html[data-theme] #world #home .mobile-desktop #desk-view .desktop-photo-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  html[data-theme] #world #home .mobile-desktop #desk-stickers {
    width: min(320px, calc(100% - 20px));
  }

  /* --- Window title bars (drag handles) --- */
  html[data-theme] #world #home .mobile-desktop .desktop-titlebar,
  html[data-theme] #world #home .mobile-desktop #desk-entry .desktop-titlebar {
    position: relative;
    top: auto;
    z-index: 5;
    flex: 0 0 auto;
    min-height: 38px;
    height: 38px;
    box-sizing: border-box;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: grab;
  }

  html[data-theme] #world #home .mobile-desktop .window-grab {
    touch-action: none;
    cursor: grab;
    padding-inline: 70px 12px;
    font-size: 12px;
    min-height: 36px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-titlebar > div {
    left: 5px;
    gap: 3px;
    height: 30px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-titlebar > div > button {
    touch-action: manipulation;
    width: 28px;
    height: 28px;
    min-height: 28px;
    /*
     * !important: pins the glyph size of these title bar buttons; the window controls block further down also
     * sets font-size with !important for them.
     */
    font-size: 16px !important;
  }

  /* --- Window contents sized for a phone --- */
  html[data-theme] #world #home .mobile-desktop #desk-entry .visual-entry {
    min-height: 0;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 6px;
    padding: 8px 6px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .memory-mode-switch {
    grid-column: 1/-1;
    justify-self: center;
    margin: 0 0 5px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .shuffle-art {
    width: 65px;
    height: 65px;
    flex-basis: 65px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .shuffle-art svg {
    width: 65px;
    height: 65px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .shuffle-object {
    gap: 9px;
    padding: 0 3px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .area-terminal {
    padding: 3px 5px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .area-terminal > label {
    padding: 0 0 6px;
    gap: 4px;
  }

  html[data-theme] #world #home .mobile-desktop .visual-entry .area-terminal > label svg {
    width: 27px;
    height: 25px;
  }

  html[data-theme] #world #home .mobile-desktop #quick-area-results {
    max-height: 100px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-menu {
    gap: 5px;
    padding: 6px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-menu button {
    min-width: 0;
    min-height: 32px;
    flex: 1;
    padding: 3px;
    font-size: calc(10 * var(--px));
  }

  html[data-theme] #world #home .mobile-desktop .desk-recordings {
    padding: 7px;
    gap: 7px;
  }

  html[data-theme] #world #home .mobile-desktop .desk-recordings img {
    height: 90px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-sky img {
    height: 130px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-contact-strip {
    padding: 5px;
    gap: 4px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-contact-strip button {
    height: 33px;
  }

  html[data-theme] #world #home .mobile-desktop #desk-stickers .sticker-play {
    max-height: none;
  }

  /* --- Dock (taskbar) --- */
  html[data-theme] #world #home .mobile-desktop .desktop-taskbar {
    position: absolute;
    left: 50%;
    right: auto;
    bottom: calc(6px + env(safe-area-inset-bottom,0px));
    top: auto;
    width: max-content;
    max-width: calc(100% - 12px);
    height: 56px;
    min-height: 56px;
    translate: -50% 0;
    transform: none;
    display: flex;
    gap: 3px;
    padding: 3px;
    box-sizing: border-box;
    z-index: 120;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-tasks {
    display: flex;
    flex: 0 1 auto;
    min-width: 0;
    max-width: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    height: 48px;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-taskbar button {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    height: 44px;
    padding: 3px;
    margin: 0;
    box-sizing: border-box;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-taskbar :is(svg, img) {
    width: 32px;
    height: 32px;
    object-fit: contain;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-taskbar .folder-art {
    width: 30px;
    height: 24px;
    margin-top: 8px;
  }

  html[data-theme]
    #world
    #home
    .mobile-desktop
    .desktop-taskbar
    :is(.dock-label, .dock-group-start:before) {
    display: none;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-taskbar .desk-reset {
    flex-basis: 30px;
    width: 30px;
    min-width: 30px;
    /*
     * !important: hyd-desktop.css sets the .desk-reset font size to 14px with !important. The phone dock needs
     * a larger reset glyph, so this has to be !important and more specific.
     */
    font-size: 22px !important;
  }

  html[data-theme] #world #home .mobile-desktop #desktop-personalise-open {
    flex-basis: 34px;
    width: 34px;
    min-width: 34px;
    padding: 2px;
  }

  /* --- Loose items on the stage: cat slot, wallpaper switch, stickers --- */
  html[data-theme] #world #home .mobile-desktop > .hyd-cat-slot-home {
    left: auto;
    right: 7px;
    bottom: 83px;
    width: 82px;
    height: 82px;
    z-index: 130;
  }

  html[data-theme] #world #home .mobile-desktop .wallpaper-switch {
    top: 4px;
    right: 3px;
    width: 25px;
    height: 25px;
    z-index: 45;
  }

  html[data-theme]
    #world
    #home
    .mobile-desktop
    .desktop-sticker.illustrated-sticker:has(img[src*='hyd-']) {
    width: 76px;
    height: 76px;
  }
}

@media (max-width: 620px) {
  /* Only the dock stays horizontal; desktop shortcuts form a compact grid. */
  html[data-theme] #world #home .mobile-desktop .desktop-icons:after {
    content: none;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-tasks {
    scrollbar-width: thin;
    scrollbar-color: #777b88 #d6d5da;
  }
}

/* P2-2 / P3-3 / O5: usable chrome stays in the visible work area. */
html[data-theme] #world #home .desktop-taskbar {
  position: fixed;
  left: 6px;
  right: 6px;
  bottom: calc(6px + env(safe-area-inset-bottom,0px));
  top: auto;
  width: max-content;
  max-width: calc(100vw - 12px);
  height: 56px;
  min-height: 56px;
  margin-inline: auto;
  /*
   * !important: the dock is fixed and centred by auto side margins, so any translate or transform from other
   * dock rules is cancelled (the phone block above centres its dock with translate: -50% 0).
   */
  translate: none !important;
  transform: none !important;
  display: flex;
  flex-wrap: nowrap;
  box-sizing: border-box;
  z-index: 120;
}

html[data-theme] #world #home .desktop-tasks {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  justify-content: flex-start;
}

html[data-theme] #world #home .desktop-window:not([hidden]) {
  display: flex;
  flex-direction: column;
  max-height: min(calc(100dvh - 88px),var(--desktop-work-height,100dvh));
  max-width: calc(100vw - 20px);
  overflow: hidden;
  box-sizing: border-box;
}

html[data-theme] #world #home .desktop-titlebar {
  flex: 0 0 auto;
  touch-action: none;
}

html[data-theme] #world #home .desktop-window-body {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

html[data-theme] #world #home #desk-view .desktop-photo-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

/* --- Tablet widths (621px to 900px): shortcut grid on the left edge --- */
@media (min-width: 621px) and (max-width: 900px) {
  /* Like the wider desktop, this band is one screen tall: the icon column ends above the dock and scrolls on its own. */
  html[data-theme] #world #home .portal-collage .web-desktop {
    height: 100dvh;
    padding-bottom: 88px;
    box-sizing: border-box;
  }

  html[data-theme] #world #home .desktop-icons {
    left: 12px;
    top: 64px;
    width: 150px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* 86px at the default size: a 48px picture, its gap and two 13px caption lines, which grow with bigger text. */
    grid-auto-rows: calc(60px + 26 * var(--px));
    gap: 10px 8px;
  }

  html[data-theme] #world #home .desktop-icons:not(.desktop-free-shortcuts) {
    height: calc(100dvh - 134px - env(safe-area-inset-bottom,0px));
    max-height: none;
    align-content: start;
    padding: 4px;
    margin: -4px;
    box-sizing: content-box;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  html[data-theme] #world #home .desktop-icons > button {
    width: 100%;
    min-height: calc(54px + 26 * var(--px));
    height: calc(54px + 26 * var(--px));
    justify-content: start;
    gap: 4px;
  }

  html[data-theme] #world #home .desktop-icons > button > :is(svg, img, span) {
    max-height: 48px;
    max-width: 50px;
    object-fit: contain;
  }

  html[data-theme] #world #home .desktop-icons b {
    font-size: calc(11 * var(--px));
    line-height: calc(13 * var(--px));
  }

  html[data-theme] #world #home #desk-photos {
    left: 176px;
  }

  html[data-theme] #world #home #desk-entry {
    left: 180px;
  }

  /* Never a scrollbar (owner, 5 Oct): as on the wider desktop, shortcuts fill the column downward and then wrap into the
    next column; default windows already start right of the measured columns (hyd-desktop.js clearIcons). */
  html[data-theme] #world #home .desktop-icons:not(.desktop-free-shortcuts) {
    width: max-content;
    grid-template-columns: none;
    grid-template-rows: repeat(auto-fill, calc(60px + 26 * var(--px)));
    grid-auto-flow: column;
    grid-auto-columns: calc(71 * var(--px));
    overflow: visible;
  }
}

/* --- Short tablets (891px tall or less): smaller shortcuts --- */
@media (min-width: 621px) and (max-width: 900px) and (max-height: 891px) {
  /* Not tall enough for eight full-size rows: smaller shortcuts keep two columns down to about 690 px, so the default
    windows keep their place right of them. */
  html[data-theme] #world #home .desktop-icons:not(.desktop-free-shortcuts) {
    /* 64 x 64px at the default size; the two 11px caption lines grow with bigger text. */
    grid-template-rows: repeat(auto-fill, calc(42px + 22 * var(--px)));
    grid-auto-columns: calc(64 * var(--px));
    gap: 6px;
  }

  html[data-theme] #world #home .desktop-icons > button {
    min-height: calc(40px + 22 * var(--px));
    height: calc(40px + 22 * var(--px));
    gap: 2px;
  }

  html[data-theme] #world #home .desktop-icons > button > :is(svg, img, span) {
    max-height: 32px;
    max-width: 34px;
  }

  html[data-theme] #world #home .desktop-icons b {
    font-size: calc(10 * var(--px));
    line-height: calc(11 * var(--px));
  }
}

@media (max-width: 620px) {
  html[data-theme] #world #home .mobile-desktop .desktop-taskbar {
    position: fixed;
    left: 6px;
    right: 6px;
    /* !important: keeps the fixed phone dock free of any translate, as in the fixed dock rule above. */
    translate: none !important;
    margin-inline: auto;
  }

  html[data-theme] #world #home .mobile-desktop > .hyd-cat-slot-home {
    z-index: 130;
    bottom: 74px;
  }
}

/* Desktop shortcuts fill rows downward, then wrap into the next column. */
@media (min-width: 901px) {
  html[data-theme] #world #home .portal-collage .web-desktop {
    height: 100dvh;
  }

  html[data-theme] #world #home .desktop-icons:not(.desktop-free-shortcuts) {
    height: calc(100dvh - 141px - env(safe-area-inset-bottom,0px));
    max-height: none;
    width: max-content;
    grid-template-columns: none;
    /* Rows and columns follow the caption size (hyd-classic-desktop.css): the same 82 x 69 px at the default size. */
    grid-template-rows: repeat(auto-fill, calc(54px + 28 * var(--px)));
    grid-auto-flow: column;
    grid-auto-columns: calc(69 * var(--px));
    align-content: start;
    gap: 14px 10px;
    padding: 4px;
    margin: -4px;
    box-sizing: content-box;
    overflow: visible;
  }

  /* Unpositioned one-pixel live regions otherwise extend the page by a pixel. */
  html[data-theme] body:has(#home.active) :is(#desktop-feedback, #player-window-status) {
    top: 0;
    left: 0;
  }
}

/* --- Phones on their side (621px to 900px wide, 430px tall or less) --- */
@media (min-width: 621px) and (max-width: 900px) and (max-height: 430px) {
  /* A phone on its side: one size smaller again (still 56 px tall touch targets), four rows instead of three, so the
    default windows keep their place right of the shortcuts. */
  html[data-theme] #world #home .desktop-icons:not(.desktop-free-shortcuts) {
    /* 56 x 60px at the default size; the two 11px caption lines grow with bigger text. */
    grid-template-rows: repeat(auto-fill, calc(34px + 22 * var(--px)));
    grid-auto-columns: calc(60 * var(--px));
    gap: 4px;
  }

  html[data-theme] #world #home .desktop-icons > button {
    min-height: calc(34px + 22 * var(--px));
    height: calc(34px + 22 * var(--px));
    gap: 1px;
  }

  html[data-theme] #world #home .desktop-icons > button > :is(svg, img, span) {
    max-height: 28px;
    max-width: 30px;
  }

  html[data-theme] #world #home .desktop-icons b {
    font-size: calc(10 * var(--px));
    line-height: calc(11 * var(--px));
  }
}

/* The dock remains scrollable by trackpad, touch and keyboard without a trough. */
html[data-theme] #world #home .desktop-tasks {
  scrollbar-width: none;
}

html[data-theme] #world #home .desktop-tasks::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* --- Dock reset button and free-placed shortcuts (hyd-desktop-shortcuts.js) --- */
html[data-theme] #world #home #desktop-reset {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  min-width: 48px;
  padding: 3px;
}

html[data-theme] #world #home #desktop-reset svg {
  display: block;
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 2px #1a283733);
}

html[data-theme] #world #home .desktop-icons > [data-shortcut-id] {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

html[data-theme] #world #home #desktop-free-shortcuts {
  position: absolute;
  /*
   * !important: the free-shortcut layer is also a .desktop-icons element, and the pocket desktop sets top on
   * every .desktop-icons with !important (above). This keeps the layer covering the whole desktop.
   */
  inset: 0 !important;
  width: 100%;
  height: 100%;
  display: block;
  padding: 0;
  translate: none;
  transform: none;
  overflow: visible;
  pointer-events: none;
  z-index: 9;
}

html[data-theme] #world #home #desktop-free-shortcuts > .desktop-free-shortcut {
  position: absolute;
  margin: 0;
  max-width: calc(100vw - 16px);
  pointer-events: auto;
  translate: none;
  transform: none;
  z-index: 1;
}

html[data-theme] #world #home #desktop-free-shortcuts > .is-shortcut-dragging {
  cursor: grabbing;
  z-index: 2;
}

/*
 * Invisible stand-in that hyd-desktop-shortcuts.js leaves in the icon grid when a shortcut is moved out into
 * the free layer; it keeps the slot but shows nothing.
 */
.desktop-shortcut-placeholder {
  display: block;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 620px) {
  html[data-theme] #world #home .mobile-desktop .desktop-tasks {
    scrollbar-width: none;
  }

  html[data-theme] #world #home .mobile-desktop #desktop-reset {
    flex-basis: 40px;
    width: 40px;
    min-width: 40px;
  }

  html[data-theme] #world #home .mobile-desktop #desktop-reset svg {
    width: 32px;
    height: 32px;
  }
}

/* Match paired window controls and center marks independently of font metrics. */
html[data-theme]
  body
  :is(
    #hyd-solitaire .solitaire-window-controls > button,
    #hyd-pinball .pinball-close,
    #hyd-jaali .jaali-window-controls > button
  ),
html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button {
  position: relative;
  box-sizing: border-box;
  flex: none;
  display: block;
  /*
   * !important: every window control (desktop windows, solitaire, pinball) gets the same size and no text, so
   * the drawn marks line up. font-size: 0 hides the glyph; the mark is drawn by ::before.
   */
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 0 !important;
  line-height: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

html[data-theme]
  body
  :is(
    #hyd-solitaire .solitaire-window-controls > button,
    #hyd-pinball .pinball-close,
    #hyd-jaali .jaali-window-controls > button
  )::before,
html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  margin: 0;
  transform: translate(-50%, -50%);
  background: currentColor;
  pointer-events: none;
}

html[data-theme]
  body
  :is(
    #hyd-solitaire .solitaire-window-controls > [data-sol-close],
    #hyd-pinball button.pinball-close,
    #hyd-jaali .jaali-window-controls > [data-jaali-close]
  )::before,
html[data-theme]
  #world
  #home
  .desktop-window
  .desktop-titlebar
  > div
  > [data-close-window]::before {
  width: 10px;
  height: 10px;
  background:
    linear-gradient(45deg, transparent 42%, currentColor 43% 57%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, currentColor 43% 57%, transparent 58%);
}

html[data-theme] body #hyd-pinball .pinball-close::after {
  content: none;
}

html[data-theme] body #hyd-solitaire .solitaire-window-controls,
html[data-theme] body #hyd-jaali .jaali-window-controls {
  align-items: center;
  width: 54px;
  height: 24px;
  gap: 6px;
}

html[data-theme] body #hyd-solitaire .solitaire-title-spacer,
html[data-theme] body #hyd-jaali .jaali-title-spacer {
  width: 54px;
}

html[data-theme] #world #home .desktop-window .desktop-titlebar > div {
  height: 24px;
  align-items: center;
}

/*
 * Touch and phone sizes for the window controls: 44px targets. The visible disc is drawn by ::after, so the
 * target can be larger than the disc.
 */
@media (max-width: 620px), (any-pointer: coarse) {
  html[data-theme]
    body
    :is(
      #hyd-solitaire .solitaire-window-controls > button,
      #hyd-pinball .pinball-close,
      #hyd-jaali .jaali-window-controls > button
    ),
  html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button {
    /* !important: these touch sizes have to beat the 24px sizes above, which are !important as well. */
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }

  html[data-theme]
    body
    :is(
      #hyd-solitaire .solitaire-window-controls > button,
      #hyd-pinball .pinball-close,
      #hyd-jaali .jaali-window-controls > button
    )::before,
  html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button::before {
    width: 12px;
  }

  html[data-theme]
    body
    :is(
      #hyd-solitaire .solitaire-window-controls > [data-sol-close],
      #hyd-pinball button.pinball-close,
      #hyd-jaali .jaali-window-controls > [data-jaali-close]
    )::before,
  html[data-theme]
    #world
    #home
    .desktop-window
    .desktop-titlebar
    > div
    > [data-close-window]::before {
    width: 12px;
    height: 12px;
  }

  html[data-theme] body #hyd-solitaire .solitaire-window-controls,
  html[data-theme] body #hyd-jaali .jaali-window-controls {
    width: 94px;
    height: 44px;
  }

  html[data-theme] body #hyd-solitaire .solitaire-titlebar,
  html[data-theme] body #hyd-jaali .jaali-titlebar {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr);
    min-height: 52px;
    gap: 8px;
  }

  html[data-theme] body #hyd-solitaire .solitaire-titlebar h2,
  html[data-theme] body #hyd-jaali .jaali-titlebar h2 {
    justify-content: center;
    min-width: 0;
    text-align: center;
  }

  html[data-theme] body #hyd-solitaire .solitaire-title-spacer,
  html[data-theme] body #hyd-jaali .jaali-title-spacer {
    display: none;
  }

  html[data-theme] body #hyd-pinball .pinball-titlebar {
    grid-template-columns: 44px minmax(0, 1fr) 24px;
    min-height: 52px;
    gap: 6px;
  }

  html[data-theme] #world #home .desktop-window .desktop-titlebar,
  html[data-theme] #world #home #desk-entry .desktop-titlebar {
    /*
     * !important: keeps the 44px touch height of window title bars; on phones the pocket desktop block near the
     * end of this file resets them to 32px (also !important, and more specific).
     */
    height: 44px !important;
    min-height: 44px !important;
  }

  html[data-theme] #world #home .desktop-window .desktop-titlebar > div {
    height: 44px;
    gap: 0;
    left: 2px;
  }

  html[data-theme] #world #home .desktop-window .window-grab {
    padding-inline: 90px 8px;
  }

  /* Keep separate thumb targets, but draw the same small discs as the desktop.
    The transparent target must not inherit the desktop's coloured background. */
  html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button {
    border: 0;
    border-radius: 4px;
    background: none;
    box-shadow: none;
  }

  html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border: 1px solid #947844;
    border-radius: 50%;
    background: radial-gradient(ellipse at 40% 15%, #fff9d9, #e9c774 55%, #bc994d);
    box-shadow:
      inset 0 1px #fff8,
      0 1px #fff7;
    pointer-events: none;
  }

  html[data-theme]
    #world
    #home
    .desktop-window
    .desktop-titlebar
    > div
    > [data-close-window]::after {
    border-color: #98635f;
    background: radial-gradient(ellipse at 40% 15%, #fff0e9, #de9a91 55%, #be706e);
  }

  html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button::before {
    width: 10px;
    z-index: 1;
  }

  html[data-theme]
    #world
    #home
    .desktop-window
    .desktop-titlebar
    > div
    > [data-close-window]::before {
    width: 10px;
    height: 10px;
  }

  html[data-theme] #world #home .desktop-window .desktop-titlebar > div > button:active::after {
    box-shadow: inset 0 1px 3px #0007;
  }
}

@media (max-width: 620px) {
  /* Phone chrome follows the heading's scale. The sixteen-pixel discs sit in
    separate 32px targets; the whole remaining heading continues to drag. */
  html[data-theme] #world #home .mobile-desktop .desktop-window .desktop-titlebar,
  html[data-theme] #world #home .mobile-desktop #desk-entry .desktop-titlebar {
    /*
     * !important: the compact 32px phone title bar (and its 32px buttons below) beat the 44px touch sizes
     * above, which are also !important; this block comes later and is more specific.
     */
    height: 32px !important;
    min-height: 32px !important;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-window .desktop-titlebar > div {
    height: 32px;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-window .window-grab {
    min-height: 0;
    padding: 0 8px 0 68px;
    font-size: 12px;
    line-height: 1.3;
  }

  html[data-theme] #world #home .mobile-desktop .desktop-window .desktop-titlebar > div > button {
    /* !important: same reason as the title bar height above. */
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }

  html[data-theme]
    #world
    #home
    .mobile-desktop
    .desktop-window
    .desktop-titlebar
    > div
    > button::after {
    width: 16px;
    height: 16px;
  }

  html[data-theme]
    #world
    #home
    .mobile-desktop
    .desktop-window
    .desktop-titlebar
    > div
    > button::before {
    width: 8px;
  }

  html[data-theme]
    #world
    #home
    .mobile-desktop
    .desktop-window
    .desktop-titlebar
    > div
    > [data-close-window]::before {
    height: 8px;
  }
}

/* Small viewports keep the question in its own bounded sheet. Opening it must
   never displace application windows beneath the fixed dock. */
html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-arrival {
  position: fixed;
  left: 50%;
  right: auto;
  top: var(--uturn-popover-top,8px);
  bottom: auto;
  translate: -50% 0;
  margin: 0;
  max-height: var(--uturn-popover-height,calc(100dvh - 80px));
  overflow: hidden;
  box-sizing: border-box;
}

html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-arrival:not([hidden]) {
  display: flex;
  flex-direction: column;
}

html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-titlebar {
  position: relative;
  flex: 0 0 auto;
  height: 32px;
  min-height: 32px;
  padding: 0 4px 0 9px;
  box-sizing: border-box;
}

html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-form {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
}

html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-close {
  position: relative;
  width: 32px;
  height: 32px;
  min-height: 32px;
  flex: 0 0 32px;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: 0;
  line-height: 0;
}

html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-close::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 1px solid #76767a;
  border-radius: 3px;
  background: #d7d7d9;
  box-shadow: inset 0 1px #fff;
  pointer-events: none;
}

html[data-theme] #world #home .compact-uturn-sheet #home-uturns .uturn-close::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: 8px;
  height: 8px;
  z-index: 1;
  background:
    linear-gradient(45deg, transparent 42%, currentColor 43% 57%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, currentColor 43% 57%, transparent 58%);
  pointer-events: none;
}

html[data-theme] #world #home .portal-brand:not(:has(.uturn-arrival:not([hidden]))) {
  /*
   * While the road question is closed the title block gets z-index 3 instead of the 20 the pocket desktop rule
   * above gives it. This selector is already more specific than that rule, so the !important is not what makes it
   * win (removing it changed nothing in Chrome at 390 and 1440 px, 6 Oct 2026). While the question is open this
   * selector no longer matches, so the other z-index values apply.
   */
  z-index: 3 !important;
}

html[data-theme] #world #home #desktop-free-shortcuts.is-shortcut-dragging {
  z-index: 160;
}

@media (max-width: 620px) {
  /* Keep initial windows beneath the complete shortcut grid, even when the
    short phone has less than the controller's usual 220px window allowance. */
  html[data-theme] #world #home .mobile-desktop .desktop-window:not([hidden]) {
    max-height: min(var(--mobile-window-height,300px),max(64px,calc(100svh - var(--mobile-icons-top,146px) - var(--mobile-icons-height,224px) - 80px - env(safe-area-inset-bottom,0px))));
  }
}

@media (max-width: 620px) and (max-height: 660px) {
  /* Avoid a second title line consuming the short phone's window work area. */
  html[data-theme] #world #home .mobile-desktop .portal-brand h1 {
    /*
     * !important: hyd-fonts.css sets the heading size with !important (40px on phones). This smaller clamp has
     * to be !important as well, and is more specific, so a short phone does not wrap the title onto a second
     * line.
     */
    font-size: clamp(26px, 7.2vw, 36px) !important;
  }
}

/* The pocket desktop has bounded window scrollers. Empty-wallpaper
   swipes must not move the root page or trigger Safari's rubber-band layout. */
@media (max-width: 620px) {
  html:has(#home.active),
  html:has(#home.active) body {
    overflow: hidden;
    overscroll-behavior-y: none;
  }
}
