/* ═══════════════════════════════════════════════════════════
   HEXLAND — Player Profile  (matches lobby dark theme)
   ═══════════════════════════════════════════════════════════ */

.pf-wrap {
  width: 100%;
  max-width: 660px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pf-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pf-root { width: 100%; display: flex; flex-direction: column; gap: 14px; }

.pf-state {
  text-align: center;
  color: rgba(var(--ink-rgb),.6);
  padding: 40px 16px;
  font-size: .95rem;
}
.pf-error { color: var(--err-red); }

.pf-card {
  background: var(--card-bg);
  border: 1px solid rgba(var(--ink-rgb),.08);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}

/* ── Header ── */
.pf-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.pf-avatar {
  width: 96px; height: 96px;
  flex: 0 0 96px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 800; color: #fff;
  border: 3px solid rgba(var(--ink-rgb),.18);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.pf-head-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pf-username { font-size: 1.5rem; font-weight: 800; color: var(--text-cream); letter-spacing: .5px; }
/* Base direction from content (dir="auto" equivalent) so Persian+emoji usernames,
   room names, and message text render the emoji on the correct logical side. */
.pf-username, .pf-dispname, .pf-h2h-name, .pf-fr-name, .pf-ref-friend-name, .pf-live-name, .pf-msg-body, .pf-about-text { unicode-bidi: plaintext; }
.pf-you { font-size: .72rem; color: #f0a030; font-weight: 600; }
.pf-dispname { font-size: .95rem; color: rgba(var(--ink-rgb),.78); }
.pf-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: .78rem; color: rgba(var(--ink-rgb),.5);
  margin-top: 2px;
}
.pf-online { color: var(--ok-green); font-weight: 600; }

.pf-rep-wrap { margin-top: 6px; width: fit-content; }
.pf-rep {
  display: inline-block;
  font-size: .82rem;
  padding: 3px 12px;
  border-radius: 20px;
  width: fit-content;
  cursor: pointer;
  list-style: none;
}
.pf-rep::-webkit-details-marker { display: none; }
.rep-trusted { background: rgba(95,209,122,.18); color: var(--ok-green); border: 1px solid rgba(95,209,122,.4); }
.rep-good    { background: rgba(77,196,245,.16); color: var(--text-link-2); border: 1px solid rgba(77,196,245,.4); }
.rep-neutral { background: rgba(var(--ink-rgb),.10); color: rgba(var(--ink-rgb),.75); border: 1px solid rgba(var(--ink-rgb),.2); }
.rep-low     { background: rgba(245,120,90,.16); color: #ff9b80; border: 1px solid rgba(245,120,90,.4); }

.pf-rep-detail {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(var(--ink-rgb),.05);
  border: 1px solid rgba(var(--ink-rgb),.08);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .76rem;
  color: rgba(var(--ink-rgb),.7);
  width: fit-content;
}

/* ── Action buttons ── */
.pf-actions { display: flex; gap: 10px; margin: 16px 0 4px; }
.pf-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(var(--ink-rgb),.2);
  background: rgba(var(--ink-rgb),.08);
  color: rgba(var(--ink-rgb),.85);
  font-size: .85rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.pf-btn:hover:not(:disabled) { background: rgba(var(--ink-rgb),.16); }
.pf-btn-soon { opacity: .45; cursor: not-allowed; }
.pf-btn-primary { background: #3a6db0; border-color: #4f88d0; color: #fff; }
.pf-btn-primary:hover:not(:disabled) { background: #4579c4; }

/* Incoming friend-request notice (replaces a bare Accept/Decline pair so it's
   clear WHO the request is from, even on narrow screens). */
.pf-fr-request {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 100%;
  background: rgba(79,136,208,.12);
  border: 1px solid rgba(79,136,208,.35);
  border-radius: 10px;
  padding: 10px 12px;
}
.pf-fr-request-txt { font-size: .85rem; color: var(--text-link-2); }
.pf-fr-request .pf-fr-btns { display: flex; gap: 8px; }

/* ── Section headers ── */
.pf-section-hd {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(var(--ink-rgb),.42);
  margin: 22px 0 10px;
  border-top: 1px solid rgba(var(--ink-rgb),.07);
  padding-top: 14px;
}
/* When a section header is the title of its own card, drop the divider/offset —
   the card border already separates it from the section above. */
.pf-card > .pf-section-hd:first-child,
.pf-card > *:first-child > .pf-section-hd:first-child {
  margin-top: 0; border-top: 0; padding-top: 0;
}
/* Top "✉️ Messages" link (the full inbox lives in the lobby panel now). */
.pf-msg-link-row { margin: 14px 0 4px; }
.pf-msg-link {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(77,196,245,.12); border: 1px solid rgba(77,196,245,.3);
  color: var(--text-link-2); text-decoration: none;
  border-radius: 9px; padding: 7px 13px; font-size: .85rem; font-weight: 600;
}
.pf-msg-link:hover { background: rgba(77,196,245,.2); }
.pf-msg-badge {
  background: #e05a5a; color: #fff; font-size: .68rem; font-weight: 700; line-height: 1;
  border-radius: 9px; padding: 2px 6px;
}
.pf-msg-badge[hidden] { display: none; }
.pf-count {
  display: inline-block;
  background: rgba(77,196,245,.2);
  color: var(--text-link-2);
  border-radius: 10px;
  padding: 0 7px;
  font-size: .72rem;
  margin-left: 4px;
}

/* ── Stats grid ── */
.pf-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.pf-stat {
  background: rgba(var(--ink-rgb),.05);
  border: 1px solid rgba(var(--ink-rgb),.07);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
}
.pf-stat-num { display: block; font-size: 1.35rem; font-weight: 800; color: var(--text-cream); }
.pf-stat-lbl { display: block; font-size: .68rem; color: rgba(var(--ink-rgb),.5); margin-top: 3px; }

/* ── Playing now ── */
.pf-games-live { display: flex; flex-direction: column; gap: 8px; }
.pf-live {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  background: rgba(77,196,245,.07);
  border: 1px solid rgba(77,196,245,.18);
  border-radius: 10px;
  padding: 10px 14px;
}
.pf-live-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-live-name { font-weight: 700; color: var(--text-strong-2); font-size: .92rem; }
.pf-live-sub { font-size: .74rem; color: rgba(var(--ink-rgb),.5); }
.pf-live-players { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 2px; }
.pf-live-pl { font-size: .74rem; color: var(--text-link-2); text-decoration: none; }
.pf-live-pl:hover { text-decoration: underline; }
.pf-live-pl-ai { color: rgba(var(--ink-rgb),.45); }
.pf-watch {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid #4f88d0;
  background: #3a6db0;
  color: #fff;
  font-size: .82rem; font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.pf-watch:hover { background: #4579c4; }
.pf-watch-off { background: transparent; border-color: rgba(var(--ink-rgb),.15); color: rgba(var(--ink-rgb),.35); cursor: default; }
.pf-rejoin {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid #28b060;
  background: #1f7a45;
  color: #fff;
  font-size: .82rem; font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.pf-rejoin:hover { background: #28b060; }

.pf-empty { color: rgba(var(--ink-rgb),.45); font-size: .85rem; padding: 4px 2px; }

/* ── Details ── */
.pf-details { display: flex; flex-wrap: wrap; gap: 10px; }
.pf-detail {
  background: rgba(var(--ink-rgb),.05);
  border-radius: 8px;
  padding: 8px 14px;
}
.pf-detail-k { display: block; font-size: .68rem; color: rgba(var(--ink-rgb),.45); text-transform: uppercase; letter-spacing: .5px; }
.pf-detail-v { font-size: .95rem; color: var(--text-strong-2); font-weight: 600; }
.pf-about { margin-top: 10px; }
.pf-about-hd { font-size: .72rem; color: rgba(var(--ink-rgb),.45); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.pf-about p { color: rgba(var(--ink-rgb),.8); font-size: .9rem; line-height: 1.5; white-space: pre-wrap; }

/* ── Badges ── */
.pf-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(240,160,48,.12);
  border: 1px solid rgba(240,160,48,.3);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .8rem; color: #f0c070;
}
.pf-badge-ic { font-size: 1rem; }

/* ── Recent games ── */
.pf-games { display: flex; flex-direction: column; gap: 6px; }
.pf-game {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(var(--ink-rgb),.04);
  border-left: 3px solid transparent;
  font-size: .84rem;
}
.pf-game-win { border-left-color: var(--ok-green); }
.pf-game-loss { border-left-color: rgba(255,120,120,.6); }
.pf-game-result { font-weight: 700; color: var(--text-strong-2); flex: 0 0 auto; }
.pf-game-meta { color: rgba(var(--ink-rgb),.5); }
.pf-game-vs { color: rgba(var(--ink-rgb),.55); margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }

/* ── Head-to-head ── */
.pf-h2h-list { display: flex; flex-direction: column; gap: 6px; }
.pf-h2h {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(var(--ink-rgb),.04);
  border-left: 3px solid transparent;
  font-size: .84rem;
}
.pf-h2h-up { border-left-color: var(--ok-green); }
.pf-h2h-down { border-left-color: rgba(255,120,120,.6); }
.pf-h2h-name { font-weight: 700; color: var(--text-link-2); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-h2h-name:hover { text-decoration: underline; }
.pf-h2h-games { color: rgba(var(--ink-rgb),.5); margin-left: auto; }
.pf-h2h-rec { font-weight: 800; color: var(--text-cream); flex: 0 0 auto; min-width: 44px; text-align: right; }

/* ── Edit form ── */
.pf-edit { margin-top: 8px; }
.pf-edit-summary { cursor: pointer; list-style: none; color: var(--text-link-2); }
.pf-edit-summary::-webkit-details-marker { display: none; }
.pf-edit-body { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.pf-edit-note { font-size: .78rem; color: rgba(var(--ink-rgb),.5); line-height: 1.5; }
.pf-field { display: flex; flex-direction: column; gap: 5px; }
.pf-field-lbl {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: .82rem; color: rgba(var(--ink-rgb),.7); font-weight: 600;
}
.pf-field input, .pf-field textarea, .pf-field select {
  background: rgba(var(--inset-rgb),.28);
  border: 1px solid rgba(var(--ink-rgb),.15);
  border-radius: 8px;
  padding: 9px 12px;
  color: rgba(var(--ink-rgb),.92);
  font-size: .9rem;
  font-family: inherit;
  width: 100%;
}
.pf-field textarea { resize: vertical; }
.pf-field input:focus, .pf-field textarea:focus, .pf-field select:focus {
  outline: none; border-color: #4f88d0;
}
/* Cascade dropdown — replaces the native <select> for the privacy + sex
   pickers so mobile shows the same inline list as desktop (instead of the
   OS overlay picker), with readable contrast on the option list. */
.pf-cdd-native { display: none; }
.pf-cdd { position: relative; }
.pf-cdd-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%;
  background: rgba(var(--inset-rgb),.28);
  border: 1px solid rgba(var(--ink-rgb),.15);
  border-radius: 8px;
  padding: 9px 12px;
  color: rgba(var(--ink-rgb),.92);
  font-size: .9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.pf-cdd-trigger:hover { border-color: rgba(var(--ink-rgb),.3); }
.pf-cdd.open .pf-cdd-trigger { border-color: #4f88d0; }
.pf-cdd-arrow { flex: 0 0 auto; opacity: .6; font-size: .75em; transition: transform .15s; }
.pf-cdd.open .pf-cdd-arrow { transform: rotate(180deg); }
.pf-cdd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; padding: 4px; list-style: none;
  background: var(--panel-bg);
  border: 1px solid rgba(var(--ink-rgb),.15);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-height: 220px;
  overflow-y: auto;
  z-index: 60;
}
.pf-cdd-menu[hidden] { display: none; }
.pf-cdd-option {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: .9rem;
  color: rgba(var(--ink-rgb),.92);
  cursor: pointer;
}
.pf-cdd-option:hover, .pf-cdd-option.active { background: rgba(var(--ink-rgb),.1); }
.pf-cdd-option.selected { color: var(--text-link-2); font-weight: 600; }
.pf-cdd-option[hidden] { display: none; }

/* Type-ahead search row for long dropdowns (nationality picker) */
.pf-cdd-searchwrap {
  position: sticky; top: -4px; z-index: 1;
  padding: 4px 4px 6px; margin: -4px -4px 4px;
  background: var(--panel-bg);
  border-bottom: 1px solid rgba(var(--ink-rgb),.12);
}
.pf-cdd-search {
  width: 100%; box-sizing: border-box;
  padding: 6px 9px; border-radius: 6px;
  border: 1px solid rgba(var(--ink-rgb),.2);
  background: rgba(var(--ink-rgb),.04);
  color: rgba(var(--ink-rgb),.92); font-size: .85rem;
}
.pf-cdd-search:focus { outline: none; border-color: var(--text-link-2); }

/* Country flag shown next to a username / in detail rows */
.pf-flag {
  height: 1em; width: auto; vertical-align: -0.12em;
  border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.18);
  display: inline-block; cursor: zoom-in;
}
.pf-username .pf-flag { height: .8em; }
.pf-detail-v .pf-flag { margin-right: 4px; }
.pf-av-zoom { cursor: zoom-in; }

/* Enlarged image view (tap avatar picture / flag) */
.pf-lightbox {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: pf-lb-in .15s ease;
}
@keyframes pf-lb-in { from { opacity: 0; } to { opacity: 1; } }
.pf-lightbox-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  max-width: 100%; max-height: 100%;
}
.pf-lightbox-img {
  max-width: min(90vw, 520px); max-height: 80vh;
  width: auto; height: auto;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
  background: #fff;
}
.pf-lightbox-round {
  width: min(80vw, 360px); height: min(80vw, 360px);
  border-radius: 50%; object-fit: cover;
}
.pf-lightbox-cap {
  color: #fff; font-size: 1rem; font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.pf-lightbox-close {
  position: fixed; top: 16px; right: 18px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.14); color: #fff;
  font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.pf-lightbox-close:hover { background: rgba(255,255,255,.26); }

/* Small pill variant for the per-field privacy selectors */
.pf-cdd-sm { flex: 0 0 auto; display: inline-block; }
.pf-cdd-sm .pf-cdd-trigger {
  width: auto;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  background: rgba(var(--ink-rgb),.06);
}
.pf-cdd-sm .pf-cdd-menu { left: auto; right: 0; width: max-content; min-width: 130px; font-size: .8rem; }

/* Avatar editing (picture + colour) */
.pf-pic-edit { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pf-pic-preview {
  width: 92px; height: 92px; flex: 0 0 92px;
  border-radius: 50%;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 800; color: #fff;
  border: 2px solid rgba(var(--ink-rgb),.18);
  box-shadow: 0 4px 16px rgba(0,0,0,.32);
}
.pf-pic-edit .pf-pic-row { justify-content: center; }
.pf-pic-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pf-btn-ghost {
  background: rgba(var(--ink-rgb),.08);
  border: 1px solid rgba(var(--ink-rgb),.2);
}
.pf-btn-ghost:hover:not(:disabled) { background: rgba(var(--ink-rgb),.15); }
.pf-btn-ghost[hidden] { display: none; }
.pf-pic-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-color {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .1s;
}
.pf-color:hover { transform: scale(1.12); }
.pf-color-on { border-color: #fff; box-shadow: 0 0 0 2px rgba(var(--ink-rgb),.3); }
.pf-edit-actions { display: flex; align-items: center; gap: 12px; }
.pf-edit-status { font-size: .82rem; color: rgba(var(--ink-rgb),.6); }
.pf-edit-status.ok { color: var(--ok-green); }
.pf-edit-status.err { color: var(--err-red); }

/* ── Responsive ── */
@media (max-width: 560px) {
  .pf-card { padding: 16px; }
  .pf-avatar { width: 76px; height: 76px; flex-basis: 76px; font-size: 2rem; }
  .pf-username { font-size: 1.25rem; }
  .pf-stats { grid-template-columns: repeat(2, 1fr); }
  .pf-game-vs { max-width: 100%; margin-left: 0; flex-basis: 100%; }
}

/* Shown when you open your own profile but the tab is signed out. */
.pf-signedout {
  background: rgba(245,180,80,.10);
  border: 1px solid rgba(245,180,80,.30);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .85rem;
  color: rgba(var(--ink-rgb),.78);
  line-height: 1.5;
}
.pf-signedout a { color: var(--text-link-2); }

/* Friend / report buttons + report modal (slice 2). */
.pf-btn-report { border-color: rgba(245,120,90,.4); color: #ff9b80; }
.pf-btn-report:hover:not(:disabled) { background: rgba(245,120,90,.15); }
.pf-btn-msg { border-color: rgba(77,196,245,.45); color: var(--text-link-2); }
.pf-btn-msg:hover:not(:disabled) { background: rgba(77,196,245,.16); }
.pf-friends { background: rgba(95,209,122,.18); border-color: rgba(95,209,122,.5); color: var(--ok-green); }
.pf-friends:hover:not(:disabled) { background: rgba(245,120,90,.15); border-color: rgba(245,120,90,.4); color: #ff9b80; }

.pf-modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.pf-modal-backdrop[hidden] { display: none; }
.pf-modal {
  background: var(--panel-bg);
  border: 1px solid rgba(var(--ink-rgb),.12);
  border-radius: 14px;
  padding: 20px;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.pf-modal-hd { font-size: 1.1rem; font-weight: 700; color: var(--text-cream); }
.pf-modal-actions { display: flex; align-items: center; gap: 10px; }

/* Avatar crop modal */
.pf-crop-modal { max-width: 360px; align-items: center; }
.crop-viewport {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
  touch-action: none;
  cursor: grab;
}
.crop-viewport:active { cursor: grabbing; }
.crop-img {
  position: absolute;
  left: 0; top: 0;
  transform-origin: top left;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.crop-guide {
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.45);
  border: 2px solid rgba(255,255,255,.6);
  pointer-events: none;
}
.crop-zoom-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 280px; }
.crop-zoom-row input[type="range"] { flex: 1; accent-color: #4f88d0; }
.crop-zoom-ic { font-size: .85rem; opacity: .6; }

/* Friends list (own profile). */
.pf-fr-sub { font-size: .74rem; color: rgba(var(--ink-rgb),.4); margin: 8px 0 4px; }
.pf-fr-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 7px 10px; border-radius: 8px;
  background: rgba(var(--ink-rgb),.04); margin-bottom: 5px;
}
.pf-fr-name { display: flex; align-items: center; gap: 8px; color: var(--text-strong-2); text-decoration: none; font-size: .9rem; font-weight: 600; }
.pf-fr-name:hover { color: var(--text-link-2); }
.pf-fr-av {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
}
.pf-fr-btns { display: flex; gap: 6px; }
.pf-fr-mini { padding: 4px 10px; font-size: .76rem; }
.pf-fr-since { font-size: .74rem; color: rgba(95,209,122,.8); }

/* ── Messages (inbox) ── */
.pf-msg-list { display: flex; flex-direction: column; gap: 8px; }
.pf-msg-item {
  background: rgba(var(--ink-rgb),.04);
  border: 1px solid rgba(var(--ink-rgb),.07);
  border-radius: 10px;
  padding: 10px 12px;
}
.pf-msg-item.pf-msg-unread {
  background: rgba(77,196,245,.08);
  border-color: rgba(77,196,245,.3);
}
.pf-msg-hd { display: flex; align-items: center; gap: 8px; }
.pf-msg-icon { font-size: 1rem; flex: 0 0 auto; }
.pf-msg-subject { flex: 1; font-weight: 700; color: var(--text-cream); font-size: .9rem; }
.pf-msg-date { font-size: .72rem; color: rgba(var(--ink-rgb),.4); white-space: nowrap; }
.pf-msg-from { font-size: .76rem; color: rgba(var(--ink-rgb),.5); margin: 4px 0; }
.pf-msg-from a { color: var(--text-link-2); text-decoration: none; }
.pf-msg-from a:hover { text-decoration: underline; }
.pf-msg-body { font-size: .88rem; color: rgba(var(--ink-rgb),.85); line-height: 1.5; white-space: pre-wrap; margin-bottom: 6px; }
.pf-msg-actions { display: flex; gap: 6px; }
.pf-count-unread { background: rgba(245,120,90,.25); color: #ff9b80; }

/* Pro gate banner on stats section */
.pf-pro-gate {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(184,134,11,.1);
  border: 1px solid rgba(218,165,32,.3);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 4px 0 8px;
  flex-wrap: wrap;
}
.pf-pro-gate--inline {
  margin-top: 10px;
}
.pf-pro-gate-icon {
  color: #daa520;
  font-weight: 800;
  font-size: .95rem;
  flex-shrink: 0;
}
.pf-pro-gate-msg {
  font-size: .82rem;
  opacity: .88;
  flex: 1;
  min-width: 0;
}
.pf-pro-gate-link {
  font-size: .8rem;
  font-weight: 700;
  color: #daa520;
  text-decoration: none;
  white-space: nowrap;
}
.pf-pro-gate-link:hover { text-decoration: underline; }

/* Pro Upgrade Modal (shared with lobby) */
.pu-backdrop { position:fixed;inset:0;z-index:1200;background:rgba(0,0,0,.6);backdrop-filter:blur(4px);align-items:center;justify-content:center;padding:16px; }
.pu-backdrop:not([hidden]) { display:flex; }
.pu-modal { background:var(--clr-card,#1e2230);border-radius:16px;width:100%;max-width:400px;box-shadow:0 20px 60px rgba(0,0,0,.5);overflow:hidden; }
.pu-head { display:flex;align-items:center;padding:16px 20px 12px;border-bottom:1px solid rgba(255,255,255,.08); }
.pu-title { font-size:1.05rem;font-weight:800;color:#daa520;flex:1; }
.pu-close { background:none;border:none;color:inherit;opacity:.55;font-size:1rem;cursor:pointer;padding:2px 6px; }
.pu-close:hover { opacity:1; }
.pu-body { padding:18px 20px 22px; }
.pu-tagline { font-size:.9rem;font-weight:600;margin:0 0 14px;opacity:.9; }
.pu-features { list-style:none;padding:0;margin:0 0 18px; }
.pu-features li { font-size:.83rem;padding:5px 0;display:flex;gap:8px;align-items:flex-start;opacity:.88; }
.pu-check { color:#daa520;font-weight:800;flex-shrink:0;margin-top:1px; }
.pu-plans { display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:16px; }
.pu-plan { border:1px solid rgba(255,255,255,.14);border-radius:10px;padding:12px 10px;text-align:center;position:relative; }
.pu-plan-featured { border-color:#daa520;background:rgba(218,165,32,.07); }
.pu-plan-badge { position:absolute;top:-10px;left:50%;transform:translateX(-50%);background:#daa520;color:#1a1000;font-size:.62rem;font-weight:800;padding:2px 8px;border-radius:999px;white-space:nowrap; }
.pu-plan-name { font-size:.82rem;font-weight:700;margin-bottom:4px; }
.pu-plan-price { font-size:.75rem;opacity:.6; }
.pu-note { font-size:.77rem;opacity:.6;text-align:center;margin:0 0 14px; }
.pu-contact-btn { display:block;text-align:center;background:linear-gradient(135deg,#b8860b,#daa520);color:#1a1000 !important;font-weight:800;font-size:.85rem;padding:10px 16px;border-radius:10px;text-decoration:none;transition:opacity .15s; }
.pu-contact-btn:hover { opacity:.88; }
[data-theme="light"] .pu-modal { background:#fff; }
[data-theme="light"] .pu-plan { border-color:rgba(0,0,0,.12); }
[data-theme="light"] .pu-plan-featured { background:rgba(184,134,11,.06); }

/* Make gate-link look like a link when it's a button */
.pf-pro-gate-link { background:none;border:none;padding:0;cursor:pointer;font-size:.8rem;font-weight:700;color:#daa520;text-decoration:none; }
.pf-pro-gate-link:hover { text-decoration:underline; }

/* Embed mode — hide page chrome when loaded inside the lobby modal */
[data-embed="1"] #auth-bar,
[data-embed="1"] .pf-topbar { display: none !important; }
[data-embed="1"] .lobby-bg {
  background: none;
  padding: 0;
  min-height: unset;
}

/* ════════════════════════════════════════════════════════════
   Friend Referral / Invite Friends dashboard (§Referral)
   ════════════════════════════════════════════════════════════ */
.pf-referral { display: block; }
.pf-ref-intro {
  font-size: .86rem; line-height: 1.5;
  color: rgba(var(--ink-rgb),.7);
  margin: 2px 0 14px;
}

/* Invite link / code box */
.pf-ref-share-box {
  background: rgba(var(--ink-rgb),.05);
  border: 1px solid rgba(var(--ink-rgb),.12);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.pf-ref-flbl {
  display: block;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .8px;
  color: rgba(var(--ink-rgb),.55);
  margin: 0 0 5px;
}
.pf-ref-flbl:not(:first-child) { margin-top: 12px; }
.pf-ref-copy-row { display: flex; gap: 8px; align-items: stretch; }
.pf-ref-input {
  flex: 1 1 auto; min-width: 0;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid rgba(var(--ink-rgb),.2);
  background: rgba(var(--ink-rgb),.04);
  color: rgba(var(--ink-rgb),.9);
  font-size: .85rem;
}
.pf-ref-code { font-weight: 700; letter-spacing: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.pf-ref-copy { white-space: nowrap; }
.pf-ref-copy.ok { background: #1f9e5a; border-color: #2cb86c; color: #fff; }

/* Share targets */
.pf-ref-share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.pf-ref-share {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--ink-rgb),.2);
  background: rgba(var(--ink-rgb),.07);
  color: rgba(var(--ink-rgb),.85);
  font-size: .8rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background .15s, transform .1s;
}
.pf-ref-share:hover { background: rgba(var(--ink-rgb),.15); transform: translateY(-1px); }
.pf-ref-share-native { background: #3a6db0; border-color: #4f88d0; color: #fff; }
.pf-ref-share-native:hover { background: #4579c4; }

/* Count stats */
.pf-ref-stats { display: flex; gap: 12px; margin-bottom: 14px; }
.pf-ref-stat {
  flex: 1 1 0;
  background: rgba(var(--ink-rgb),.05);
  border: 1px solid rgba(var(--ink-rgb),.12);
  border-radius: 12px;
  padding: 12px; text-align: center;
}
.pf-ref-stat-n { font-size: 1.5rem; font-weight: 800; color: rgba(var(--ink-rgb),.92); line-height: 1; }
.pf-ref-stat-l { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: rgba(var(--ink-rgb),.55); margin-top: 5px; }

/* Progress bar + milestone ticks */
.pf-ref-progress { margin: 6px 0 18px; }
.pf-ref-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb),.12);
  margin: 26px 0 30px;
}
.pf-ref-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #3a6db0, #f0b429);
  transition: width .5s ease;
}
.pf-ref-tick {
  position: absolute; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
}
.pf-ref-tick-dot {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--pf-card-bg, #fff);
  border: 2px solid rgba(var(--ink-rgb),.25);
  font-size: .85rem;
  filter: grayscale(1); opacity: .6;
}
.pf-ref-tick.done .pf-ref-tick-dot {
  border-color: #f0b429;
  box-shadow: 0 0 0 3px rgba(240,180,41,.25);
  filter: none; opacity: 1;
}
.pf-ref-tick-lbl {
  position: absolute; top: 30px;
  font-size: .7rem; font-weight: 700;
  color: rgba(var(--ink-rgb),.55);
}
.pf-ref-next { font-size: .85rem; color: rgba(var(--ink-rgb),.75); text-align: center; }

/* Reward cards */
.pf-ref-rewards { display: flex; flex-direction: column; gap: 10px; }
.pf-ref-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(var(--ink-rgb),.14);
  background: rgba(var(--ink-rgb),.04);
}
.pf-ref-card-ic { font-size: 1.6rem; line-height: 1; }
.pf-ref-card-main { flex: 1 1 auto; min-width: 0; }
.pf-ref-card-lbl { font-weight: 700; font-size: .92rem; color: rgba(var(--ink-rgb),.9); }
.pf-ref-card-desc { font-size: .78rem; color: rgba(var(--ink-rgb),.6); margin-top: 2px; }
.pf-ref-card-action { flex: 0 0 auto; }
.pf-ref-need { font-size: .78rem; color: rgba(var(--ink-rgb),.5); white-space: nowrap; }
.pf-ref-done { font-size: .82rem; font-weight: 700; color: #1f9e5a; white-space: nowrap; }
.pf-ref-claimable {
  border-color: rgba(240,180,41,.5);
  background: linear-gradient(135deg, rgba(240,180,41,.12), rgba(240,180,41,.04));
  animation: pf-ref-glow 2.4s ease-in-out infinite;
}
@keyframes pf-ref-glow { 0%,100% { box-shadow: 0 0 0 0 rgba(240,180,41,.0); } 50% { box-shadow: 0 0 0 4px rgba(240,180,41,.18); } }
.pf-ref-locked { opacity: .72; }
.pf-ref-card.pf-ref-claimed .pf-ref-card-ic { filter: none; }
.pf-ref-claim { animation: none; }

/* Invited-friends list */
.pf-ref-list { margin-top: 14px; }
.pf-ref-list > summary {
  cursor: pointer; font-size: .82rem; font-weight: 600;
  color: rgba(var(--ink-rgb),.7);
  padding: 6px 0;
}
.pf-ref-friend {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px;
  font-size: .85rem;
}
.pf-ref-friend-name { flex: 1 1 auto; min-width: 0; color: rgba(var(--ink-rgb),.85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-ref-friend-tag { font-size: .72rem; font-weight: 700; white-space: nowrap; }
.pf-ref-friend-tag.ok { color: #1f9e5a; }
.pf-ref-friend-tag.pending { color: rgba(var(--ink-rgb),.45); }

/* Exclusive avatar cosmetic — gold "Founding Referrer" ring */
.pf-av-referrer-gold {
  box-shadow: 0 0 0 3px #f0b429, 0 0 0 5px rgba(240,180,41,.35), 0 0 14px rgba(240,180,41,.5);
}

/* Toast for referral events */
.pf-ref-toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #243; color: #fff;
  background: rgba(28,40,32,.96);
  border: 1px solid rgba(240,180,41,.5);
  padding: 12px 18px; border-radius: 12px;
  font-size: .88rem; font-weight: 600;
  max-width: 90vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
}
.pf-ref-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 540px) {
  .pf-ref-stats { gap: 8px; }
  .pf-ref-card { flex-wrap: wrap; }
  .pf-ref-card-action { flex-basis: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   Modern profile — hero, header actions, view cards, edit sheet
   ═══════════════════════════════════════════════════════════ */

/* Hero card holds the avatar/identity plus the owner's action links
   (Edit Profile · Settings · Messages) or the visitor's friend/message/report row. */
.pf-hero { display: flex; flex-direction: column; gap: 12px; }
.pf-hero .pf-head { gap: 18px; }

/* About / personal text presentation (read-only view mode). */
.pf-about-text {
  color: rgba(var(--ink-rgb),.82);
  font-size: .95rem; line-height: 1.55;
  white-space: pre-wrap; margin: 0;
  unicode-bidi: plaintext;
}

/* Owner self-action row — compact text links, not buttons. Separated by thin
   dividers so Edit / Settings / Messages read as one tidy group. */
.pf-selfbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(var(--ink-rgb),.08);
}
.pf-linkbtn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0;
  padding: 5px 12px;
  color: var(--text-link-2);
  font-size: .88rem; font-weight: 600;
  font-family: inherit; cursor: pointer;
  text-decoration: none; border-radius: 8px;
  transition: background .15s;
}
.pf-linkbtn:hover { background: rgba(77,196,245,.12); text-decoration: underline; }
.pf-linkbtn:active { opacity: .7; }
.pf-linkbtn:focus-visible { outline: 2px solid #4f88d0; outline-offset: 1px; }
/* Hairline divider between links. */
.pf-linkbtn + .pf-linkbtn::before {
  content: ""; position: absolute; left: -2px; top: 50%;
  height: 14px; width: 1px; transform: translateY(-50%);
  background: rgba(var(--ink-rgb),.15);
}
#pf-messages-link .pf-msg-badge { margin-left: 1px; }

/* Visitor actions live inside the hero too — keep them tidy and wrapping. */
.pf-hero .pf-actions { margin: 2px 0 0; flex-wrap: wrap; }

/* ── Edit slide-over sheet ── */
.pf-sheet {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.55);
  opacity: 0;
  transition: opacity .25s ease;
}
.pf-sheet.open { opacity: 1; }
.pf-sheet[hidden] { display: none; }
.pf-sheet-panel {
  width: 100%; max-width: 660px;
  max-height: 94dvh;
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid rgba(var(--ink-rgb),.12);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -14px 50px rgba(0,0,0,.55);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22,1,.36,1);
}
.pf-sheet.open .pf-sheet-panel { transform: translateY(0); }

.pf-sheet-hd {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  padding: 12px 14px;
  background: var(--panel-bg);
  border-bottom: 1px solid rgba(var(--ink-rgb),.1);
  border-radius: 20px 20px 0 0;
}
.pf-sheet-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border: 0; border-radius: 10px;
  background: transparent; color: rgba(var(--ink-rgb),.8);
  font-size: 1.3rem; line-height: 1; cursor: pointer;
  transition: background .15s;
}
.pf-sheet-back:hover { background: rgba(var(--ink-rgb),.1); }
.pf-sheet-title { font-size: 1.05rem; font-weight: 700; color: var(--text-cream); }

.pf-sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 20px;
  display: flex; flex-direction: column; gap: 22px;
}
.pf-sheet-foot {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--panel-bg);
  border-top: 1px solid rgba(var(--ink-rgb),.1);
}
.pf-sheet-save {
  margin-left: auto;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: .95rem;
}

/* Grouped edit sections inside the sheet. */
.pf-egroup { display: flex; flex-direction: column; gap: 13px; }
.pf-egroup-hd {
  font-size: .72rem; text-transform: uppercase; letter-spacing: 1.1px;
  color: rgba(var(--ink-rgb),.5); font-weight: 700;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(var(--ink-rgb),.08);
}
.pf-egroup-note { font-size: .78rem; color: rgba(var(--ink-rgb),.5); line-height: 1.5; margin: 0; }
/* In the grouped Privacy section each field's visibility gets a labelled row. */
.pf-privrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pf-privrow-lbl { font-size: .88rem; color: rgba(var(--ink-rgb),.8); font-weight: 600; }
.pf-privrow .pf-cdd-sm .pf-cdd-trigger { font-size: .8rem; padding: 6px 12px; }

/* Lock background scroll while the sheet is open. */
body.pf-sheet-lock { overflow: hidden; }

@media (max-width: 560px) {
  .pf-sheet-panel { max-height: 92dvh; }
}

/* Match Report entry point (§Pro Phase 1) — a recent-game row becomes clickable on
   your own profile. Purely additive: non-openable rows keep their existing look. */
.pf-game-open { cursor: pointer; }
.pf-game-open:hover { background: rgba(255, 255, 255, .05); }
.pf-game-open:focus-visible { outline: 2px solid var(--accent, #4a7ad0); outline-offset: 2px; }
.pf-game-report { margin-left: auto; opacity: .55; flex: 0 0 auto; }
.pf-game-open:hover .pf-game-report { opacity: 1; }
