/* ─── Screens ───────────────────────────────────────────────── */
.psm-screen {
  display: none;
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.psm-screen.active { display: flex; }
.psm-screen--wide  { max-width: 900px; }

#screen-matchover {
  max-width: min(1400px, 98vw);
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* ─── Lobby layout ───────────────────────────────────────────── */
.psm-lobby-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  width: 100%;
  align-items: start;
}
.psm-lobby-left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.psm-lobby-right {
  min-width: 0;
}
@media (max-width: 640px) {
  .psm-lobby-layout { grid-template-columns: 1fr; }
  .psm-sub { white-space: normal; }
  .psm-lobby-left { align-items: center; }
}

/* ─── Common text ─────────────────────────────────────────────── */
.psm-title {
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  margin: 0;
  letter-spacing: -0.02em;
}
.psm-sub {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
  margin: 0;
}

/* ─── How-to ──────────────────────────────────────────────────── */
.psm-how-to {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  width: 100%;
}
.psm-how-step {
  font-size: 0.79rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
}

/* ─── Lobby box ───────────────────────────────────────────────── */
.psm-lobby-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  max-width: 320px;
}

/* ── Find match card ── */
.psm-btn-find {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 38%, transparent);
}
.psm-btn-find:hover { transform: translateY(-2px); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 50%, transparent); }
.psm-btn-find:active { transform: translateY(0); }
.psm-find-icon  { font-size: 1.7rem; flex-shrink: 0; line-height: 1; }
.psm-find-text  { display: flex; flex-direction: column; flex: 1; gap: 0.1rem; }
.psm-find-text strong { font-size: 1rem; font-weight: 800; display: block; }
.psm-find-text small  { font-size: 0.78rem; opacity: 0.82; display: block; }
.psm-find-arrow { font-size: 1.6rem; opacity: 0.75; flex-shrink: 0; line-height: 1; }

/* ── Divider ── */
.psm-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.psm-divider::before,
.psm-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Buttons ── */
.psm-btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
  white-space: nowrap;
}
.psm-btn-secondary:hover { border-color: var(--accent); }
.psm-btn-full { width: 100%; }

.psm-join-row { display: flex; gap: 0.5rem; width: 100%; }
.psm-private-box { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }

.psm-code-input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 700;
  text-align: center;
  font-family: inherit;
  outline: none;
}
.psm-code-input:focus { border-color: var(--accent); }
.psm-error { color: #ef4444; font-size: 0.85rem; text-align: center; }

/* ─── Leaderboard ─────────────────────────────────────────────── */
.psm-leaderboard {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.psm-lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.psm-lb-title { font-size: 0.9rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.psm-lb-toggle { display: flex; gap: 0.3rem; }
.psm-lb-mode-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.psm-lb-mode-btn:hover { border-color: var(--accent); color: var(--accent); }
.psm-lb-mode-btn.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
.psm-lb-loading,
.psm-lb-empty { font-size: 0.82rem; color: var(--text-muted); text-align: center; margin: 0; padding: 1rem 0; }
.psm-lb-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.psm-lb-row:last-child { border-bottom: none; }
.psm-lb-medal { font-size: 1rem; width: 1.4rem; text-align: center; flex-shrink: 0; }
.psm-lb-rank  { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }
.psm-lb-av {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.psm-lb-av--initial {
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
}
.psm-lb-name { flex: 1; font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psm-lb-winrate { font-size: 0.82rem; font-weight: 800; color: var(--accent); flex-shrink: 0; }
.psm-lb-record  { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

/* ─── Queue dots ──────────────────────────────────────────────── */
.psm-queue-dots { display: flex; gap: 0.5rem; }
.psm-queue-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  animation: psm-dot-bounce 1.2s ease-in-out infinite;
}
.psm-queue-dots span:nth-child(2) { animation-delay: 0.2s; }
.psm-queue-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes psm-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-8px); }
}

/* ─── Waiting ────────────────────────────────────────────────── */
.psm-room-code-box {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: 16px; padding: 1.5rem 2rem; width: 100%; max-width: 300px;
}
.psm-room-label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; margin: 0; }
.psm-room-code  { font-size: 2.5rem; font-weight: 900; letter-spacing: 0.25em; color: var(--accent); }
.psm-copy-row   { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; justify-content: center; }
.psm-btn-copy {
  background: none; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 0.5rem 0.6rem; font-size: 0.78rem; cursor: pointer; color: var(--text);
  transition: border-color 0.15s; flex: 1 1 auto; min-width: 0; text-align: center;
}
.psm-btn-copy:hover { border-color: var(--accent); }
.psm-copy-confirm { color: #22c55e; font-size: 0.85rem; margin: 0; }
.psm-waiting-hint { color: var(--text-muted); font-size: 0.85rem; text-align: center; margin: 0; }

/* ─── Players row ─────────────────────────────────────────────── */
.psm-players-row {
  display: flex; align-items: center; justify-content: center; gap: 1rem; width: 100%;
}
.psm-player {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  flex: 1; padding: 0.6rem; border-radius: 12px;
  border: 2px solid transparent; transition: border-color 0.2s, background 0.2s;
}
.psm-player-av {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card-bg); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
  background-size: cover; background-position: center; overflow: hidden;
}
.psm-player-name {
  font-size: 0.8rem; font-weight: 600; text-align: center;
  max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.psm-player--me .psm-player-name::after { content: ' (toi)'; font-size: 0.7em; color: var(--text-muted); }
.psm-player-record { font-size: 0.68rem; color: var(--text-muted); text-align: center; white-space: nowrap; }
.psm-player-score  { font-size: 1.6rem; font-weight: 900; line-height: 1; color: var(--accent); }
.psm-vs-badge { font-size: 0.85rem; font-weight: 900; color: var(--text-muted); flex-shrink: 0; }

/* ─── Game header ────────────────────────────────────────────── */
.psm-game-header {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem; width: 100%;
}
.psm-round-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
}
.psm-pokemon-name {
  font-size: 1.4rem; font-weight: 900; text-align: center;
}
.psm-pokemon-sprite {
  width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated;
}
.psm-timer-wrap {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
}
.psm-timer-track {
  flex: 1; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.psm-timer-fill {
  height: 100%; background: #22c55e; border-radius: 99px; transition: width 0.9s linear, background 0.5s;
}
.psm-timer-fill--mid { background: #f59e0b; }
.psm-timer-fill--low { background: #ef4444; }
.psm-timer-num { font-size: 0.9rem; font-weight: 700; min-width: 28px; text-align: right; }

/* ─── Stat inputs ────────────────────────────────────────────── */
.psm-stats-form {
  display: flex; flex-direction: column; gap: 0.65rem; width: 100%;
}
.psm-stat-row {
  display: flex; align-items: center; gap: 0.6rem;
}
.psm-stat-bar-wrap {
  width: 52px; height: 22px; background: var(--border); border-radius: 6px; overflow: hidden;
  flex-shrink: 0;
}
.psm-stat-bar-fill {
  height: 100%; width: 0%; border-radius: 6px; transition: width 0.15s;
}
.psm-stat-bar-hp  { background: #4ade80; }
.psm-stat-bar-atk { background: #f87171; }
.psm-stat-bar-def { background: #fb923c; }
.psm-stat-bar-spa { background: #60a5fa; }
.psm-stat-bar-spd { background: #a78bfa; }
.psm-stat-bar-spe { background: #facc15; }

.psm-stat-label {
  width: 70px; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0; text-align: right;
}
.psm-stat-input {
  flex: 1; padding: 0.45rem 0.7rem; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text);
  font-size: 0.95rem; font-weight: 700; text-align: center;
  font-family: inherit; outline: none; transition: border-color 0.15s;
}
.psm-stat-input:focus { border-color: var(--accent); }
.psm-stat-input:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Submit button ───────────────────────────────────────────── */
.psm-btn-submit {
  width: 100%; background: var(--accent); color: #fff;
  border: 2px solid rgba(255,255,255,0.32);
  border-radius: 14px; padding: 1rem; font-size: 1.05rem; font-weight: 800;
  cursor: pointer; font-family: inherit; transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
  letter-spacing: 0.01em;
}
.psm-btn-submit:hover  { opacity: 0.88; transform: translateY(-1px); }
.psm-btn-submit:active { transform: scale(0.98); }
.psm-btn-submit:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; transform: none; }

.psm-submitted-label {
  font-size: 0.9rem; color: #22c55e; font-weight: 700; text-align: center;
}

/* ─── Opponent indicator ──────────────────────────────────────── */
.psm-opponent-status {
  font-size: 0.78rem; color: var(--text-muted); text-align: center;
}
.psm-opponent-status--done { color: #22c55e; font-weight: 700; }

/* ─── Forfeit ─────────────────────────────────────────────────── */
.psm-btn-forfeit {
  background: none; border: 1.5px solid #ef4444; border-radius: 10px;
  padding: 0.4rem 1rem; font-size: 0.78rem; font-weight: 600;
  color: #ef4444; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.psm-btn-forfeit:hover { background: rgba(239,68,68,0.08); }
.psm-btn-forfeit--confirm {
  background: rgba(239,68,68,0.13);
  animation: psm-forfeit-pulse 0.5s ease;
}
@keyframes psm-forfeit-pulse {
  0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); }
}

/* ─── Round result ────────────────────────────────────────────── */
.psm-result-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 1rem; width: 100%;
}
.psm-round-outcome {
  font-size: 1.4rem; font-weight: 900; text-align: center;
}
.psm-tiebreak-label {
  font-size: 0.78rem; font-weight: 600; color: var(--text-muted); display: block; margin-top: 0.1rem;
}
.psm-win  { color: #22c55e; }
.psm-lose { color: #ef4444; }

/* ─── Stat compare (résultat round & récap final) ─────────────── */
.psm-stat-compare { display: flex; flex-direction: column; width: 100%; }

.psm-compare-group {
  display: flex; flex-direction: column; gap: 0.18rem;
  padding: 0.45rem 0;
}
.psm-compare-sep {
  border: none; border-top: 1px solid var(--border); margin: 0;
}
.psm-compare-row {
  display: flex; align-items: center; gap: 0.5rem;
}
.psm-compare-name {
  font-size: 0.76rem; font-weight: 700;
  width: 86px; flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.psm-compare-stat-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}
.psm-compare-bar-wrap {
  flex: 1; height: 9px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.psm-compare-bar {
  height: 100%; border-radius: 99px; transition: width 0.4s ease;
}
.psm-compare-bar--you { background: #60a5fa; }
.psm-compare-bar--opp { background: #fb923c; }

.psm-compare-val {
  font-size: 0.82rem; font-weight: 700;
  min-width: 28px; text-align: right; flex-shrink: 0; color: var(--text);
}
.psm-val-you { color: #60a5fa; }
.psm-val-opp { color: #fb923c; }

.psm-compare-diff {
  font-size: 0.76rem; font-weight: 700;
  min-width: 36px; text-align: right; flex-shrink: 0;
}
.psm-compare-diff-spacer { min-width: 36px; flex-shrink: 0; }

.psm-diff-0    { color: #22c55e; }
.psm-diff-low  { color: #a3e635; }
.psm-diff-mid  { color: #f59e0b; }
.psm-diff-high { color: #ef4444; }

/* Header Pokémon dans l'écran résultat */
.psm-result-poke-header {
  display: flex; align-items: center; gap: 0.75rem;
}
.psm-result-sprite {
  width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated;
}
.psm-result-poke-name {
  font-size: 1.1rem; font-weight: 800;
}

/* Total erreurs */
.psm-result-totals {
  font-size: 0.82rem; color: var(--text-muted);
  text-align: center; width: 100%;
}
.psm-result-totals strong { font-size: 0.88rem; }

/* Bouton skip vers résultat final */
.psm-btn-skip {
  background: none; border: 1.5px solid var(--accent); border-radius: 12px;
  padding: 0.55rem 1.4rem; font-size: 0.88rem; font-weight: 700;
  color: var(--accent); cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.psm-btn-skip:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* Légende couleurs joueurs */
.psm-result-legend {
  display: flex; gap: 1.2rem; font-size: 0.8rem; font-weight: 700; align-items: center;
}
.psm-legend-you { color: #60a5fa; }
.psm-legend-opp { color: #fb923c; }
.psm-legend-total {
  font-size: 0.8rem; color: var(--text-muted); text-align: center;
}
.psm-legend-total strong { color: var(--text); }

/* ─── Next round ──────────────────────────────────────────────── */
.psm-next-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem; width: 100%;
}
.psm-btn-next {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 0.6rem 1.5rem; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: border-color 0.15s; color: var(--text);
}
.psm-btn-next:hover { border-color: var(--accent); }
.psm-btn-next:disabled { opacity: 0.45; cursor: default; }
.psm-next-hint { font-size: 0.75rem; color: var(--text-muted); text-align: center; }

/* ─── Match over (final result) ───────────────────────────────── */
.psm-final-box {
  display: flex; flex-direction: column; align-items: stretch; gap: 1.25rem;
  width: 100%; padding-top: 1rem;
}
.psm-final-emoji,
.psm-final-title,
.psm-final-scores,
.psm-final-reason,
.psm-btn-lobby { align-self: center; }
.psm-final-emoji  { font-size: 3rem; }
.psm-final-title  { font-size: 1.8rem; font-weight: 900; text-align: center; }
.psm-final-scores { font-size: 1.3rem; font-weight: 900; color: var(--text-muted); letter-spacing: 0.05em; }
.psm-final-reason { font-size: 0.82rem; color: var(--text-muted); text-align: center; }

/* Récap des manches avec graphes — côte à côte */
.psm-recap-sections {
  display: grid;
  gap: 1rem;
  width: 100%;
  overflow-x: auto;
  /* grid-template-columns set by JS via .style */
}
.psm-recap-section {
  display: flex; flex-direction: column; gap: 0.45rem;
  min-width: 0; overflow: hidden;
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: 14px; padding: 0.75rem 0.85rem;
}

/* Layout dans le récap (colonnes fixes à 275px) */
.psm-recap-section .psm-compare-name {
  width: 72px; font-size: 0.68rem;
}
.psm-recap-section .psm-compare-val {
  min-width: 24px; font-size: 0.76rem;
}
.psm-recap-section .psm-compare-diff {
  min-width: 28px; font-size: 0.68rem;
}
.psm-recap-section .psm-compare-diff-spacer {
  min-width: 28px;
}
.psm-recap-section-header {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.82rem; font-weight: 700;
}
.psm-recap-section-header .psm-recap-badge {
  font-size: 1rem; font-weight: 900; flex-shrink: 0;
}
.psm-recap-section-header.psm-win  .psm-recap-badge { color: #22c55e; }
.psm-recap-section-header.psm-lose .psm-recap-badge { color: #ef4444; }
.psm-recap-section-err {
  margin-left: auto; font-size: 0.74rem; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; gap: 0.25rem;
}

/* Mini header Pokémon dans le récap */
.psm-recap-poke-header {
  display: flex; align-items: center; gap: 0.5rem;
}
.psm-recap-sprite {
  width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated;
}
.psm-recap-poke-name {
  font-size: 0.88rem; font-weight: 700; color: var(--text-muted);
}

.psm-btn-lobby {
  margin-top: 0.25rem; background: var(--accent); color: #fff; border: none;
  border-radius: 14px; padding: 0.85rem 2.5rem; font-size: 1rem; font-weight: 800;
  cursor: pointer; font-family: inherit; transition: opacity 0.15s;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.psm-btn-lobby:hover { opacity: 0.88; }
