/* ---------- Whole board: My games (profile import and its dashboard) ----------
   Prefix pf-. The panel half (lookup, card, story, table) lives in #viz-controls;
   the dashboard half fills #stage. Charts are inline SVG or plain flex bars in
   one accent hue, with fixed result colours (win, draw, loss) that never change
   job. Everything reads on the app's dark surfaces. */

/* ----- Panel: lookup ----- */

.pf-lookup { display: flex; flex-direction: column; gap: 8px; }
.pf-sites { display: inline-flex; gap: 4px; }
.pf-site { font-size: 0.85rem; padding: 4px 10px; }
.pf-name-row { display: flex; gap: 6px; }
.pf-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
.pf-name:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.pf-go { flex: 0 0 auto; }
.pf-recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pf-recent-label, .pf-try-label { color: var(--muted); font-size: 0.85rem; }
.pf-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--control);
  border: 1px solid var(--line);
}
.pf-chip-site { color: var(--muted); font-size: 0.72rem; }
.pf-status { min-height: 1.2em; font-size: 0.85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.pf-status.error { color: #f2a2a2; }
.pf-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: pf-spin 0.9s linear infinite;
}
@keyframes pf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pf-spinner { animation: none; border-top-color: var(--line); } }

/* ----- Panel: profile card ----- */

.pf-card {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px 12px;
  align-items: center;
}
.pf-face {
  width: 56px; height: 56px; border-radius: 14px; overflow: hidden;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 1.6rem;
}
.pf-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-who { min-width: 0; }
.pf-name-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pf-title { font-size: 0.72rem; font-weight: 700; color: #f5c542; letter-spacing: 0.04em; }
.pf-display { font-weight: 700; font-size: 1.05rem; }
.pf-flag { font-size: 1rem; }
.pf-handle { color: var(--accent); font-size: 0.85rem; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-handle:hover { text-decoration: underline; }
.pf-since { color: var(--muted); font-size: 0.8rem; }
.pf-ratings { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; }
.pf-rating {
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
}
.pf-rating.selected { border-color: var(--accent); }
.pf-rating-label { font-size: 0.72rem; color: var(--label); text-transform: uppercase; letter-spacing: 0.04em; }
.pf-rating-value { font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.pf-rating-note { font-size: 0.72rem; color: var(--muted); }

/* ----- Panel: story and table ----- */

.pf-story { margin: 12px 0 4px; }
.pf-story p { margin: 0 0 6px; font-size: 0.92rem; }
.pf-story p:first-child { font-weight: 600; }
.pf-games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pf-game {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center;
  padding: 6px 2px; border-bottom: 1px solid var(--line); min-width: 0;
}
.pf-game:last-child { border-bottom: 0; }
.pf-res { display: inline-flex; justify-content: center; }
.pf-game-main { min-width: 0; }
.pf-game-top { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-as { font-weight: 600; }
.pf-vs { color: var(--muted); }
.pf-game-sub { font-size: 0.76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-replay { font-size: 0.78rem; padding: 2px 8px; }

/* ----- Stage: the dashboard ----- */

.pf-dash {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pf-dash-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.pf-dash-title { font-weight: 700; font-size: 1.15rem; }
.pf-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.pf-filter {
  display: inline-flex; gap: 6px; align-items: baseline;
  padding: 4px 10px; border-radius: 999px; font-size: 0.85rem;
  background: var(--panel); border: 1px solid var(--line);
}
.pf-filter.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.pf-filter-n { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.pf-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.pf-kpi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
}
.pf-kpi-label { font-size: 0.75rem; color: var(--label); text-transform: uppercase; letter-spacing: 0.04em; }
.pf-kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.pf-kpi-note { font-size: 0.78rem; color: var(--muted); }
.pf-kpi.up .pf-kpi-note { color: #4fd1b0; }
.pf-kpi.down .pf-kpi-note { color: #f2a2a2; }
.pf-form { margin-top: 4px; }

.pf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pf-chart {
  position: relative;
  padding: 12px 14px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.pf-chart:first-child { grid-column: 1 / -1; }
.pf-chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.pf-chart-title { margin: 0; font-size: 0.95rem; font-weight: 600; }
.pf-chart-note { font-size: 0.78rem; color: var(--muted); }
.pf-empty { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* Line chart */
.pf-plot { position: relative; }
.pf-svg { width: 100%; height: auto; display: block; }
.pf-grid { stroke: var(--line); stroke-width: 1; }
.pf-axis { fill: var(--label); font-size: 11px; }
.pf-path { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; opacity: 0.8; }
.pf-path.focus { stroke-width: 2.25; opacity: 1; }
.pf-area { opacity: 0.12; }
.pf-end { stroke: var(--panel); stroke-width: 2; }
.pf-label { fill: var(--muted); font-size: 11px; }
.pf-label.focus { fill: var(--text); font-weight: 600; }
.pf-cross { stroke: var(--label); stroke-width: 1; opacity: 0.6; pointer-events: none; }
.pf-cross-dot { fill: var(--text); stroke: #3987e5; stroke-width: 2; pointer-events: none; }

/* Tooltip shared by every chart */
.pf-tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--control);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  font-size: 0.8rem;
  max-width: 200px;
  transform: translateY(-100%);
}
.pf-tip-head { font-weight: 600; }
.pf-tip-line { color: var(--muted); }

/* Legend: text wears text colours, the swatch carries identity */
.pf-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.78rem; color: var(--label); }
.pf-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pf-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

/* Stacked result bars */
.pf-stacks { display: flex; flex-direction: column; gap: 10px; }
.pf-stack-row { display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; gap: 2px 10px; align-items: center; }
.pf-stack-label { font-weight: 600; font-size: 0.88rem; grid-row: 1 / span 2; }
.pf-stack-n { font-size: 0.75rem; color: var(--muted); }
.pf-stack { display: flex; gap: 2px; height: 22px; border-radius: 4px; overflow: hidden; background: var(--panel-2); }
.pf-seg { flex: 0 0 var(--w); min-width: 0; background: var(--c); display: grid; place-items: center; position: relative; transition: filter 0.15s; }
.pf-seg:hover { filter: brightness(1.15); }
.pf-seg-label { font-size: 0.75rem; font-weight: 600; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }

/* Single-hue horizontal bars */
.pf-bars { display: flex; flex-direction: column; gap: 6px; }
.pf-bar-row { display: grid; grid-template-columns: minmax(70px, 40%) 1fr 30px; gap: 8px; align-items: center; font-size: 0.85rem; }
.pf-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-bar-track { height: 12px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.pf-bar-fill { display: block; height: 100%; width: var(--w); min-width: 3px; border-radius: 0 4px 4px 0; background: #3987e5; transition: filter 0.15s; }
.pf-bar-row:hover .pf-bar-fill { filter: brightness(1.15); }
.pf-bar-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--label); }
.pf-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pf-half { min-width: 0; }
.pf-half-title { margin: 0 0 6px; font-size: 0.8rem; font-weight: 600; color: var(--label); }
.pf-openings { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }
.pf-openings-label { color: var(--label); }

/* Heatmap: weekday by time of day */
.pf-heat { display: grid; grid-template-columns: 76px repeat(7, minmax(0, 1fr)); gap: 3px; align-items: center; }
.pf-heat-day, .pf-heat-slot { font-size: 0.75rem; color: var(--muted); text-align: center; }
.pf-heat-slot { text-align: right; padding-right: 6px; }
.pf-heat-cell { display: block; aspect-ratio: 1.6; border-radius: 4px; background: var(--panel-2); }
.pf-heat-cell[data-level="1"] { background: rgba(57, 135, 229, 0.25); }
.pf-heat-cell[data-level="2"] { background: rgba(57, 135, 229, 0.42); }
.pf-heat-cell[data-level="3"] { background: rgba(57, 135, 229, 0.6); }
.pf-heat-cell[data-level="4"] { background: rgba(57, 135, 229, 0.8); }
.pf-heat-cell[data-level="5"] { background: #3987e5; }
.pf-heat-cell:hover { outline: 2px solid var(--text); outline-offset: -2px; }
.pf-ramp { display: flex; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--muted); justify-content: flex-end; }
.pf-ramp-step { width: 16px; height: 10px; aspect-ratio: auto; }

/* Story / Rivals switch in the dashboard head */
.pf-dash-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pf-views { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.pf-view { padding: 4px 12px; font-size: 0.85rem; border: 0; border-radius: 0; background: var(--panel); }
.pf-view.selected { background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* Rivals: the peer table. One bar per player scaled to the table's range,
   the player's own row in the accent, everyone else grey (emphasis form). */
.pf-rivals, .pf-eliminated { width: 100%; }
.pf-rival-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--label); }
.pf-rival-list { display: flex; flex-direction: column; gap: 2px; }
.pf-rival {
  display: grid;
  grid-template-columns: 28px minmax(120px, 1.2fr) minmax(60px, 2fr) 52px 64px;
  gap: 8px; align-items: center;
  padding: 5px 6px; border-radius: 8px; font-size: 0.88rem;
}
.pf-rival.me { background: var(--accent-soft); }
.pf-rival-head { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-bottom: 2px; }
.pf-rival-rank { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.pf-rival.me .pf-rival-rank { color: var(--text); font-weight: 700; }
.pf-rival-who { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.pf-rival-name { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-rival-name:hover { text-decoration: underline; }
.pf-rival.me .pf-rival-name { font-weight: 700; }
.pf-rival-you { font-size: 0.7rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.pf-rival-status { font-size: 0.72rem; color: #f2a2a2; white-space: nowrap; }
.pf-rival-track { height: 10px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.pf-rival-fill { display: block; height: 100%; width: var(--w); border-radius: 0 4px 4px 0; background: var(--rival-bar, #6b6f7a); }
.pf-rival.me .pf-rival-fill { --rival-bar: #3987e5; }
.pf-rival-rating { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pf-rival-record { text-align: right; font-variant-numeric: tabular-nums; color: var(--label); font-size: 0.82rem; }
.pf-rival-summary { margin: 4px 0 0; font-size: 0.88rem; }
.pf-rival-unrated { margin: 0; font-size: 0.8rem; color: var(--muted); }
.pf-eliminated .pf-rival-track { visibility: hidden; }
.pf-eliminated .pf-rival-rating { color: var(--muted); font-weight: 400; }
.pf-eliminated .pf-rival-name { color: var(--muted); text-decoration: line-through; }
.pf-eliminated .pf-rival-name:hover { text-decoration: line-through underline; }

/* Welcome, before anyone is looked up */
.pf-welcome {
  max-width: 560px; margin: 24px auto; padding: 20px 22px;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  text-align: center;
}
.pf-welcome-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.pf-welcome-text { margin: 0 0 12px; color: var(--label); }
.pf-try { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.pf-loading { text-align: center; color: var(--muted); }

/* Narrow screens: one column, shorter labels */
@media (max-width: 760px) {
  .pf-grid, .pf-two { grid-template-columns: 1fr; }
  .pf-heat { grid-template-columns: 64px repeat(7, minmax(0, 1fr)); }
  .pf-kpi-value { font-size: 1.5rem; }
  .pf-rival { grid-template-columns: 22px minmax(90px, 1.4fr) minmax(36px, 1fr) 44px 50px; gap: 6px; font-size: 0.82rem; padding: 4px 4px; }
  .pf-rival-record { font-size: 0.75rem; }
  .pf-rival-flag { display: none; }
}
