/* v30 mobile pass: scrolling sheets, one sheet at a time, sheet headers, the phone build mode.
   Loaded last; desktop rules here are small and shared. */

/* Scrolling. The page itself never scrolls (overflow hidden), so the body no longer needs touch-action:none,
   which on iOS Safari also blocked scrolling inside the sheets. Only the map canvas takes raw touches. */
html,
body {
  touch-action: manipulation;
}
#c {
  touch-action: none;
}
.panel,
.tray,
.qbody,
.side > .card,
.dev {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
/* s1-polish (П11): the ends of the tab row. Sticky inside the row, laid over the first and last tabs (negative
   margins), shown only where more tabs hide (js/ui/panels.js tabsEdge); a tap scrolls by a screenful */
.tabs .tabar {
  position: sticky;
  z-index: 2;
  flex: none;
  align-self: stretch;
  width: 56px;
  min-height: 40px;
  border: 0;
  padding: 0 8px;
  font: 900 26px/1 var(--body);
  color: var(--rim, #3a2414);
  cursor: pointer;
  visibility: hidden;
}
.tabs .tabar.l {
  left: 0;
  margin-right: -56px;
  text-align: left;
  background: linear-gradient(90deg, var(--cream) 45%, transparent);
  box-shadow: -6px 0 0 var(--cream); /* (over the row's padding too: the tabs scroll under it) */
}
.tabs .tabar.r {
  right: 0;
  margin-left: -56px;
  text-align: right;
  background: linear-gradient(270deg, var(--cream) 45%, transparent);
  box-shadow: 6px 0 0 var(--cream);
}
.tabs.ml .tabar.l,
.tabs.mr .tabar.r {
  visibility: visible;
}

/* Sheet header: the title and the close button on one line; the content below uses the full width. */
.panel > h3:first-child,
.side > .card > .shead {
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel > h3:first-child > [data-p='close'],
.shead > .sx {
  float: none !important;
  margin-left: auto;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  font-size: 16px;
}
.panel .acts.menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.panel .acts.menu .btn {
  width: 100%;
  margin: 0;
}

/* Camp card: a header that can fold the card away, tabs, and a separate card for the selected building. */
.campCard .shead h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.campCard.folded > :not(.shead) {
  display: none !important;
}
.campCard .ctabs {
  display: flex;
  gap: 6px;
  margin: 8px 0 6px;
}
.campCard .ctabs .pill {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.campCard .ctabs .pill[aria-pressed='true'] {
  background: var(--ink);
  color: var(--stone);
}

/* Wallet: shells in the HUD; tapping them opens the other resources. */
.rpill .chip[data-it='money'] {
  cursor: pointer;
}
.wallet .rrow {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--stone-lo);
  font-size: 15px;
}

/* Build cards: the name, then the price written as "2,500 (shell)" on its own line. */
.item .price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  white-space: nowrap;
}
.item .price .coin {
  width: 15px;
  height: 15px;
}
.item .sub {
  display: block;
  font-size: 11px;
  opacity: 0.85;
}

/* Guest thought bubbles stay small (drawn by PixiJS, see js/ui/guestinfo.js). */

/* Phone build mode: the picked building sits in the middle of the screen; check and cross below it. */
.placeBar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--cmdH, 100px) + 18px);
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  z-index: 8;
  pointer-events: auto;
}
.placeBar[hidden],
body.qopen .placeBar,
body.popen .placeBar,
body.bopen:not(.bmini) .placeBar {
  display: none;
}
.placeBar button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--stone-lo);
  box-shadow: 0 4px 0 rgba(36, 21, 9, 0.35);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.placeBar button svg {
  width: 30px;
  height: 30px;
}
.placeBar .pbOk {
  background: #4f8a2b;
  color: #fff;
}
.placeBar .pbOk:disabled {
  background: #9aa58e;
  pointer-events: none; /* the tap reaches the bar, which says why (js/ui/why.js) */
}
.placeBar .pbX {
  background: var(--stone);
  color: var(--ink);
}
.placeBar .pbWarn {
  color: #ffd23a;
  white-space: normal;
}
/* build orders: «Bring» for what the building is short of, a small pill (not one of the round check / cross buttons) */
.placeBar .pbName .pbBring {
  display: inline-block;
  width: auto;
  height: auto;
  border-radius: 9px;
  border: 1px solid var(--stone-lo);
  box-shadow: none;
  padding: 1px 8px;
  margin-left: 4px;
  font: inherit;
  font-weight: 700;
  background: var(--orange, #e07a2a);
  color: #fff;
}
.placeBar .pbName {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--dim);
  color: #f6eedc;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 13px;
  /* the label floats over the map and placeViewRect ignores it, whatever the label says */
  max-height: 74px;
  box-sizing: border-box;
  overflow-y: auto;
  touch-action: pan-y;
}
/* Claiming land with a finger: the cross and the check under the picked plot (js/render/overlays.js, landBarTick) */
.landBar {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 18px;
  z-index: 8;
}
.landBar[hidden],
body.photo .landBar,
body.visiting .landBar {
  display: none;
}
.landBar button.buildAction {
  width: 56px;
  height: 56px;
}
.landBar button.buildAction:disabled {
  pointer-events: none;
}
/* Clearing: the check and cross stand right under what is lit, the label under them (js/ui/place.js, bulldozeBar) */
body.placing .placeBar.under {
  right: auto;
  bottom: auto;
  height: auto;
  width: max-content;
  max-width: min(92vw, 320px);
  transform: translateX(-50%);
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 18px;
}
body.placing .placeBar.under .pbName {
  position: static;
  order: 3;
  flex: 1 1 100%;
  transform: none;
  text-align: center;
  max-height: none;
  white-space: normal;
}
body.placing .toolChip {
  display: none !important;
}
/* Phone coaster builder: while the track is drawn its buttons stand in a bar over the command bar, in place of the
   ride's sheet, so the map stays in view (js/ui/place.js) */
.trackBar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(var(--cmdH, 100px) + 8px);
  z-index: 8;
  pointer-events: auto;
  background: var(--dim);
  color: #f6eedc;
  border-radius: 14px;
  padding: 6px 8px 8px 12px;
}
.trackBar[hidden],
body.qopen .trackBar,
body.popen .trackBar,
body.bopen:not(.bmini) .trackBar {
  display: none;
}
.trackBar .tbTop {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.trackBar .tbText {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.trackBar .tbText b {
  display: block;
  font-size: 13px;
}
.trackBar .tbText small {
  display: block;
  font-size: 11.5px;
  opacity: 0.85;
}
.trackBar .tbX {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--bark);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.trackBar .tbX svg {
  width: 16px;
  height: 16px;
}
.trackBar .tbBtns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.trackBar .tbBtns .btn {
  min-height: 38px;
  padding: 2px 4px;
  font-size: 13.5px;
  white-space: nowrap;
}
/* the track buttons' painted icons (tbLabel, js/rides/track-kinds.js) are bigger than an icon in a line of text */
.trackBar .tbBtns .uin,
#info [data-tb] .uin,
#train2 .uin {
  width: 1.9em;
  height: 1.9em;
  margin: -0.45em 3px -0.45em -2px;
}
/* a wide screen: the bar stands in the middle above the command bar, its buttons in one or two rows */
@media (min-width: 700px) {
  .trackBar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(760px, calc(100vw - 32px));
    box-sizing: border-box;
  }
  .trackBar .tbBtns {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
  .trackBar .tbBtns .btn {
    min-height: 46px;
  }
  .trackBar .tbBtns .uin {
    width: 2.5em;
    height: 2.5em;
    margin: -0.6em 4px -0.6em -2px;
  }
}
body.tracking .toolChip {
  display: none !important;
}

@media (max-width: 700px) {
  /* one sheet at a time: the cards on the right never sit on top of an open drawer, menu or quest list */
  body.bopen:not(.bmini) .side,
  body.qopen .side,
  body.popen .side {
    display: none;
  }
  .side > .card {
    max-height: min(48vh, calc(100vh - var(--hudB, 110px) - var(--cmdH, 100px) - 40px));
  }
  .panel {
    left: 10px;
    right: 10px;
    width: auto;
    transform: none;
    max-height: calc(100% - var(--hudB, 110px) - var(--cmdH, 100px) - 24px);
  }
  /* build drawer: tabs scroll sideways; an arrow over a fade at each end where more tabs hide (.tabar) */
  .tabs {
    display: flex;
    flex-wrap: nowrap;
  }
  .tabs .tab {
    flex: none;
  }
  .tray::after {
    content: '';
    position: sticky;
    display: block;
    bottom: calc(var(--cmdH, 100px) + 4px);
    height: 0;
  }
  .items .item b {
    font-size: 12.5px;
    line-height: 1.15;
  }
  .scrollHint {
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 2px 0 6px;
  }
}
@media (min-width: 701px) {
  .scrollHint {
    display: none;
  }
  /* (the track builder's bar shows on every screen: js/ui/place.js) */
  .placeBar {
    display: none !important;
  }
}
.items .scrollHint {
  grid-column: 1 / -1;
  margin: 0;
}
/* the camp card put away: a small pill at the bottom, the camp stays in view */
.campCard.folded {
  padding: 6px 8px !important;
  width: auto !important;
}
.campCard.folded .shead {
  gap: 6px;
}
.campCard.folded .cfoldpill {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.campCard.folded .sx {
  white-space: nowrap;
}
.campCard.folded::before {
  display: none !important;
}

/* a build card whose price went up with the copies already standing (a phone; a desktop's cards keep one height and
   its details pane says it) */
.item .copyUp {
  display: block;
  font-size: 13px;
  line-height: 1.15;
  color: var(--muted);
  text-align: center;
}
@media (min-width: 701px) {
  .item .copyUp {
    display: none;
  }
}

/* the Quests card a round button on the map opened (the waiting event): it blinks */
#qbody > .card.pulse {
  animation: pulseCard 0.8s ease 3;
}

/* s1-polish (newbie review Р4, Р5): on a phone no text under 13 px and no target under 40 px in the bottom bar, the
   build drawer and the camp sheet (tools/tests_ui.py --polish measures them) */
@media (max-width: 700px) {
  /* the bar: a little less frame around it, so 13-px «Стоянка» and «Задания» fit inside their tiles */
  .cmdbar {
    left: 6px;
    right: 6px;
    padding-left: 6px;
    padding-right: 6px;
  }
  .cmdbar .cb {
    width: 68px;
    font-size: 13px;
    letter-spacing: -0.02em;
  }
  .cmdbar .cb.big {
    width: 78px;
  }
  /* the drawer's cards: name, price, the ✿ and goods after it, the biome, what is missing */
  .items .item b,
  .items .item span,
  .items .item .sub,
  .items .item .bio,
  .items .item .short,
  .items .item small,
  .scrollHint {
    font-size: 13px;
  }
  .items .item .bio {
    white-space: normal;
  }
  /* the camp sheet */
  .campCard small,
  .campCard .clv b,
  .campCard .rrow {
    font-size: 13px;
  }
  .campCard .ctabs .pill,
  .restab.cstore .rrow .pill {
    min-height: 40px;
    box-sizing: border-box;
    font-size: 13px;
  }
  .campCard .ctabs .pill {
    display: flex;
    align-items: center;
  }
  /* (a wider keep pill: «в парке 40» on one line at 13 px, not four lines in a 75-px one) */
  .restab.cstore .rrow {
    grid-template-columns: 22px minmax(0, 1fr) 50px 36%;
  }
}

/* A sheet's header and its close cross stay put: the window is a flex column, its header (on the window's own hide, nothing
   painted over it) does not scroll and the rest scrolls in a box of its own. The box is made after the sheet is written:
   .pbody for a window (js/ui/panels.js, a MutationObserver), .ibody for the ride and guest card (setPinned, js/ui/hud.js). */
.panel.hasbody:not([hidden]),
#info.hasbody:not([hidden]) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel.hasbody > h3:first-child,
#info.hasbody > h3:first-child {
  flex: none;
  margin-bottom: 4px;
}
.panel.hasbody > .pbody,
#info.hasbody > .ibody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
#info > h3:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}
#info > h3:first-child > .sx {
  margin-left: auto;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  font-size: 16px;
}

/* Building on a phone (the placing bar, the coaster's track bar) is quiet: of the HUD only the top bar stays (shells, guests,
   mood, rating), and of the rest only what is being built. No goals, Now line, events, quest portrait, tips or
   news; errors (the red messages) still come. The bottom bar stays: it is the way out. */
body.placing .hudL > :not(.rpill),
body.tracking .hudL > :not(.rpill),
body.placing .sideBtns,
body.tracking .sideBtns,
body.placing .hudPop,
body.tracking .hudPop,
body.placing .qbub,
body.tracking .qbub,
body.placing .hint,
body.tracking .hint,
body.placing .alerts,
body.tracking .alerts,
body.placing #tut,
body.tracking #tut,
body.placing .layerCard,
body.tracking .layerCard,
body.placing .hudTip,
body.tracking .hudTip,
body.placing .plotTip,
body.tracking .plotTip,
body.placing #toast .t:not(.bad),
body.tracking #toast .t:not(.bad) {
  display: none !important;
}
.placeBar button[hidden],
.toolChip button[hidden] {
  display: none;
}
