/* The phone shell (data-form="phone"): portrait = top bar · stage · sheet · bottom nav; landscape = rail · top bar ·
   stage · side sheet. Every hit target ≥ 44 px. Panels inside sheets lose their frame (the sheet is the frame). */

[data-form='phone'] {
  --tap: 44px;
  --phone-top: 54px;
  --phone-nav: 64px;
  --phone-rail: 78px;
  --gap: 8px;
}
[data-form='phone'][data-orient='landscape'] {
  --phone-top: 48px;
}
.hud--phone {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: 'top' 'body' 'nav';
}
.hud--phone[data-orient='landscape'] {
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: 'nav top' 'nav body';
}
.hud--phone > .phone-top {
  grid-area: top;
}
.hud--phone > .hud__body {
  grid-area: body;
}
.hud--phone > .phone-nav {
  grid-area: nav;
}

/* ---------------------------------------------------------------- top bar */
.phone-top {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--phone-top);
  padding: 0 6px 0 4px;
  background: var(--lacquer-black);
  color: var(--paper-50);
  border-bottom: 3px solid var(--son-500);
  box-shadow: 0 1px 0 var(--vang-400), 0 6px 16px rgba(9, 8, 6, 0.35);
}
.phone-top__main {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 46px;
  padding: 0 6px 0 4px;
  overflow: hidden;
  border-radius: 9px;
  color: inherit;
  text-decoration: none;
}
.phone-top__main:active {
  background: rgba(246, 232, 197, 0.08);
}
.phone-top__gold {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}
.phone-top__gold-text {
  display: grid;
  line-height: 1.08;
}
.phone-top__amount {
  color: var(--vang-200);
  font-size: 17px;
}
.phone-top__rate {
  color: var(--la-bright);
  font-size: 11.5px;
}
.phone-top__tier,
.phone-top__good {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.phone-top__tier .portrait {
  box-shadow: 0 0 0 1.5px var(--tone);
}
.phone-top__tier .is-short {
  color: var(--chusa-bright);
}
.phone-top__good.is-low .num {
  color: var(--chusa-bright);
}
.phone-top [data-prio].is-hidden {
  display: none;
}
.phone-top__btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--then-600);
  border-radius: 10px;
  background: rgba(246, 232, 197, 0.05);
  color: var(--vang-200);
}

/* ---------------------------------------------------------------- body: stage + sheet */
.phone-body {
  position: relative;
  min-height: 0;
}
.phone-stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.phone-stage > * {
  pointer-events: auto;
}
.phone-dock {
  position: absolute;
  top: var(--gap);
  right: var(--gap);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.phone-dock__btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--then-900);
  border-radius: 50%;
  background: var(--lacquer-red);
  color: var(--vang-200);
  box-shadow: inset 0 0 0 1px var(--vang-500), var(--shadow);
}
.phone-notice {
  position: absolute;
  top: var(--gap);
  left: var(--gap);
  right: calc(var(--gap) * 2 + 48px);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border-width: 2px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}
.phone-bottom {
  position: absolute;
  left: var(--gap);
  right: var(--gap);
  bottom: calc(var(--sheet-h, 0px) + var(--gap));
  display: flex;
  justify-content: center;
}
.hud--phone[data-orient='landscape'] .phone-bottom {
  right: auto;
  width: min(380px, calc(100% - 2 * var(--gap)));
}
.hud--phone[data-orient='landscape'][data-sheet]:not([data-sheet='none']) .phone-bottom {
  right: auto;
  width: calc(100% - var(--sheet-w, 0px) - 3 * var(--gap));
  bottom: var(--gap);
}
.phone-guide {
  width: 100%;
  max-width: 480px;
  border-width: 3px;
  color: var(--text);
  text-decoration: none;
}
.phone-guide--obj {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 12px 8px 8px;
}
.phone-guide__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--lacquer-red);
  color: var(--vang-200);
}
.phone-guide__text {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
}
.phone-guide__text small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.phone-guide__text b {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  line-height: 1.25;
}
.phone-guide__text b img {
  flex: none;
  object-fit: contain;
}
.phone-guide__n {
  flex: none;
  color: var(--text-2);
  font-size: 13px;
}
.phone-guide:not(.phone-guide--obj) {
  padding: 10px 10px 10px;
}
.phone-guide__row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.phone-guide__row .advisor {
  flex: none;
}
.phone-guide__say {
  color: var(--text-2);
  font-size: 12px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-guide__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.phone-guide__actions .btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0 10px;
}
.phone-guide__actions .btn--ghost {
  flex: none;
}

/* the sheet: portrait from the bottom; landscape on the right */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  height: var(--sheet-h, 50%);
  border-top: 3px solid var(--son-frame);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -1px 0 var(--vang-400) inset, 0 -10px 26px rgba(9, 8, 6, 0.38);
  container: sheet / inline-size;
  overflow: hidden;
}
.hud--phone[data-orient='landscape'] .sheet {
  left: auto;
  width: var(--sheet-w, 52%);
  border-left: 3px solid var(--son-frame);
  border-radius: 14px 0 0 0;
}
.sheet__grip {
  position: relative;
  display: flex;
  justify-content: center;
  flex: none;
  height: 22px;
}
.sheet__handle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 120px;
  height: 44px;
  z-index: 2;
}
.sheet__handle span {
  width: 44px;
  height: 5px;
  margin-top: -14px;
  border-radius: 3px;
  background: var(--muc-500);
}
.sheet__snaps {
  position: absolute;
  right: 12px;
  top: 7px;
  display: flex;
  gap: 3px;
}
.sheet__snaps i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--paper-400);
}
.sheet__snaps i.on {
  background: var(--son-400);
}
.sheet__head {
  flex: none;
  padding: 0 10px 6px 14px;
}
.sheet__head .panel__title {
  font-size: 19px;
}
.sheet__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  color: var(--text-title);
}
.sheet__head .panel__img {
  width: 48px;
  height: 48px;
}
.sheet__head .icon-btn {
  width: 44px;
  height: 44px;
}
.sheet__content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet__content > .panel__body {
  padding: 2px 14px 14px;
}
.sheet[data-snap='peek'] .sheet__content > .panel__body,
.sheet[data-snap='peek'] .panel__foot {
  visibility: hidden;
}
.sheet .panel__foot {
  flex: none;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
}
.sheet .panel__foot .btn {
  flex: 1 1 auto;
}
/* desktop panels inside a sheet: no frame, no absolute placement */
.sheet__content--raw {
  padding: 0;
}
.sheet__content--raw > .frame,
.sheet__content--raw > .modal-layer > .frame {
  position: static;
  flex: 1;
  width: auto;
  max-height: none;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.sheet__content--raw > .modal-layer {
  position: static;
  display: flex;
  flex: 1;
  min-height: 0;
  padding: 0;
  background: none;
}
.sheet .corner,
.sheet .watermark {
  display: none;
}
.sheet__content--raw .panel__head {
  padding: 0 10px 6px 14px;
}
.sheet__content--raw .panel__head .icon-btn {
  width: 44px;
  height: 44px;
}
.sheet__content--raw .panel__head > .glyph {
  width: 26px;
  height: 26px;
}
.sheet .tabs {
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 10px;
}
.sheet .tab {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
}
.sheet .kpis {
  gap: 6px;
}
.sheet .need-grid {
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
}
.sheet .need {
  --ring: 54px !important;
}
.sheet .btn,
.sheet .switch,
.sheet .select,
.sheet .speed__btn,
.sheet .seg button,
.sheet .amount input {
  min-height: 44px;
}
.sheet .speed__btn {
  min-width: 48px;
}
.sheet .store {
  min-height: 60px;
}
.sheet .act {
  height: 30px;
}
.sheet .tipped > .tip {
  display: none;
}
.sheet .stats-filter {
  display: none;
}
.sheet .need-row {
  grid-template-columns: 34px minmax(70px, 1fr) minmax(80px, 1.2fr) auto;
}
.sheet .need-row > .num {
  display: none;
}
.sheet .need-row .switch {
  font-size: 0;
  gap: 0;
  min-width: 44px;
  justify-content: center;
}
.sheet .table .opt {
  display: none;
}
@container sheet (min-width: 560px) {
  .sheet .table .opt {
    display: table-cell;
  }
}
.sheet .table td,
.sheet .table th {
  padding: 6px 4px;
}
.sheet .table td .btn {
  min-width: 44px;
}
.sheet .fin-row {
  grid-template-columns: minmax(0, 1fr) 70px 56px;
  min-height: 34px;
}
.sheet .route-act {
  grid-template-columns: 1fr auto;
}
.sheet .route-act .seg {
  grid-column: 1 / -1;
}
.sheet .route-stop__head .icon-btn {
  width: 44px;
  height: 44px;
}
.sheet .chat__input input {
  min-height: 44px;
}
.sheet .chat__input .icon-btn {
  width: 44px;
  height: 44px;
}
.sheet .need-cell > .need {
  width: 54px;
  height: 54px;
}
.sheet .cargo__slot {
  min-height: 64px;
}
.sheet .player {
  min-height: 44px;
}
.sheet .infotip {
  width: 44px;
  height: 44px;
  margin: -13px -13px -13px -10px;
}

/* the build sheet (PhoneBuild) */
.ptabs {
  display: flex;
  gap: 6px;
  margin: 0 -14px 6px;
  padding: 2px 14px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--paper-300);
}
.ptab {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--paper-400);
  border-radius: 999px;
  background: var(--paper-50);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.ptab.is-on {
  border-color: var(--then-900);
  background: var(--lacquer-red);
  color: var(--paper-50);
}
.ptab .portrait {
  box-shadow: 0 0 0 1.5px var(--tone);
}
.prows {
  display: grid;
  gap: 6px;
}
.prow__head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 4px;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.prow__tiles {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -14px;
  padding: 2px 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ptile {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2px;
  flex: none;
  width: 72px;
  min-height: 84px;
  padding: 4px 2px 4px;
  border: 1px solid var(--paper-400);
  border-radius: 9px;
  background: radial-gradient(circle at 50% 35%, var(--paper-50), var(--paper-200));
  color: var(--text);
}
.ptile__img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.ptile__img--good {
  width: 42px;
  height: 42px;
  margin: 7px;
}
.ptile.is-temp::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(117, 94, 54, 0.4);
  border-radius: 7px;
  pointer-events: none;
}
.ptile__name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}
.ptile.is-on {
  border-color: var(--son-300);
  box-shadow: 0 0 0 2px var(--son-300), 0 0 0 4px rgba(239, 200, 112, 0.6);
}
.ptile--tool {
  align-content: center;
  color: var(--text-2);
}
.ptile--feed {
  width: 60px;
  min-height: 60px;
  align-content: center;
  border-style: dashed;
  background: transparent;
}
.pchain__col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pchain__arrow {
  flex: none;
  color: var(--muc-500);
}
.pchain__end {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--paper-50), var(--paper-200));
  box-shadow: 0 0 0 2px var(--vang-500), 0 0 0 3px var(--then-700);
}
.pupgrade {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
}
.pcard {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--son-300);
  border-radius: 10px;
  background: var(--paper-50);
  box-shadow: 0 0 0 3px rgba(144, 28, 8, 0.12);
}
.pcard__img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.pcard__img--good {
  width: 44px;
  height: 44px;
  margin: 6px;
}
.pcard__text {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.pcard__text b {
  font-family: var(--font-title);
  font-size: 16px;
}
.pcard__facts {
  color: var(--text-2);
  font-size: 12px;
}
.pcard__go {
  min-height: 52px !important;
  padding: 0 14px;
  font-size: 15px;
}
.pcard .cost {
  height: 24px;
  font-size: 12px;
}
.pmenu {
  display: grid;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.pmenu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--paper-300);
  color: var(--text);
  text-decoration: none;
}
.pmenu__item > .glyph:first-child {
  color: var(--text-title);
}
.pmenu__item span {
  flex: 1;
  display: grid;
  line-height: 1.2;
}
.pmenu__item small {
  color: var(--text-muted);
  font-size: 12px;
}
.pmenu-players {
  padding: 4px 0;
}
.ptiers {
  display: grid;
  gap: 4px;
}
.ptier {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.ptier > span:nth-child(2) {
  flex: 1;
  display: grid;
  line-height: 1.15;
}
.ptier small {
  color: var(--text-muted);
  font-size: 11.5px;
}
.pgoods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 6px;
}
.pgood {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 6px 2px;
  border: 1px solid var(--paper-300);
  border-radius: 8px;
  background: rgba(246, 232, 197, 0.8);
  font-size: 13px;
}
.pgood small {
  font-size: 10.5px;
}
.pgood.is-low {
  border-color: var(--nghe-ui);
}

/* ---------------------------------------------------------------- bottom nav / left rail (red lacquer) */
.phone-nav {
  position: relative;
  z-index: 9;
  display: flex;
  height: calc(var(--phone-nav) + env(safe-area-inset-bottom, 0px));
  padding: 4px 4px env(safe-area-inset-bottom, 0px);
  background: var(--lacquer-red);
  border-top: 2px solid var(--vang-400);
  box-shadow: 0 -1px 0 var(--then-900), 0 -6px 18px rgba(9, 8, 6, 0.3);
}
.hud--phone[data-orient='landscape'] .phone-nav {
  flex-direction: column;
  width: var(--phone-rail);
  height: auto;
  padding: 4px;
  border-top: 0;
  border-right: 2px solid var(--vang-400);
}
.phone-nav__btn {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  border-radius: 9px;
  color: var(--paper-50);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
}
.phone-nav__btn .glyph {
  color: var(--vang-200);
}
.phone-nav__btn span {
  white-space: nowrap;
}
.phone-nav__btn.is-on {
  background: rgba(9, 8, 6, 0.35);
  box-shadow: inset 0 0 0 1px var(--vang-500);
}
.phone-nav__btn.is-on span {
  color: var(--vang-200);
}
.phone-nav__new {
  position: absolute;
  top: 2px;
  right: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ngoc-500);
  color: var(--paper-50);
  font-size: 9.5px;
  font-weight: 700;
}
.hud--phone .spotlight {
  border-radius: 12px;
}
.sheet .opt-inline {
  display: none !important;
}
@container sheet (min-width: 560px) {
  .sheet .opt-inline {
    display: inline-block !important;
  }
}
.hud--phone[data-orient='landscape']:not([data-sheet='none']) .phone-dock {
  right: calc(var(--sheet-w) + var(--gap));
}
.hud--phone[data-snap='full'] .phone-dock,
.hud--phone[data-orient='portrait'][data-snap='half'] .phone-notice {
  display: none;
}
.sheet .seg button {
  min-width: 48px;
}
.sheet__content--raw > .modal-layer {
  flex-direction: column;
}
.sheet__content--raw .frame {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sheet__content--raw .panel__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
[data-form='phone'] kbd,
[data-form='phone'] .keycap {
  display: none;
}
.sheet__content--raw .frame {
  z-index: auto;
}
.sheet__handle {
  z-index: 10;
}
