/* ==========================================================================
   Premium dark-fantasy layer (loaded LAST, after dragon-puzzle.css, multiplayer.css
   and the page's own <style>). Visual only: it changes no markup behaviour.

   Palette: midnight black + charcoal, silver-white type, ONE restrained accent
   (electric cyan). Red is kept only where it is meaning (errors, the dragon's
   glowing eyes in the artwork).
   ========================================================================== */
:root {
  --pm-void: rgb(var(--surf-6));
  --pm-night: rgb(var(--surf-13));
  --pm-charcoal: rgb(var(--surf-36));
  --pm-slate: rgb(var(--surf-53));
  --pm-silver: rgb(var(--txt-42));
  --pm-mist: rgb(var(--txt-32));
  --pm-fog: rgb(var(--txt-17));
  --pm-line: rgba(var(--wash-8), 0.16);
  --pm-line-hi: rgba(var(--cy-line-3), 0.55);
  --pm-cyan: rgb(var(--cy-text-6));
  --pm-cyan-deep: rgb(var(--cy-text-2));
  --pm-focus: rgb(var(--cy-line-5));
  --pm-serif: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;
  --pm-sans: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --pm-ease: cubic-bezier(.2, .7, .2, 1);
  --pm-display: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;   /* headings (font files: assets/fonts, declared in css/typography.css) */
}

/* ---------- page atmosphere ---------- */
html { background: var(--pm-void); color-scheme: dark; }
body {
  font-family: var(--pm-sans);
  color: var(--pm-mist);
  background:
    radial-gradient(75% 38% at 50% -6%, rgba(var(--cy-wash-7), 0.2), transparent 70%),
    radial-gradient(40% 30% at 100% 12%, rgba(var(--cy-wash-11), 0.05), transparent 70%),
    linear-gradient(180deg, rgb(var(--surf-9)) 0%, rgb(var(--surf-6)) 60%) fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(var(--cy-wash-11), 0.28); color: rgb(var(--txt-46)); }

/* One consistent, clearly visible keyboard focus ring everywhere */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--pm-focus) !important;
  outline-offset: 3px;
}

/* ---------- navigation ---------- */
.site-nav { border-bottom: 1px solid var(--pm-line); }
.nav-logo { font-family: var(--pm-display); font-weight: 600; font-size: 1.12rem; letter-spacing: 0.04em; color: var(--pm-silver); }
.nav-logo::before { content: none; display: none; }   /* the dragon icon (.nav-logo-icon) replaces the old accent bar */
.site-nav .mp-open {
  font-family: var(--pm-sans); font-weight: 600; color: var(--pm-silver);
  border: 1px solid rgba(var(--cy-line-3), 0.35); background: linear-gradient(180deg, rgba(var(--cy-wash-11), 0.1), rgba(var(--cy-wash-11), 0.03));
  transition: transform .2s var(--pm-ease), border-color .2s, box-shadow .25s, background .2s;
}
.site-nav .mp-open:hover { transform: translateY(-1px); border-color: var(--pm-line-hi); box-shadow: 0 6px 22px rgba(var(--cy-glow-7), 0.22); background: rgba(var(--cy-wash-11), 0.14); }

/* ---------- puzzle panel + gallery ---------- */
.dragon-puzzle {
  border: 1px solid var(--pm-line);
  box-shadow: 0 30px 80px rgba(var(--shade-1), calc(0.55 * var(--shade-k))), inset 0 1px 0 rgba(var(--hi-4), calc(0.04 * var(--hi-k)));
}
.dragon-puzzle .dp-title { font-weight: 600; background: linear-gradient(180deg, rgb(var(--wash-14)) 25%, rgb(var(--wash-9)) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gallery-label { font-family: var(--pm-sans); font-weight: 600; font-size: 0.74rem; letter-spacing: 0.16em; color: var(--pm-fog); }
.picker button { transition: border-color .2s, background .2s, transform .2s var(--pm-ease), box-shadow .25s; }
.picker button:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(var(--shade-1), calc(0.4 * var(--shade-k))); }
.picker button[aria-pressed="true"] { box-shadow: 0 0 0 1px rgba(var(--cy-glow-12), 0.18), 0 8px 28px rgba(var(--cy-glow-5), 0.16); }
.gallery-track::before { background: linear-gradient(to right, rgb(var(--surf-6)) 8%, rgba(var(--surf-6), 0)); }
.gallery-track::after { background: linear-gradient(to left, rgb(var(--surf-6)) 8%, rgba(var(--surf-6), 0)); }

/* ---------- FEATURED "Browse All Puzzles" card ---------- */
.bp-feature { padding: 26px 12px 4px; }   /* below the puzzle and the quick gallery: a calm secondary entry, not the first thing on the page */
.bp-feature .bp-open {
  position: relative; overflow: hidden; width: 100%; min-height: 72px; padding: 12px 18px 12px 14px; border-radius: 18px;
  display: flex; align-items: center; gap: 16px; text-align: left; white-space: normal; cursor: pointer; appearance: none; color: var(--pm-silver);
  border: 1px solid rgba(var(--cy-line-3), 0.28);
  background:
    radial-gradient(60% 140% at 0% 50%, rgba(var(--cy-wash-11), 0.16), transparent 70%),
    linear-gradient(160deg, rgba(var(--surf-61), 0.78), rgba(var(--surf-21), 0.92));
  box-shadow: 0 14px 38px rgba(var(--shade-1), calc(0.45 * var(--shade-k))), inset 0 1px 0 rgba(var(--hi-4), calc(0.06 * var(--hi-k)));
  font-family: var(--pm-sans);
  transition: transform .28s var(--pm-ease), border-color .25s, box-shadow .3s;
}
.bp-feature .bp-open::after { /* a slow light sweep, only on hover */
  content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(var(--wash-14), 0.07) 50%, transparent 65%);
  transform: translateX(-120%); transition: transform .8s var(--pm-ease); pointer-events: none;
}
.bp-feature .bp-open:hover { transform: translateY(-2px); border-color: var(--pm-line-hi); background: radial-gradient(60% 140% at 0% 50%, rgba(var(--cy-wash-11), 0.22), transparent 70%), linear-gradient(160deg, rgba(var(--surf-68), 0.82), rgba(var(--surf-21), 0.94)); box-shadow: 0 20px 50px rgba(var(--shade-1), calc(0.55 * var(--shade-k))), 0 0 36px rgba(var(--cy-glow-7), 0.16); }
.bp-feature .bp-open:hover::after { transform: translateX(120%); }
.bp-feature .bp-open:active { transform: translateY(0) scale(0.995); }
.bp-open-orb { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: var(--pm-cyan); border: 1px solid rgba(var(--cy-line-3), 0.32); background: linear-gradient(150deg, rgba(var(--cy-wash-11), 0.2), rgba(var(--cy-wash-11), 0.04)); box-shadow: 0 0 24px rgba(var(--cy-glow-7), 0.2), inset 0 1px 0 rgba(var(--hi-4), calc(0.12 * var(--hi-k))); }
.bp-open-orb svg, .bp-open-go svg { display: block; }
.bp-open-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bp-open-title { font-family: var(--pm-display); font-weight: 600; font-size: clamp(1.1rem, 2.2vw, 1.3rem); line-height: 1.2; color: var(--pm-silver); }
.bp-open-sub { color: var(--pm-fog); font-size: 0.88rem; line-height: 1.4; }
.bp-open-stack { flex: none; display: flex; padding-left: 12px; }
.bp-open-stack img { width: 58px; height: 40px; margin-left: -12px; object-fit: cover; border-radius: 9px; border: 2px solid rgb(var(--surf-27)); box-shadow: 0 6px 14px rgba(var(--shade-1), calc(0.45 * var(--shade-k))); transition: transform .3s var(--pm-ease); }
.bp-open:hover .bp-open-stack img:nth-child(odd) { transform: translateY(-3px) rotate(-2deg); }
.bp-open:hover .bp-open-stack img:nth-child(even) { transform: translateY(2px) rotate(2deg); }
.bp-open-go { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: rgb(var(--txt-35)); background: rgba(var(--wash-14), 0.06); border: 1px solid var(--pm-line); box-shadow: none; transition: transform .25s var(--pm-ease); }
.bp-open:hover .bp-open-go { transform: translateX(3px); color: rgb(var(--onfill-1)); background: linear-gradient(135deg, rgb(var(--pri-fill-10)), rgb(var(--pri-fill-17))); border-color: transparent; }
@media (max-width: 720px) { .bp-open-stack { display: none; } }
@media (max-width: 480px) {
  .bp-feature .bp-open { gap: 12px; padding: 12px 14px 12px 12px; border-radius: 18px; }
  .bp-open-orb { width: 44px; height: 44px; border-radius: 14px; }
  .bp-open-sub { font-size: 0.8rem; }
  .bp-open-go { width: 38px; height: 38px; }
}

/* ---------- Browse modal ---------- */
.bp { background: radial-gradient(60% 50% at 50% 0%, rgba(var(--cy-wash-5), 0.16), transparent 70%), rgba(var(--surf-2), 0.82); }
.bp-panel { background: linear-gradient(180deg, rgb(var(--surf-34)), rgb(var(--surf-14))); border-color: rgba(var(--wash-8), 0.22); box-shadow: 0 30px 90px rgba(var(--shade-1), calc(0.7 * var(--shade-k))), 0 0 0 1px rgba(var(--cy-glow-12), 0.05); font-family: var(--pm-sans); }
.bp-title { font-family: var(--pm-display); font-weight: 600; font-size: 1.6rem; color: var(--pm-silver); }
.bp-sub { color: var(--pm-fog); }
.bp-close:hover { border-color: rgba(var(--cy-line-3), 0.6); background: rgba(var(--cy-wash-11), 0.1); }
.bp-tools { flex: none; display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 22px 14px; border-bottom: 1px solid rgba(var(--wash-6), 0.16); }   /* same 22px sides; equal space above and below the pills, and a hairline (like the header's) so cards scroll away under a clean edge instead of touching the pills */
.bp-tools[hidden] { display: none; }
.bp-tools button { appearance: none; min-height: 40px; padding: 6px 16px; border-radius: 999px; cursor: pointer; font: 600 0.84rem/1 var(--pm-sans); letter-spacing: 0.03em; color: var(--pm-fog); border: 1px solid var(--pm-line); background: rgba(var(--wash-14), 0.025); transition: color .2s, border-color .2s, background .2s; }
.bp-tools button:hover { color: var(--pm-silver); border-color: rgba(var(--wash-11), 0.4); }
.bp-tools button[aria-pressed="true"] { color: var(--pm-silver); border-color: rgba(var(--cy-line-3), 0.55); background: rgba(var(--cy-wash-11), 0.12); box-shadow: inset 0 -2px 0 rgba(var(--cy-glow-12), 0.6); }
.bp-card { border-radius: 16px; background: linear-gradient(165deg, rgba(var(--surf-61), 0.7), rgba(var(--surf-30), 0.9)); border-color: var(--pm-line); transition: transform .25s var(--pm-ease), border-color .2s, box-shadow .3s, background .2s; }
.bp-card:hover, .bp-card:focus-visible { transform: translateY(-4px); border-color: var(--pm-line-hi); background: linear-gradient(165deg, rgba(var(--surf-72), 0.8), rgba(var(--surf-30), 0.94)); box-shadow: 0 18px 40px rgba(var(--shade-1), calc(0.5 * var(--shade-k))), 0 0 28px rgba(var(--cy-glow-7), 0.16); }
.bp-card:active { transform: translateY(-1px) scale(0.99); }
.bp-card[aria-current="true"] { border-color: rgba(var(--cy-line-3), 0.7); background: linear-gradient(165deg, rgba(var(--cy-wash-1), 0.38), rgba(var(--surf-30), 0.92)); box-shadow: 0 0 0 1px rgba(var(--cy-glow-12), 0.22), 0 12px 34px rgba(var(--cy-glow-5), 0.2); }
.bp-card[aria-current="true"] .bp-meta { color: rgb(var(--cy-text-9)); }
.bp-thumb img { transition: transform .5s var(--pm-ease), opacity .3s; }
.bp-card:hover .bp-thumb img { transform: scale(1.05); }
.bp-thumb.is-loading { background: linear-gradient(100deg, rgb(var(--surf-32)) 30%, rgb(var(--surf-65)) 50%, rgb(var(--surf-32)) 70%) 0 0 / 220% 100%; animation: pm-shimmer 1.4s linear infinite; }
.bp-thumb.is-loading img { opacity: 0; }
.bp-thumb.is-broken { background: radial-gradient(circle at 50% 40%, rgb(var(--surf-55)), rgb(var(--surf-14))); }
.bp-thumb.is-broken::after { content: "Picture unavailable"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--pm-fog); font-size: 0.78rem; }
.bp-now { background: linear-gradient(135deg, rgb(var(--pri-fill-10)), rgb(var(--pri-fill-17))); color: rgb(var(--onfill-1)); box-shadow: 0 4px 12px rgba(var(--shade-1), calc(0.4 * var(--shade-k))); }
.bp-name { font-family: var(--pm-display); font-weight: 600; font-size: 1.02rem; line-height: 1.3; color: var(--pm-silver); }
.bp-meta { color: var(--pm-fog); }
.bp-grid-size::before { content: "·"; margin-right: 12px; color: rgba(var(--txt-17), 0.5); }
@media (max-width: 640px) { .bp-tools { padding: 12px 12px 12px; } .bp-grid-size::before { margin-right: 8px; } }

/* loading / empty / error */
.bp-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 20px; text-align: center; color: var(--pm-fog); }
.bp-state[hidden] { display: none; }
.bp-state strong { font: 600 1.3rem/1.25 var(--pm-display); color: var(--pm-silver); }
.bp-state span { max-width: 26rem; font-size: 0.92rem; }
.bp-state--error strong { color: rgb(var(--red-text-6)); }
.bp-spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(var(--cy-line-3), 0.2); border-top-color: var(--pm-cyan); animation: pm-spin .8s linear infinite; }
.bp-retry { appearance: none; min-height: 44px; margin-top: 6px; padding: 8px 22px; border-radius: 999px; cursor: pointer; font: 600 0.9rem/1 var(--pm-sans); color: rgb(var(--onfill-1)); border: 1px solid rgba(var(--pri-line-3), 0.5); background: linear-gradient(135deg, rgb(var(--pri-fill-10)), rgb(var(--pri-fill-17))); }
@keyframes pm-shimmer { to { background-position: -120% 0; } }
@keyframes pm-spin { to { transform: rotate(360deg); } }

/* ---------- Play with friends entry: a little more atmosphere ---------- */
.mp--flow .mp-pick { border-radius: 26px; }
.mp--flow .mp-pick-title { font-weight: 600; }
.mp--flow .mp-pick:focus-visible { outline-offset: 4px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bp-feature .bp-open, .bp-feature .bp-open::after, .bp-open-stack img, .bp-open-go, .bp-card, .bp-thumb img, .picker button, .site-nav .mp-open { transition: none !important; }
  .bp-feature .bp-open:hover, .bp-card:hover, .bp-card:focus-visible, .picker button:hover, .site-nav .mp-open:hover { transform: none !important; }
  .bp-open:hover .bp-open-stack img { transform: none !important; }
  .bp-thumb.is-loading, .bp-spinner { animation: none !important; }
  .dragon-puzzle .dp-fog i { animation: none !important; }
}

/* ---------- Join / Create: error + focus polish ---------- */
.mp--flow .mp-input[aria-invalid="true"] { border-color: rgba(var(--red-7), 0.75); box-shadow: 0 0 0 4px rgba(var(--red-5), 0.14); }
.mp--flow .mp-notice p.is-error { border-radius: 14px; }
.mp .mp-notice { scroll-margin-top: 16px; }

/* ---------- narrow phones: keep the nav on one line (these must come AFTER the base nav rules above) ---------- */
@media (max-width: 400px) {
  .nav-logo { font-size: 1.08rem; letter-spacing: 0.03em; gap: 7px; padding: 0 4px; }
  .site-nav .mp-open { padding-inline: 0.8rem; font-size: 0.84rem; letter-spacing: 0; }
}
@media (max-width: 340px) {
  .nav-logo { font-size: 0.95rem; letter-spacing: 0.01em; gap: 5px; padding: 0 2px; }
  .site-nav .mp-open { padding-inline: 0.55rem; font-size: 0.76rem; }
}

/* ---------- consistent page frame: nav stays at the top on every screen (the original page centred short screens vertically) ---------- */
body { align-items: flex-start; }
.page { min-height: 100vh; min-height: 100dvh; }


/* ==========================================================================
   STAGE 1: PROFILE (nav pill + menu) and MY BEST TIMES
   Visual only. profile.js builds the same elements, classes and data-pf hooks as before and keeps every handler.
   ========================================================================== */

/* ---- the nav control: a quiet pill with a ringed disc; the word "Profile" is drawn by CSS (the accessible name is the button's aria-label) ---- */
.pf-avatar { width: auto; min-width: 44px; padding: 0 4px; gap: 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; }
.pf-avatar-disc {
  width: 34px; height: 34px; position: relative; font-family: var(--pm-display); font-weight: 600; font-size: 0.98rem; color: var(--pm-silver);
  border: 1px solid rgba(var(--wash-8), 0.34); background: radial-gradient(circle at 50% 22%, rgb(var(--surf-74)), rgb(var(--surf-40)) 78%);
  box-shadow: inset 0 1px 0 rgba(var(--hi-4), calc(0.08 * var(--hi-k))), 0 4px 12px rgba(var(--shade-1), calc(0.4 * var(--shade-k)));
}
.pf-avatar[data-named="true"] .pf-avatar-disc { border-color: rgba(var(--cy-line-3), 0.6); box-shadow: inset 0 1px 0 rgba(var(--hi-4), calc(0.1 * var(--hi-k))), 0 0 0 2px rgba(var(--cy-glow-12), 0.1), 0 4px 14px rgba(var(--cy-glow-4), 0.28); }
.pf-avatar:hover .pf-avatar-disc, .pf-avatar[aria-expanded="true"] .pf-avatar-disc { border-color: rgba(var(--cy-line-5), 0.85); box-shadow: inset 0 1px 0 rgba(var(--hi-4), calc(0.12 * var(--hi-k))), 0 0 0 3px rgba(var(--cy-glow-12), 0.14), 0 6px 18px rgba(var(--cy-glow-4), 0.3); }
/* The text beside the disc is drawn by CSS from the button's data-label (profile.js sets it to the player's display name, or "Profile"
   while there is no name yet). It is not part of the button's text, so the button's text stays the initial and its accessible name
   stays the aria-label. Below 560px only the disc is shown, as before. */
.pf-avatar::after { content: attr(data-label); display: none; padding-right: 8px; font: 600 0.84rem/1 var(--pm-sans); letter-spacing: 0.04em; color: var(--pm-mist); transition: color 0.2s ease; }
.pf-avatar:hover::after, .pf-avatar[aria-expanded="true"]::after { color: var(--pm-silver); }
@media (min-width: 560px) {
  .pf-avatar { height: 44px; padding: 0 13px 0 4px; gap: 10px; border: 1px solid transparent; transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease; }
  .pf-avatar::after {
    display: block; padding: 0; max-width: clamp(4.5rem, 12vw, 10.5rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font: 600 0.9rem/1.25 var(--pm-sans); letter-spacing: 0.02em; unicode-bidi: plaintext;
  }
  /* a small chevron after the name: it says "this opens a menu" and turns over while the menu is open */
  .pf-avatar::before {
    content: ""; order: 3; flex: none; width: 6px; height: 6px; margin: 0 0 0 -1px;
    border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; color: var(--pm-fog);
    transform: translateY(-2px) rotate(45deg); transition: transform 0.2s ease, color 0.2s ease;
  }
  .pf-avatar:hover::before { color: var(--pm-silver); }
  .pf-avatar[aria-expanded="true"]::before { color: var(--pm-cyan); transform: translateY(1px) rotate(225deg); }
  /* with a name: the whole control reads as one quiet pill (teal-tinted hairline, faint glass), the name in silver */
  .pf-avatar[data-named="true"] {
    border-color: rgba(var(--cy-line-3), 0.22);
    background: linear-gradient(180deg, rgba(var(--cy-wash-11), 0.08), rgba(var(--wash-14), 0.02));
    box-shadow: inset 0 1px 0 rgba(var(--hi-4), calc(0.05 * var(--hi-k)));
  }
  .pf-avatar[data-named="true"]::after { color: var(--pm-silver); }
  .pf-avatar:hover, .pf-avatar[aria-expanded="true"] { border-color: var(--pm-line); background: rgba(var(--wash-14), 0.04); }
  .pf-avatar[data-named="true"]:hover, .pf-avatar[data-named="true"][aria-expanded="true"] {
    border-color: rgba(var(--cy-line-3), 0.5); background: linear-gradient(180deg, rgba(var(--cy-wash-11), 0.14), rgba(var(--wash-14), 0.03));
    box-shadow: inset 0 1px 0 rgba(var(--hi-4), calc(0.07 * var(--hi-k))), 0 0 16px rgba(var(--cy-glow-7), 0.16);
  }
}
@media (min-width: 560px) and (prefers-reduced-motion: reduce) { .pf-avatar, .pf-avatar::before, .pf-avatar::after { transition: none; } }

/* ---- PHONE profile control (below 560px): visual only. Same button, same click handler and menu; the bare initial becomes a
   compact, layered pill: a lit, ringed disc + a clear chevron that says "this opens a menu" and turns over while it is open.
   Name text stays hidden here (space), exactly as before; the accessible name is still the button's aria-label. ---- */
@media (max-width: 559.98px) {
  .pf-avatar {
    position: relative; height: 44px; min-width: 62px; padding: 0 11px 0 5px; gap: 7px; isolation: isolate;
    border: 1px solid rgba(var(--cy-line-3), 0.3);
    background:
      linear-gradient(180deg, rgba(var(--hi-4), calc(0.07 * var(--hi-k))), rgba(var(--hi-4), 0) 46%),
      linear-gradient(180deg, rgb(var(--surf-40)), rgb(var(--surf-14)));
    box-shadow:
      inset 0 1px 0 rgba(var(--hi-4), calc(0.12 * var(--hi-k))),
      inset 0 -1px 0 rgba(var(--shade-1), calc(0.35 * var(--shade-k))),
      0 0 0 1px rgba(var(--shade-1), calc(0.25 * var(--shade-k))),
      0 6px 16px rgba(var(--shade-1), calc(0.45 * var(--shade-k)));
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  /* a soft teal glow under the glass, strongest when named or open */
  .pf-avatar::after {
    content: ""; display: block; position: absolute; inset: 0; z-index: -1; padding: 0; border-radius: inherit; pointer-events: none;
    background: radial-gradient(120% 140% at 18% 0%, rgba(var(--cy-wash-11), 0.14), transparent 62%); opacity: 0.7; transition: opacity 0.2s ease;
  }
  .pf-avatar[data-named="true"] { border-color: rgba(var(--cy-line-3), 0.45); }
  .pf-avatar[data-named="true"]::after, .pf-avatar[aria-expanded="true"]::after { opacity: 1; }
  .pf-avatar-disc { width: 32px; height: 32px; font-size: 0.95rem; display: grid; place-items: center; flex: none; }
  /* chevron: a drawn caret, a touch larger and brighter than the desktop one so it reads on a small screen */
  .pf-avatar::before {
    content: ""; order: 3; flex: none; width: 7px; height: 7px; margin: 0 1px 0 0;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; border-radius: 1px; color: var(--pm-mist);
    transform: translateY(-2px) rotate(45deg); transition: transform 0.2s ease, color 0.2s ease;
  }
  .pf-avatar[aria-expanded="true"] { border-color: rgba(var(--cy-line-5), 0.8); box-shadow: inset 0 1px 0 rgba(var(--hi-4), calc(0.14 * var(--hi-k))), 0 0 0 1px rgba(var(--cy-glow-12), 0.18), 0 0 16px rgba(var(--cy-glow-7), 0.22), 0 6px 16px rgba(var(--shade-1), calc(0.45 * var(--shade-k))); }
  .pf-avatar[aria-expanded="true"]::before { color: var(--pm-cyan); transform: translateY(1px) rotate(225deg); }
  /* pressed: it sinks a little (inner shadow, tiny scale) so a tap always gives feedback */
  .pf-avatar:active {
    transform: scale(0.96); border-color: rgba(var(--cy-line-5), 0.85);
    box-shadow: inset 0 2px 6px rgba(var(--shade-1), calc(0.5 * var(--shade-k))), 0 0 0 1px rgba(var(--shade-1), calc(0.25 * var(--shade-k))), 0 2px 6px rgba(var(--shade-1), calc(0.4 * var(--shade-k)));
  }
  .pf-avatar:active::before { color: var(--pm-silver); }
  /* hover only where a real pointer exists, so a phone does not keep a "stuck" hover after a tap */
  .pf-avatar:hover { background: linear-gradient(180deg, rgba(var(--hi-4), calc(0.07 * var(--hi-k))), rgba(var(--hi-4), 0) 46%), linear-gradient(180deg, rgb(var(--surf-40)), rgb(var(--surf-14))); }
  @media (hover: hover) { .pf-avatar:hover { border-color: rgba(var(--cy-line-5), 0.7); } .pf-avatar:hover::before { color: var(--pm-silver); } }
  @media (hover: none) {
    .pf-avatar:hover .pf-avatar-disc { border-color: rgba(var(--wash-8), 0.34); }
    .pf-avatar[data-named="true"]:hover .pf-avatar-disc { border-color: rgba(var(--cy-line-3), 0.6); }
    .pf-avatar[aria-expanded="true"] .pf-avatar-disc { border-color: rgba(var(--cy-line-5), 0.85); }
  }
}
@media (max-width: 380px) { .pf-avatar { min-width: 56px; padding: 0 9px 0 4px; gap: 6px; } .pf-avatar-disc { width: 30px; height: 30px; font-size: 0.9rem; } }
@media (max-width: 559.98px) and (prefers-reduced-motion: reduce) { .pf-avatar, .pf-avatar::before, .pf-avatar::after { transition: none; } .pf-avatar:active { transform: none; } }

/* ---- the menu ---- */
.pf-menu {
  width: 320px; padding: 8px; border-radius: 18px; border: 1px solid rgba(var(--wash-8), 0.22);
  background: linear-gradient(180deg, rgb(var(--surf-40)), rgb(var(--surf-14)));
  box-shadow: 0 28px 70px rgba(var(--shade-1), calc(0.7 * var(--shade-k))), 0 0 0 1px rgba(var(--cy-glow-12), 0.05), inset 0 1px 0 rgba(var(--hi-4), calc(0.05 * var(--hi-k)));
  font-family: var(--pm-sans); scrollbar-width: thin; scrollbar-color: rgba(var(--wash-8), 0.3) transparent;
}
.pf-who {
  display: flex; align-items: center; gap: 14px; margin: 0 0 8px; padding: 14px;
  border: 1px solid var(--pm-line); border-radius: 14px;
  background: radial-gradient(90% 140% at 0% 0%, rgba(var(--cy-wash-11), 0.12), transparent 65%), rgba(var(--wash-14), 0.025);
}
.pf-who-disc {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  font: 600 1.35rem/1 var(--pm-display); color: var(--pm-silver); border: 1px solid rgba(var(--cy-line-3), 0.55);
  background: radial-gradient(circle at 50% 20%, rgb(var(--surf-78)), rgb(var(--surf-43)) 80%); box-shadow: 0 0 0 3px rgba(var(--cy-glow-12), 0.08), 0 6px 16px rgba(var(--shade-1), calc(0.4 * var(--shade-k)));
}
.pf-who-disc .pf-glyph { color: rgb(var(--txt-11)); width: 26px; height: 26px; }
.pf-who-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pf-who .pf-label, .pf-sub > .pf-label { font: 600 0.64rem/1 var(--pm-sans); letter-spacing: 0.16em; color: var(--pm-fog); }
.pf-name { margin: 0; font: 600 1.18rem/1.25 var(--pm-display); color: var(--pm-silver); overflow-wrap: anywhere; }
.pf-name.pf-none { color: var(--pm-fog); font-style: normal; font-weight: 500; }

.pf-item {
  position: relative; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; min-height: 58px; padding: 8px 12px; border-radius: 14px;
  color: var(--pm-mist); transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s var(--pm-ease);
}
.pf-item + .pf-item { margin-top: 2px; }
.pf-item:hover, .pf-item:focus-visible { background: rgba(var(--cy-wash-11), 0.07); border-color: rgba(var(--cy-line-3), 0.22); color: var(--pm-silver); }
.pf-item-ico { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--pm-cyan); border: 1px solid rgba(var(--cy-line-3), 0.22); background: linear-gradient(150deg, rgba(var(--cy-wash-11), 0.14), rgba(var(--cy-wash-11), 0.03)); transition: border-color 0.18s ease, box-shadow 0.2s ease; }
.pf-item:hover .pf-item-ico, .pf-item:focus-visible .pf-item-ico { border-color: rgba(var(--cy-line-5), 0.55); box-shadow: 0 0 16px rgba(var(--cy-glow-7), 0.22); }
.pf-item-ico svg, .pf-chev { display: block; }
.pf-item-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pf-item-title { font: 600 0.95rem/1.25 var(--pm-sans); color: inherit; }
.pf-hint { margin: 0; color: var(--pm-fog); font: 500 0.76rem/1.3 var(--pm-sans); }
.pf-chev { flex: none; color: rgba(var(--txt-17), 0.6); transition: transform 0.18s var(--pm-ease), color 0.18s ease; }
.pf-item:hover .pf-chev, .pf-item:focus-visible .pf-chev { transform: translateX(3px); color: var(--pm-cyan); }
.pf-item[aria-disabled="true"] { opacity: 0.6; }
.pf-item[aria-disabled="true"] .pf-item-ico { color: var(--pm-fog); border-color: var(--pm-line); background: rgba(var(--wash-14), 0.03); box-shadow: none; }
.pf-item[aria-disabled="true"] .pf-chev { display: none; }
.pf-item[aria-disabled="true"]:hover { background: transparent; border-color: transparent; color: var(--pm-mist); }

/* sub screens (rename / best times) */
.pf-sub { padding: 6px 8px 8px; }
.pf-back { min-height: 40px; margin: 0 0 6px -8px; padding: 4px 10px; border-radius: 10px; color: var(--pm-fog); font: 600 0.84rem/1 var(--pm-sans); letter-spacing: 0.02em; transition: color 0.18s ease, background-color 0.18s ease; }
.pf-back:hover { color: var(--pm-silver); background: rgba(var(--wash-14), 0.05); }
.pf-sub > .pf-label { display: block; margin: 0 0 10px; }
.pf-input { margin-top: 8px; border-radius: 12px; border-color: rgba(var(--wash-8), 0.3); background: rgba(var(--surf-6), 0.8); transition: border-color 0.18s ease, box-shadow 0.18s ease; }
.pf-input:focus { border-color: rgba(var(--cy-line-3), 0.7); box-shadow: 0 0 0 3px rgba(var(--cy-glow-12), 0.14); }
.pf-help { color: var(--pm-fog); }
.pf-btn { border-radius: 12px; font-weight: 600; }
.pf-btn--primary { color: rgb(var(--onfill-1)); border-color: transparent; background: linear-gradient(135deg, rgb(var(--pri-fill-10)), rgb(var(--pri-fill-17))); }
.pf-btn--primary:hover { border-color: transparent; background: linear-gradient(135deg, rgb(var(--pri-fill-13)), rgb(var(--pri-fill-20))); }

/* My Best Times: compact rows, played puzzles only */
.pf-summary { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 0 8px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--pm-line); background: rgba(var(--wash-14), 0.025); color: var(--pm-mist); font: 500 0.8rem/1.2 var(--pm-sans); }
.pf-summary-best { color: var(--pm-cyan); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-times { margin: 0; max-height: min(46vh, 340px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(var(--wash-8), 0.3) transparent; }
.pf-times li { align-items: center; gap: 12px; min-height: 44px; padding: 6px 12px; border-bottom: 0; border-radius: 10px; transition: background-color 0.15s ease; }
.pf-times li:nth-child(odd) { background: rgba(var(--wash-14), 0.025); }
.pf-times li:hover { background: rgba(var(--cy-wash-11), 0.07); }
.pf-t-name { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pf-t-title { color: var(--pm-silver); font: 600 0.88rem/1.25 var(--pm-sans); overflow-wrap: anywhere; }
.pf-t-meta { color: var(--pm-fog); font: 500 0.7rem/1.2 var(--pm-sans); letter-spacing: 0.02em; }
.pf-times .pf-t { flex: none; color: var(--pm-silver); font: 700 1.02rem/1 var(--pm-sans); letter-spacing: -0.01em; }
.pf-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 14px 14px; text-align: center; }
.pf-empty-ico { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; color: var(--pm-cyan); border: 1px solid rgba(var(--cy-line-3), 0.25); background: linear-gradient(150deg, rgba(var(--cy-wash-11), 0.14), rgba(var(--cy-wash-11), 0.02)); }
.pf-empty-ico svg { display: block; }
.pf-empty-title { font: 600 1.1rem/1.2 var(--pm-display); color: var(--pm-silver); }
.pf-empty .pf-help { margin: 0; max-width: 17rem; }

@media (max-width: 400px) { .pf-menu { width: min(320px, calc(100vw - 24px)); } }
@media (prefers-reduced-motion: reduce) { .pf-item, .pf-chev, .pf-item-ico, .pf-avatar, .pf-avatar::after, .pf-back, .pf-times li, .pf-input { transition: none !important; } .pf-item:hover .pf-chev { transform: none; } }
