/* profile.css: the "My stats" panel + achievement banner for game-profile (profile.js).
   Copy unchanged into css/profile.css. Colours come from the game's own variables when it has them
   (--card, --line, --text, --muted, --accent, --good, --bad), so the panel matches each game. */

.pf-ov {
  position: fixed; inset: 0; z-index: 900; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .55); -webkit-tap-highlight-color: transparent;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  animation: pf-fade .18s ease;
}
@keyframes pf-fade { from { opacity: 0; } }
@keyframes pf-up { from { transform: translateY(24px); opacity: .4; } }
.pf-panel {
  --pf-card: var(--card, #1a1e2b); --pf-line: var(--line, #2a3042); --pf-text: var(--text, #e8eaf0);
  --pf-muted: var(--muted, #969db4); --pf-acc: var(--accent, #6ea8fe); --pf-good: var(--good, #6ee7a8); --pf-bad: var(--bad, #f08c8c);
  /* fixed height: switching tabs or editing never makes the panel jump */
  box-sizing: border-box; width: 100%; max-width: 480px; height: min(82vh, 600px); height: min(82dvh, 600px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--pf-card); color: var(--pf-text); border: 1px solid var(--pf-line); border-bottom: 0;
  border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  font: 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  animation: pf-up .22s cubic-bezier(.3, .7, .3, 1);
}
.pf-panel *, .pf-panel *::before, .pf-panel *::after { box-sizing: border-box; }
.pf-panel button { font: inherit; color: inherit; }

/* head: who you are, Elo, close */
.pf-head {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 12px;
  border-bottom: 1px solid var(--pf-line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent);
}
.pf-me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding: 2px; border: 0; background: none; cursor: pointer; text-align: left; border-radius: 10px; }
.pf-me:active { transform: scale(.98); }
.pf-av { flex: none; display: block; border-radius: 50%; }
.pf-who { display: flex; flex-direction: column; min-width: 0; }
.pf-who b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-who small { color: var(--pf-acc); font-size: 12.5px; }
.pf-elo { flex: none; display: flex; flex-direction: column; align-items: center; line-height: 1.1; padding: 0 4px; }
.pf-elo b { font-size: 24px; font-variant-numeric: tabular-nums; }
.pf-elo small { color: var(--pf-muted); font-size: 11.5px; }
.pf-x { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .06); cursor: pointer; color: var(--pf-muted); }
.pf-x:hover { color: var(--pf-text); }

/* totals row */
.pf-nums { flex: none; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 10px 8px 8px; text-align: center; }
.pf-nums > div { display: flex; flex-direction: column; min-width: 0; }
.pf-nums b { font-size: 20px; font-variant-numeric: tabular-nums; }
.pf-nums small { color: var(--pf-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-nums2 { grid-template-columns: repeat(2, 1fr); padding: 6px 0; }

/* tabs (phone) */
.pf-tabs { flex: none; display: flex; gap: 4px; padding: 0 10px 8px; }
.pf-tabs button { flex: 1; min-height: 38px; border: 1px solid var(--pf-line); border-radius: 9px; background: transparent; color: var(--pf-muted); cursor: pointer; font-size: 14px; }
.pf-tabs button[aria-selected="true"] { background: rgba(110, 168, 254, .14); border-color: var(--pf-acc); color: var(--pf-text); }

.pf-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 14px; -webkit-overflow-scrolling: touch; }
.pf-sec { display: none; }
.pf-body[data-show="levels"] [data-sec="levels"], .pf-body[data-show="awards"] [data-sec="awards"], .pf-body[data-show="daily"] [data-sec="daily"] { display: block; }
.pf-sec h4 { margin: 6px 0 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--pf-muted); display: flex; justify-content: space-between; }
.pf-n { text-transform: none; letter-spacing: 0; color: var(--pf-text); }

/* level table */
.pf-tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pf-tbl th { font-size: 11.5px; font-weight: 500; color: var(--pf-muted); text-align: center; padding: 2px 4px 4px; }
.pf-tbl th:first-child, .pf-tbl td:first-child { text-align: left; }
.pf-tbl td { text-align: center; padding: 7px 4px; border-top: 1px solid var(--pf-line); font-size: 15px; }
.pf-tbl td:first-child b { font-weight: 600; }
.pf-tbl td:first-child small { margin-left: 6px; color: var(--pf-muted); font-size: 11.5px; }
.pf-tbl td:last-child { font-weight: 600; }
.pf-modes td { text-align: left; }

/* achievements */
.pf-aw { display: grid; grid-template-columns: 1fr; gap: 6px; }
.pf-a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .03); }
.pf-a svg { flex: none; }
.pf-a span { display: flex; flex-direction: column; min-width: 0; }
.pf-a b { font-size: 14.5px; font-weight: 600; }
.pf-a small { color: var(--pf-muted); font-size: 12.5px; }
.pf-a:not(.on) b { color: var(--pf-muted); }

/* daily */
.pf-day { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0 6px; }
.pf-today { display: flex; flex-direction: column; }
.pf-today small { color: var(--pf-muted); font-size: 12px; }
.pf-today b { font-size: 18px; }
.pf-strip { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; padding-top: 6px; }
.pf-dd { display: block; aspect-ratio: 1; max-height: 22px; border-radius: 5px; background: rgba(255, 255, 255, .07); }
.pf-dd.r-w { background: var(--pf-good); } .pf-dd.r-l { background: var(--pf-bad); } .pf-dd.r-d, .pf-dd.r-p { background: var(--pf-acc); }

/* buttons */
.pf-btn { min-height: 40px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--pf-line); background: rgba(255, 255, 255, .05); cursor: pointer; font-size: 14.5px; }
.pf-btn.pri { background: var(--pf-acc); border-color: var(--pf-acc); color: #0d1424; font-weight: 600; }
.pf-btn:disabled { opacity: .45; cursor: default; }
.pf-btn:active:not(:disabled) { transform: scale(.97); }

/* edit name + picture */
.pf-edit { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.pf-lab { font-size: 12.5px; color: var(--pf-muted); }
.pf-edit input[type="text"] { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--pf-line); background: rgba(0, 0, 0, .25); color: var(--pf-text); font: inherit; font-size: 16px; }
.pf-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.pf-pick button { padding: 3px; border: 2px solid transparent; border-radius: 50%; background: none; cursor: pointer; aspect-ratio: 1; display: grid; place-items: center; }
.pf-pick button .pf-av { width: 100%; height: auto; }
.pf-pick button[aria-checked="true"] { border-color: var(--pf-acc); }
.pf-row { display: flex; gap: 8px; padding-top: 4px; }
.pf-row .pri { margin-left: auto; }
.pf-msg { min-height: 18px; font-size: 13px; color: var(--pf-muted); }

/* achievement banner (top of the screen, never moves the page) */
.pf-banner {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top, 0)); z-index: 950; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 10px; max-width: calc(100vw - 24px);
  border-radius: 14px; background: var(--card, #1a1e2b); color: var(--text, #e8eaf0); border: 1px solid #9c7414;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5); font: 600 15px/1.25 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  pointer-events: none; animation: pf-drop .3s cubic-bezier(.3, .7, .3, 1.2);
  transition: opacity .35s, transform .35s;
}
.pf-banner span { display: flex; flex-direction: column; min-width: 0; }
.pf-banner small { font: 500 11.5px/1.2 system-ui, sans-serif; color: #e8b53a; text-transform: uppercase; letter-spacing: .05em; }
.pf-banner em { font-style: normal; font-weight: 500; color: #cdbb98; }
.pf-banner.out { opacity: 0; transform: translate(-50%, -12px); }
@keyframes pf-drop { from { transform: translate(-50%, -24px); opacity: 0; } }

/* the button a game puts in its UI: <button class="pf-open">… */
.pf-open { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.pf-open .pf-av { width: 28px; height: 28px; }

/* laptop: a centred card, the three sections side by side, no tabs */
@media (min-width: 900px) and (min-height: 520px) {
  .pf-ov { align-items: center; padding: 24px; }
  .pf-panel { max-width: 920px; height: auto; min-height: min(86vh, 440px); max-height: min(86vh, 620px); border-bottom: 1px solid var(--pf-line); border-radius: 16px; }
  .pf-head { padding: 14px 16px 12px; }
  .pf-nums { padding: 12px 16px 10px; }
  .pf-nums b { font-size: 24px; }
  .pf-tabs { display: none; }
  .pf-body { display: grid; grid-template-columns: 1.15fr 1fr; gap: 0 22px; padding: 0 16px 16px; }
  .pf-body:has(> [data-sec="daily"]) { grid-template-columns: 1.15fr 1fr .85fr; }
  .pf-body .pf-sec { display: block; min-width: 0; }
  .pf-pick { grid-template-columns: repeat(16, 1fr); }
  .pf-edit { padding: 14px 16px 16px; }
}
/* phone on its side: little height, so use the width */
@media (max-height: 519px) and (orientation: landscape) {
  .pf-ov { align-items: center; padding: 8px; }
  .pf-panel { max-width: 760px; height: calc(100vh - 16px); height: calc(100dvh - 16px); border-radius: 14px; border-bottom: 1px solid var(--pf-line); }
  .pf-head { padding: 6px 10px; }
  .pf-head .pf-av { width: 36px; height: 36px; }
  .pf-nums { padding: 4px 8px; }
  .pf-nums b { font-size: 17px; }
  .pf-tabs { padding-bottom: 4px; }
  .pf-tabs button { min-height: 32px; }
  .pf-tbl td { padding: 4px; }
  .pf-pick { grid-template-columns: repeat(16, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .pf-ov, .pf-panel, .pf-banner { animation: none; } }
