/* ruletka.vip / Chatroulette-style dual stage */

/* Hidden SVG sprite host */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Unified stroke icons (currentColor) */
.icon {
  width: 1.2rem;
  height: 1.2rem;
  display: block;
  flex-shrink: 0;
  color: currentColor;
}
.icon-sm {
  width: 1.05rem;
  height: 1.05rem;
  opacity: 0.92;
}
.icon-empty {
  width: 1.7rem;
  height: 1.7rem;
  color: #8b9bb0;
  opacity: 0.85;
}
.icon-next {
  width: 1rem;
  height: 1rem;
  color: #fff;
}

/* Full-bleed live page: override shared style.css body padding/max layout */
html:has(.stage-body),
html.stage-html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #07080c;
}

.stage-body {
  margin: 0 !important;
  /* style.css sets body padding — kill it so cams fill the viewport */
  padding: 0 !important;
  width: 100%;
  max-width: none !important;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  height: 100dvh;
  background: #07080c !important;
  /* Drop decorative gradients from style.css so stage is edge-to-edge */
  background-image: none !important;
  color: #eef2f7;
  font-family: var(
    --sans,
    system-ui,
    "Segoe UI",
    Roboto,
    "Noto Sans",
    "Inter",
    sans-serif
  );
  overflow: hidden;
  /* Better Cyrillic line metrics */
  font-feature-settings: "kern" 1;
  text-rendering: optimizeLegibility;
}

/* Language switcher */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #8b9bb0;
}

.lang-switch select {
  background: #141a22;
  color: #e8eef7;
  border: 1px solid #2a3548;
  border-radius: 6px;
  padding: 0.15rem 0.35rem;
  font: inherit;
  cursor: pointer;
}

.lang-switch .icon {
  width: 0.95rem;
  height: 0.95rem;
  opacity: 0.9;
  color: #9aa8bc;
}

/* Language chip (placed last in .stage-top-actions = top-right) */
.lang-top-right {
  flex: 0 0 auto;
  margin-left: 0.15rem;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  background: #141a22;
  border: 1px solid #2a3548;
}
.lang-top-right select {
  font-weight: 600;
  min-width: 2.5rem;
}

/* Chat: allow full Unicode (Cyrillic) */
.bottom-chat input {
  font-family: inherit;
  unicode-bidi: plaintext;
}

.arch-pill {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 214, 140, 0.35);
  color: #7ddea8;
  background: rgba(20, 48, 36, 0.55);
  white-space: nowrap;
}

.pool-hint {
  font-size: 0.72rem;
  color: #9ec5ff;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* First-run age gate + user agreement (full-screen, Cambly-style) */
.rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: #07080c;
  /* full black so live UI never peeks through before accept */
}
.rules-overlay[hidden] { display: none !important; }
.rules-overlay.has-agree-open {
  justify-content: flex-end;
}

.age-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(22rem, 100%);
  gap: 0.35rem;
  z-index: 1;
  transition: opacity 0.2s ease, filter 0.2s ease;
}
.rules-overlay.has-agree-open .age-gate {
  opacity: 0.28;
  filter: blur(2px);
  pointer-events: none;
}
.age-gate-visual {
  margin-bottom: 1.1rem;
}
.age-gate-logo {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 1.25rem;
  object-fit: cover;
  box-shadow:
    0 12px 40px rgba(255, 45, 85, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}
.age-gate-title {
  margin: 0;
  font-size: clamp(1.45rem, 4.5vw, 1.85rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #f2f5fa;
  line-height: 1.2;
}
.age-gate-sub {
  margin: 0.35rem 0 1.35rem;
  font-size: 0.95rem;
  color: #8b9bb0;
  line-height: 1.4;
  max-width: 18rem;
}
.age-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
}
.age-gate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.15rem;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 650;
  font-size: 1.02rem;
  cursor: pointer;
  transition: filter 0.12s, transform 0.1s;
}
.age-gate-btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #ff2d55 0%, #ff5c3a 55%, #ff7a3b 100%);
  box-shadow: 0 10px 28px rgba(255, 45, 85, 0.4);
}
.age-gate-btn.primary:hover {
  filter: brightness(1.06);
}
.age-gate-btn.primary:active {
  transform: scale(0.98);
}
.age-gate-btn.ghost {
  color: #c5d0e0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.age-gate-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}
.age-gate-underage {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
  color: #ff8fab;
  font-weight: 600;
}
.age-gate-underage[hidden] {
  display: none !important;
}
/* Phone: larger type + bottom safe area so age gate never sits under home bar */
@media (max-width: 720px) {
  .age-gate {
    width: min(24rem, 100%);
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
  .age-gate-title {
    font-size: clamp(1.5rem, 6vw, 1.95rem);
  }
  .age-gate-sub {
    font-size: 1rem;
    max-width: 20rem;
  }
  .age-gate-btn {
    min-height: 3.35rem;
    font-size: 1.06rem;
  }
  .agree-sheet .age-gate-btn {
    min-height: 3.1rem;
  }
}

.agree-sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2;
}
.agree-sheet-scrim[hidden] {
  display: none !important;
}

.agree-sheet {
  position: relative;
  z-index: 3;
  width: min(28rem, 100%);
  max-height: min(78dvh, 560px);
  display: flex;
  flex-direction: column;
  background: #f4f6fa;
  color: #1a2433;
  border-radius: 18px 18px 14px 14px;
  box-shadow: 0 -8px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: agree-sheet-in 0.22s ease-out;
}
@media (max-width: 720px) {
  .agree-sheet {
    width: 100%;
    max-width: none;
    max-height: min(82dvh, 100%);
    border-radius: 18px 18px 0 0;
    margin-bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .rules-overlay.has-agree-open {
    padding: 0;
    justify-content: flex-end;
  }
}
@keyframes agree-sheet-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.agree-sheet[hidden] {
  display: none !important;
}
.agree-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem 0.65rem;
  flex-shrink: 0;
}
.agree-sheet-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
  color: #121820;
  letter-spacing: -0.02em;
}
.agree-sheet-close {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: #4a5568;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.agree-sheet-close:hover {
  background: rgba(0, 0, 0, 0.1);
}
.agree-sheet-body {
  padding: 0 1.15rem 0.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.agree-lead {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a2433;
}
.agree-list {
  margin: 0;
  padding-left: 1.15rem;
  color: #3d4a5c;
  font-size: 0.9rem;
  line-height: 1.45;
}
.agree-list li {
  margin-bottom: 0.55rem;
}
.agree-list a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}
.agree-list a:hover {
  text-decoration: underline;
}
.agree-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem 1.1rem 1.1rem;
  flex-shrink: 0;
  background: #f4f6fa;
}
.agree-sheet .age-gate-btn.primary {
  /* keep brand pink on light sheet */
  color: #fff;
}
.agree-sheet .age-gate-btn.ghost {
  color: #4a5568;
  background: transparent;
  border: none;
  min-height: 2.6rem;
  font-weight: 550;
}
.agree-sheet .age-gate-btn.ghost:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* legacy class kept for safety if old markup cached */
.rules-card { display: none; }

.arch-pill.p2p-live {
  border-color: rgba(91, 157, 255, 0.45);
  color: #9ec5ff;
  background: rgba(20, 32, 56, 0.65);
}

.room-field {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #8b9bb0;
}

.room-field input {
  width: 7.5rem;
  background: #141a22;
  color: #e8eef7;
  border: 1px solid #2a3548;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font: inherit;
}

.room-field.room-in-tile input {
  border: none;
  border-radius: 0;
  background: transparent;
}

.room-field input:focus {
  outline: 1px solid #5b9dff;
  border-color: #5b9dff;
}

.pill.tight {
  padding: 0.35rem 0.55rem;
  min-width: 2rem;
}

.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.check-row input {
  width: auto !important;
  accent-color: #5b9dff;
}

/* Vertical split when stranger sees a party of 2 */
.remote-stack {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.remote-stack .vid {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1;
  object-fit: cover;
  background: #000;
}
.remote-stack.split .vid {
  height: 50%;
  flex: 1 1 50%;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.remote-stack.split .vid.remote-b {
  border-bottom: none;
}
.remote-stack .vid[hidden] {
  display: none !important;
}

.pill.accent {
  background: linear-gradient(135deg, #0d9488, #3dd68c);
  border-color: transparent;
  color: #04120c;
  font-weight: 600;
}
.pill.danger {
  border-color: rgba(243, 18, 96, 0.5);
  color: #ff8aab;
}

.row-inline {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.row-inline input { flex: 1; }

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: min(42vh, 320px);
  overflow: auto;
}
.friend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.55rem;
  border-radius: 12px;
  background: #0e131a;
  border: 1px solid #243041;
  font-size: 0.85rem;
}
.friend-avatar {
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(145deg, #1c2430, #121820);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}
.friend-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.friend-avatar.letter {
  font-weight: 750;
  font-size: 0.95rem;
  color: #c5d4ec;
  letter-spacing: -0.02em;
}
.friend-row.online .friend-avatar {
  box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.45);
}
.friend-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a5568;
  flex-shrink: 0;
  /* Online ring is on avatar — hide tiny dot when avatar present */
  display: none;
}
.friend-row .meta { flex: 1; min-width: 0; }
.friend-row .meta strong { display: block; color: #eef2f7; }
.friend-row .meta span { color: #8b9bb0; font-size: 0.72rem; }
.friend-row .friend-realname {
  display: block;
  font-size: 0.68rem;
  color: #6a7a90;
  font-weight: 500;
  margin-top: -0.05rem;
}
.friend-row .friend-preview {
  display: block;
  font-size: 0.72rem;
  color: #8b9bb0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
  margin-top: 0.1rem;
}
.friend-row .friend-preview.unread,
.friend-row.unread .friend-preview {
  color: #9ec0ff;
  font-weight: 600;
}
.friend-row.unread strong {
  color: #e8eef7;
}
.friend-row .friend-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
  max-width: 55%;
}
.friend-row .friend-actions .pill { font-size: 0.72rem; }
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.pill.primary {
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 45, 85, 0.28);
}

/* Only present in DOM while a real call is ringing (created in JS) */
.call-toast {
  position: fixed;
  bottom: max(5.5rem, 18vh);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  background: rgba(20, 24, 36, 0.96);
  border: 1px solid rgba(91, 157, 255, 0.45);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  max-width: min(420px, 92vw);
}
.call-toast-actions { display: flex; gap: 0.4rem; }

/* Flash partner tile on match */
.tile.match-flash {
  box-shadow: inset 0 0 0 2px #3dd68c, 0 0 28px rgba(61, 214, 140, 0.35);
  animation: matchFlash 0.85s ease-out;
}

@keyframes matchFlash {
  0% { box-shadow: inset 0 0 0 3px #3dd68c, 0 0 40px rgba(61, 214, 140, 0.55); }
  100% { box-shadow: inset 0 0 0 0 transparent, 0 0 0 transparent; }
}

@media (max-width: 900px) {
  .arch-pill { display: none; }
  .pool-hint { display: none; }
}

.stage-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none; /* was 1400px — left empty side gutters until browser zoom */
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  position: relative;
  overflow: hidden;
}

/* Top bar */
.stage-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #1c2230;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(8px);
  z-index: 5;
  flex-shrink: 0;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-mark {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #ff2d55;
  box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.18);
  flex-shrink: 0;
  display: inline-block;
}
.brand-logo {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 0.4rem;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.pool-bar {
  display: flex;
  gap: 0.9rem;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: #8b9bb0;
  flex: 1;
}

.pool-bar strong { color: #e8eef7; }

.pool-bar .searching {
  color: #f5a524;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.stage-top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.8rem;
  margin-left: auto; /* push whole action cluster (lang last) to the right */
  flex-shrink: 0;
}

/* Display name chip (top bar) */
.name-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.45rem 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #2a3548;
  background: #141a22;
  font-size: 0.75rem;
  color: #8b9bb0;
}
.name-chip-lbl {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}
.name-chip input {
  width: 7.5rem;
  max-width: 28vw;
  border: none;
  background: transparent;
  color: #e8eef7;
  font: inherit;
  font-weight: 600;
  padding: 0.15rem 0.2rem;
  outline: none;
}
.name-chip input:focus {
  color: #fff;
}
.name-chip input::placeholder {
  color: #5a6a80;
  font-weight: 500;
}
.name-on-tile {
  color: #9ec5ff;
  font-weight: 600;
  margin-left: 0.25rem;
}

/* Room lobby chip in pool bar */
.room-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #cfe0ff;
  background: rgba(91, 157, 255, 0.14);
  border: 1px solid rgba(91, 157, 255, 0.3);
  max-width: 10rem;
}
.room-chip[hidden] { display: none !important; }
.room-chip .icon { width: 0.85rem; height: 0.85rem; opacity: 0.85; }
#room-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Match session timer on partner tile */
.match-timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(232, 238, 248, 0.85);
  background: rgba(0, 0, 0, 0.45);
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.25rem;
}
.match-timer[hidden] { display: none !important; }

/* Long-wait tips (bottom chip, non-blocking) */
.wait-tips {
  position: fixed;
  left: 50%;
  bottom: max(5.5rem, calc(env(safe-area-inset-bottom) + 4.5rem));
  transform: translateX(-50%);
  z-index: 40;
  width: min(420px, calc(100vw - 1.5rem));
  pointer-events: none;
}
.wait-tips[hidden] { display: none !important; }
.wait-tips-card {
  pointer-events: auto;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(18, 22, 30, 0.94);
  border: 1px solid rgba(91, 157, 255, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
}
.wait-tips-card strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
  color: #cfe0ff;
}
.wait-tips-card p {
  margin: 0 0 0.65rem;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #9aa8bc;
}
.wait-tips-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Keyboard shortcuts overlay */
.keys-help {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.keys-help[hidden] { display: none !important; }
.keys-help-card {
  width: min(360px, 100%);
  padding: 1rem 1.1rem 1.15rem;
  border-radius: 16px;
  background: #12161e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.keys-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.keys-help-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.keys-help-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}
.keys-help-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  color: #b0bccf;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.keys-help-list li:last-child { border-bottom: none; }
.keys-help-list kbd {
  flex: 0 0 auto;
  min-width: 2.4rem;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: #1a2230;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8eef7;
}

/* Friend presence toast */
.presence-toast {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 50;
  max-width: min(320px, calc(100vw - 2rem));
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(18, 28, 22, 0.95);
  border: 1px solid rgba(61, 214, 140, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: #d8f5e6;
  font-size: 0.88rem;
  line-height: 1.35;
  animation: presence-in 0.25s ease;
}
.presence-toast strong { color: #fff; }
@keyframes presence-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Network hub settings */
.hub-url.mono,
#hub-current-url {
  margin: 0 0.75rem 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
  color: #b8c4d6;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-row.static {
  pointer-events: none;
  opacity: 0.9;
}

/* Failed-call coach overlay */
.call-coach {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.call-coach[hidden] { display: none !important; }
.call-coach-card {
  width: min(420px, 100%);
  padding: 1.1rem 1.15rem 1.15rem;
  border-radius: 18px;
  background: #12161e;
  border: 1px solid rgba(245, 165, 36, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.call-coach-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffd58a;
}
.call-coach-lead {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #b0bccf;
}
.call-coach-tips {
  margin: 0 0 0.75rem;
  padding-left: 1.15rem;
  color: #9aa8bc;
  font-size: 0.84rem;
  line-height: 1.45;
}
.call-coach-tips li { margin-bottom: 0.3rem; }
.call-coach-meta {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
  color: #6a7a90;
}
.call-coach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.call-coach-actions .pill.ghost {
  background: transparent;
  border-color: transparent;
  color: #8b9bb0;
}
@media (min-width: 700px) {
  .call-coach {
    align-items: center;
  }
}

/* Connection strip — pill overlay (position set near docks styles) */
.conn-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #8b9bb0;
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5a6a80;
  flex-shrink: 0;
}
.conn-strip.ok .conn-dot { background: #3dd68c; box-shadow: 0 0 8px #3dd68c88; }
.conn-strip.warn .conn-dot { background: #f5a524; box-shadow: 0 0 8px #f5a52488; }
.conn-strip.bad .conn-dot { background: #f31260; box-shadow: 0 0 8px #f3126088; }
.conn-strip.call .conn-dot { background: #5b9dff; box-shadow: 0 0 8px #5b9dff88; }
.conn-strip.is-reconnecting {
  border-color: rgba(245, 165, 36, 0.55);
  animation: conn-strip-pulse 1.2s ease-in-out infinite;
}
@keyframes conn-strip-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

/* Full-width reconnect banner (hub socket down) */
.reconnect-banner {
  position: fixed;
  left: 50%;
  top: max(0.5rem, env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 85;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 0.65rem;
  max-width: min(28rem, 94vw);
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 165, 36, 0.45);
  background: rgba(40, 28, 10, 0.94);
  color: #ffe8c0;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: auto;
}
.reconnect-banner[hidden] {
  display: none !important;
}
.reconnect-banner-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #f5a524;
  box-shadow: 0 0 8px #f5a524aa;
  animation: conn-strip-pulse 1s ease-in-out infinite;
  flex: 0 0 auto;
}
.reconnect-banner-text {
  flex: 1 1 auto;
  min-width: 8rem;
  text-align: center;
}
html[data-theme="light"] .reconnect-banner {
  background: rgba(255, 247, 237, 0.98);
  border-color: rgba(234, 88, 12, 0.35);
  color: #9a3412;
}
html[data-theme="saloon"] .reconnect-banner {
  background: rgba(48, 28, 10, 0.96);
  border-color: rgba(220, 140, 60, 0.45);
  color: #ffd8a8;
}
@media (max-width: 720px) {
  .reconnect-banner {
    top: auto;
    bottom: max(4.75rem, calc(env(safe-area-inset-bottom) + 3.75rem));
    border-radius: 14px;
    width: min(24rem, 94vw);
  }
}
.conn-ice { display: none; }
.conn-strip.idle,
.conn-strip[hidden] { display: none; }

/* Chat panel — floats inside partner tile above stage footer */
.chat-panel {
  position: absolute;
  left: 0.65rem;
  right: 0.65rem;
  bottom: 0.75rem;
  width: auto;
  max-width: none;
  max-height: min(32vh, 240px);
  display: flex;
  flex-direction: column;
  background: rgba(14, 18, 28, 0.92);
  border: 1px solid #2a3548;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  z-index: 6;
  overflow: hidden;
  backdrop-filter: blur(10px);
}
.chat-panel[hidden] { display: none !important; }
.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b9bb0;
  border-bottom: 1px solid #243041;
}
.chat-head-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
#chat-panel-title {
  font-weight: 650;
  color: #c5d0e0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head-sub {
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  color: #7a8a9e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head-sub.chat-sub-p2p {
  color: #3dd68c;
  font-weight: 650;
}
.chat-head-sub[hidden] { display: none !important; }
.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
}
.chat-clear,
.chat-head-btn {
  border: none;
  background: transparent;
  color: #8b9bb0;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  line-height: 1;
}
.chat-clear:hover,
.chat-head-btn:hover {
  color: #e8eef7;
  background: rgba(255, 255, 255, 0.06);
}

/* ── Messages inbox sheet ── */
.messages-sheet {
  display: flex;
  flex-direction: column;
  max-height: min(88dvh, 720px);
  height: min(88dvh, 640px);
  padding: 0;
  overflow: hidden;
}
.messages-sheet .msg-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.messages-sheet .msg-view[hidden] {
  display: none !important;
}
.msg-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}
.msg-sheet-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #eef2f7;
}
.msg-thread-head {
  justify-content: flex-start;
}
.msg-thread-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.msg-thread-meta h3 {
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-thread-sub {
  font-size: 0.72rem;
  color: #8b9bb0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-back {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 24, 32, 0.7);
  color: #e8eef7;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.msg-back:hover {
  background: rgba(40, 48, 64, 0.9);
}
.msg-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem 0.35rem;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.msg-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #8b9bb0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.msg-tab:hover {
  color: #d0dae8;
  background: rgba(255, 255, 255, 0.04);
}
.msg-tab.active {
  color: #eef4ff;
  background: rgba(91, 157, 255, 0.16);
  border-color: rgba(91, 157, 255, 0.35);
}
.msg-tab-count {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #ff2d55;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}
.msg-tab-count[hidden] { display: none !important; }
.msg-list-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.55rem 0.75rem 1rem;
}
.msg-list-hint {
  margin: 0 0 0.55rem;
}
.msg-thread-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.msg-thread-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 24, 32, 0.55);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.msg-thread-row:hover {
  background: rgba(36, 44, 60, 0.75);
  border-color: rgba(126, 182, 255, 0.28);
}
.msg-thread-row.unread {
  border-color: rgba(91, 157, 255, 0.4);
  background: rgba(30, 42, 68, 0.55);
}
.msg-thread-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #2a3548, #1a2230);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9ec0ff;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  overflow: hidden;
}
.msg-thread-avatar.has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg-thread-row.online .msg-thread-avatar {
  box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.55);
}
.msg-thread-row .meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.msg-thread-row .meta strong {
  font-size: 0.9rem;
  color: #eef2f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-thread-row.unread .meta strong {
  color: #fff;
}
.msg-thread-row .meta .preview {
  font-size: 0.78rem;
  color: #8b9bb0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-thread-row.unread .meta .preview {
  color: #b8c8e0;
  font-weight: 550;
}
.msg-thread-row .when {
  flex: 0 0 auto;
  font-size: 0.68rem;
  color: #6b7a90;
  align-self: flex-start;
  padding-top: 0.15rem;
}
.msg-thread-row .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5b9dff;
  flex: 0 0 auto;
  box-shadow: 0 0 8px #5b9dff88;
}
.msg-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: #8b9bb0;
  font-size: 0.88rem;
  line-height: 1.45;
}
.msg-thread-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: rgba(8, 10, 14, 0.35);
}
.msg-thread-body .chat-bubble {
  max-width: 88%;
}
.msg-compose {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
  background: rgba(12, 14, 20, 0.92);
}
.msg-compose input {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 24, 32, 0.85);
  color: #e8eef7;
  padding: 0.55rem 0.9rem;
  font: inherit;
}
.msg-compose input:focus {
  outline: none;
  border-color: rgba(91, 157, 255, 0.55);
}
.msg-compose input:disabled {
  opacity: 0.55;
}
.msg-compose .pill {
  flex: 0 0 auto;
}
.dock-icon .msg-badge {
  /* same badge style as friends */
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 80px;
  max-height: min(32vh, 260px);
}
.chat-bubble {
  max-width: 92%;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.35;
  word-break: break-word;
}
.chat-bubble .who {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
  opacity: 0.85;
}
.chat-bubble a.chat-link {
  color: #8eb6ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.chat-bubble.mine a.chat-link {
  color: #c7dbff;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: #1a2434;
  color: #e8eef7;
  border: 1px solid #2a3548;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb55, #4f46e555);
  border: 1px solid #3b82f688;
  color: #eef4ff;
}
.chat-bubble.sys {
  align-self: center;
  font-size: 0.75rem;
  color: #8b9bb0;
  background: transparent;
  border: none;
  padding: 0.2rem;
}

@media (max-width: 900px) {
  .chat-panel {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    bottom: 6.5rem;
    max-height: 28vh;
  }
  .name-chip { display: none; }
}

.stage-top-actions .phase {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #1c2430;
  color: #8b9bb0;
}

.stage-top-actions .phase.waiting,
.stage-top-actions .phase.claiming { color: #f5a524; background: #2a2418; }
.stage-top-actions .phase.matched { color: #3dd68c; background: #14261c; }

.pid {
  font-family: ui-monospace, monospace;
  color: #5b9dff;
  font-size: 0.78rem;
}

.status-pill {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: #8b9bb0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dual cameras — fills space between header and stage footer */
.stage {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #05060a;
  border-bottom: none;
}

/* Full-width bottom bar: Friends + room/chat (left) · Spin/Stop/Next (right) */
.stage-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem max(0.5rem, env(safe-area-inset-bottom));
  background: linear-gradient(
    180deg,
    rgba(10, 12, 18, 0.92) 0%,
    rgba(6, 8, 12, 0.98) 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  z-index: 8;
  min-height: 3.25rem;
}
.stage-footer-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-width: 0;
}
.stage-footer-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 1 auto;
  flex-wrap: wrap;
}
.stage-footer .footer-friends {
  /* furthest bottom-left control */
  order: -1;
  margin-right: 0.1rem;
}
.stage-footer .room-in-tile {
  flex: 0 0 auto;
}
.stage-footer .dock-chat {
  flex: 1 1 10rem;
  min-width: 7rem;
  max-width: 28rem;
}
.stage-footer .footer-context:empty {
  display: none;
}
.stage-footer .footer-match {
  flex-wrap: nowrap;
}
.stage-footer .dock-icon {
  order: unset;
  margin-left: 0;
}
.stage-footer .dock-settings {
  order: unset;
}

/* Fullscreen — top-right of partner camera window */
.tile-corner-btn {
  position: absolute;
  z-index: 7;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 24, 32, 0.72);
  backdrop-filter: blur(10px);
  color: #eef2f7;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 0;
}
.tile-corner-btn .icon {
  width: 1.15rem;
  height: 1.15rem;
}
.tile-corner-btn:hover {
  background: rgba(40, 48, 64, 0.92);
  border-color: rgba(255, 255, 255, 0.22);
}
.tile-corner-btn:active {
  transform: scale(0.96);
}
.tile-fs-btn {
  top: 0.55rem;
  right: 0.55rem;
}
.tile-pip-btn {
  top: 0.55rem;
  right: calc(0.55rem + 2.55rem + 0.4rem);
}
.tile-pip-btn[hidden] {
  display: none !important;
}
.tile-pip-btn.is-active {
  border-color: rgba(91, 157, 255, 0.55);
  background: rgba(40, 70, 120, 0.85);
  color: #d6e8ff;
}

.tile {
  position: relative;
  overflow: hidden;
  background: #0c0f14;
  min-height: 0; /* fill grid cell; don't force 280px that can break full-height layout */
  width: 100%;
  height: 100%;
}

.tile-remote {
  border-right: 1px solid #1c2230;
}

.vid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0d12;
}

.vid.local {
  transform: scaleX(-1);
}
/* Rear camera: natural orientation (no selfie mirror) */
.vid.local.facing-environment {
  transform: none;
}
.tile-local.self-blurred .vid.local.facing-environment {
  transform: scale(1.06);
}

/* Friend PiP — party browse: keep friend visible while stranger(s) use main remote */
.friend-pip {
  position: absolute;
  left: 0.55rem;
  bottom: 0.75rem;
  z-index: 6;
  width: min(32%, 9.5rem);
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  background: #0a0d12;
  pointer-events: none;
}
.friend-pip[hidden] {
  display: none !important;
}
.friend-pip-vid {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0a0d12;
  transform: scaleX(-1);
}
.friend-pip-lbl {
  position: absolute;
  left: 0.35rem;
  bottom: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #f0f4fa;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.45);
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
}
@media (max-width: 560px) {
  .friend-pip {
    width: min(36%, 7.5rem);
    bottom: 4.25rem;
    left: 0.4rem;
  }
}

/* Partner blur (manual + 2s intro) — local view only */
.tile-remote.partner-blurred .vid.remote {
  filter: blur(28px) saturate(0.85);
  transform: scale(1.08);
}
.tile-remote.partner-blurred .remote-stack {
  overflow: hidden;
}

/* Self-hide: local preview looks blurred; partner gets black via track replace */
.tile-local.self-blurred .vid.local {
  filter: blur(26px) saturate(0.8);
  transform: scaleX(-1) scale(1.06);
}
.tile-local.self-blurred {
  overflow: hidden;
}
.self-blur-badge {
  position: absolute;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffe8c8;
  background: rgba(20, 12, 8, 0.78);
  border: 1px solid rgba(255, 180, 100, 0.45);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.self-blur-badge[hidden] {
  display: none !important;
}
#btn-blur-self.active {
  border-color: rgba(245, 165, 36, 0.55);
  background: rgba(245, 165, 36, 0.16);
  color: #f5c56b;
}
#btn-blur-remote.active {
  border-color: rgba(91, 157, 255, 0.5);
  background: rgba(91, 157, 255, 0.14);
}

/* Click partner video for actions (not fullscreen) */
.tile-remote.partner-clickable {
  cursor: pointer;
}
.tile-remote.partner-clickable .vid.remote {
  cursor: pointer;
}

/* Partner action sheet */
.partner-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
.partner-menu-backdrop[hidden],
.partner-menu[hidden] {
  display: none !important;
}
.partner-menu {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px) + 0.75rem);
  transform: translateX(-50%);
  z-index: 46;
  width: min(360px, calc(100vw - 1.5rem));
  padding: 0.85rem 0.9rem 0.75rem;
  border-radius: 16px;
  background: rgba(16, 20, 30, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(88dvh, 640px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 720px) {
  .partner-menu {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 18px 18px 0 0;
    padding: 1rem 1rem max(1.1rem, env(safe-area-inset-bottom));
    max-height: min(92dvh, 100%);
  }
  .partner-menu-btn {
    min-height: 3rem;
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }
  .partner-menu-hint {
    font-size: 0.88rem;
    line-height: 1.4;
  }
  #btn-report-dock {
    min-height: 2.5rem;
  }
}
.partner-menu-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0.35rem 0.35rem;
}
.partner-menu-head strong {
  font-size: 0.95rem;
  color: #eef2f7;
}
.partner-menu-name {
  font-size: 0.8rem;
  color: #8b9bb0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.partner-menu-hint {
  margin: 0 0 0.25rem;
  padding: 0 0.25rem;
  font-size: 0.8rem;
  color: #9aa8bc;
}
.partner-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.partner-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(36, 42, 56, 0.9);
  color: #eef2f7;
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.partner-menu-btn:hover:not(:disabled) {
  background: rgba(52, 62, 82, 0.95);
  border-color: rgba(91, 157, 255, 0.35);
}
.partner-menu-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.partner-menu-btn .pm-ico {
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.partner-menu-btn .pm-ico .icon {
  width: 1.15rem;
  height: 1.15rem;
  color: currentColor;
}
.partner-menu-btn.warn {
  border-color: rgba(245, 165, 36, 0.35);
  color: #ffd58a;
}
.partner-menu-btn.danger {
  border-color: rgba(243, 18, 96, 0.35);
  color: #ff8fb0;
}
.partner-menu-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: #9aa8bc;
  justify-content: center;
  font-weight: 400;
}
.partner-menu-btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
  color: #eef2f7;
}

.tile-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  /* Keep copy clear of side rails + in-tile docks */
  padding: 2.5rem 3.75rem 5.5rem;
  box-sizing: border-box;
  text-align: center;
  color: #9aa8bc;
  background: radial-gradient(ellipse at center, #141a24 0%, #0a0c10 70%);
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.tile-empty.hidden { display: none; }

/* Looping brand loading video behind idle partner copy */
.empty-bg-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}
.empty-bg-poster[hidden] {
  display: none !important;
}
.empty-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
  /* subtle scale so edges don’t flash letterbox on some aspect ratios */
  transform: scale(1.02);
}
.empty-bg-video[hidden] {
  display: none !important;
}
.empty-bg-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(8, 10, 14, 0.25) 0%, rgba(8, 10, 14, 0.72) 100%),
    linear-gradient(180deg, rgba(6, 8, 12, 0.35) 0%, rgba(6, 8, 12, 0.55) 100%);
}
.empty-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  max-width: 18rem;
}
#remote-empty .empty-title {
  color: #f2f5fa;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.75);
}
#remote-empty .empty-sub {
  color: rgba(200, 210, 224, 0.9);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}
#remote-empty .empty-icon {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 1;
}
.enable-cam-btn {
  margin-top: 0.85rem;
  pointer-events: auto;
  z-index: 2;
  position: relative;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  box-shadow: 0 8px 24px rgba(255, 45, 85, 0.35);
}
.enable-cam-btn:active { transform: scale(0.98); }
.enable-cam-btn[hidden] { display: none !important; }
.tile-empty .enable-cam-btn { margin-top: 1rem; }

/* Big Start CTA — center of partner (remote) empty tile */
.start-match-btn {
  margin-top: 1.15rem;
  pointer-events: auto;
  z-index: 3;
  position: relative;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 2.4rem;
  min-width: 10.5rem;
  font: inherit;
  font-weight: 750;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #ff2d55 0%, #ff5c3a 55%, #ff7a3b 100%);
  box-shadow:
    0 12px 36px rgba(255, 45, 85, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.start-match-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow:
    0 16px 42px rgba(255, 45, 85, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.start-match-btn:active {
  transform: scale(0.97);
}
.start-match-btn[hidden] {
  display: none !important;
}
/* When waiting/searching, keep empty tile but no Start */
#remote-empty.is-searching .start-match-btn {
  display: none !important;
}
#remote-empty.is-searching .empty-icon {
  animation: start-pulse 1.4s ease-in-out infinite;
}
@keyframes start-pulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
.empty-title { font-size: 1.05rem; font-weight: 600; color: #e8eef7; }
.empty-sub { font-size: 0.85rem; color: #7a8a9e; }

/* Empty-pool share / QR (idle + searching, hidden when matched) */
.empty-share {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 17rem;
  pointer-events: auto;
  z-index: 3;
  position: relative;
}
.empty-share[hidden] {
  display: none !important;
}
.empty-share-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: rgba(200, 210, 224, 0.88);
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}
.empty-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}
.empty-share-actions .pill {
  font-size: 0.78rem;
  min-height: 2rem;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  background: rgba(12, 16, 24, 0.72);
  border-color: rgba(255, 255, 255, 0.16);
  color: #e8eef7;
}
.empty-share-actions .pill.accent {
  background: linear-gradient(135deg, rgba(255, 45, 85, 0.85), rgba(255, 107, 53, 0.85));
  border-color: transparent;
  color: #fff;
}
.empty-share-qr {
  margin-top: 0.35rem;
  padding: 0.45rem;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.empty-share-qr[hidden] {
  display: none !important;
}
.empty-share-qr img {
  display: block;
  width: 140px;
  height: 140px;
  border-radius: 6px;
}

/* Friend row: primary actions + overflow ⋮ for rename/remove/block */
.friend-actions-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  justify-content: flex-end;
}
.friend-more-wrap {
  position: relative;
  flex-shrink: 0;
}
.btn-friend-more {
  min-width: 2rem;
  padding: 0.25rem 0.45rem;
  font-size: 1rem;
  line-height: 1;
  letter-spacing: 0.05em;
}
.friend-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 8;
  min-width: 8.5rem;
  padding: 0.3rem;
  border-radius: 10px;
  background: rgba(16, 20, 30, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.friend-more-menu[hidden] {
  display: none !important;
}
.friend-more-menu .pill {
  width: 100%;
  justify-content: flex-start;
  font-size: 0.78rem;
  min-height: 2.1rem;
}
/* Desktop: show rename/remove/block inline; hide overflow */
@media (min-width: 721px) {
  .friend-more-wrap {
    display: none !important;
  }
  .friend-actions-overflow-inline {
    display: contents;
  }
}
/* Mobile: collapse secondary into ⋮ */
@media (max-width: 720px) {
  .friend-row .friend-actions {
    max-width: none;
    flex-wrap: nowrap;
    gap: 0.25rem;
  }
  .friend-actions-overflow-inline {
    display: none !important;
  }
  .friend-more-wrap {
    display: block;
  }
  .friend-actions-primary .pill {
    min-height: 2.15rem;
  }
}

/* One-time export nudge toast */
.export-nudge-toast {
  position: fixed;
  left: 50%;
  bottom: max(5.5rem, env(safe-area-inset-bottom, 0px) + 4.5rem);
  transform: translateX(-50%);
  z-index: 48;
  width: min(360px, calc(100vw - 1.5rem));
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: rgba(16, 20, 30, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.export-nudge-toast[hidden] {
  display: none !important;
}
.export-nudge-toast p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #d0dae8;
}
.export-nudge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

html[data-theme="light"] .empty-share-hint {
  color: rgba(40, 50, 65, 0.9);
}
html[data-theme="light"] .empty-share-actions .pill:not(.accent) {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.1);
  color: #1a2433;
}
html[data-theme="light"] .friend-more-menu {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .export-nudge-toast {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .export-nudge-toast p {
  color: #2a3548;
}
html[data-theme="saloon"] .empty-share-actions .pill:not(.accent) {
  background: rgba(40, 28, 18, 0.85);
  border-color: rgba(212, 165, 116, 0.35);
  color: #f0e0c8;
}
html[data-theme="saloon"] .friend-more-menu,
html[data-theme="saloon"] .export-nudge-toast {
  background: rgba(32, 22, 14, 0.98);
  border-color: rgba(212, 165, 116, 0.3);
}

.tile-tag {
  position: absolute;
  top: 0.55rem;
  left: 0.65rem;
  z-index: 3;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  /* Names only — no role labels, no ALL CAPS */
  text-transform: none;
  letter-spacing: 0;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  pointer-events: none;
  max-width: calc(100% - 5.5rem); /* leave room for fullscreen corner btn */
}
.tile-tag[hidden] {
  display: none !important;
}
.tile-tag .name-on-tile {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.quality {
  font-family: ui-monospace, monospace;
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  color: #3dd68c;
  opacity: 0.85;
}
.quality[hidden] {
  display: none !important;
}

.quality.warn { color: #f5a524; }
.quality.bad { color: #f31260; }

/* Live connection chip on partner name row */
.conn-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 214, 140, 0.4);
  background: rgba(61, 214, 140, 0.14);
  color: #3dd68c;
  white-space: nowrap;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.conn-chip[hidden] {
  display: none !important;
}
.conn-chip.grade-ok {
  color: #f5c842;
  border-color: rgba(245, 200, 66, 0.45);
  background: rgba(245, 200, 66, 0.12);
}
.conn-chip.grade-weak,
.conn-chip.path-relay.grade-weak {
  color: #ff8fab;
  border-color: rgba(255, 107, 53, 0.5);
  background: rgba(255, 45, 85, 0.14);
}
.conn-chip.path-relay:not(.grade-weak) {
  color: #f5a524;
  border-color: rgba(245, 165, 36, 0.45);
  background: rgba(245, 165, 36, 0.12);
}

/* Outgoing friend request: waiting state */
.friend-row-pending {
  border-color: rgba(245, 165, 36, 0.35);
  background: rgba(245, 165, 36, 0.06);
}
.friend-row .dot.pending {
  display: inline-block;
  background: #f5a524;
  box-shadow: 0 0 0 3px rgba(245, 165, 36, 0.25);
}
.friend-wait-badge {
  display: inline-block !important;
  margin-top: 0.15rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem !important;
  font-weight: 700;
  color: #f5c842 !important;
  background: rgba(245, 165, 36, 0.14);
  border: 1px solid rgba(245, 165, 36, 0.35);
}
.friend-wait-sub {
  display: block !important;
  font-size: 0.68rem !important;
  color: #9aa8bc !important;
  margin-top: 0.12rem;
  line-height: 1.3;
}
/* Collapsible “how codes work” inside Friends sheet — optional, not a nag */
.friends-how-codes {
  margin: 0.35rem 0 0.55rem;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
}
.friends-how-codes summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  list-style: none;
}
.friends-how-codes summary::-webkit-details-marker {
  display: none;
}
.friends-how-codes summary::before {
  content: "▸ ";
  opacity: 0.7;
}
.friends-how-codes[open] summary::before {
  content: "▾ ";
}
.friends-how-codes .hint-inline {
  margin: 0.4rem 0 0.15rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.62);
}
html[data-theme="light"] .friends-how-codes {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] .friends-how-codes summary {
  color: #334155;
}
html[data-theme="light"] .friends-how-codes .hint-inline {
  color: #64748b;
}
html[data-theme="saloon"] .friends-how-codes {
  background: rgba(40, 18, 8, 0.45);
  border-color: rgba(196, 120, 60, 0.25);
}

.friends-pending-banner {
  margin: 0.15rem 0 0.45rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: rgba(245, 165, 36, 0.1);
  border: 1px solid rgba(245, 165, 36, 0.28);
  color: #e8d5a0;
  font-size: 0.78rem;
  line-height: 1.35;
}
.friends-pending-banner[hidden] {
  display: none !important;
}

.friend-soft-toast {
  position: fixed;
  left: 50%;
  bottom: max(5.5rem, env(safe-area-inset-bottom, 0px) + 4.5rem);
  transform: translateX(-50%);
  z-index: 49;
  width: min(340px, calc(100vw - 1.5rem));
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: rgba(16, 20, 30, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  pointer-events: none;
}
.friend-soft-toast strong {
  font-size: 0.88rem;
  color: #eef2f7;
}
.friend-soft-toast span {
  font-size: 0.78rem;
  color: #9aa8bc;
}
.friend-soft-toast-ok {
  border-color: rgba(61, 214, 140, 0.4);
}
.friend-soft-toast-ok strong {
  color: #9aecc0;
}

/* Desktop footer invite (before Spin) — not under Start on mobile */
.footer-invite {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  position: relative;
  max-width: min(42rem, 55vw);
}
.footer-invite[hidden] {
  display: none !important;
}
.footer-invite .dock-pill {
  font-size: 0.72rem;
  padding: 0.32rem 0.55rem;
  min-height: 2.15rem;
  white-space: nowrap;
}
.footer-invite-qr {
  position: absolute;
  bottom: calc(100% + 0.45rem);
  right: 0;
  z-index: 40;
  padding: 0.45rem;
  border-radius: 12px;
  background: rgba(12, 16, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}
.footer-invite-qr[hidden] {
  display: none !important;
}
.footer-invite.is-long-wait .dock-pill.accent {
  box-shadow: 0 0 0 1px rgba(255, 45, 85, 0.45), 0 6px 18px rgba(255, 45, 85, 0.25);
}
/* Mobile alone-pool invite under Start (desktop uses footer-invite) */
.mobile-invite {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
  max-width: 16rem;
  pointer-events: auto;
}
.mobile-invite[hidden] {
  display: none !important;
}
.mobile-invite-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 16, 24, 0.72);
  color: #e8eef7;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  min-height: 2.35rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}
.mobile-invite-btn.accent {
  background: rgba(255, 45, 85, 0.88);
  border-color: rgba(255, 90, 120, 0.55);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 45, 85, 0.28);
}
.mobile-invite-btn:active {
  transform: scale(0.97);
}
.mobile-invite.is-long-wait .mobile-invite-btn.accent {
  box-shadow: 0 0 0 1px rgba(255, 45, 85, 0.5), 0 8px 22px rgba(255, 45, 85, 0.35);
  animation: mobile-invite-pulse 1.6s ease-in-out infinite;
}
@keyframes mobile-invite-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-invite.is-long-wait .mobile-invite-btn.accent {
    animation: none;
  }
}
/* Mobile / narrow: footer invite off; compact under-Start invite on */
@media (max-width: 900px) {
  .footer-invite {
    display: none !important;
  }
  .mobile-invite:not([hidden]) {
    display: flex;
  }
}
/* Desktop: never show mobile under-Start invite */
@media (min-width: 901px) {
  .mobile-invite {
    display: none !important;
  }
}

/* Friends first-run code block */
.friends-code-hero {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
}
.friends-code-hero.is-first-run {
  border-color: rgba(91, 157, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(91, 157, 255, 0.2), 0 10px 28px rgba(0, 0, 0, 0.25);
}
.friends-code-label {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: rgba(230, 236, 245, 0.78);
}
.friends-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.friends-code-value {
  flex: 1 1 auto;
  min-width: 6rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #f4f7fc;
  user-select: all;
  -webkit-user-select: all;
}
.friends-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.friends-first-hint {
  margin: 0.55rem 0 0 !important;
  color: rgba(160, 200, 255, 0.9) !important;
}
.friends-first-hint[hidden] {
  display: none !important;
}
#btn-copy-code.pulse-once {
  animation: copy-pulse 0.9s ease 2;
}
@keyframes copy-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: none;
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 3px rgba(91, 157, 255, 0.35);
  }
}
html[data-theme="light"] .friends-code-hero {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] .friends-code-value {
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
}
html[data-theme="light"] .friends-code-label {
  color: #475569;
}

/* Soft weak-connection tip (once per match, after 8s weak) */
.weak-conn-tip {
  position: fixed;
  left: 50%;
  bottom: max(5.75rem, calc(env(safe-area-inset-bottom) + 4.75rem));
  transform: translateX(-50%);
  z-index: 78;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  max-width: min(24rem, 94vw);
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 180, 80, 0.4);
  background: rgba(48, 32, 12, 0.94);
  color: #ffe8c8;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  font-size: 0.88rem;
  line-height: 1.35;
  animation: report-toast-in 0.2s ease-out;
}
.weak-conn-tip span {
  flex: 1 1 12rem;
}
html[data-theme="light"] .weak-conn-tip {
  background: rgba(255, 247, 237, 0.98);
  border-color: rgba(234, 88, 12, 0.3);
  color: #9a3412;
}
html[data-theme="saloon"] .weak-conn-tip {
  background: rgba(48, 28, 10, 0.95);
  border-color: rgba(220, 140, 60, 0.4);
  color: #ffd8a8;
}
@media (max-width: 720px) {
  .empty-share {
    width: min(100%, 22rem);
    padding: 0.55rem 0.45rem 0.65rem;
  }
  .empty-share-hint {
    font-size: 0.82rem;
    line-height: 1.35;
  }
  .empty-share-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
  }
  .empty-share-actions .pill {
    min-height: 2.55rem;
    min-width: 5.25rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.88rem;
  }
  .empty-share-qr img {
    width: 160px;
    height: 160px;
  }
}
.empty-share.is-long-wait {
  max-width: 19rem;
}
.empty-share.is-long-wait .empty-share-hint {
  color: #ffe0a8;
  font-weight: 600;
  font-size: 0.8rem;
}
.empty-share.is-long-wait .empty-share-actions .pill.accent {
  box-shadow: 0 8px 28px rgba(255, 45, 85, 0.45);
  transform: scale(1.02);
}
.settings-row-accent {
  border-color: rgba(91, 157, 255, 0.35) !important;
  background: rgba(91, 157, 255, 0.08) !important;
}
.profile-export-callout {
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  background: rgba(91, 157, 255, 0.1);
  border: 1px solid rgba(91, 157, 255, 0.28);
  color: #c5d8f5;
}
.profile-export-callout strong {
  color: #e8f0ff;
}
.conn-prefer-direct-row {
  margin: 0.65rem 0 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

/* Hub chip when matchmaking is on a different origin than the page */
.hub-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(91, 157, 255, 0.35);
  background: rgba(91, 157, 255, 0.12);
  color: #9ec5ff;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-chip[hidden] {
  display: none !important;
}
.hub-chip .icon {
  width: 0.85rem;
  height: 0.85rem;
  opacity: 0.9;
}
.post-match-friend-nudge {
  pointer-events: auto;
  z-index: 52;
}

/* ICE media path badge (Direct P2P vs TURN) + weak-link hint */
.ice-path {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 24, 32, 0.65);
  color: #9aa8bc;
  white-space: nowrap;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ice-path.path-direct {
  color: #3dd68c;
  border-color: rgba(61, 214, 140, 0.4);
  background: rgba(61, 214, 140, 0.12);
}
.ice-path.path-relay {
  color: #f5a524;
  border-color: rgba(245, 165, 36, 0.4);
  background: rgba(245, 165, 36, 0.12);
}
.ice-path.path-unknown {
  color: #8b9bb0;
}
.ice-path.path-weak {
  color: #ffb4a0;
  border-color: rgba(255, 107, 53, 0.45);
  background: rgba(255, 45, 85, 0.12);
}
.arch-pill.path-direct {
  color: #3dd68c;
}
.arch-pill.path-relay {
  color: #f5a524;
}
.settings-security .sec-row {
  flex-wrap: wrap;
  gap: 0.35rem;
}
.settings-security .sec-value {
  color: #9aa8bc;
  font-size: 0.8rem;
  text-align: right;
  max-width: 58%;
}
.settings-security .sec-note .sec-value {
  max-width: 100%;
  text-align: left;
  color: #7a8a9e;
  font-size: 0.78rem;
  line-height: 1.35;
}

.mic-pill {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  text-transform: none;
  letter-spacing: 0;
}

.mic-pill.hot { background: rgba(61, 214, 140, 0.35); color: #3dd68c; }
.mic-pill.muted { background: rgba(243, 18, 96, 0.35); color: #ff6b9d; }

/* Side rails — vertical stacks flush to bottom of each tile (both sides) */
.side-rail {
  position: absolute;
  top: auto;
  bottom: 0.55rem; /* sit on the tile floor; docks leave side strips clear */
  transform: none;
  z-index: 6; /* above dock gradient so icons stay tappable */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem;
  pointer-events: none; /* only buttons capture clicks */
}

.side-rail > * { pointer-events: auto; }

.side-rail-right {
  right: 0.65rem;
  gap: 0.4rem; /* tighter than left — fewer labels collide with dock */
}
.side-rail-left { left: 0.65rem; }

/* Right rail mic meter — shorter so stack stays tidy above dock */
.side-rail-right .mic-meter-rail {
  padding: 0.35rem 0.25rem 0.3rem;
  gap: 0.2rem;
}
.side-rail-right .meter-v {
  height: 56px;
  width: 8px;
}

.side-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(20, 24, 32, 0.72);
  backdrop-filter: blur(10px);
  color: #eef2f7;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.side-btn:hover {
  background: rgba(40, 48, 64, 0.9);
  border-color: rgba(255,255,255,0.22);
}

.side-btn:active { transform: scale(0.96); }

.side-btn .ico {
  position: relative;
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  line-height: 0;
}
.side-btn .ico .icon {
  width: 1.2rem;
  height: 1.2rem;
  grid-area: 1 / 1;
}
.side-btn .ico .icon-off {
  display: none;
}
/* Muted / off state swaps SVG glyphs */
.side-btn.muted-on .ico .icon-on {
  display: none;
}
.side-btn.muted-on .ico .icon-off {
  display: block;
  color: #ff6b9d;
}
.side-btn.muted-on {
  border-color: rgba(243, 18, 96, 0.35);
  background: rgba(60, 20, 36, 0.72);
}
.side-btn.active .ico .icon-on {
  display: none;
}
.side-btn.active .ico .icon-off {
  display: block;
  color: #8eb6ff;
}
.side-btn.active {
  border-color: rgba(91, 157, 255, 0.4);
  background: rgba(30, 42, 68, 0.85);
}
.side-btn .lbl {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa8bc;
  margin-top: 2px;
}

.side-btn {
  position: relative;
}
.friends-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #ff2d55;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(20, 24, 32, 0.9);
}
.friends-badge[hidden] { display: none !important; }

.req-panel {
  border: 1px solid rgba(61, 214, 140, 0.35);
  border-radius: 12px;
  padding: 0.45rem;
  background: rgba(20, 48, 36, 0.35);
}
.req-title {
  color: #9ee6b8 !important;
  margin-bottom: 0.35rem;
}
.req-row .pill.primary {
  font-weight: 700;
  min-width: 4.5rem;
}
.friend-req-toast .toast-sub {
  display: block;
  font-size: 0.75rem;
  color: #8b9bb0;
  margin-top: 0.2rem;
  max-width: 16rem;
}

.side-btn.active {
  border-color: rgba(61, 214, 140, 0.55);
  background: rgba(20, 48, 36, 0.85);
}

.side-btn.muted-on {
  border-color: rgba(243, 18, 96, 0.55);
  background: rgba(48, 16, 28, 0.85);
}

/* Vertical volume / meter */
.side-vol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.3rem;
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.72);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.side-vol .lbl {
  font-size: 0.55rem;
  text-transform: uppercase;
  color: #9aa8bc;
}

.side-vol input[type="range"] {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 22px;
  height: 100px;
  padding: 0;
  margin: 0;
  accent-color: #5b9dff;
  cursor: pointer;
  background: transparent;
}

/* vertical mic meter — fill uses transform scaleY (more reliable than %) */
.meter-v {
  width: 10px;
  height: 88px;
  border-radius: 999px;
  background: #1c2430;
  overflow: hidden;
  border: 1px solid #2a3548;
  position: relative;
}

.meter-v > span {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  transform-origin: bottom center;
  transform: scaleY(0);
  background: linear-gradient(to top, #3dd68c 0%, #5b9dff 70%, #a8d4ff 100%);
  transition: transform 0.05s linear;
  will-change: transform;
}

/* Legacy in-tile docks (unused — controls live in .stage-footer) */
.tile-dock {
  display: none !important;
}
.tile-dock > * { pointer-events: auto; }

.dock-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.dock-row-context {
  justify-content: flex-start;
  min-height: 0;
}
.dock-row-context:empty { display: none; }
.dock-row-main {
  gap: 0.5rem;
  align-items: center;
}
.stop-in-tile {
  flex: 0 0 auto;
  min-width: 4.25rem;
  font-weight: 650;
}
#btn-stop.dock-pill.danger {
  border-color: rgba(243, 18, 96, 0.4);
  background: rgba(48, 16, 28, 0.88);
  color: #ffb3c9;
}
#btn-stop.dock-pill.danger:hover {
  border-color: rgba(255, 80, 120, 0.65);
  background: rgba(70, 20, 36, 0.95);
  color: #fff;
}

.dock-pill {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 24, 32, 0.78);
  backdrop-filter: blur(10px);
  color: #e8eef7;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.dock-pill:hover {
  border-color: rgba(91, 157, 255, 0.55);
  background: rgba(36, 44, 58, 0.9);
}
.dock-pill:active { transform: scale(0.97); }
.dock-pill.ghost {
  background: rgba(14, 18, 26, 0.55);
  color: #c5d0e0;
  font-weight: 500;
}
.dock-pill.danger {
  border-color: rgba(243, 18, 96, 0.45);
  background: rgba(48, 16, 28, 0.82);
  color: #ffb3c9;
}
.dock-pill.accent {
  border-color: rgba(91, 157, 255, 0.45);
  background: rgba(20, 36, 64, 0.85);
  color: #9ec5ff;
}
.dock-pill.tight {
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
}
.dock-pill[hidden] { display: none !important; }

/* Sheets / friends still use .pill */
.pill {
  font: inherit;
  border: 1px solid #2a3548;
  background: #141a22;
  color: #e8eef7;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pill:hover { border-color: #5b9dff; }
.pill.primary {
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  border-color: transparent;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 45, 85, 0.28);
}
.pill.ghost {
  background: transparent;
  color: #8b9bb0;
}
.pill.danger {
  border-color: rgba(243, 18, 96, 0.45);
  background: rgba(48, 16, 28, 0.85);
  color: #ffb3c9;
}
.pill.accent {
  border-color: rgba(91, 157, 255, 0.45);
  background: rgba(20, 36, 64, 0.85);
  color: #9ec5ff;
}
.pill.tight {
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
}

.next-big {
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  box-shadow: 0 6px 22px rgba(255, 45, 85, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.1s, box-shadow 0.15s;
}
.next-big.next-in-tile {
  min-width: 7.5rem;
  justify-content: center;
}
.next-big:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(255, 45, 85, 0.5);
}
.next-big:active { transform: scale(0.98); }

/* Circular dock icons — Friends + Settings (bottom-right of local dock) */
.dock-icon {
  position: relative;
  flex: 0 0 auto;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 24, 32, 0.78);
  backdrop-filter: blur(10px);
  color: #eef2f7;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  margin-left: 0.1rem;
  order: 9;
}
.dock-icon .icon {
  width: 1.2rem;
  height: 1.2rem;
  color: #e8eef7;
}
.dock-icon:hover {
  background: rgba(40, 48, 64, 0.92);
  border-color: rgba(255, 255, 255, 0.22);
}
.dock-icon:active {
  transform: scale(0.96);
}
.dock-settings {
  order: 10; /* always last = bottom-right in the dock row */
}
/* Friends badge sits on the dock icon */
.dock-icon .friends-badge {
  top: -3px;
  right: -3px;
}

.tile-dock-remote,
.tile-dock-local {
  display: none !important;
}
.room-in-tile {
  flex: 0 0 auto;
  padding: 0.2rem 0.35rem 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.room-in-tile span {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.room-in-tile input {
  width: 5.5rem;
  background: transparent;
  border: none;
  padding: 0.25rem 0.2rem;
  color: #e8eef7;
}
.room-in-tile input:focus {
  outline: none;
}

.bottom-chat,
.dock-chat {
  display: flex;
  gap: 0.35rem;
  min-width: 0;
  flex: 1 1 10rem;
}
.bottom-chat input,
.dock-chat input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(14, 18, 26, 0.82);
  backdrop-filter: blur(10px);
  color: #e8eef7;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.bottom-chat input:focus,
.dock-chat input:focus {
  outline: none;
  border-color: rgba(91, 157, 255, 0.55);
}

/* Conn strip: in header (not bottom — avoids overlap with Room field) */
.stage-top .conn-strip {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  z-index: 1;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(36vw, 14rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  background: rgba(14, 18, 26, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: none;
  pointer-events: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-top .conn-strip #conn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.stage-top .conn-retry {
  pointer-events: auto;
  flex-shrink: 0;
}

/* Log drawer */
.log-drawer {
  margin: 0 1rem 1rem;
  border: 1px solid #1c2230;
  border-radius: 12px;
  background: #0e131a;
  color: #8b9bb0;
  font-size: 0.85rem;
}

.log-drawer summary {
  cursor: pointer;
  padding: 0.55rem 0.85rem;
  user-select: none;
}

.log-drawer .log {
  max-height: 160px;
  overflow-y: auto;
  padding: 0 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log .sys {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: #7a8a9e;
}

.log .bubble {
  max-width: 90%;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  background: #1c2533;
  border: 1px solid #2a3548;
  color: #e8eef7;
}

.log .bubble.mine {
  align-self: flex-end;
  background: #1a2a44;
}

/* Settings sheet — clean hub + sub-pages */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  z-index: 40;
}
/* Animate only settings (friends sheet shares .sheet-backdrop class) */
#sheet-backdrop {
  opacity: 0;
  transition: opacity 0.18s ease;
}
#sheet-backdrop.is-open {
  opacity: 1;
}

.sheet {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(400px, calc(100vw - 1.25rem));
  max-height: min(88dvh, 640px);
  overflow: hidden;
  z-index: 50;
  background: #0c0f14;
  border: 1px solid #222a38;
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
}

.sheet.settings-app {
  padding: 0;
  /* Fill almost the full viewport so more rows are visible (less scrolling) */
  top: max(0.5rem, env(safe-area-inset-top, 0px));
  right: 0.65rem;
  bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
  left: auto;
  width: min(420px, calc(100vw - 1.1rem));
  height: auto; /* top+bottom pin the height */
  max-height: none;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity 0.18s ease, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  /* Stack sub-pages so only one view paints (avoids “meshed” multi-view bleed) */
  position: fixed;
  isolation: isolate;
  /* Beat .sheet[hidden] when open: ensure flex layout is used */
  display: flex;
  flex-direction: column;
  visibility: visible;
}
.sheet.settings-app.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
/* While hidden attribute is set, stay fully gone */
.sheet.settings-app[hidden] {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.sheet[hidden],
.sheet-backdrop[hidden] {
  display: none !important;
}

/* Hub directory rows (Settings → Network hub) */
.hub-row-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 0;
}
.hub-row-text strong {
  font-weight: 600;
  font-size: 0.88rem;
  color: inherit;
}
.hub-row-sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: #8b9bb0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16rem;
}
.settings-choice.hub-dead {
  opacity: 0.55;
}
.settings-choice.hub-dead .hub-row-sub {
  color: #f31260;
}

/* Friends sheet — ensure it always paints above stage chrome when open */
#friends-sheet {
  z-index: 55;
}
#friends-backdrop {
  z-index: 54;
  opacity: 1;
}
#friends-sheet.is-open {
  display: flex !important;
}
/* Mobile: full-width bottom sheet so Friends is obvious + usable */
@media (max-width: 720px) {
  #friends-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    max-height: min(92dvh, 100%);
    height: min(88dvh, 100%);
    border-radius: 18px 18px 0 0;
  }
  #friends-sheet .sheet-body {
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  #friends-sheet .row-inline {
    flex-wrap: wrap;
  }
  #friends-sheet #add-friend-code {
    flex: 1 1 8rem;
    min-width: 0;
    min-height: 2.5rem;
    font-size: 16px; /* avoid iOS zoom */
  }
  #friends-sheet #btn-add-friend {
    min-height: 2.5rem;
    min-width: 5.5rem;
  }
}

.sheet header,
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid #161b24;
  flex-shrink: 0;
  background: rgba(12, 14, 18, 0.96);
  backdrop-filter: blur(10px);
  z-index: 2;
}

.sheet header h3,
.settings-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-align: center;
  flex: 1;
}

.sheet-close,
.sheet-nav-btn {
  border: none;
  background: transparent;
  color: #c5d0e0;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sheet-nav-btn:hover { background: #161b24; }
.sheet-nav-spacer { width: 2.25rem; flex-shrink: 0; }

/* One settings page at a time — absolute fill of the sheet */
#settings-sheet > .settings-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: inherit;
  z-index: 1;
}
#settings-sheet > .settings-view:not([hidden]) {
  display: flex;
}
/* Friends / other sheets still use flow layout */
.sheet:not(.settings-app) > .settings-view,
.sheet:not(#settings-sheet) .settings-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  position: relative;
}
.settings-view[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.settings-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.55rem 0.85rem 0.75rem !important;
  gap: 0.38rem !important;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #2a3548 transparent;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.settings-body-main {
  padding-bottom: 0.65rem !important;
}
/* Keep groups from collapsing / clipping rows */
.settings-body > .settings-group,
.settings-body > .settings-hero,
.settings-body > .settings-status-card,
.settings-body > .settings-section-label {
  flex: 0 0 auto;
  width: 100%;
}

/* Profile hero */
.settings-hero {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.45rem;
  border-radius: 14px;
  background: linear-gradient(145deg, #161c28 0%, #12161f 100%);
  border: 1px solid #243041;
}
.settings-hero-avatar {
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 45, 85, 0.12);
  border: 1px solid rgba(255, 107, 53, 0.35);
  color: #ffb4a8;
  flex-shrink: 0;
  position: relative;
}
.settings-hero-avatar .icon,
.settings-hero-avatar .settings-hero-letter {
  grid-area: 1 / 1;
}
.settings-hero-avatar .icon {
  width: 1.75rem;
  height: 1.75rem;
}
.settings-hero-letter {
  display: none;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #dce9ff;
  line-height: 1;
}
.settings-hero-avatar.has-letter .settings-hero-letter {
  display: block;
}
.settings-hero-avatar.has-letter .settings-hero-fallback {
  display: none;
}
.settings-hero-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.settings-hero-name {
  width: 100%;
  border: none;
  background: transparent;
  color: #f2f6fc;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0;
  outline: none;
}
.settings-hero-name::placeholder {
  color: #5a6a80;
  font-weight: 600;
}
.settings-hero-sub {
  margin: 0;
  font-size: 0.75rem;
  color: #6a7a90;
}

.settings-section-label {
  margin: 0.55rem 0 0.3rem 0.45rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #9aa8bc !important;
  font-weight: 650;
  flex-shrink: 0;
}
.settings-section-label:first-child { margin-top: 0.2rem; }

.settings-group {
  background: #151a22;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #222b3a;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  width: 100%;
  min-height: 2.85rem;
  padding: 0.58rem 0.9rem;
  border: none;
  border-bottom: 1px solid rgba(28, 36, 48, 0.95);
  background: transparent;
  color: #eef2f7 !important;
  font: inherit;
  font-size: 0.94rem;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  opacity: 1 !important;
  visibility: visible !important;
}
/* Never leave labels unreadable */
.settings-row .row-left,
.settings-row .row-left > span:not(.row-ico):not(.row-flag),
.settings-row .avatar-attach-copy > span:first-child {
  color: #eef2f7 !important;
  opacity: 1 !important;
}
.settings-row .row-value,
.settings-row .chev {
  color: #9aa8bc !important;
}
.settings-group .settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: rgba(255, 255, 255, 0.035); }
.settings-row:active { background: rgba(255, 255, 255, 0.05); }

.settings-row .row-left {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1 1 auto;
}
/* Multi-line rows (theme / flag / avatar) — keep columns clean */
.settings-row:has(.theme-pick-copy),
.settings-row:has(.flag-pick-copy),
.settings-row:has(.avatar-attach-copy) {
  align-items: center;
  min-height: 3.4rem;
}
.settings-row .theme-pick-copy,
.settings-row .flag-pick-copy,
.settings-row .avatar-attach-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}
.settings-row .theme-pick-title,
.settings-row .flag-pick-title {
  font-weight: 650;
  line-height: 1.2;
}
.settings-row .theme-pick-sub,
.settings-row .flag-pick-sub,
.settings-row .avatar-attach-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: #8b9bb0;
  line-height: 1.25;
  white-space: normal;
}
.settings-row .row-ico {
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #8b9bb0;
}
.settings-row .row-ico .icon {
  width: 1.05rem;
  height: 1.05rem;
}
.settings-row-danger .row-ico {
  color: #ff8fab;
}
.settings-row .row-flag { font-size: 1.15rem; line-height: 1; width: 1.35rem; text-align: center; }
.settings-row .row-right {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #8b9bb0;
  font-size: 0.86rem;
  flex: 0 1 auto;
  max-width: 48%;
  min-width: 0;
  justify-content: flex-end;
}
.settings-row .row-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(11rem, 42vw);
  color: #9aa8bc;
  font-weight: 500;
}
.settings-row .chev {
  color: #4a5568;
  font-size: 1.2rem;
  font-weight: 300;
  flex-shrink: 0;
  line-height: 1;
}

.settings-row-input {
  cursor: default;
}
.settings-row-input:hover { background: transparent; }
.settings-inline-input,
.row-right-input input {
  border: none;
  background: transparent;
  color: #8eb6ff;
  font: inherit;
  font-weight: 600;
  text-align: right;
  min-width: 0;
  width: 9rem;
  max-width: 42vw;
  outline: none;
}
.row-right-input {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.settings-icon-btn {
  border: none;
  background: #1c2430;
  color: #c5d0e0;
  border-radius: 999px;
  width: 1.85rem;
  height: 1.85rem;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.settings-icon-btn:hover { background: #273244; }
.settings-icon-btn .icon {
  width: 0.95rem;
  height: 0.95rem;
}
.sheet-close-x {
  font-size: 1.05rem !important;
  color: #9aa8bc !important;
}
.settings-row-actions-loose {
  margin-top: 0.75rem;
  border-radius: 14px;
  border: 1px solid #222b3a;
  background: #151a22;
}

/* Mini actions under devices */
.settings-row-actions {
  display: flex;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem 0.7rem;
  border-top: 1px solid rgba(28, 36, 48, 0.95);
  background: rgba(0, 0, 0, 0.12);
}
.settings-mini-btn {
  flex: 1;
  border: 1px solid #243041;
  background: #1a202a;
  color: #c5d0e0;
  border-radius: 10px;
  padding: 0.5rem 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
}
.settings-mini-btn:hover { background: #222a36; border-color: #334155; }

.settings-row-static {
  cursor: default;
}
.settings-row-static:hover { background: transparent; }
.settings-vol-row {
  gap: 1rem;
}
.settings-vol-row input[type="range"] {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 5rem;
  accent-color: #5b9dff;
  height: 1.25rem;
}

/* iOS-like switches */
.settings-row-toggle {
  cursor: pointer;
  align-items: center;
  gap: 0.85rem;
}
.settings-row-toggle:hover { background: rgba(255, 255, 255, 0.02); }
.settings-row-toggle .toggle-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-width: 0;
}
.settings-row-toggle .toggle-title {
  font-size: 0.94rem;
  color: #eef2f7;
  line-height: 1.25;
}
.settings-row-toggle .toggle-hint {
  font-size: 0.72rem;
  color: #6a7a90;
  line-height: 1.25;
}
.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.55rem;
}
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.switch-ui {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #2a3344;
  border: 1px solid #3a4558;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.55rem - 6px);
  height: calc(1.55rem - 6px);
  border-radius: 999px;
  background: #eef2f7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.switch input:checked + .switch-ui {
  background: #2db87a;
  border-color: #2db87a;
}
.switch input:checked + .switch-ui::after {
  transform: translateX(1.15rem);
}
.switch input:focus-visible + .switch-ui {
  outline: 2px solid #5b9dff;
  outline-offset: 2px;
}

/* Compact connection status */
.settings-status-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: default;
  background: #12161e;
  border: 1px solid #1e2634;
  border-radius: 14px;
  padding: 0.65rem 0.85rem 0.6rem;
  margin-top: 0.85rem;
}
.settings-status-compact {
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}
.settings-status-label {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa8bc !important;
  font-weight: 650;
}
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.status-pill-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #3dd68c !important;
  background: rgba(61, 214, 140, 0.1);
  border: 1px solid rgba(61, 214, 140, 0.28);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-pill-chip.muted {
  color: #c5d0e0 !important;
  background: rgba(255, 255, 255, 0.05);
  border-color: #2a3548;
}
.status-note {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #9aa8bc !important;
}

.settings-row-danger {
  color: #ff8fab;
}
.settings-row-danger .row-left { color: #ff8fab; }

/* Sticky footer Done */
.settings-footer {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #161b24;
  background: rgba(10, 12, 16, 0.96);
  backdrop-filter: blur(10px);
}
.settings-done-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 0.78rem 1rem;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(255, 45, 85, 0.32);
}
.settings-done-btn:hover { filter: brightness(1.06); }
.settings-done-btn:active { transform: scale(0.99); }

.settings-choice .choice-check {
  color: #3dd68c;
  font-weight: 700;
  opacity: 0;
}
.settings-choice.is-selected .choice-check { opacity: 1; }

.settings-hidden-select { display: none !important; }

/* Old security rows (if any remain) */
.settings-security .sec-row { flex-wrap: wrap; gap: 0.35rem; }
.settings-security .sec-value {
  color: #9aa8bc;
  font-size: 0.8rem;
  text-align: right;
  max-width: 58%;
}

@media (max-width: 560px) {
  .sheet.settings-app {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    max-height: none;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .settings-row .row-value { max-width: 9rem; }
}

.sheet-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Friends sheet still uses classic labels */
#friends-sheet .sheet-body label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: #8b9bb0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#friends-sheet .sheet-body select,
#friends-sheet .sheet-body input[type="text"],
#friends-sheet .sheet-body input[type="range"] {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  border: 1px solid #2a3548;
  background: #0e131a;
  color: #e8eef7;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  pointer-events: auto;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
}

.sheet-body input[type="range"] {
  padding: 0.35rem 0;
  accent-color: #5b9dff;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.hint-inline {
  font-size: 0.78rem;
  color: #7a8a9e;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: 0;
}

.hint-inline kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  border: 1px solid #2a3548;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  background: #0e131a;
}

/* —— Phone / narrow: icon-only rails, thumb-friendly docks —— */
@media (max-width: 900px) {
  .stage-body {
    /* Avoid mobile browser chrome jumps */
    min-height: 100dvh;
  }
  .stage-app {
    height: 100dvh;
    max-height: 100dvh;
  }
  .stage-top {
    padding: 0.35rem 0.5rem;
    gap: 0.4rem;
  }
  .brand { font-size: 0.92rem; }
  .brand .badge { display: none; }
  .pid,
  .phase,
  .arch-pill,
  .pool-hint,
  .name-chip {
    display: none !important;
  }
  .pool-bar {
    font-size: 0.68rem;
    gap: 0.55rem;
    flex: 1 1 auto;
    min-width: 0;
  }
  .status-pill {
    font-size: 0.68rem;
    max-width: min(11rem, 36vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .lang-top-right .lang-ico { display: none; }
  .lang-top-right {
    /* Stay visible on phone (name/phase hidden) — last item = top-right */
    display: inline-flex !important;
    padding: 0.15rem 0.3rem;
  }

  .stage {
    /* Partner gets more vertical room (match / Next live here) */
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }
  .tile {
    min-height: 0;
  }
  .tile-remote { border-right: none; border-bottom: 1px solid #1c2230; }

  .tile-empty {
    padding: 1.75rem 3.25rem 4.75rem;
  }
  .empty-icon { font-size: 1.25rem; }
  .empty-title { font-size: 0.95rem; }
  .empty-sub { font-size: 0.78rem; }

  .tile-tag {
    top: 0.4rem;
    left: 0.45rem;
    font-size: 0.65rem;
    max-width: calc(100% - 4.25rem);
    gap: 0.4rem;
  }
  .tile-avatar {
    width: 3.15rem;
    height: 3.15rem;
  }
  .name-on-tile {
    max-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Icon-only controls, flush to bottom like desktop (docks pad around rails) */
  .side-rail {
    top: auto;
    bottom: max(0.35rem, env(safe-area-inset-bottom));
    transform: none;
    gap: 0.32rem;
    padding: 0.2rem;
  }
  .side-rail-right { right: 0.35rem; }
  .side-rail-left { left: 0.35rem; }
  .side-btn {
    width: 40px;
    height: 40px;
  }
  .side-btn .lbl,
  .side-vol .lbl {
    display: none;
  }
  /* Mic meter is tall — rely on mic pill + settings on phone */
  .mic-meter-rail {
    display: none;
  }
  .side-vol {
    padding: 0.35rem 0.2rem;
  }
  .side-vol input[type="range"] {
    height: 56px;
    width: 18px;
  }

  .stage-footer {
    flex-wrap: wrap;
    padding: 0.4rem 0.45rem max(0.45rem, env(safe-area-inset-bottom));
    gap: 0.4rem 0.35rem;
  }
  .stage-footer-left {
    flex: 1 1 100%;
    order: 1;
    gap: 0.3rem;
  }
  .stage-footer-right {
    flex: 1 1 100%;
    order: 2;
    justify-content: stretch;
    gap: 0.3rem;
  }
  .stage-footer .footer-match {
    flex: 1 1 auto;
    width: 100%;
    justify-content: stretch;
    gap: 0.3rem;
  }
  .stage-footer .footer-match .dock-pill,
  .stage-footer .footer-match .next-big {
    min-height: 2.55rem; /* thumb-friendly */
  }
  .stage-footer .dock-chat {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }
  .stage-footer .dock-icon {
    width: 2.55rem;
    height: 2.55rem;
  }
  .dock-chat input {
    font-size: 16px; /* avoid iOS zoom on focus */
    padding: 0.45rem 0.7rem;
  }
  .stage-footer .room-in-tile {
    flex: 0 0 auto;
    max-width: 34%;
  }
  .stage-footer .room-in-tile span { display: none; }
  .stage-footer .room-in-tile input {
    width: 4rem;
    font-size: 0.8rem;
  }
  .friends-list {
    max-height: min(52vh, 360px);
  }
  .friend-avatar {
    width: 2.85rem;
    height: 2.85rem;
  }
  .friend-actions .pill {
    min-height: 2rem;
  }
  .messages-sheet {
    border-radius: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
  }
  .start-match-btn {
    min-width: min(16rem, 78vw);
    padding: 1rem 2rem;
    font-size: 1.2rem;
  }
  /* Never auto-surface long-wait “stay open” tips on phone */
  .wait-tips {
    display: none !important;
  }
  .tile-fs-btn {
    top: 0.4rem;
    right: 0.4rem;
    width: 2.35rem;
    height: 2.35rem;
  }
  .tile-pip-btn {
    top: 0.4rem;
    right: calc(0.4rem + 2.35rem + 0.35rem);
    width: 2.35rem;
    height: 2.35rem;
  }
  .next-big.next-in-tile {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  .dock-pill {
    font-size: 0.7rem;
    padding: 0.32rem 0.6rem;
  }
  .dock-row-context {
    gap: 0.3rem;
  }
  /* Shorter labels for context pills on narrow screens */
  #btn-browse-together {
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-panel {
    left: 0.4rem;
    right: 0.4rem;
    bottom: 0.5rem;
    max-height: min(18vh, 130px);
  }
  .stage-top .conn-strip {
    max-width: min(42vw, 11rem);
    font-size: 0.68rem;
    padding: 0.18rem 0.5rem;
  }
  .call-toast {
    bottom: max(4rem, 12vh);
    width: min(420px, 94vw);
    padding: 0.7rem 0.85rem;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .side-btn {
    width: 36px;
    height: 36px;
  }
  .side-btn .ico { font-size: 0.95rem; }
  .stage-footer .room-in-tile { display: none; } /* room still in URL / settings if needed */
  .next-big.next-in-tile { font-size: 0.85rem; padding: 0.45rem 0.75rem; }
}

/* Landscape phones / short height: dual tiles side-by-side, compact chrome */
@media (max-width: 900px) and (orientation: landscape) {
  .stage-app {
    height: 100dvh;
    max-height: 100dvh;
  }
  .stage-top {
    padding: 0.2rem 0.45rem;
    min-height: 0;
    gap: 0.35rem;
  }
  .stage-top .pool-stats {
    font-size: 0.68rem;
    gap: 0.35rem;
  }
  .stage-top-actions .phase {
    font-size: 0.65rem;
    padding: 0.12rem 0.4rem;
  }
  .stage {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }
  .tile-remote {
    border-bottom: none;
    border-right: 1px solid #1c2230;
  }
  .tile-empty {
    padding: 0.65rem 2.75rem 3.25rem;
  }
  .empty-title {
    font-size: 0.88rem;
  }
  .empty-sub {
    font-size: 0.72rem;
    max-width: 16rem;
  }
  .start-match-btn {
    min-width: min(12rem, 42vw);
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
  }
  .empty-share {
    max-width: min(100%, 18rem);
    padding: 0.35rem 0.35rem 0.4rem;
  }
  .empty-share-hint,
  .empty-share-stats {
    font-size: 0.72rem;
  }
  .empty-share-actions .pill {
    min-height: 2.15rem;
    font-size: 0.78rem;
    padding: 0.3rem 0.55rem;
  }
  .side-rail {
    bottom: max(0.25rem, env(safe-area-inset-bottom));
    gap: 0.22rem;
  }
  .side-btn {
    width: 34px;
    height: 34px;
  }
  .mic-meter-rail {
    display: none !important;
  }
  .tile-tag {
    font-size: 0.62rem;
    top: 0.3rem;
    left: 0.35rem;
  }
  .tile-avatar {
    width: 2.35rem;
    height: 2.35rem;
  }
  .tile-fs-btn,
  .tile-pip-btn {
    top: 0.3rem;
    width: 2.1rem;
    height: 2.1rem;
  }
  .tile-fs-btn {
    right: 0.3rem;
  }
  .tile-pip-btn {
    right: calc(0.3rem + 2.1rem + 0.28rem);
  }
  .friend-pip {
    width: min(28%, 6.5rem);
    bottom: 0.4rem;
    left: 0.35rem;
  }
  .chat-panel {
    max-height: min(28vh, 110px);
    bottom: 0.35rem;
  }
  /* Footer: one compact row when possible */
  .stage-footer {
    flex-wrap: nowrap;
    padding: 0.28rem 0.4rem max(0.3rem, env(safe-area-inset-bottom));
    gap: 0.3rem;
  }
  .stage-footer-left {
    flex: 0 1 auto;
    order: 0;
    width: auto;
    max-width: 42%;
  }
  .stage-footer-right {
    flex: 1 1 auto;
    order: 0;
    width: auto;
    justify-content: flex-end;
  }
  .stage-footer .footer-match {
    width: auto;
    flex: 1 1 auto;
  }
  .stage-footer .footer-match .dock-pill,
  .stage-footer .footer-match .next-big {
    min-height: 2.2rem;
    font-size: 0.72rem;
    padding: 0.28rem 0.55rem;
  }
  .stage-footer .dock-chat {
    min-width: 0;
    max-width: 9rem;
  }
  .stage-footer .dock-chat input {
    font-size: 14px;
    padding: 0.28rem 0.45rem;
  }
  .stage-footer .dock-icon {
    width: 2.2rem;
    height: 2.2rem;
  }
  .stage-footer .room-in-tile {
    display: none;
  }
  .call-toast,
  .weak-conn-tip,
  .friend-soft-toast,
  .export-nudge-toast {
    bottom: max(3.25rem, calc(env(safe-area-inset-bottom) + 2.75rem));
    max-width: min(22rem, 70vw);
    font-size: 0.82rem;
  }
  .age-gate {
    max-height: 96dvh;
    overflow-y: auto;
  }
  .age-gate-logo {
    width: 3.5rem;
    height: 3.5rem;
  }
  .age-gate-title {
    font-size: 1.2rem;
  }
  .age-gate-btn {
    min-height: 2.55rem;
  }
}

/* Very short landscape (phones flipped, small height) */
@media (max-height: 420px) and (orientation: landscape) {
  .stage-top {
    display: none; /* tiles + footer only — max camera room */
  }
  .stage-footer {
    padding: 0.2rem 0.35rem max(0.22rem, env(safe-area-inset-bottom));
  }
  .empty-sub {
    display: none;
  }
  .empty-share-stats {
    display: none;
  }
  .side-btn .lbl {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Visual polish — align live stage with homepage metallic / glass
   ═══════════════════════════════════════════════════════════ */

html:has(.stage-body),
html.stage-html {
  background: #07080c;
  color-scheme: dark;
}

.stage-body {
  background: #07080c !important;
  color-scheme: dark;
}

/* Keyboard focus — match product coral, not browser default blue */
.stage-body :is(button, a, input, select, textarea, .settings-row, .dock-pill, .side-btn, .home-cta):focus {
  outline: none;
}
.stage-body :is(button, a, input, select, textarea, .settings-row, .dock-pill, .side-btn):focus-visible {
  outline: 2px solid rgba(255, 107, 53, 0.85);
  outline-offset: 2px;
}

.stage-app {
  background:
    radial-gradient(900px 400px at 10% -10%, rgba(91, 157, 255, 0.08) 0%, transparent 55%),
    radial-gradient(700px 360px at 95% 0%, rgba(255, 45, 85, 0.06) 0%, transparent 50%),
    #07080c;
}

/* Top chrome — frosted glass */
.stage-top {
  padding: 0.55rem 0.95rem;
  border-bottom: 1px solid transparent;
  background: linear-gradient(
    180deg,
    rgba(10, 12, 18, 0.92) 0%,
    rgba(10, 12, 18, 0.78) 100%
  );
  backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}
.stage-top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  pointer-events: none;
}
.stage-app > .stage-top {
  position: relative;
}

.brand {
  font-weight: 750;
  letter-spacing: -0.025em;
}
.brand-logo {
  border-radius: 0.45rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.4);
}
.brand .badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 45, 85, 0.15);
  color: #ff8fab;
  border: 1px solid rgba(255, 45, 85, 0.35);
}

.pool-bar {
  gap: 0.55rem;
  font-family: inherit;
  font-size: 0.76rem;
  color: #8b9bb0;
  flex-wrap: wrap;
  align-items: center;
}
.pool-bar > span:not(.room-chip):not(.arch-pill):not(.ice-path):not(.pool-hint) {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.pool-bar strong {
  color: #f0f4fa;
  font-variant-numeric: tabular-nums;
}

.room-chip {
  background: rgba(91, 157, 255, 0.12);
  border-color: rgba(91, 157, 255, 0.32);
}

.arch-pill {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(61, 214, 140, 0.32);
  color: #8ee4b4;
  background: rgba(20, 48, 36, 0.5);
}

.name-chip {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
}
.name-chip input {
  background: transparent;
  border: none;
  color: #eef2f7;
  font-weight: 600;
}
.name-chip input:focus {
  outline: none;
}

.lang-top-right {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.stage-top-actions .phase {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}
.stage-top-actions .phase.waiting,
.stage-top-actions .phase.claiming {
  color: #f5c56b;
  background: rgba(245, 165, 36, 0.12);
  border-color: rgba(245, 165, 36, 0.28);
}
.stage-top-actions .phase.matched,
.stage-top-actions .phase.friend_call {
  color: #6ee7a8;
  background: rgba(61, 214, 140, 0.12);
  border-color: rgba(61, 214, 140, 0.3);
}

.status-pill {
  font-family: inherit;
  font-size: 0.72rem;
  color: #7a8a9e;
  max-width: 11rem;
}

/* Stage tiles */
.stage {
  background: #05060a;
  gap: 0;
}
.tile {
  background: #0a0c12;
}
.tile-remote {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* Side rails — denser glass */
.side-btn {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(14, 18, 28, 0.72);
  backdrop-filter: blur(14px) saturate(1.1);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.side-btn:hover {
  background: rgba(30, 38, 54, 0.88);
  border-color: rgba(126, 182, 255, 0.35);
}

/* Docks */
.tile-dock {
  background: linear-gradient(
    to top,
    rgba(5, 7, 12, 0.9) 0%,
    rgba(5, 7, 12, 0.55) 50%,
    transparent 100%
  );
  padding-top: 1.5rem;
}
.dock-pill {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(16, 20, 30, 0.78);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.dock-pill:hover {
  border-color: rgba(126, 182, 255, 0.5);
  background: rgba(28, 36, 52, 0.9);
}

/* Next — homepage coral CTA */
.next-big {
  font-weight: 750;
  letter-spacing: -0.01em;
  padding: 0.62rem 1.4rem;
  background: linear-gradient(135deg, #ff2d55 0%, #ff5c3a 55%, #ff7a3b 100%);
  box-shadow:
    0 8px 28px rgba(255, 45, 85, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.next-big:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 36px rgba(255, 45, 85, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.next-big.next-in-tile {
  min-width: 8rem;
}

.dock-icon,
.dock-settings {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(16, 20, 30, 0.8);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.dock-icon:hover,
.dock-settings:hover {
  border-color: rgba(126, 182, 255, 0.4);
}

/* Chat glass */
.chat-panel {
  background: rgba(12, 16, 26, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.chat-bubble.mine {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.45), rgba(99, 102, 241, 0.4));
  border-color: rgba(99, 102, 241, 0.45);
}

/* Name chip on video */
.tile-tag .name-on-tile {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  padding: 0.28rem 0.65rem;
}
.match-timer {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
}

/* Sheets / menus */
.partner-menu {
  background: rgba(14, 18, 28, 0.96);
  border-color: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.sheet {
  border-color: rgba(255, 255, 255, 0.1);
  background: #0e121a;
}
.sheet header {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

/* Pills in sheets */
.pill {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}
.pill:hover {
  border-color: rgba(126, 182, 255, 0.45);
}
.pill.primary {
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  box-shadow: 0 6px 20px rgba(255, 45, 85, 0.3);
  color: #fff;
}

/* Conn strip */
.conn-strip {
  backdrop-filter: blur(10px);
  background: rgba(12, 16, 24, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.28rem 0.55rem 0.28rem 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: min(92vw, 28rem);
}
.conn-strip #conn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.conn-retry {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 45, 85, 0.18);
  color: #ffd0d8;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.conn-retry:hover {
  background: rgba(255, 45, 85, 0.32);
  color: #fff;
}
.conn-retry[hidden] {
  display: none !important;
}

/* Federated match (nextface-fed/1) — media still P2P */
.fed-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #c4e0ff;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.35);
  white-space: nowrap;
}

/* Settings hub polish hooks */
.settings-sheet,
#settings-sheet {
  border-color: rgba(255, 255, 255, 0.1);
}

/* Mobile: keep glass but slightly denser header */
@media (max-width: 700px) {
  .stage-top {
    padding: 0.45rem 0.65rem;
  }
  .pool-bar > span:not(.room-chip):not(.arch-pill):not(.ice-path):not(.pool-hint) {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
  }
  .arch-pill {
    display: none; /* free space on narrow; still in settings */
  }
}

/* PWA install banner */
#pwa-install-banner {
  position: fixed;
  left: 50%;
  bottom: max(4.75rem, calc(env(safe-area-inset-bottom) + 4.25rem));
  transform: translateX(-50%);
  z-index: 12000;
  width: min(440px, calc(100vw - 1.5rem));
  pointer-events: auto;
}
.pwa-install-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem 0.7rem 0.85rem;
  border-radius: 16px;
  background: rgba(14, 16, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
}
.pwa-install-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}
.pwa-install-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
  font-size: 0.8rem;
  line-height: 1.3;
  color: #b8becf;
}
.pwa-install-copy strong {
  color: #f2f3f7;
  font-size: 0.88rem;
  font-weight: 650;
}
.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.pwa-install-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ff7a6a, #e84d3d);
}
.pwa-install-x {
  border: 0;
  background: transparent;
  color: #9aa0b4;
  font-size: 1.25rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  cursor: pointer;
}
.pwa-install-x:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* ═══════════════════════════════════════════════════════════
   Themes — dark (default) · light · saloon (western)
   Applied via html[data-theme="…"] (see live.js applyTheme)
   ═══════════════════════════════════════════════════════════ */

.theme-pick .row-left {
  align-items: center;
  gap: 0.55rem;
}
.theme-swatch {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.4rem;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.theme-swatch-dark {
  background: linear-gradient(145deg, #1a2030, #07080c 70%);
}
.theme-swatch-light {
  background: linear-gradient(145deg, #ffffff, #d8dee8 70%);
  border-color: rgba(0, 0, 0, 0.12);
}
.theme-swatch-saloon {
  background: linear-gradient(145deg, #c9a227, #3b2412 55%, #1a1008);
  border-color: rgba(201, 162, 39, 0.45);
}
.theme-pick-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  text-align: left;
}
.theme-pick-title {
  font-weight: 650;
  font-size: 0.95rem;
}
.theme-pick-sub {
  font-size: 0.72rem;
  color: #8b9bb0;
  font-weight: 500;
}
.theme-choice-list .settings-choice.is-selected {
  background: rgba(91, 157, 255, 0.1);
}

/* Hide auto wait-tips globally (no stay-on-site reminders) */
.wait-tips {
  display: none !important;
}

/* Report success toast */
.report-toast {
  position: fixed;
  left: 50%;
  bottom: max(5.5rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: min(22rem, 92vw);
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(243, 18, 96, 0.35);
  background: rgba(48, 16, 28, 0.94);
  color: #ffd0dc;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  pointer-events: none;
  animation: report-toast-in 0.2s ease-out;
}
@media (max-width: 720px) {
  .report-toast {
    bottom: max(6.25rem, calc(env(safe-area-inset-bottom) + 4.5rem));
    max-width: min(24rem, 94vw);
    padding: 0.9rem 1.1rem;
    font-size: 1rem;
  }
  .report-toast strong {
    font-size: 0.82rem;
  }
  .report-toast span {
    font-size: 0.95rem;
  }
}
.report-toast strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #ff8fab;
}
.report-toast span {
  font-size: 0.88rem;
  line-height: 1.35;
  color: #ffe8ee;
}
@keyframes report-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
html[data-theme="light"] .report-toast {
  background: rgba(255, 241, 245, 0.98);
  border-color: rgba(190, 18, 60, 0.3);
  color: #9f1239;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.15);
}
html[data-theme="light"] .report-toast strong {
  color: #be123c;
}
html[data-theme="light"] .report-toast span {
  color: #881337;
}
html[data-theme="saloon"] .report-toast {
  background: rgba(48, 20, 12, 0.95);
  border-color: rgba(196, 70, 40, 0.45);
  color: #ffd0c0;
}
html[data-theme="saloon"] .report-toast strong {
  color: #ffb4a0;
}

/* Dark theme: clearer sheets + footer glass */
.sheet {
  background: #0d1118;
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72);
}
.sheet header,
.settings-header {
  background: rgba(12, 14, 20, 0.92);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
.settings-group {
  background: #141a24;
  border-color: rgba(255, 255, 255, 0.07);
}
.settings-row:hover {
  background: rgba(255, 255, 255, 0.04);
}
.chat-panel {
  background: rgba(12, 16, 24, 0.94);
  border-color: rgba(255, 255, 255, 0.1);
}
.side-btn {
  background: rgba(16, 20, 28, 0.78);
  border-color: rgba(255, 255, 255, 0.12);
}
.side-btn:hover {
  background: rgba(36, 44, 58, 0.92);
}

/* ─── Light theme ─── */
html[data-theme="light"] {
  color-scheme: light;
}
html[data-theme="light"].stage-html,
html[data-theme="light"]:has(.stage-body) {
  background: #f0f3f8;
  color-scheme: light;
}
html[data-theme="light"] .stage-body {
  background: #f0f3f8 !important;
  color: #0f172a;
  color-scheme: light;
}
html[data-theme="light"] .stage-app {
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(91, 157, 255, 0.14) 0%, transparent 55%),
    radial-gradient(720px 380px at 96% 0%, rgba(255, 107, 53, 0.09) 0%, transparent 50%),
    linear-gradient(180deg, #f4f6fa 0%, #e9eef6 100%);
}
html[data-theme="light"] .stage-top {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(248, 250, 252, 0.94) 100%
  );
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
}
html[data-theme="light"] .stage-top::after {
  background: linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.1), transparent);
}
html[data-theme="light"] .brand {
  color: #0f172a;
}
html[data-theme="light"] .brand .badge {
  background: rgba(255, 45, 85, 0.1);
  color: #c2183a;
  border-color: rgba(255, 45, 85, 0.28);
}
html[data-theme="light"] .brand-logo {
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.08),
    0 4px 12px rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] .pool-bar {
  color: #5a6b82;
}
html[data-theme="light"] .pool-bar > span:not(.room-chip):not(.arch-pill):not(.ice-path):not(.pool-hint) {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .pool-bar strong {
  color: #0f172a;
}
html[data-theme="light"] .name-chip {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.75);
}
html[data-theme="light"] .name-chip input {
  color: #0f172a;
}
html[data-theme="light"] .lang-top-right {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] .lang-switch {
  color: #5a6b82;
}
html[data-theme="light"] .lang-switch select {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .stage-top-actions .phase {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
  color: #334155;
}
html[data-theme="light"] .status-pill {
  color: #64748b;
}
html[data-theme="light"] .stage {
  background: #d4dbe6;
  border-top: 1px solid rgba(15, 23, 42, 0.05);
}
html[data-theme="light"] .tile {
  background: #0a0c12;
}
html[data-theme="light"] .tile-remote {
  border-right-color: rgba(15, 23, 42, 0.14);
}
html[data-theme="light"] .stage-footer {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96) 0%,
    rgba(244, 247, 251, 0.98) 100%
  );
  border-top-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] .stage-footer .dock-pill {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] .stage-footer .dock-pill:hover {
  border-color: rgba(91, 157, 255, 0.45);
  background: #fff;
}
html[data-theme="light"] .stage-footer .dock-pill.ghost {
  background: rgba(15, 23, 42, 0.04);
  color: #334155;
}
html[data-theme="light"] .stage-footer .dock-pill.danger {
  border-color: rgba(243, 18, 96, 0.35);
  background: rgba(255, 240, 245, 0.95);
  color: #be123c;
}
html[data-theme="light"] .stage-footer .dock-icon,
html[data-theme="light"] .stage-footer .dock-settings {
  border-color: rgba(15, 23, 42, 0.12);
  background: #fff;
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .stage-footer .dock-chat input {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .stage-footer .room-in-tile {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.1);
  color: #334155;
}
html[data-theme="light"] .stage-footer .room-in-tile input {
  color: #0f172a;
}
html[data-theme="light"] .start-match-btn {
  box-shadow:
    0 12px 36px rgba(255, 45, 85, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
html[data-theme="light"] .sheet,
html[data-theme="light"] .messages-sheet {
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .friend-row {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .friend-row .meta strong {
  color: #0f172a;
}
html[data-theme="light"] .friend-row .meta span,
html[data-theme="light"] .friend-realname {
  color: #64748b;
}
html[data-theme="light"] .friend-avatar {
  border-color: rgba(15, 23, 42, 0.1);
  background: linear-gradient(145deg, #e8eef8, #f1f5f9);
  color: #334155;
}
html[data-theme="light"] .friend-avatar.letter {
  color: #334155;
}
html[data-theme="light"] .ice-path {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] .ice-path.path-direct {
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.1);
}
html[data-theme="light"] .ice-path.path-relay {
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}
html[data-theme="light"] .ice-path.path-weak {
  color: #c2410c;
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(255, 237, 213, 0.9);
}
html[data-theme="light"] .msg-thread-row {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}
html[data-theme="light"] .msg-thread-row .meta strong {
  color: #0f172a;
}
html[data-theme="light"] .msg-tab.active {
  color: #0f172a;
  background: rgba(91, 157, 255, 0.14);
  border-color: rgba(91, 157, 255, 0.35);
}
html[data-theme="light"] .msg-compose {
  background: rgba(248, 250, 252, 0.98);
  border-top-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .msg-compose input {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .hint-inline {
  color: #64748b;
}
html[data-theme="light"] .side-btn {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}
html[data-theme="light"] .side-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(91, 157, 255, 0.55);
}
html[data-theme="light"] .tile-dock {
  background: linear-gradient(
    to top,
    rgba(8, 10, 16, 0.88) 0%,
    rgba(8, 10, 16, 0.45) 55%,
    transparent 100%
  );
}
html[data-theme="light"] .dock-pill {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.16);
  color: #f8fafc;
}
html[data-theme="light"] .dock-pill:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(126, 182, 255, 0.55);
}
html[data-theme="light"] .dock-icon,
html[data-theme="light"] .dock-settings {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.18);
  color: #f8fafc;
}
html[data-theme="light"] .dock-chat input {
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .dock-chat input::placeholder {
  color: #94a3b8;
}
html[data-theme="light"] .room-in-tile,
html[data-theme="light"] .room-field {
  color: #e2e8f0;
}
html[data-theme="light"] .room-field input {
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .chat-panel {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(15, 23, 42, 0.1);
  color: #0f172a;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .chat-panel-head {
  color: #0f172a;
  border-bottom-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .chat-bubble.mine {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(99, 102, 241, 0.16));
  border-color: rgba(99, 102, 241, 0.35);
  color: #0f172a;
}
html[data-theme="light"] .sheet,
html[data-theme="light"] .settings-sheet,
html[data-theme="light"] #settings-sheet,
html[data-theme="light"] #friends-sheet {
  background: #f7f8fb;
  border-color: rgba(15, 23, 42, 0.1);
  color: #0f172a;
}
html[data-theme="light"] .sheet header,
html[data-theme="light"] .settings-header {
  border-bottom-color: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}
html[data-theme="light"] .settings-section-label {
  color: #64748b;
}
html[data-theme="light"] .settings-group {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .settings-row {
  color: #0f172a;
  border-bottom-color: rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] .settings-row:hover {
  background: rgba(15, 23, 42, 0.03);
}
html[data-theme="light"] .settings-row .row-value,
html[data-theme="light"] .settings-row .chev,
html[data-theme="light"] .theme-pick-sub {
  color: #64748b;
}
html[data-theme="light"] .settings-hero-name,
html[data-theme="light"] .settings-row-input input,
html[data-theme="light"] input.settings-hero-name {
  color: #0f172a;
  background: transparent;
}
html[data-theme="light"] .settings-hero-sub,
html[data-theme="light"] .hint-inline {
  color: #64748b;
}
html[data-theme="light"] .settings-status-card {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .status-pill-chip {
  background: rgba(15, 23, 42, 0.05);
  color: #334155;
  border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .settings-done-btn {
  background: linear-gradient(135deg, #ff2d55, #ff6b35);
  color: #fff;
}
html[data-theme="light"] .partner-menu {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(15, 23, 42, 0.1);
  color: #0f172a;
}
html[data-theme="light"] .rules-overlay {
  /* Age gate stays dark full-screen for brand consistency */
  background: #07080c;
}
html[data-theme="light"] .age-gate-title {
  color: #f2f5fa;
}
html[data-theme="light"] .age-gate-sub {
  color: #8b9bb0;
}
html[data-theme="light"] .conn-strip {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.1);
  color: #0f172a;
}
html[data-theme="light"] .friend-row {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}
html[data-theme="light"] .friend-row .meta span {
  color: #64748b;
}
html[data-theme="light"] .pill {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
  color: #0f172a;
}
html[data-theme="light"] .theme-choice-list .settings-choice.is-selected {
  background: rgba(37, 99, 235, 0.08);
}
html[data-theme="light"] .stage-body :is(button, a, input, select, textarea, .settings-row, .dock-pill, .side-btn):focus-visible {
  outline-color: rgba(37, 99, 235, 0.75);
}

/* ─── Saloon (western) theme ─── */
html[data-theme="saloon"] {
  color-scheme: dark;
}
html[data-theme="saloon"].stage-html,
html[data-theme="saloon"]:has(.stage-body) {
  background: #120c07;
  color-scheme: dark;
}
html[data-theme="saloon"] .stage-body {
  background: #120c07 !important;
  color: #f3e6c8;
  color-scheme: dark;
  font-family: "Source Serif 4", "Noto Sans", Georgia, serif;
}
html[data-theme="saloon"] .stage-app {
  background:
    radial-gradient(800px 380px at 12% -8%, rgba(201, 162, 39, 0.14) 0%, transparent 55%),
    radial-gradient(640px 320px at 100% 0%, rgba(139, 58, 28, 0.18) 0%, transparent 50%),
    radial-gradient(500px 280px at 50% 100%, rgba(61, 36, 18, 0.35) 0%, transparent 55%),
    #120c07;
}
html[data-theme="saloon"] .stage-top {
  background: linear-gradient(
    180deg,
    rgba(36, 22, 12, 0.95) 0%,
    rgba(26, 16, 8, 0.88) 100%
  );
  box-shadow:
    0 1px 0 rgba(201, 162, 39, 0.18),
    0 8px 24px rgba(0, 0, 0, 0.35);
}
html[data-theme="saloon"] .stage-top::after {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(201, 162, 39, 0.45),
    transparent
  );
}
html[data-theme="saloon"] .brand {
  font-family: "Rye", "Source Serif 4", serif;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #f6e7c1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}
html[data-theme="saloon"] .brand .badge {
  font-family: "Source Serif 4", serif;
  background: rgba(201, 162, 39, 0.18);
  color: #f0d78c;
  border-color: rgba(201, 162, 39, 0.45);
}
html[data-theme="saloon"] .brand-logo {
  border-radius: 0.35rem;
  box-shadow:
    0 0 0 1px rgba(201, 162, 39, 0.35),
    0 4px 14px rgba(0, 0, 0, 0.5);
  filter: sepia(0.35) saturate(1.15);
}
html[data-theme="saloon"] .pool-bar {
  color: #c4a882;
}
html[data-theme="saloon"] .pool-bar > span:not(.room-chip):not(.arch-pill):not(.ice-path):not(.pool-hint) {
  background: rgba(201, 162, 39, 0.08);
  border-color: rgba(201, 162, 39, 0.22);
}
html[data-theme="saloon"] .pool-bar strong {
  color: #f6e7c1;
}
html[data-theme="saloon"] .room-chip {
  background: rgba(201, 162, 39, 0.14);
  border-color: rgba(201, 162, 39, 0.4);
  color: #f0d78c;
}
html[data-theme="saloon"] .arch-pill {
  border-color: rgba(201, 162, 39, 0.35);
  color: #e8c96a;
  background: rgba(61, 40, 18, 0.65);
}
html[data-theme="saloon"] .arch-pill.p2p-live {
  border-color: rgba(201, 162, 39, 0.45);
  color: #f0d78c;
  background: rgba(61, 40, 18, 0.7);
}
html[data-theme="saloon"] .name-chip {
  border-color: rgba(201, 162, 39, 0.28);
  background: rgba(36, 22, 12, 0.75);
}
html[data-theme="saloon"] .name-chip input {
  color: #f6e7c1;
}
html[data-theme="saloon"] .lang-top-right {
  background: rgba(36, 22, 12, 0.8);
  border-color: rgba(201, 162, 39, 0.28);
}
html[data-theme="saloon"] .lang-switch select {
  background: #24160c;
  color: #f6e7c1;
  border-color: rgba(201, 162, 39, 0.3);
}
html[data-theme="saloon"] .stage-top-actions .phase {
  border-color: rgba(201, 162, 39, 0.22);
  background: rgba(36, 22, 12, 0.7);
  color: #e8d4b0;
}
html[data-theme="saloon"] .stage-top-actions .phase.waiting,
html[data-theme="saloon"] .stage-top-actions .phase.claiming {
  color: #f0d78c;
  background: rgba(201, 162, 39, 0.14);
  border-color: rgba(201, 162, 39, 0.4);
}
html[data-theme="saloon"] .stage-top-actions .phase.matched,
html[data-theme="saloon"] .stage-top-actions .phase.friend_call {
  color: #9fd98a;
  background: rgba(46, 80, 36, 0.35);
  border-color: rgba(120, 180, 90, 0.35);
}
html[data-theme="saloon"] .status-pill {
  color: #b89a72;
}
html[data-theme="saloon"] .stage {
  background: #0c0805;
}
html[data-theme="saloon"] .tile {
  background: #100b07;
}
html[data-theme="saloon"] .tile-remote {
  border-right: 1px solid rgba(201, 162, 39, 0.15);
}
html[data-theme="saloon"] .tile::after {
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.06);
}
html[data-theme="saloon"] .side-btn {
  border-color: rgba(201, 162, 39, 0.32);
  background: rgba(36, 22, 12, 0.78);
  color: #f0d78c;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(201, 162, 39, 0.12);
}
html[data-theme="saloon"] .side-btn:hover {
  background: rgba(58, 36, 18, 0.92);
  border-color: rgba(201, 162, 39, 0.55);
  color: #ffe9a8;
}
html[data-theme="saloon"] .side-btn .lbl {
  color: #e8d4b0;
}
html[data-theme="saloon"] .tile-dock {
  background: linear-gradient(
    to top,
    rgba(18, 10, 5, 0.94) 0%,
    rgba(18, 10, 5, 0.55) 50%,
    transparent 100%
  );
}
html[data-theme="saloon"] .dock-pill {
  border-color: rgba(201, 162, 39, 0.3);
  background: rgba(36, 22, 12, 0.85);
  color: #f3e6c8;
  font-family: "Source Serif 4", serif;
}
html[data-theme="saloon"] .dock-pill:hover {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(58, 36, 18, 0.95);
}
html[data-theme="saloon"] .dock-pill.accent {
  background: linear-gradient(135deg, #8b3a1c, #c45c26);
  border-color: transparent;
  color: #fff6e0;
}
html[data-theme="saloon"] .dock-pill.danger {
  border-color: rgba(196, 70, 40, 0.5);
  color: #ffb4a0;
}
html[data-theme="saloon"] .next-big {
  font-family: "Rye", "Source Serif 4", serif;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #8b3a1c 0%, #c45c26 45%, #d4a017 100%);
  box-shadow:
    0 8px 28px rgba(139, 58, 28, 0.5),
    inset 0 1px 0 rgba(255, 230, 160, 0.25);
  border: 1px solid rgba(240, 215, 140, 0.35);
  color: #fff8e8;
}
html[data-theme="saloon"] .next-big:hover {
  box-shadow:
    0 12px 36px rgba(196, 92, 38, 0.55),
    inset 0 1px 0 rgba(255, 230, 160, 0.3);
}
html[data-theme="saloon"] .icon-next {
  color: #fff8e8;
}
html[data-theme="saloon"] .dock-icon,
html[data-theme="saloon"] .dock-settings {
  border-color: rgba(201, 162, 39, 0.35);
  background: rgba(36, 22, 12, 0.88);
  color: #f0d78c;
}
html[data-theme="saloon"] .dock-icon:hover,
html[data-theme="saloon"] .dock-settings:hover {
  border-color: rgba(201, 162, 39, 0.55);
  color: #ffe9a8;
}
html[data-theme="saloon"] .dock-chat input {
  background: rgba(26, 16, 8, 0.9);
  color: #f3e6c8;
  border: 1px solid rgba(201, 162, 39, 0.28);
  font-family: "Source Serif 4", serif;
}
html[data-theme="saloon"] .dock-chat input::placeholder {
  color: #a89070;
}
html[data-theme="saloon"] .room-field {
  color: #c4a882;
}
html[data-theme="saloon"] .room-field input {
  background: rgba(26, 16, 8, 0.9);
  color: #f3e6c8;
  border-color: rgba(201, 162, 39, 0.28);
}
html[data-theme="saloon"] .chat-panel {
  background: rgba(26, 16, 8, 0.94);
  border-color: rgba(201, 162, 39, 0.28);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  color: #f3e6c8;
}
html[data-theme="saloon"] .chat-bubble.mine {
  background: linear-gradient(135deg, rgba(139, 58, 28, 0.55), rgba(201, 162, 39, 0.28));
  border-color: rgba(201, 162, 39, 0.4);
}
html[data-theme="saloon"] .tile-empty .empty-title {
  font-family: "Rye", serif;
  color: #f0d78c;
}
html[data-theme="saloon"] .tile-empty .empty-sub {
  color: #c4a882;
}
html[data-theme="saloon"] .icon-empty {
  color: #c9a227;
}
html[data-theme="saloon"] .sheet,
html[data-theme="saloon"] .settings-sheet,
html[data-theme="saloon"] #settings-sheet,
html[data-theme="saloon"] #friends-sheet {
  background: #1c120a;
  border-color: rgba(201, 162, 39, 0.28);
  color: #f3e6c8;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
html[data-theme="saloon"] .sheet header,
html[data-theme="saloon"] .settings-header {
  border-bottom-color: rgba(201, 162, 39, 0.18);
  font-family: "Rye", "Source Serif 4", serif;
  font-weight: 400;
  color: #f0d78c;
}
html[data-theme="saloon"] .settings-section-label {
  color: #b89a72;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
html[data-theme="saloon"] .settings-group {
  background: rgba(36, 22, 12, 0.75);
  border: 1px solid rgba(201, 162, 39, 0.18);
  border-radius: 12px;
  overflow: hidden;
}
html[data-theme="saloon"] .settings-row {
  color: #f3e6c8;
  border-bottom-color: rgba(201, 162, 39, 0.1);
}
html[data-theme="saloon"] .settings-row:hover {
  background: rgba(201, 162, 39, 0.08);
}
html[data-theme="saloon"] .settings-row .row-value,
html[data-theme="saloon"] .settings-row .chev,
html[data-theme="saloon"] .theme-pick-sub {
  color: #b89a72;
}
html[data-theme="saloon"] .settings-row .row-ico {
  color: #c9a227;
}
html[data-theme="saloon"] .settings-hero-name {
  color: #f6e7c1;
  font-family: "Rye", serif;
}
html[data-theme="saloon"] .settings-hero-sub,
html[data-theme="saloon"] .hint-inline {
  color: #b89a72;
}
html[data-theme="saloon"] .settings-hero-avatar {
  background: linear-gradient(145deg, #3b2412, #1a1008);
  border-color: rgba(201, 162, 39, 0.4);
  color: #f0d78c;
}
html[data-theme="saloon"] .settings-status-card {
  background: rgba(36, 22, 12, 0.7);
  border-color: rgba(201, 162, 39, 0.2);
}
html[data-theme="saloon"] .status-pill-chip {
  background: rgba(201, 162, 39, 0.1);
  color: #e8d4b0;
  border-color: rgba(201, 162, 39, 0.22);
}
html[data-theme="saloon"] .settings-done-btn {
  font-family: "Rye", serif;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #8b3a1c, #c45c26 50%, #d4a017);
  color: #fff8e8;
  border: 1px solid rgba(240, 215, 140, 0.3);
}
html[data-theme="saloon"] .partner-menu {
  background: rgba(28, 18, 10, 0.97);
  border-color: rgba(201, 162, 39, 0.3);
  color: #f3e6c8;
}
html[data-theme="saloon"] .rules-overlay {
  background: rgba(12, 8, 5, 0.9);
}
html[data-theme="saloon"] .rules-card {
  background: #1c120a;
  border: 1px solid rgba(201, 162, 39, 0.35);
  color: #f3e6c8;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
html[data-theme="saloon"] .rules-card h2 {
  font-family: "Rye", serif;
  color: #f0d78c;
}
html[data-theme="saloon"] .rules-list {
  color: #c4a882;
}
html[data-theme="saloon"] .conn-strip {
  background: rgba(36, 22, 12, 0.88);
  border-color: rgba(201, 162, 39, 0.28);
  color: #f3e6c8;
}
html[data-theme="saloon"] .conn-retry {
  background: rgba(139, 58, 28, 0.35);
  border-color: rgba(201, 162, 39, 0.35);
  color: #f0d78c;
}
html[data-theme="saloon"] .friend-row {
  background: rgba(36, 22, 12, 0.8);
  border-color: rgba(201, 162, 39, 0.2);
  color: #f3e6c8;
}
html[data-theme="saloon"] .friend-row .meta span {
  color: #b89a72;
}
html[data-theme="saloon"] .pill {
  border-color: rgba(201, 162, 39, 0.25);
  background: rgba(201, 162, 39, 0.08);
  color: #f3e6c8;
}
html[data-theme="saloon"] .pill.primary {
  background: linear-gradient(135deg, #8b3a1c, #c45c26);
  color: #fff8e8;
  box-shadow: 0 6px 20px rgba(139, 58, 28, 0.35);
}
html[data-theme="saloon"] .pill.accent {
  background: linear-gradient(135deg, #8b4513, #c9a227);
  color: #1a1008;
}
html[data-theme="saloon"] .fed-chip {
  color: #f0d78c;
  background: rgba(201, 162, 39, 0.14);
  border-color: rgba(201, 162, 39, 0.4);
}
html[data-theme="saloon"] .theme-choice-list .settings-choice.is-selected {
  background: rgba(201, 162, 39, 0.14);
}
html[data-theme="saloon"] .stage-body :is(button, a, input, select, textarea, .settings-row, .dock-pill, .side-btn):focus-visible {
  outline-color: rgba(201, 162, 39, 0.85);
}
html[data-theme="saloon"] .settings-row-danger .row-left,
html[data-theme="saloon"] .settings-row-danger .row-ico {
  color: #ffb4a0;
}
html[data-theme="saloon"] .enable-cam-btn {
  font-family: "Rye", serif;
  background: linear-gradient(135deg, #8b3a1c, #c45c26);
  border-color: rgba(240, 215, 140, 0.3);
  color: #fff8e8;
}

/* Saloon: footer, start, messages, ice — match dark/light polish */
html[data-theme="saloon"] .stage-footer {
  background: linear-gradient(
    180deg,
    rgba(36, 22, 12, 0.96) 0%,
    rgba(18, 10, 5, 0.98) 100%
  );
  border-top-color: rgba(201, 162, 39, 0.22);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
}
html[data-theme="saloon"] .stage-footer .dock-pill {
  border-color: rgba(201, 162, 39, 0.3);
  background: rgba(36, 22, 12, 0.9);
  color: #f3e6c8;
}
html[data-theme="saloon"] .stage-footer .dock-pill.ghost {
  background: rgba(26, 16, 8, 0.75);
  color: #e8d4b0;
}
html[data-theme="saloon"] .stage-footer .dock-pill.danger {
  border-color: rgba(196, 70, 40, 0.5);
  background: rgba(60, 20, 12, 0.9);
  color: #ffb4a0;
}
html[data-theme="saloon"] .stage-footer .dock-icon,
html[data-theme="saloon"] .stage-footer .dock-settings {
  border-color: rgba(201, 162, 39, 0.35);
  background: rgba(36, 22, 12, 0.92);
  color: #f0d78c;
}
html[data-theme="saloon"] .stage-footer .dock-chat input {
  background: rgba(26, 16, 8, 0.92);
  color: #f3e6c8;
  border-color: rgba(201, 162, 39, 0.28);
}
html[data-theme="saloon"] .stage-footer .room-in-tile {
  background: rgba(36, 22, 12, 0.9);
  border-color: rgba(201, 162, 39, 0.28);
  color: #e8d4b0;
}
html[data-theme="saloon"] .start-match-btn {
  font-family: "Rye", "Source Serif 4", serif;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #8b3a1c 0%, #c45c26 45%, #d4a017 100%);
  border: 1px solid rgba(240, 215, 140, 0.35);
  box-shadow:
    0 12px 36px rgba(139, 58, 28, 0.5),
    inset 0 1px 0 rgba(255, 230, 160, 0.25);
  color: #fff8e8;
}
html[data-theme="saloon"] .messages-sheet,
html[data-theme="saloon"] #messages-sheet {
  background: #1c120a;
  border-color: rgba(201, 162, 39, 0.28);
  color: #f3e6c8;
}
html[data-theme="saloon"] .msg-tab.active {
  color: #ffe9a8;
  background: rgba(201, 162, 39, 0.16);
  border-color: rgba(201, 162, 39, 0.4);
}
html[data-theme="saloon"] .msg-thread-row {
  background: rgba(36, 22, 12, 0.75);
  border-color: rgba(201, 162, 39, 0.2);
  color: #f3e6c8;
}
html[data-theme="saloon"] .msg-thread-row .meta strong {
  color: #f6e7c1;
}
html[data-theme="saloon"] .msg-compose {
  background: rgba(18, 10, 5, 0.95);
  border-top-color: rgba(201, 162, 39, 0.18);
}
html[data-theme="saloon"] .msg-compose input {
  background: rgba(26, 16, 8, 0.92);
  color: #f3e6c8;
  border-color: rgba(201, 162, 39, 0.28);
}
html[data-theme="saloon"] .friend-avatar {
  border-color: rgba(201, 162, 39, 0.35);
  background: linear-gradient(145deg, #3b2412, #1a1008);
  color: #f0d78c;
}
html[data-theme="saloon"] .friend-row.online .friend-avatar {
  box-shadow: 0 0 0 2px rgba(159, 217, 138, 0.45);
}
html[data-theme="saloon"] .friend-realname {
  color: #a89070;
}
html[data-theme="saloon"] .ice-path {
  background: rgba(36, 22, 12, 0.75);
  border-color: rgba(201, 162, 39, 0.28);
  color: #e8d4b0;
}
html[data-theme="saloon"] .ice-path.path-direct {
  color: #9fd98a;
  border-color: rgba(120, 180, 90, 0.4);
  background: rgba(46, 80, 36, 0.35);
}
html[data-theme="saloon"] .ice-path.path-relay {
  color: #f0d78c;
  border-color: rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.12);
}
html[data-theme="saloon"] .ice-path.path-weak {
  color: #ffb4a0;
  border-color: rgba(196, 70, 40, 0.5);
  background: rgba(80, 28, 16, 0.55);
}
html[data-theme="saloon"] .tile-avatar {
  border-color: rgba(201, 162, 39, 0.4);
}
html[data-theme="saloon"] .settings-status-card.is-clickable {
  cursor: pointer;
}
html[data-theme="saloon"] .settings-status-card.is-clickable:hover {
  border-color: rgba(201, 162, 39, 0.4);
  background: rgba(48, 30, 16, 0.85);
}
html[data-theme="saloon"] .conn-detail-row .conn-detail-value {
  color: #e8d4b0;
}
html[data-theme="saloon"] .conn-detail-hint {
  color: #b89a72;
}

/* Connection details (settings sub-page) */
.conn-detail-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.conn-detail-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.conn-detail-row:last-child {
  border-bottom: none;
}
.conn-detail-label {
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b9bb0;
}
.conn-detail-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: #eef2f7;
  word-break: break-word;
}
.conn-detail-hint {
  font-size: 0.75rem;
  color: #7a8a9e;
  line-height: 1.4;
}
.settings-status-card.is-clickable {
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.settings-status-card.is-clickable:hover {
  border-color: rgba(126, 182, 255, 0.35);
  background: rgba(30, 40, 56, 0.55);
}
html[data-theme="light"] .conn-detail-label {
  color: #64748b;
}
html[data-theme="light"] .conn-detail-value {
  color: #0f172a;
}
html[data-theme="light"] .conn-detail-hint {
  color: #64748b;
}
html[data-theme="light"] .settings-status-card.is-clickable:hover {
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(255, 255, 255, 0.95);
}
html[data-theme="light"] .conn-detail-row {
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

/* ─── Flag picker (cosmetic, not location) ─── */
.flag-choice-list {
  max-height: min(52vh, 28rem);
  overflow: auto;
}
.flag-emoji-lg {
  font-size: 1.35rem;
  line-height: 1;
  width: 1.75rem;
  text-align: center;
  flex-shrink: 0;
}
.flag-pick-copy {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
  text-align: left;
}
.flag-pick-title {
  font-weight: 600;
  font-size: 0.92rem;
}
.flag-pick-sub {
  font-size: 0.7rem;
  color: #8b9bb0;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.name-on-tile {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: min(70vw, 16rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html[data-theme="light"] .flag-pick-sub {
  color: #64748b;
}
html[data-theme="saloon"] .flag-pick-sub {
  color: #b89a72;
}

/* ─── Avatar photo (settings + tiles) ─── */
.settings-hero-avatar {
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
}
.settings-hero-avatar:hover {
  border-color: rgba(255, 107, 53, 0.55);
  filter: brightness(1.05);
}
.settings-hero-avatar:focus-visible {
  outline: 2px solid rgba(255, 107, 53, 0.85);
  outline-offset: 2px;
}
.settings-hero-img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
  display: block;
}
.settings-hero-avatar.has-photo .settings-hero-letter,
.settings-hero-avatar.has-photo .settings-hero-fallback {
  display: none !important;
}
.settings-hero-cam {
  grid-area: 1 / 1;
  align-self: end;
  justify-self: end;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  color: #eef2f7;
  transform: translate(12%, 12%);
  pointer-events: none;
}
.settings-hero-cam .icon {
  width: 0.82rem !important;
  height: 0.82rem !important;
  opacity: 1 !important;
}
.settings-hero-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.2rem;
}
.settings-link-btn {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  color: #7eb6ff;
  cursor: pointer;
  text-decoration: none;
}
.settings-link-btn:hover {
  color: #a8ceff;
  text-decoration: underline;
}
.settings-link-btn[hidden] {
  display: none !important;
}
.tile-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.tile-avatar {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
  background: #141a22;
}
.tile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile-avatar[hidden] {
  display: none !important;
}
html[data-theme="light"] .settings-link-btn {
  color: #2563eb;
}
html[data-theme="light"] .settings-link-btn:hover {
  color: #1d4ed8;
}
html[data-theme="saloon"] .settings-link-btn {
  color: #f0d78c;
}
html[data-theme="saloon"] .settings-hero-cam {
  background: rgba(26, 16, 8, 0.9);
  border-color: rgba(201, 162, 39, 0.45);
  color: #f0d78c;
}
html[data-theme="saloon"] .tile-avatar {
  border-color: rgba(201, 162, 39, 0.4);
}

/* Avatar attach row */
.avatar-attach-group {
  margin-bottom: 0.65rem;
}
.avatar-attach-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  text-align: left;
}
.avatar-attach-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: #8b9bb0;
  line-height: 1.25;
}
.settings-hero.is-drop-target {
  outline: 2px dashed rgba(126, 182, 255, 0.75);
  outline-offset: 2px;
  background: linear-gradient(145deg, #1a2438 0%, #141a28 100%);
}
html[data-theme="light"] .avatar-attach-hint {
  color: #64748b;
}
html[data-theme="light"] .settings-hero.is-drop-target {
  outline-color: rgba(37, 99, 235, 0.65);
  background: #eef2ff;
}
html[data-theme="saloon"] .avatar-attach-hint {
  color: #b89a72;
}
html[data-theme="saloon"] .settings-hero.is-drop-target {
  outline-color: rgba(201, 162, 39, 0.7);
  background: linear-gradient(145deg, #2a1a0c, #1a1008);
}
