/* Pages des profils [F] : classement, profil, magnétoscope, compte, administration.
   S'ajoute à style.css (couleurs du tapis, boutons, cartes). Graphiques : méthode dataviz
   (traits fins, une seule couleur par série, valeurs écrites, infobulles, tableau des données). */

body.pf {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, var(--felt-light), var(--felt-dark) 70%) fixed;
  --ink-2: #52514e;
  --viz-blue: #2a78d6;
  --viz-red: #e34948;
  --viz-mid: #e1e0d9;
  --hairline: #efede6;
}

/* ---------- barre du haut */
.pf-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(10, 40, 26, .9); color: #fff;
}
.pf-top .brand { text-decoration: none; font-weight: 800; letter-spacing: 3px; color: var(--accent); }
.pf-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; min-width: 0; }
.pf-nav a {
  color: rgba(255,255,255,.85); text-decoration: none; padding: 6px 10px; border-radius: 8px;
  font-size: 14px; white-space: nowrap;
}
.pf-nav a:hover { background: rgba(255,255,255,.1); }
.pf-nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.pf-auth { font-size: 14px; white-space: nowrap; }
.pf-top .btn.ghost { text-decoration: none; }

/* ---------- mise en page */
.pf-main { max-width: 1080px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.pf .panel { padding: 18px 20px; border-radius: 14px; }
.pf-section h2 { margin: 0 0 6px; font-size: 18px; color: var(--felt); }
.pf-intro { margin: 0 0 12px; font-size: 13px; line-height: 1.45; }
.pf-loading { text-align: center; color: var(--muted); }
.pf-empty h1 { margin-top: 0; color: var(--felt); }
.pf-empty .btn { text-decoration: none; display: inline-block; }
.pf-empty-line { color: var(--muted); margin: 6px 0; }
.pf-more { display: inline-block; margin-top: 10px; font-size: 14px; color: var(--felt); }
.pf-note { font-size: 13px; margin: 8px 0 0; }
.pf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pf-warn { background: #fff8e6; border-left: 4px solid var(--accent); font-weight: 600; }

/* ---------- en-tête du profil */
.pf-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pf-avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--felt); color: #fff; flex: none;
  font-size: 30px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.pf-id { flex: 1 1 220px; min-width: 0; }
.pf-id h1 { margin: 0; font-size: 26px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.pf-id p { margin: 4px 0 0; font-size: 14px; }
.pf-elo { text-align: right; }
.pf-elo-value { font-size: 46px; font-weight: 700; line-height: 1.05; }

/* ---------- tuiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border-radius: 12px; padding: 12px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.pf-section .tile { box-shadow: none; border: 1px solid var(--border); }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 650; margin: 2px 0; }
.tile-sub { font-size: 12px; color: var(--ink-2); }

/* ---------- onglets */
.pf-tabs { display: flex; gap: 4px; overflow-x: auto; background: rgba(0,0,0,.22); padding: 4px; border-radius: 12px; }
.pf-tab {
  color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 9px; font-size: 14px;
  font-weight: 600; white-space: nowrap; opacity: .85;
}
.pf-tab:hover { background: rgba(255,255,255,.1); opacity: 1; }
.pf-tab.active { background: var(--panel); color: var(--felt); opacity: 1; }
.pf-content { display: flex; flex-direction: column; gap: 14px; }

/* ---------- tableaux */
.table-scroll { overflow-x: auto; }
.pf-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pf-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.pf-table td { padding: 8px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.pf-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-table td.strong, .pf-table tr.strong-row td { font-weight: 700; }
.pf-table tr.is-me td { background: #fff8e6; }
.pf-table td.rank { width: 2.5em; text-align: center; }
.player-name { color: var(--ink); font-weight: 600; text-decoration: none; }
a.player-name:hover { text-decoration: underline; }
.data-table { margin-top: 12px; font-size: 13px; }
.data-table summary { cursor: pointer; color: var(--felt); font-weight: 600; }
.data-table table { margin-top: 8px; }

/* ---------- robots repères */
.bot-refs { display: flex; flex-wrap: wrap; gap: 8px; }
.bot-ref {
  display: flex; gap: 10px; align-items: center; padding: 6px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 99px;
}

/* ---------- légendes, barres, face-à-face */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin: 0 0 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend-line { width: 16px; height: 2px; border-radius: 1px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-swatch.win, .seg.win { background: var(--viz-blue); }
.legend-swatch.tie, .seg.tie { background: var(--viz-mid); }
.legend-swatch.loss, .seg.loss { background: var(--viz-red); }
.h2h-row { padding: 10px 0; border-top: 1px solid var(--hairline); }
.legend + .h2h-row { border-top: none; }
.h2h-who { font-size: 15px; margin-bottom: 6px; }
.h2h-line { display: flex; align-items: center; gap: 10px; }
.stack { flex: 1; display: flex; gap: 2px; height: 16px; min-width: 0; }
.seg { min-width: 4px; height: 100%; }
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:only-child { border-radius: 4px; }
.seg:hover, .seg:focus { filter: brightness(1.12); outline: none; }
.h2h-pct { width: 7.5em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.h2h-detail { font-size: 12px; margin-top: 4px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; border-radius: 6px; }
.bar-row:focus { outline: 2px solid var(--hl); outline-offset: 2px; }
.bar-label { width: 9.5em; flex: none; color: var(--ink-2); }
.bar-track { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar { height: 14px; background: var(--viz-blue); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row:hover .bar { filter: brightness(1.12); }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- graphiques */
.chart { width: 100%; min-height: 200px; }
.chart-svg { display: block; max-width: 100%; }
.chart-svg:focus { outline: 2px solid var(--hl); outline-offset: 2px; border-radius: 6px; }
.chart-tick { font-size: 11px; fill: #898781; font-variant-numeric: tabular-nums; }
.chart-ref { font-size: 11px; fill: var(--ink-2); }
.viz-tip {
  position: fixed; z-index: 90; pointer-events: none; background: #fff; color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); max-width: 260px;
}
.tip-title { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tip-row b { font-variant-numeric: tabular-nums; }

/* ---------- trophées */
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.trophy {
  display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #faf9f6;
}
.trophy:not(.got) .trophy-name, .trophy:not(.got) .trophy-desc { color: var(--muted); }
.trophy.got { background: #fffaf0; border-color: #f3d38a; }
.trophy-emoji { font-size: 30px; line-height: 1; filter: grayscale(1); opacity: .45; }
.trophy.got .trophy-emoji { filter: none; opacity: 1; }
.trophy-body { min-width: 0; flex: 1; }
.trophy-name { font-weight: 700; }
.trophy-desc { font-size: 13px; color: var(--ink-2); }
.trophy-when { font-size: 12px; color: var(--muted); margin-top: 4px; }
.trophy-when a { color: var(--felt); }
.meter { height: 6px; background: #cde2fb; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--viz-blue); border-radius: 99px; }

/* ---------- parties */
.games { display: flex; flex-direction: column; }
.game-row {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; padding: 10px 0;
  border-top: 1px solid var(--hairline); align-items: center;
}
.games .game-row:first-child, .pf-section h2 + .game-row { border-top: none; }
.g-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); grid-column: 1; }
.g-players { grid-column: 1; font-size: 14px; }
.g-player.is-me { font-weight: 700; }
.g-player a { color: inherit; }
.g-level { color: var(--muted); font-size: 12px; }
.g-score { font-variant-numeric: tabular-nums; }
.g-sep { color: var(--muted); }
.g-meta { grid-column: 1; font-size: 12px; }
.g-replay { grid-column: 2; grid-row: 1 / span 3; text-decoration: none; white-space: nowrap; }
span.g-replay { font-size: 12px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.badge.ok { background: #e8f6ee; color: #155f2e; }
.badge.bad { background: #fdecea; color: #a12622; }
.badge.live { background: #fff1cf; color: #7a5300; }
.badge.off { background: #f0efec; color: var(--ink-2); }

/* ---------- compte et administration */
.pf-form { max-width: 420px; }
.pf-section .field.inline { max-width: 560px; gap: 12px; }
.pf-section .field.inline span { font-size: 14px; color: var(--ink); }
.pf-section .field.inline input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--felt); flex: none; }
.admin-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0;
  border-top: 1px solid var(--hairline); font-size: 14px;
}
.pf-intro + .admin-row { border-top: none; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
code.pw { background: #f6f4ee; padding: 3px 8px; border-radius: 6px; font-size: 15px; }

/* ---------- magnétoscope */
.rp { display: flex; flex-direction: column; gap: 12px; }
.rp-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.rp-head .btn { text-decoration: none; }
.rp-title { flex: 1; min-width: 0; }
.rp-title h1 { margin: 0; font-size: 20px; }
.rp-title p { margin: 4px 0 0; font-size: 14px; }
.rp-players { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.rp-player { font-weight: 600; color: var(--ink); }
.rp-final { font-variant-numeric: tabular-nums; }
.rp-controls { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 52px; z-index: 10; }
.rp-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rp-buttons .btn { min-width: 42px; }
.rp-buttons .btn.rp-play { min-width: 112px; }
.rp-speed {
  font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; margin-left: auto;
}
.rp-pos { display: flex; align-items: center; gap: 12px; }
.rp-slider { flex: 1; padding: 0; accent-color: var(--felt); min-width: 0; }
.rp-pos-text { font-size: 13px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-rounds { display: flex; gap: 4px; flex-wrap: wrap; }
.rp-buttons .btn.rp-chip, .rp-rounds .btn { min-width: 0; padding: 3px 9px; font-size: 12px; }
.rp-rounds .btn.active { background: var(--felt); color: #fff; border-color: var(--felt); }
.rp-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.rp-table {
  position: relative; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px;
  min-height: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
  background: radial-gradient(ellipse at center, var(--felt-light), var(--felt) 60%, var(--felt-dark));
}
.rp-narr { background: rgba(255,255,255,.95); border-radius: 12px; padding: 10px 14px; min-height: 52px; font-size: 15px; }
.rp-narr.gap { background: #fff8e6; }
.rp-narr-who { font-size: 12px; font-weight: 700; color: var(--felt); text-transform: uppercase; letter-spacing: .5px; }
.rp-narr-line.secret, .rp-log-list li.secret { color: #6b5a2a; }
.rp-center-in { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rp-piles { display: flex; gap: 28px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.rp-discard { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
.rp-pending {
  background: rgba(0,0,0,.3); color: #fff; padding: 6px 10px; border-radius: 10px;
  display: flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap;
}
.rp-seats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.rp-seats.many { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.rp-seat { background: rgba(0,0,0,.22); border: 2px solid transparent; border-radius: 12px; padding: 8px 10px; color: #fff; min-width: 0; }
.rp-seat.active { border-color: var(--accent); box-shadow: 0 0 18px rgba(242,179,61,.45); }
.rp-seat-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; margin-bottom: 6px; }
.rp-seat-head .tag.guest { background: rgba(255,255,255,.16); color: #fff; }
.rp-seat-pts { margin-left: auto; font-weight: 400; font-size: 13px; opacity: .85; font-variant-numeric: tabular-nums; }
.rp-hand { display: flex; gap: 6px; flex-wrap: wrap; min-height: 74px; align-items: center; }
.rp-hand .card { width: 52px; height: 74px; }
.rp-hand .card .mid { font-size: 24px; }
.rp-hand .card .tl, .rp-hand .card .br { font-size: 13px; }
.card.rp-new { box-shadow: 0 0 0 3px var(--accent), 0 4px 12px rgba(0,0,0,.4); animation: rp-in .35s ease; }
@keyframes rp-in { from { transform: translateY(-8px); opacity: .3; } to { transform: none; opacity: 1; } }
.rp-seat-phase { font-size: 13px; color: var(--accent); margin-top: 6px; font-weight: 600; }
.rp-result {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.rp-result-in { background: var(--panel); border-radius: 14px; padding: 18px; width: 100%; max-width: 560px; max-height: 100%; overflow: auto; }
.rp-result-in h2 { margin-top: 0; }
.rp-ranking li { padding: 3px 0; font-weight: 600; }
.rp-log { position: sticky; top: 64px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; padding: 12px; }
.rp-log h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.rp-log-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; font-size: 13px; flex: 1; position: relative; }
.rp-log-list li { padding: 3px 4px; border-bottom: 1px dashed #eee; cursor: pointer; border-radius: 4px; }
.rp-log-list li:hover { background: #f6f4ee; }
.rp-log-list li.round { font-weight: 700; color: var(--felt); border: none; padding-top: 8px; }
.rp-log-list li.current { background: #fff1cf; }

@media (prefers-reduced-motion: reduce) {
  .card.rp-new { animation: none; }
}

@media (max-width: 900px) {
  .rp-body { grid-template-columns: minmax(0, 1fr); }
  .rp-log { position: static; max-height: 320px; }
}

@media (max-width: 600px) {
  .pf-main { padding: 10px; gap: 10px; }
  .pf .panel { padding: 14px; }
  .pf-top { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .pf-nav .lbl, .pf-top .lbl, .pf-who { display: none; }
  .pf-elo { text-align: left; width: 100%; }
  .pf-elo-value { font-size: 36px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 22px; }
  .bar-label { width: 7.5em; }
  .h2h-pct { width: auto; }
  .rp-controls { position: static; }
  .rp-speed { margin-left: 0; }
  .rp-table { padding: 10px; min-height: 0; }
  .rp-hand .card { width: 42px; height: 60px; }
  .rp-hand .card .mid { font-size: 19px; }
  .rp-hand .card .tl, .rp-hand .card .br { font-size: 11px; }
  .rp-discard .card.big { width: 58px; height: 84px; }
  .rp-discard .card.big .mid { font-size: 26px; }
  .game-row { grid-template-columns: minmax(0, 1fr); }
  .rp-result { align-items: flex-start; padding: 8px; }
  .rp-result-in { padding: 14px; }
  .rp-result .result-row { flex-wrap: wrap; gap: 4px 10px; }
  .rp-result .result-row .who { width: auto; flex: 1 0 100%; }
  .rp-result .result-row .cards { flex: 1 1 auto; }
  .g-replay { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 4px; }
}
