/* Skybound phase 3 shell (WP-B, ui.md §3–§6): the one sheet system, the component kit, dialogs,
   and the Home layouts for phones and tablets. Linked right after app.css, so it refines the base
   styles there. Media queries use the shared strings from client/js/ui/layout.js:
     P  (max-width: 480px) and (min-height: 501px)        phone portrait
     L  (max-height: 500px)                                short / phone landscape
     TP (min-width: 481px) and (max-width: 1024px) and (min-height: 501px) and (orientation: portrait)
     TL everything else (the default rules)
   plus (any-pointer: coarse), (hover: hover), (prefers-reduced-motion: reduce) and @container. */

/* ── Sheets (kit.sheetView) ─────────────────────────────────────────────────────────────── */
.overlay.sv {
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  background: rgba(5, 7, 11, 0.45);
}
.sv > .sheet {
  display: flex;
  flex-direction: column;
  width: min(820px, 100%);
  max-height: calc(var(--vvh) - var(--pad-t) - var(--pad-b));
  overflow: hidden;
  padding: 0;
  min-width: 0;
}
.sv > .sheet.sv-sm {
  width: min(440px, 100%);
}
.sv > .sheet.sv-md {
  width: min(620px, 100%);
}
.sv > .sheet.sv-lg {
  width: min(820px, 100%);
}
.sv > .sheet.sv-xl {
  width: min(1100px, 100%);
}
.sv .sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 18px 22px 10px;
  flex: none;
}
.sv .sv-titles {
  flex: 1;
  min-width: 0;
}
.sv .sv-titles h2 {
  outline: none;
  overflow-wrap: anywhere;
}
.sv .sheet-head .sub {
  font-size: var(--fs-200);
  margin-top: 2px;
}
.sv .sv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.sv .sv-close {
  flex: none;
}
.sv .sheet-tabs {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 0 22px 10px;
  min-width: 0;
}
.sv .sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 22px calc(var(--sp-4) + var(--kb));
  container-type: inline-size;
}
.sv .sheet-foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 22px max(14px, var(--sa-b));
  border-top: 1px solid var(--line);
}
.sv .sheet-foot > .btn {
  flex: 1 1 auto;
}
.sv .sheet-foot > .grow-2 {
  flex: 2 1 auto;
}
.sv-end {
  justify-items: end;
}
.sv-end > .sheet {
  align-self: stretch;
  max-height: none;
}
.sv-bottom {
  align-items: end;
}
.stage-slot {
  pointer-events: none;
  min-width: 0;
  min-height: 0;
}
/* Tablets and computers with a stage: the character stays in view to the left of the sheet. */
.sv-wide.sv-stage {
  background: transparent;
  grid-template-columns: minmax(0, 1fr) auto;
  place-items: stretch;
}
.sv-wide.sv-stage > .stage-slot {
  grid-column: 1;
  grid-row: 1;
}
.sv-wide.sv-stage > .sheet {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}
.sv-enter.sv-wide > .sheet {
  animation: sv-in 0.15s ease-out;
}
@keyframes sv-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
}

/* Phones: one full-screen, opaque sheet (the 3D view underneath is paused), Back at the top left. */
.overlay.sv-phone {
  padding: 0;
  place-items: stretch;
  background: var(--opaque);
}
.sv-phone > .sheet {
  width: 100%;
  height: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.sv-phone > .sheet.sv-sm,
.sv-phone > .sheet.sv-md,
.sv-phone > .sheet.sv-lg,
.sv-phone > .sheet.sv-xl {
  width: 100%;
}
.sv-phone .sheet-head {
  align-items: center;
  padding: var(--pad-t) var(--pad-r) 8px var(--pad-l);
}
.sv-phone .sheet-tabs {
  padding: 0 var(--pad-r) 8px var(--pad-l);
}
.sv-phone .sheet-body {
  padding: 4px var(--pad-r) calc(var(--sp-4) + var(--kb)) var(--pad-l);
}
.sv-phone .sheet-foot {
  padding: 10px var(--pad-r) max(12px, var(--sa-b)) var(--pad-l);
  background: var(--opaque);
}
/* A sheet with no foot (the Room menu on L): the scrolling body stops above the home indicator, so
   no control rests inside the bottom safe area (M11; found on pixel7-land in WP-Z1). */
.sv-phone .sheet-body:last-child {
  margin-bottom: var(--sa-b);
}
.sv-phone .sv-close {
  padding-left: 10px;
  padding-right: 14px;
}
.sv-enter.sv-phone > .sheet {
  animation: sv-up 0.18s ease-out;
}
@keyframes sv-up {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
}
/* Phone portrait with a stage: the character in the top 40 %, the sheet below it. */
.sv-phone.sv-stage-top {
  background: transparent;
  grid-template-rows: minmax(200px, 40%) minmax(0, 1fr);
}
.sv-phone.sv-stage-top > .stage-slot {
  grid-row: 1;
}
.sv-phone.sv-stage-top > .sheet {
  grid-row: 2;
  height: auto;
  min-height: 0;
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  background: var(--opaque);
}
.sv-phone.sv-stage-top .sheet-head {
  padding-top: 10px;
}
/* Short portrait phones (e.g. 320×568): a smaller stage and no subtitle, so the sheet's sticky
   foot (Equip, Cancel) always fits. */
@media (max-width: 480px) and (max-height: 700px) {
  .sv-phone.sv-stage-top:not(.sv-peek) {
    grid-template-rows: minmax(120px, 30%) minmax(0, 1fr);
  }
  .sv-phone.sv-stage-top .sheet-head .sub {
    display: none;
  }
}
/* Phone landscape with a stage: the character on the left, the sheet at the end. */
.sv-phone.sv-stage-start {
  background: transparent;
  grid-template-columns: minmax(0, 1fr) min(58vw, 520px);
}
.sv-phone.sv-stage-start > .stage-slot {
  grid-column: 1;
  grid-row: 1;
}
.sv-phone.sv-stage-start > .sheet {
  grid-column: 2;
  grid-row: 1;
  background: var(--opaque);
  border-left: 1px solid var(--line);
}
@media (max-height: 500px) {
  .sv-phone.sv-stage-start .sheet-head .sub {
    display: none;
  }
}
/* The Tricks "peek": only a bar, the preview fills the rest. */
.sv-peek .sheet-body {
  display: none;
}
.sv-phone.sv-stage-top.sv-peek {
  grid-template-rows: minmax(0, 1fr) auto;
}
.sv-phone.sv-stage-start.sv-peek {
  grid-template-columns: minmax(0, 1fr) min(44vw, 400px);
}
.sv-phone.sv-stage-start.sv-peek > .sheet {
  align-self: end;
  height: auto;
  border-radius: 18px 0 0 0;
}
.peek-line {
  flex: 1 1 100%;
  font-weight: 800;
  color: var(--cyan-hi);
}
/* Small modal sheets (the nickname): a bottom sheet above the keyboard on phones. */
.overlay.sv-phone.sv-dialog {
  align-items: end;
  background: rgba(5, 7, 11, 0.62);
}
.sv-phone.sv-dialog > .sheet {
  height: auto;
  max-height: calc(var(--vvh) - var(--kb) - 24px);
  margin-bottom: var(--kb);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  background: var(--opaque);
}
/* See-through sheets (How to play): the scene stays faintly visible. */
.overlay.sv-phone.sv-see:not(.sv-dialog) {
  background: rgba(13, 15, 20, 0.88);
}

/* ── Component kit ──────────────────────────────────────────────────────────────────────── */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--ink-2);
  border: 1px solid var(--line);
}
.seg-btn {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--silver);
  font-weight: 800;
  cursor: pointer;
}
.seg-btn.on {
  background: var(--graphite);
  color: var(--cyan-hi);
  box-shadow: inset 0 0 0 1px var(--cyan);
}
.seg-btn:focus-visible,
.set-item:focus-visible,
.list-btn:focus-visible,
.kit-details > summary:focus-visible {
  outline: 3px solid var(--cyan-hi);
  outline-offset: 2px;
}
.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 2px;
  min-width: 0;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
.chip-row::-webkit-scrollbar {
  display: none;
}
.chip-row .chip {
  flex: none;
  cursor: pointer;
  font-size: var(--fs-200);
  padding: 8px 14px;
  white-space: nowrap;
  color: var(--silver);
}
.chip-row .chip:last-child {
  margin-right: 20px;
}
.badge-dot {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--amber);
  color: #1e1204;
  font-size: var(--fs-100);
}
.list-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--ink-2);
  border: 1px solid var(--graphite);
  color: var(--white);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.list-btn:active {
  background: var(--graphite);
}
@media (hover: hover) {
  .list-btn:hover,
  .set-item:hover {
    border-color: var(--line-strong);
  }
}
.lr-ico {
  flex: none;
  width: 28px;
  text-align: center;
  font-size: 1.2rem;
}
.lr-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.lr-title {
  font-weight: 800;
}
.lr-sub {
  font-size: var(--fs-100);
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lr-chev {
  flex: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}
.lr-badge {
  flex: none;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--amber);
  color: #1e1204;
  font-size: var(--fs-100);
  text-align: center;
}
.empty-state,
.error-state {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--ink-2);
  border: 1px dashed var(--line);
}
.empty-state p,
.error-state p {
  margin: 0;
}
.es-ico {
  font-size: 1.6rem;
}
.skeleton {
  display: grid;
  gap: 8px;
}
.sk-row {
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--ink-2) 0%, var(--graphite) 50%, var(--ink-2) 100%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.6s linear infinite;
}
@keyframes sk-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sk-row {
    animation: none;
  }
}
.kit-details {
  border-radius: 12px;
  background: var(--ink-2);
  border: 1px solid var(--graphite);
  min-width: 0;
}
.kit-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  font-weight: 800;
}
.kit-details > summary::-webkit-details-marker {
  display: none;
}
.kit-details > summary::after {
  content: '▾';
  color: var(--muted);
  margin-left: 8px;
}
.kit-details[open] > summary::after {
  content: '▴';
}
.kd-sum {
  margin-right: auto;
}
.kd-val {
  color: var(--cyan-hi);
  font-size: var(--fs-200);
  font-weight: 700;
  text-align: right;
}
.kd-body {
  padding: 4px 14px 14px;
  display: grid;
  gap: 10px;
  min-width: 0;
}
.field-err {
  margin: 0;
  color: var(--amber-hi);
}
.field-err:empty {
  display: none;
}
.conn-chip {
  white-space: nowrap;
}
.link-btn {
  min-height: var(--tap);
  padding: 8px 12px;
  border-color: transparent;
  background: transparent;
  color: var(--cyan-hi);
  text-transform: none;
  letter-spacing: 0;
}
.selectable {
  -webkit-user-select: text;
  user-select: text;
}
[data-input='touch'] .kbd-only,
[data-input='kbm'] .touch-only {
  display: none;
}
.title-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.bird-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.grid-2 {
  grid-template-columns: minmax(0, 1fr);
}
@container (min-width: 640px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* ── Confirmations (dialog.js) ──────────────────────────────────────────────────────────── */
.overlay.dlg-overlay {
  position: fixed;
  z-index: var(--z-dialog);
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  background: rgba(5, 7, 11, 0.62);
}
.dlg {
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  max-height: calc(var(--vvh) - 32px);
  overflow-y: auto;
}
.dlg h2 {
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}
.dlg-body {
  margin: 0;
  color: var(--silver);
  font-weight: 600;
}
.dlg-msg {
  margin: 0;
  color: var(--amber-hi);
}
.dlg-msg:empty {
  display: none;
}
.dlg-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 10px;
}
.dlg-actions .btn {
  flex: 1 1 0;
  min-height: 48px;
}
.pin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.pin-field {
  width: 10ch;
  text-align: center;
  letter-spacing: 0.2em;
}
/* Phone portrait: a bottom action sheet, confirm on top, Cancel nearest the thumb. */
@media (max-width: 480px) and (min-height: 501px) {
  .overlay.dlg-overlay {
    align-items: end;
    padding: 0;
  }
  .dlg {
    width: 100%;
    border-radius: 18px 18px 0 0;
    padding-bottom: max(18px, var(--sa-b));
    margin-bottom: var(--kb);
    max-height: calc(var(--vvh) - var(--kb) - 16px);
  }
  .dlg-actions {
    flex-direction: column;
  }
  .pin-row > * {
    flex: 1 1 0;
    min-width: 0;
  }
  .pin-row .pin-field {
    width: auto;
  }
}

/* ── Home (Screens.menu) ────────────────────────────────────────────────────────────────── */
/* TL (tablet landscape and desktop): today's three columns; the character stands in the middle. */
.menu {
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr) minmax(240px, 320px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(clamp(16px, 3vw, 36px), var(--sa-t)) max(clamp(16px, 3vw, 36px), var(--sa-r)) max(clamp(16px, 3vw, 36px), var(--sa-b)) max(clamp(16px, 3vw, 36px), var(--sa-l));
  overflow: hidden;
}
.menu-panel {
  display: contents;
}
.menu-top {
  grid-column: 1 / 3;
  grid-row: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.menu-brand {
  min-width: 0;
}
.menu-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.menu > .stage-slot {
  grid-column: 2;
  grid-row: 1 / 4;
}
.menu-news:empty {
  display: none;
}
.menu-nav {
  grid-column: 1;
  grid-row: 2 / 4;
  align-self: end;
}
.menu-nav .nav-item .nav-lbl {
  min-width: 0;
}
.menu-side {
  grid-column: 3;
  grid-row: 1 / 3;
  min-width: 0;
}
.menu:has(.menu-ad:not([hidden]):not(:empty)) .menu-side {
  grid-row: 1;
}
.menu .menu-ad {
  grid-column: 3;
  grid-row: 2;
  align-self: end;
}
.menu-play {
  grid-column: 2;
  grid-row: 3;
  min-width: 0;
}
.menu-trust {
  grid-column: 3;
  grid-row: 3;
  align-self: end;
}
.menu-invite {
  display: block;
  width: fit-content;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--glass);
  border: 1px solid var(--line);
}
.pc-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pc-name .grow {
  min-width: 0;
}
.pc-name .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 6px;
}
.pc-feathers,
.pc-next {
  display: none;
}
.pc-bar {
  width: 100%;
  padding: 4px 0 0;
}
.join-inline input {
  width: 170px;
  text-transform: uppercase;
}
.join-inline input::placeholder {
  text-transform: none;
  letter-spacing: 0.02em;
}
.play-help {
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--glass);
  text-align: center;
}
.join-hint {
  margin: 0;
  color: var(--muted);
  text-align: center;
  max-width: 34ch;
}
.join-hint:empty {
  display: none;
}
.join-hint.err {
  color: var(--amber-hi);
}
.home-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  width: 100%;
  padding: 8px 10px 8px 14px;
}
.home-card p {
  margin: 0;
}
.hc-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hc-btns .btn {
  flex: none;
}
.hc-btns .hc-x {
  flex: none;
  min-width: var(--tap);
  padding: 0;
}
.trust-link {
  display: flex;
  justify-content: center;
}

/* P (phone portrait): brand, news, the character, you, PLAY and Join, then the dock. */
@media (max-width: 480px) and (min-height: 501px) {
  .menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: var(--pad-t) var(--pad-r) 0 var(--pad-l);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto; /* a scroll container: a drag anywhere on it scrolls when text is large */
  }
  .menu-top {
    order: 1;
    flex: none;
  }
  .menu-news {
    order: 2;
    flex: none;
  }
  .menu > .stage-slot {
    order: 3;
    flex: 1 1 0;
  }
  .menu-side {
    order: 4;
    flex: none;
  }
  .menu-play {
    order: 5;
    flex: none;
  }
  .menu .menu-ad {
    order: 6;
    flex: none;
  }
  .menu-trust {
    order: 7;
    flex: none;
  }
  .menu-nav {
    order: 8;
  }
  .menu-brand .brand-top {
    display: inline-block;
    font-size: clamp(14px, 4.8vw, 18px);
    margin: 0 6px 0 0;
  }
  .menu-brand .logo {
    display: inline-block;
    font-size: clamp(22px, 7.4vw, 28px);
  }
  .menu-brand .tag-marker {
    display: none;
  }
  .menu-invite {
    display: block;
    margin-top: 4px;
    font-size: var(--fs-100);
    max-width: none;
  }
  .milestone-card {
    display: none;
  }
  .menu-side {
    display: block;
  }
  .profile-card {
    padding: 8px 12px;
  }
  .pc-as,
  .pc-bar {
    display: none;
  }
  .pc-name .name {
    font-size: 1rem;
  }
  .pc-stats {
    margin-top: 2px;
  }
  .pc-feathers {
    display: inline;
  }
  .pc-next {
    display: block;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .menu-play {
    align-items: stretch;
    gap: 8px;
  }
  .play-btn {
    width: 100%;
    min-width: 0;
    min-height: var(--tap-xl);
    font-size: 1.6rem;
  }
  .join-inline input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }
  .join-btn {
    flex: none;
    min-width: 96px;
  }
  .join-hint {
    max-width: none;
  }
  .play-help {
    display: none;
  }
  /* The dock: five equal columns, stuck to the bottom above the home indicator. */
  .menu-nav {
    position: sticky;
    bottom: 0;
    z-index: 1;
    flex: none;
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    max-width: none;
    margin: 0 calc(-1 * var(--pad-r)) 0 calc(-1 * var(--pad-l));
    padding: 4px var(--sa-r) var(--sa-b) var(--sa-l);
    background: var(--opaque);
    border-top: 1px solid var(--line);
  }
  .menu-nav .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    padding: 6px 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--fs-100);
  }
  .menu-nav .nav-item .ico {
    width: auto;
    font-size: 22px;
    line-height: 1;
  }
  .nav-lbl {
    white-space: nowrap;
  }
}
/* The phone-portrait ad row only when there is height to spare (never pushes PLAY away). */
@media (max-width: 480px) and (max-height: 699px) {
  .menu .menu-ad {
    display: none;
  }
}

/* L (phone landscape, short screens): rail | character | the side panel with PLAY. */
@media (max-height: 500px) {
  .menu {
    display: grid;
    grid-template-columns: calc(76px + var(--sa-l)) minmax(0, 1fr) minmax(260px, 36%);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px 12px;
    padding: var(--pad-t) var(--pad-r) var(--pad-b) 0;
    overflow: hidden;
  }
  .menu-nav {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: none;
    padding-left: var(--sa-l);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .menu-nav .nav-item {
    flex: none;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    min-height: 52px;
    padding: 4px 2px;
    border-radius: 12px;
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--fs-100);
  }
  .menu-nav .nav-item .ico {
    width: auto;
    font-size: 20px;
    line-height: 1.1;
  }
  .nav-lbl {
    white-space: nowrap;
  }
  .menu-top {
    grid-column: 2;
    grid-row: 1;
  }
  .menu > .stage-slot {
    grid-column: 2;
    grid-row: 2;
  }
  .menu-news {
    display: none;
  }
  .menu-brand .brand-top {
    display: inline-block;
    font-size: 16px;
    margin: 0 6px 0 0;
  }
  .menu-brand .logo {
    display: inline-block;
    font-size: 24px;
  }
  .menu-brand .tag-marker {
    display: none;
  }
  .menu-invite {
    display: block;
    width: fit-content;
    margin-top: 4px;
    font-size: var(--fs-100);
    max-width: 100%;
  }
  .menu-panel {
    grid-column: 3;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--glass);
    border: 1px solid var(--line);
  }
  .menu-side {
    display: block;
  }
  .milestone-card {
    display: none;
  }
  .profile-card {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .pc-as,
  .pc-bar {
    display: none;
  }
  .pc-stats {
    margin-top: 2px;
  }
  .pc-feathers {
    display: inline;
  }
  .menu-play {
    align-items: stretch;
    gap: 8px;
  }
  .play-btn {
    width: 100%;
    min-width: 0;
    min-height: var(--tap-xl);
    font-size: 1.5rem;
  }
  .join-inline input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }
  .join-btn {
    flex: none;
    min-width: 80px;
  }
  .play-help {
    display: none;
  }
  .menu-play {
    display: flex;
    flex-direction: column;
  }
  .menu-play .home-card {
    order: 9;
    grid-template-columns: minmax(0, 1fr);
  }
  .menu-trust {
    align-self: auto;
  }
}

/* TP (tablet portrait): brand across the top, nav and your cards on the left of the character,
   PLAY in a band below. */
@media (min-width: 481px) and (max-width: 1024px) and (min-height: 501px) and (orientation: portrait) {
  .menu {
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr auto auto;
    grid-template-areas: 'top top' 'news news' 'nav stage' 'side stage' 'trust stage' 'play play' 'ad ad';
    gap: 12px 16px;
    overflow-y: auto;
  }
  .menu-top {
    grid-area: top;
  }
  .menu-brand .logo {
    font-size: clamp(42px, 7vw, 64px);
  }
  .menu-news {
    grid-area: news;
  }
  .menu > .stage-slot {
    grid-area: stage;
  }
  .menu-nav {
    grid-area: nav;
    align-self: start;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: none;
  }
  .menu-nav .nav-item {
    min-height: 52px;
    padding: 8px 10px;
    gap: 8px;
    text-transform: none;
    letter-spacing: 0;
  }
  .menu-side {
    grid-area: side;
    align-self: start;
  }
  .menu:has(.menu-ad:not([hidden]):not(:empty)) .menu-side {
    grid-row: auto;
  }
  /* The Bird Form card folds into the profile card (feathers and the next step). */
  .milestone-card {
    display: none;
  }
  .pc-feathers,
  .pc-next {
    display: inline;
  }
  .pc-next {
    display: block;
    margin-top: 4px;
  }
  .menu-trust {
    grid-area: trust;
    align-self: start;
  }
  .menu-play {
    grid-area: play;
    justify-self: center;
    width: min(560px, 100%);
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--glass);
    border: 1px solid var(--line);
  }
  .menu .menu-ad {
    grid-area: ad;
    justify-self: center;
    max-width: 360px;
  }
}

/* ── Settings ───────────────────────────────────────────────────────────────────────────── */
.set-md {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.set-list {
  display: grid;
  gap: 6px;
  position: sticky;
  top: 0;
}
.set-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid var(--graphite);
  background: var(--ink-2);
  color: var(--white);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.set-item.on {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px var(--cyan);
}
.set-pane {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.set-h {
  margin: 0;
}
.set-root {
  gap: 8px;
}
.check-row {
  align-items: center;
  flex-wrap: nowrap;
}
.check-row input {
  flex: none;
}
.key-btn {
  min-width: 72px;
}
.about-body ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}
.about-body p {
  margin: 0;
}

/* ── Room menu ──────────────────────────────────────────────────────────────────────────── */
.room-grid {
  grid-template-columns: minmax(0, 1fr);
}
@container (min-width: 700px) {
  .room-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
}
.invite-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(31, 178, 255, 0.07);
  border: 1px solid var(--line);
}
.invite-card .code {
  font-size: var(--fs-600);
  letter-spacing: 0.16em;
}
.ic-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.player-row {
  flex-wrap: wrap;
}
.pr-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.pr-actions {
  display: flex;
  gap: 8px;
}
.host-settings {
  gap: 8px;
  min-width: 0;
}
@media (max-width: 480px) and (min-height: 501px) {
  .player-row .pr-actions {
    width: 100%;
  }
  .pr-actions > * {
    flex: 1 1 0;
  }
  .ic-btns {
    width: 100%;
  }
  .ic-btns .btn {
    flex: 1 1 auto;
  }
}

/* ── Results ────────────────────────────────────────────────────────────────────────────── */
.results .winner {
  font-size: var(--fs-600);
}
.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
.results-actions .btn {
  flex: 1 1 auto;
}
.your-round {
  padding: 14px;
}
@media (max-width: 480px) and (min-height: 501px) {
  .results-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .results-actions .ra-again {
    grid-column: 1 / -1;
  }
}

/* ── Tricks, playgrounds ────────────────────────────────────────────────────────────────── */
.trick-row,
.pg-row {
  flex-wrap: wrap;
}
.trick-btns,
.pg-btns {
  display: flex;
  gap: 8px;
}
@media (max-width: 480px) and (min-height: 501px) {
  .trick-btns,
  .pg-btns {
    width: 100%;
  }
  .trick-btns .btn,
  .pg-btns .btn {
    flex: 1 1 0;
  }
}
@media (max-height: 500px) {
  .trick-btns {
    width: 100%;
  }
  .trick-btns .btn {
    flex: 1 1 0;
  }
}

/* ── More, How to play, install, nickname ───────────────────────────────────────────────── */
.more-list {
  gap: 8px;
}
.howto {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  touch-action: pan-y;
}
.howto p {
  margin: 0;
  max-width: 40ch;
}
.howto-art {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
}
.ha-phone {
  position: relative;
  width: 200px;
  height: 100px;
  border-radius: 18px;
  border: 3px solid var(--steel);
  background: linear-gradient(160deg, #1b3550, #0d1119);
}
.ha-thumb {
  position: absolute;
  bottom: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--cyan-hi);
  background: rgba(31, 178, 255, 0.18);
}
.ha-thumb.left {
  left: 18px;
}
.ha-thumb.right {
  right: 64px;
  top: 16px;
  bottom: auto;
  border-style: dashed;
}
.ha-btn {
  position: absolute;
  right: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 2px solid var(--cyan-hi);
  font-size: var(--fs-100);
  font-weight: 900;
}
.ha-btn.b1 {
  bottom: 12px;
}
.ha-btn.b2 {
  bottom: 44px;
}
.howto-dots {
  display: grid;
  justify-items: center;
  gap: 4px;
}
.howto-dots .dots i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--steel);
}
.howto-dots .dots i.on {
  background: var(--cyan);
}
.install-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}
.nick-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nick-row input {
  flex: 1 1 auto;
  min-width: 0;
}
.savekey-field {
  width: 100%;
}

/* ── The 3D view paused (WebGL context lost) ────────────────────────────────────────────── */
.gl-lost {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  display: grid;
  place-items: center;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  background: rgba(5, 7, 11, 0.82);
}
.gl-lost .panel {
  display: grid;
  gap: 10px;
  width: min(420px, 100%);
  padding: 22px;
}
.gl-lost p {
  margin: 0;
}
