/* Party screens (M2, LOBBIES §2): the Party sheet, the Join screen and the Lobby, in look A.
   Built only from the shared pieces in style.css (.glass, .btn, .caps, .field look, .netcover/.netcard,
   .sheet nav); this file adds the party-only selectors. */

/* ---------- toast ---------- */
.toast {
  position: absolute;
  /* Under the 44 pt gear row, so it never covers a button. */
  top: calc(var(--sat) + 56px);
  left: 20px;
  right: 20px;
  margin: 0 auto;
  width: fit-content;
  max-width: 360px;
  box-sizing: border-box;
  padding: 11px 18px;
  border-radius: 22px;
  font: 700 14px/1.3 var(--sys);
  color: var(--ink);
  text-align: center;
  z-index: 8;
  pointer-events: none;
}
#ui-root > .toast {
  pointer-events: none;
}
.toast.in {
  animation: toast-in 0.22s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---------- party sheet (over Home) ---------- */
.psheet {
  z-index: 4;
}
.psheet .netcard,
.kickc .netcard {
  width: 340px;
}
.psheet .p-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--g-text);
  background: rgba(var(--g), 0.12);
  box-shadow: inset 0 0 0 1px rgba(var(--g), 0.3);
}
.psheet .p-icon svg {
  width: 28px;
  height: 22px;
}
.psheet .spinner:not(.hidden) + .p-icon {
  display: none;
}
.psheet .acts {
  gap: 16px;
}
.psheet .btn-primary svg {
  width: 24px;
  height: 24px;
}
.err {
  font: 700 14px/1.35 var(--sys);
  color: var(--red-text);
}

/* ---------- join screen (a sheet like Settings) ---------- */
.joinp > .col {
  justify-content: flex-start;
}
.joinp .card {
  margin-top: 28px;
  padding: 20px 18px 18px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.joinp .card > .caps {
  margin: 0 4px 12px;
}
.codeboxes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
}
.codebox {
  width: 100%;
  min-width: 0;
  height: 66px;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 17px;
  background: rgba(6, 5, 20, 0.62);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  font: 400 34px/1 var(--display);
  text-transform: uppercase;
  color: #fff;
  caret-color: var(--green);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  -webkit-appearance: none;
  appearance: none;
}
.codebox:focus {
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 0 0 2px rgba(var(--g), 0.7),
    0 0 0 3px rgba(var(--g), 0.14);
}
.codebox.filled {
  background: rgba(30, 26, 72, 0.7);
}
.joinp.has-err .codebox {
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1.5px rgba(255, 68, 102, 0.55);
}
.joinp.has-err .codebox:focus {
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 0 0 2px rgba(255, 68, 102, 0.75);
}
.joinp .err {
  min-height: 19px;
  margin: 12px 4px 0;
  text-align: center;
}
.joinp .btn-primary {
  margin-top: 12px;
}
.joinp .btn-primary:disabled {
  opacity: 0.5;
}
.joinp .hint {
  margin-top: 16px;
  text-align: center;
  font: 600 12.5px/1.5 var(--sys);
  color: rgba(214, 208, 255, 0.62);
}

/* ---------- lobby ---------- */
.lobby {
  background:
    radial-gradient(100% 34% at 50% 16%, rgba(10, 8, 28, 0.7) 0%, rgba(10, 8, 28, 0) 100%),
    linear-gradient(180deg, rgba(10, 8, 28, 0.62), rgba(10, 8, 28, 0.72) 50%, rgba(7, 6, 20, 0.88));
}
.lobby > .col {
  gap: 10px;
  justify-content: safe center;
}
.lobby > .col > * {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
}
.lobby .ptitle {
  margin-top: 2px;
  text-align: center;
  font: 400 24px/1 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(10, 8, 40, 0.85),
    0 0 20px rgba(var(--g), 0.18);
}
.lobby .card {
  border-radius: 26px;
  padding: 12px 14px 14px;
}
.lobby .lbl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 2px 8px;
  min-height: 24px;
}
.lobby .cnt {
  font: 800 12px/1 var(--sys);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}
/* COPY: a small glass pill; the hit area is 44 pt tall even though the pill looks smaller. */
.pill-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  font: 800 11.5px/1 var(--sys);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(236, 234, 255, 0.9);
}
.pill-btn::before {
  content: '';
  position: absolute;
  inset: -7px -4px;
}
.pill-btn svg {
  width: 15px;
  height: 15px;
}
.pill-btn:active {
  background: rgba(255, 255, 255, 0.14);
}
.ctiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.ctile {
  height: 56px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font: 400 36px/1 var(--display);
  color: #fff;
  background: linear-gradient(180deg, rgba(58, 52, 140, 0.9), rgba(36, 31, 92, 0.95));
  box-shadow:
    0 4px 0 #19164a,
    inset 0 1.5px 0 rgba(255, 255, 255, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  text-shadow: 0 2px 0 rgba(10, 8, 40, 0.75);
}
.share-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
/* The QR sits on a light rounded tile: dark modules on white so phone cameras read it. */
.qr {
  flex: none;
  width: 104px;
  height: 104px;
  box-sizing: border-box;
  padding: 4px;
  border-radius: 16px;
  /* Clip the SVG's square white backing to the tile's rounded corners. */
  overflow: hidden;
  background: #fff;
  box-shadow:
    0 4px 0 rgba(10, 8, 40, 0.6),
    0 8px 18px rgba(0, 0, 0, 0.35);
}
.qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
.share-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.share-txt {
  font: 600 13px/1.4 var(--sys);
  color: rgba(214, 208, 255, 0.7);
}
.share-side .btn-secondary {
  height: 50px;
  font-size: 18px;
  gap: 8px;
  padding: 0 10px;
}
.share-side .btn-secondary svg {
  width: 20px;
  height: 20px;
}
/* The invite link, selected, when nothing could copy or share (http on iOS). */
.linkc .netcard {
  width: 360px;
}
.linkfield {
  width: 100%;
  height: 48px;
  margin-top: 4px;
  box-sizing: border-box;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: rgba(6, 5, 20, 0.62);
  box-shadow: inset 0 0 0 1.5px rgba(var(--g), 0.5);
  font: 700 15px/1 var(--sys);
  color: var(--ink);
  text-align: center;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
.linkc .hint {
  font: 700 12.5px/1.3 var(--sys);
  color: var(--g-text);
}

/* Member slots: swatch · name (+ YOU) · status line · crown · kick. */
.slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slot {
  position: relative;
  height: 46px;
  box-sizing: border-box;
  padding: 0 1px 0 10px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(6, 5, 20, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.slot.me {
  background: rgba(var(--g), 0.1);
  box-shadow: inset 0 0 0 1px rgba(var(--g), 0.26);
}
/* A small green tube with two eyes: everyone in the lobby is a party friend. */
.slot .sw {
  position: relative;
  flex: none;
  width: 32px;
  height: 15px;
  border-radius: 8px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, rgb(var(--g)) 55%, #fff) 0%,
    rgb(var(--g)) 45%,
    var(--g-lo) 100%
  );
  box-shadow:
    0 0 0 1.5px var(--g-lip),
    0 0 10px rgba(var(--g), 0.35);
}
.slot .sw::before,
.slot .sw::after {
  content: '';
  position: absolute;
  right: 4px;
  width: 3.6px;
  height: 3.6px;
  border-radius: 50%;
  background: #0a0c16;
  box-shadow: 0 0 0 1.3px #eef3f7;
}
.slot .sw::before {
  top: 2.4px;
}
.slot .sw::after {
  bottom: 2.4px;
}
.slot .who {
  flex: 1;
  min-width: 0;
}
.slot .nm-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.slot .nm {
  font: 800 15px/1.2 var(--sys);
  color: var(--g-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.slot.me .nm {
  color: #fff;
}
.slot .you-tag {
  flex: none;
  font: 800 9.5px/1 var(--sys);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #03140a;
  background: var(--green);
  border-radius: 6px;
  padding: 3px 6px 2px;
}
.slot .st {
  margin-top: 1px;
  font: 600 11.5px/1.2 var(--sys);
  color: var(--faint);
}
.slot.away .sw {
  filter: grayscale(0.7) brightness(0.7);
}
.slot.away .nm {
  opacity: 0.6;
}
.slot.away .st {
  color: var(--gold);
}
.slot .crown {
  flex: none;
  width: 22px;
  height: 19px;
  color: var(--gold);
  filter: drop-shadow(0 1.5px 0 #a86a00) drop-shadow(0 0 8px rgba(255, 201, 77, 0.35));
  margin-right: 10px;
}
.slot .kick {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: none;
  color: rgba(236, 234, 255, 0.55);
}
.slot .kick svg {
  width: 18px;
  height: 18px;
}
.slot .kick:active {
  background: rgba(255, 68, 102, 0.16);
  color: var(--red-text);
}
.slot.empty {
  background: none;
  box-shadow: none;
  /* An inset outline, not a border, so the Invite button keeps the slot's full 44 pt height. */
  outline: 1.5px dashed rgba(222, 218, 255, 0.18);
  outline-offset: -1.5px;
  padding: 0;
}
.slot.empty > :not(.invite) {
  display: none;
}
.slot .invite {
  flex: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: none;
  border-radius: 13px;
  font: 700 14px/1 var(--sys);
  color: rgba(214, 208, 255, 0.66);
}
.slot .invite svg {
  width: 16px;
  height: 16px;
}
.slot .invite:active {
  background: rgba(255, 255, 255, 0.05);
}

/* Match type: a segmented control (host only), with one line under it. */
.mtype {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(6, 5, 20, 0.55);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.seg-btn {
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: none;
  font: 400 16.5px/1 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(222, 218, 255, 0.6);
}
.seg-btn.on {
  color: #fff;
  background: linear-gradient(180deg, #4a43b0 0%, #352f86 100%);
  box-shadow:
    0 3px 0 #19164a,
    inset 0 1.5px 0 rgba(255, 255, 255, 0.22);
  text-shadow: 0 2px 0 rgba(10, 8, 40, 0.7);
}
.seg-btn:disabled {
  cursor: default;
}
.seg-btn:disabled:not(.on) {
  color: rgba(222, 218, 255, 0.38);
}
/* The line under the match type: what it means (info), "Your party is playing", or a notice. */
.pline {
  min-height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font: 600 12px/1.35 var(--sys);
  color: rgba(214, 208, 255, 0.62);
}
.pline .dot {
  display: none;
}
.pline.playing {
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--g-text);
}
.pline.playing .dot {
  display: inline-block;
  animation: party-pulse 1.4s ease-in-out infinite;
}
.pline.note {
  font-weight: 700;
  color: var(--gold);
}
@keyframes party-pulse {
  50% {
    opacity: 0.35;
  }
}

/* LEAVE next to START / JOIN GAME, or next to "Waiting for the host". */
.pact {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding-bottom: 6px;
}
.pact .leave {
  flex: none;
  width: auto;
  height: 62px;
  padding: 0 16px 0 12px;
  gap: 4px;
  font-size: 18px;
}
.pact .leave svg {
  width: 18px;
  height: 18px;
}
.pact .go {
  flex: 1;
  width: auto;
  min-width: 0;
}
.pact .btn-primary svg {
  width: 26px;
  height: 26px;
}
.pact .btn-primary:disabled {
  opacity: 0.7;
}
.wait {
  flex: 1;
  min-width: 0;
  height: 62px;
  box-sizing: border-box;
  padding: 0 14px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(6, 5, 20, 0.5);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.09),
    inset 0 2px 5px rgba(0, 0, 0, 0.35);
  font: 700 14px/1.25 var(--sys);
  color: rgba(236, 234, 255, 0.85);
  text-align: center;
}
.wait > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wait .dots {
  flex: none;
  display: inline-flex;
  gap: 4px;
}
.wait .dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: party-pulse 1.2s ease-in-out infinite;
}
.wait .dots i:nth-child(2) {
  animation-delay: 0.2s;
}
.wait .dots i:nth-child(3) {
  animation-delay: 0.4s;
}
.danger {
  color: #fff;
}
.kickc .acts,
.linkc .acts {
  gap: 14px;
}
.kickc .btn-secondary.danger {
  background: linear-gradient(180deg, #b3304e 0%, #8a1f3a 100%);
  box-shadow:
    0 4px 0 #4a0614,
    0 8px 18px rgba(0, 0, 0, 0.35),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.22);
}
.reconc {
  z-index: 6;
}
@media (prefers-reduced-motion: reduce) {
  .pline.playing .dot,
  .wait .dots i {
    animation: none;
  }
}

/* Short phones (SE, mini): tighter cards, a smaller QR and no title, so the lobby fits unscrolled. */
@media (max-height: 740px) {
  .lobby > .col {
    gap: 8px;
  }
  .lobby .ptitle {
    display: none;
  }
  .lobby .card {
    padding: 10px 12px 12px;
    border-radius: 22px;
  }
  .lobby .lbl-row {
    margin-bottom: 6px;
    min-height: 22px;
  }
  .ctile {
    height: 46px;
    font-size: 29px;
    border-radius: 13px;
  }
  .share-row {
    margin-top: 12px;
  }
  .qr {
    width: 80px;
    height: 80px;
    border-radius: 13px;
    padding: 3px;
  }
  .share-txt {
    font-size: 12px;
    line-height: 1.3;
  }
  .share-side {
    gap: 7px;
  }
  .share-side .btn-secondary {
    height: 44px;
    font-size: 16.5px;
  }
  .slots {
    gap: 3px;
  }
  .slot {
    height: 44px;
  }
  .slot .nm {
    font-size: 14.5px;
  }
  .seg-btn {
    font-size: 15px;
  }
  .pline.info {
    display: none;
  }
  .pact .btn-primary,
  .pact .leave,
  .wait {
    height: 54px;
  }
  .pact .btn-primary {
    font-size: 22px;
  }
  .joinp .card {
    margin-top: 16px;
  }
  .codebox {
    height: 58px;
    font-size: 30px;
  }
}

/*
 * 4.7-inch phones in Safari (about 375 x 550 with the toolbars): the QR moves up next to the code and
 * the share button, the rest tightens, so START is on screen without scrolling. If a note still pushes
 * it down, LEAVE / START stay pinned to the bottom.
 */
@media (max-height: 600px) and (orientation: portrait) {
  .lobby > .col {
    gap: 5px;
    padding-top: max(var(--safe-top), 6px);
    padding-bottom: max(var(--safe-bottom), 6px);
  }
  .lobby .card {
    padding: 8px 10px 10px;
    border-radius: 20px;
  }
  .lobby .lbl-row {
    margin-bottom: 4px;
    min-height: 20px;
  }
  .lobby .card.invite {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      'lbl lbl'
      'qr tiles'
      'qr btn';
    column-gap: 12px;
    row-gap: 6px;
  }
  .lobby .card.invite .lbl-row {
    grid-area: lbl;
  }
  .lobby .card.invite .ctiles {
    grid-area: tiles;
    gap: 6px;
  }
  .lobby .share-row,
  .lobby .share-side {
    display: contents;
  }
  .lobby .share-txt {
    display: none;
  }
  .lobby .qr {
    grid-area: qr;
    width: 90px;
    height: 90px;
  }
  .lobby .share-side .btn-secondary {
    grid-area: btn;
    height: 44px;
  }
  .ctile {
    height: 40px;
    font-size: 26px;
    border-radius: 12px;
    box-shadow:
      0 3px 0 #19164a,
      inset 0 1.5px 0 rgba(255, 255, 255, 0.2);
  }
  .slots {
    gap: 2px;
  }
  .seg {
    padding: 3px;
  }
  .mtype {
    gap: 4px;
  }
  .lobby .pact {
    position: sticky;
    bottom: 0;
    padding-bottom: 0;
  }
  .pact .btn-primary,
  .pact .leave,
  .wait {
    height: 50px;
  }
  .pact .btn-primary {
    font-size: 21px;
  }
}

/* Phone held sideways: invite + game type + START on the left, the players on the right. */
@media (orientation: landscape) and (max-height: 500px) {
  .lobby > .col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas:
      'invite members'
      'mtype members'
      'pact members';
    column-gap: 16px;
    row-gap: 8px;
    align-content: center;
    align-items: start;
    justify-items: stretch;
    padding-top: max(var(--safe-top), 8px);
    padding-bottom: max(var(--safe-bottom), 8px);
  }
  .lobby > .col > * {
    max-width: none;
  }
  .lobby .ptitle {
    display: none;
  }
  .lobby .invite {
    grid-area: invite;
  }
  .lobby .members {
    grid-area: members;
  }
  .lobby .mtype {
    grid-area: mtype;
  }
  .lobby .pact {
    grid-area: pact;
    padding-bottom: 0;
  }
  .lobby .card {
    padding: 10px 12px 12px;
    border-radius: 20px;
  }
  .lobby .lbl-row {
    margin-bottom: 6px;
    min-height: 22px;
  }
  .ctile {
    height: 40px;
    font-size: 26px;
    border-radius: 12px;
    box-shadow:
      0 3px 0 #19164a,
      inset 0 1.5px 0 rgba(255, 255, 255, 0.2);
  }
  .share-row {
    margin-top: 10px;
  }
  .qr {
    width: 76px;
    height: 76px;
    border-radius: 12px;
    padding: 3px;
  }
  .share-txt {
    font-size: 12px;
    line-height: 1.3;
  }
  .share-side {
    gap: 6px;
  }
  .share-side .btn-secondary {
    height: 44px;
    font-size: 16px;
  }
  .slots {
    gap: 3px;
  }
  .slot {
    height: 44px;
  }
  .seg-btn {
    font-size: 15px;
  }
  .pline.info {
    display: none;
  }
  .pact .btn-primary,
  .pact .leave,
  .wait {
    height: 50px;
  }
  .pact .btn-primary {
    font-size: 21px;
  }
  .joinp .card {
    margin-top: 8px;
    padding: 14px 16px 12px;
  }
  .codebox {
    height: 52px;
    font-size: 28px;
  }
  .joinp .hint {
    display: none;
  }
}
