/* Ranked battles, the BP Exchange and the Alpha swarm (client/js/ui/ranked.js,
   bpshop.js, swarm.js):
   pixel-kit windows (client/css/social-ui.css) laid out for a computer, and
   full-width sheets with the main button at the bottom on a phone. Sized from
   #windows (100%: the room the bar and the touch pads leave, style.css), not
   the viewport — a phone on its side keeps only the middle of the screen. */
.rk { width: min(1200px, calc(100% - 24px)); height: min(640px, calc(100% - 16px)); padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.rk.small { width: min(560px, calc(100% - 24px)); height: auto; }
.rk-head { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 2px dashed var(--rule); }
.rk-title { font-size: 24px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.rk-hint { color: var(--ink-3); font-size: 13px; }
.rk-label { color: var(--ink-3); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.rk-grow { flex-grow: 1; }
/* never shrunk by its flex row (the header could squeeze it to a sliver on a
   narrow phone otherwise); everywhere, not just the phone media query below */
.rk-x { width: 40px; height: 40px; padding: 0; border: 3px solid var(--frame); border-radius: 8px; background: #fff; font-weight: 600; flex: none; }
.rk-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 2px solid var(--blue); border-radius: 8px; background: var(--sky); font-size: 14px; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.rk-pill.ok { border-color: #1e7a3c; background: #e2f4e6; color: #1e7a3c; }
.rk-pill.bad { border-color: var(--danger); background: #fbe3dc; color: var(--danger); }
.rk-pill.bp { border: 3px solid var(--sel-line); background: var(--sel); height: 40px; font-size: 18px; }
.rk-body { flex: 1; min-height: 0; display: grid; gap: 18px; }
.rk-lobby { grid-template-columns: 280px minmax(0, 1fr) 300px; }
.rk-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 3px solid var(--blue); border-radius: 12px; background: #fff; min-height: 0; overflow: auto; }
.rk-rating { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.rk-meter { height: 16px; border: 3px solid var(--frame); border-radius: 6px; background: var(--plain); overflow: hidden; }
.rk-meter > i { display: block; height: 100%; background: var(--blue); }
.rk-meter.bp > i { background: var(--sel-line); }
.rk-row { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.rk-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.rk-team { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rk-team .px-slot { min-height: 64px; }
.rk-team .px-slot.bad { border-color: var(--danger); background: #fbe3dc; flex-wrap: wrap; }
.rk-team .px-slot.empty { border-style: dashed; background: #eef4fa; color: var(--ink-3); justify-content: center; }
.rk-problem { flex-basis: 100%; color: var(--danger); font-size: 13px; font-weight: 600; }
.rk-mon { flex: none; display: inline-block; image-rendering: pixelated; background-repeat: no-repeat; }
.rk-ball, .rk-item { image-rendering: pixelated; flex: none; }
.rk-rules { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 12px; border: 2px solid var(--blue); border-radius: 8px; background: var(--sky); font-size: 14px; }
.rk-find { height: 64px; font-size: 24px; letter-spacing: .04em; }
.rk-board { display: flex; flex-direction: column; gap: 6px; overflow: auto; min-height: 0; }
.rk-board .px-slot { padding: 4px 8px 4px 6px; gap: 8px; }
.rk-board .px-slot.me { border-color: var(--sel-line); }
.rk-num { font-variant-numeric: tabular-nums; font-weight: 700; }
.rk-cnt { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 2px solid var(--frame); border-radius: 6px; background: var(--sel-line); color: #fff; font-weight: 700; }
.rk-builder { grid-template-columns: 460px minmax(0, 1fr); }
.rk-pool { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: auto; min-height: 0; align-content: start; }
.rk-pool .px-slot { cursor: pointer; }
.rk-note { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 3px solid #1e7a3c; border-radius: 12px; background: #eaf7ec; }
.rk-start { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 3px solid var(--sel-line); border-radius: 12px; background: #fff7ea; }
.rk-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.rk-picks { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 3px solid var(--sel-line); border-radius: 12px; background: #fff7ea; flex-wrap: wrap; }
.rk-timer { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 40px; padding: 0 10px; border: 3px solid var(--frame); border-radius: 8px; background: var(--sel); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rk-big { font-size: 36px; font-weight: 700; letter-spacing: .03em; }
.rk-win { color: #1e7a3c; }
.rk-lose { color: var(--danger); }
.rk-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rk-stats .px-slot { flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; }
/* (the top bar's Ranked search chip, .rk-barchip and .rk-stop: its own
   44 px buttons, in social-layout.css with the rest of the bar) */
/* BP Exchange */
.bpx-body { grid-template-columns: minmax(0, 1fr) 380px; }
.bpx-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; min-height: 0; padding-right: 4px; }
.bpx-list .px-slot { cursor: pointer; min-height: 52px; padding: 4px 12px 4px 6px; }
.bpx-detail { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 3px solid var(--blue); border-radius: 12px; background: #fff; }
.bpx-art { display: flex; align-items: center; justify-content: center; width: 104px; height: 104px; border: 3px solid var(--sel-line); border-radius: 12px; background: var(--sel); }
.bpx-qty { display: flex; align-items: center; gap: 10px; }
.bpx-qty .px-btn { width: 44px; padding: 0; }
.bpx-confirm { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(360px, calc(100% - 32px)); padding: 16px; display: flex; flex-direction: column; gap: 12px; z-index: 2; }
/* A touch screen of any size: the kit's 44px touch targets (social-ui.css
   gives them only inside `.pxui.touch`, i.e. the social layer's #social, not
   these windows in #windows). */
@media (pointer: coarse) {
  .rk .px-btn, .rk .px-tab, .rk button.px-slot, .rk-x { min-height: 44px; }
  .rk .px-btn.sm, .rk-x { min-width: 44px; }
}
/* A phone upright (narrow) or on its side (short: 844 x 390 leaves #windows
   about 500 x 330 between the pads), the same short-screen break style.css
   uses: one column that scrolls, the main button pinned at the bottom. */
@media (max-width: 720px), (max-height: 520px) {
  .rk, .rk.small { width: calc(100% - 16px); height: calc(100% - 8px); padding: 12px; }
  /* the small windows (match found, result) have no scrolling body of their own: they scroll, their parts keep their height */
  .rk.small { overflow: auto; }
  .rk.small > * { flex-shrink: 0; }
  /* Rows take their natural height and the body itself scrolls, instead of
     the grid squeezing every row to fit inside the window (which clipped
     .rk-card to a sliver and let .rk-col's content spill onto the board
     below it). grid-auto-rows: max-content stops the squeeze; the overflow
     these children used for their OWN internal scrolling is dropped since
     there's nothing left to scroll past inside them once their row is
     sized to fit. */
  .rk-lobby, .rk-builder, .rk-preview, .bpx-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: max-content; overflow: auto; }
  .rk-card, .rk-board, .rk-pool { overflow: visible; }
  .rk-team { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rk-team .px-slot { flex-direction: column; min-height: 0; padding: 4px; }
  .rk-team .rk-slot-text { display: none; }
  .rk-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rk .px-btn, .rk-x { min-height: 44px; }
  .rk-x { min-width: 44px; }
  .rk-sticky { position: sticky; bottom: 0; background: var(--cream); padding-top: 6px; }
  /* .rk-head is too narrow here for a title, its pills and the ✕ on one
     line (the ✕ was squeezed to 18px and pushed off-screen). Wrap it: the
     ::after is a zero-height flex item that claims the whole row's width,
     so title/✕/timer/the grow spacer (already the shorter, front-loaded
     part of every header) stay on the first line and anything else (pills,
     hints, the ◀ Lobby button) is always forced onto the row below. */
  .rk-head { flex-wrap: wrap; }
  .rk-head::after { content: ''; order: 2; flex-basis: 100%; }
  .rk-head > *:not(.rk-title):not(.rk-x):not(.rk-timer):not(.rk-grow) { order: 3; }
  .bpx-detail { display: none; }
  /* the compact sticky detail: only the essentials, capped so the list
     above it keeps most of the body. */
  /* the chosen item: a compact bar pinned under the list (name; how many and the cost; Exchange) */
  .bpx-body.chosen .bpx-detail { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 10px 12px; position: sticky; bottom: 0; }
  .bpx-detail > * { grid-column: 1 / -1; }
  .bpx-detail .bpx-qty { grid-column: 1; }
  .bpx-detail .bpx-cost { grid-column: 2; gap: 8px; }
  .bpx-top b { font-size: 18px !important; }
  .bpx-art, .bpx-desc, .bpx-foot, .bpx-left, .bpx-top .rk-pill, .bpx-top .rk-hint, .bpx-detail > .rk-grow { display: none; }
}
/* A phone on its side: only about 330px of height between the bar and the
   bottom, so the big buttons and the header come down a size (still 44px+). */
@media (max-height: 520px) {
  .rk-head { padding-bottom: 6px; }
  .rk-title { font-size: 20px; }
  .rk-pill { height: 26px; font-size: 13px; }
  .rk-find { height: 48px; font-size: 20px; }
  .rk-big { font-size: 28px; }
  /* the BP Exchange: one header row (no place line) and the chosen item on one row
     (how many, cost, Exchange; the item itself is the highlighted row above) */
  .rk:has(.bpx-body) .rk-head { flex-wrap: nowrap; }
  .rk:has(.bpx-body) .rk-head::after, .rk:has(.bpx-body) .rk-head > .rk-hint { display: none; }
  .rk:has(.bpx-body) .rk-head > *:not(.rk-title):not(.rk-x):not(.rk-timer):not(.rk-grow) { order: 0; }
  .bpx-body.chosen .bpx-detail { grid-template-columns: auto auto minmax(0, 1fr); padding: 6px 10px; }
  .bpx-detail .bpx-top, .bpx-qty .rk-label { display: none; }
  .bpx-detail .rk-find { grid-column: 3; height: 44px; }
}
/* The Alpha swarm (client/js/ui/swarm.js): a small window, the species'
   picture, its route and level, the time, the traits, this player's catches
   and the schedule. A phone on its side (about 330px of height between the
   bar and the bottom) gets the 1x picture. */
.aw { width: min(440px, calc(100% - 24px)); max-height: calc(100% - 16px); overflow: auto; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.aw > * { flex-shrink: 0; }
.aw .rk-title { font-size: 20px; }
.aw-main { display: flex; align-items: center; gap: 14px; }
.aw-art { flex: none; display: flex; align-items: center; justify-content: center; width: 136px; height: 136px; border: 3px solid var(--sel-line); border-radius: 12px; background: var(--sel); }
.aw-pic { width: 128px; height: 128px; background-repeat: no-repeat; background-size: 128px auto; background-position: 0 0; image-rendering: pixelated; }
.aw-glyph { color: var(--busy); font-size: 64px; line-height: 1; }
.aw-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.aw-name { font-size: 21px; }
.aw-where { display: flex; flex-wrap: wrap; gap: 6px; }
.aw-when { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.aw-when.on { color: var(--busy); }
.aw-traits { padding: 6px 10px; border: 2px dashed var(--rule); border-radius: 8px; font-size: 15px; }
.aw-counts { font-size: 16px; font-weight: 600; }
.aw-counts.full { color: var(--danger); }
.aw-schedule { justify-content: center; font-size: 14px; }
@media (max-width: 720px), (max-height: 520px) {
  .aw { width: calc(100% - 16px); padding: 10px 12px 12px; gap: 8px; }
  .aw-art { width: 104px; height: 104px; }
  .aw-pic { width: 96px; height: 96px; background-size: 96px auto; }
}
@media (max-height: 520px) {
  .aw { width: min(560px, calc(100% - 16px)); }
  .aw-art { width: 72px; height: 72px; }
  .aw-pic { width: 64px; height: 64px; background-size: 64px auto; }
  .aw-glyph { font-size: 40px; }
  .aw-name { font-size: 18px; }
  .aw-traits, .aw-schedule { font-size: 13px; }
}
