:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --success: #006300;
  --danger: #d03b3b;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
}

/* Le site reste en clair par défaut, y compris si le téléphone est en mode sombre.
   Le mode sombre ne s'applique que si data-theme="dark" est posé explicitement sur <html>
   (pas de bouton pour ça actuellement, donc en pratique toujours clair). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --success: #0ca30c;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideFadeIn {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popScale {
  0% { transform: scale(1); }
  35% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes pressDown {
  to { transform: scale(0.95); }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 600;
}

body { min-height: 100vh; }

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface-1);
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 38px;
  width: auto;
}

.topbar nav { display: flex; gap: 4px; }

.topbar nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 8px 13px;
  border-radius: var(--radius-s);
  font-size: 0.92rem;
  font-weight: 700;
  transition: background 0.12s ease, color 0.12s ease;
}

.topbar nav a:hover,
.topbar nav a.active {
  background: var(--gridline);
  color: var(--text-primary);
}

@media (max-width: 480px) {
  .topbar { padding: 8px 12px; }
  .brand-logo { height: 30px; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: 7px 8px; font-size: 0.8rem; }
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 72px;
  animation: fadeInUp 0.28s ease;
}

@media (max-width: 700px) {
  .container { padding: 20px 16px 72px; }
}

h1 { font-size: clamp(1.7rem, 4.4vw, 2.4rem); font-weight: 800; letter-spacing: -0.01em; margin: 0 0 6px; line-height: 1.15; }
h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 14px; }
.subtitle { color: var(--text-secondary); margin: 0 0 20px; font-size: 0.92rem; font-weight: 600; }

.section { margin-bottom: 48px; }

.card {
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-l);
  padding: 24px;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-l);
  padding: 22px;
  transition: transform 0.16s cubic-bezier(.2,.8,.2,1), border-color 0.16s ease, box-shadow 0.16s ease;
  animation: fadeInUp 0.32s ease backwards;
}
.game-card:nth-child(1) { animation-delay: 0.02s; }
.game-card:nth-child(2) { animation-delay: 0.07s; }
.game-card:nth-child(3) { animation-delay: 0.12s; }
.game-card:nth-child(n+4) { animation-delay: 0.16s; }

.game-card:hover { transform: translateY(-3px); border-color: var(--accent, var(--series-1)); box-shadow: 0 8px 18px color-mix(in srgb, var(--accent, var(--series-1)) 18%, transparent); }
.game-card:active { transform: translateY(-1px) scale(0.99); }

.game-card .emoji {
  font-size: 2.3rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--accent, var(--series-1)) 16%, transparent);
}

.game-card .name { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; }
.game-card .tagline { color: var(--text-secondary); font-size: 0.86rem; font-weight: 600; }

.game-card.disabled {
  opacity: 0.6;
  cursor: default;
}

.game-card-badge {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--gridline);
  padding: 3px 8px;
  border-radius: 999px;
}

.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }

.player-badge {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  gap: 6px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--gridline);
  font-size: 0.85rem;
  font-weight: 600;
}

.player-dot, .player-avatar {
  border-radius: 999px;
  display: inline-block;
  vertical-align: middle;
  text-align: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
  background:
    radial-gradient(circle at 32% 28%,
      color-mix(in srgb, var(--dot-color, var(--series-1)) 80%, white 20%) 0%,
      var(--dot-color, var(--series-1)) 55%,
      color-mix(in srgb, var(--dot-color, var(--series-1)) 78%, black 22%) 100%);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--dot-color, var(--series-1)) 45%, transparent), inset 0 0 0 2px rgba(255,255,255,0.18);
}

.player-dot { width: 20px; height: 20px; font-size: 0.75rem; line-height: 20px; }

.player-avatar {
  width: 72px;
  height: 72px;
  font-size: 2rem;
  line-height: 66px;
  border: 3px solid var(--surface-1);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--dot-color, var(--series-1)) 50%, transparent), 0 0 0 2px color-mix(in srgb, var(--dot-color, var(--series-1)) 40%, transparent);
}

.player-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-chip {
  display: flex;
  align-items: center;
  line-height: 1;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--gridline);
  background: var(--surface-1);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}

.player-chip.selected {
  border-color: var(--dot-color, var(--series-1));
  background: color-mix(in srgb, var(--dot-color, var(--series-1)) 14%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 22px;
  border-radius: var(--radius-m);
  border: none;
  background: var(--text-primary);
  color: var(--page);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: var(--gridline); color: var(--text-primary); }
.btn.ghost { background: transparent; color: var(--text-muted); box-shadow: inset 0 0 0 1.5px var(--gridline); font-size: 0.85rem; }
.btn.danger { background: var(--danger); color: white; }
.btn.small { padding: 8px 14px; font-size: 0.85rem; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

input[type="text"], input[type="number"], select {
  padding: 10px 12px;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--gridline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

input[type="number"] { font-variant-numeric: tabular-nums; }

.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.emoji-picker, .color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 168px;
  overflow-y: auto;
  padding: 4px 2px;
}

.emoji-option, .color-option {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-s);
  border: 2px solid transparent;
  background: var(--gridline);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.emoji-option.selected, .color-option.selected {
  border-color: var(--text-primary);
  transform: scale(1.06);
}

.color-option {
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 85%, white 15%), var(--c));
  position: relative;
}

.color-option.taken {
  cursor: not-allowed;
  opacity: 0.28;
  filter: grayscale(0.6);
}

.color-option-custom {
  position: relative;
  background: repeating-conic-gradient(from 0deg, #f43f5e 0deg 60deg, #facc15 60deg 120deg, #4ade80 120deg 180deg, #38bdf8 180deg 240deg, #818cf8 240deg 300deg, #f472b6 300deg 360deg);
  color: white;
}
.color-option-custom.selected { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 85%, white 15%), var(--c)); }
.color-custom-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.color-option.taken::after {
  content: '✕';
  position: absolute;
  color: white;
  font-size: 0.85rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.avatar-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid var(--gridline);
}
.player-row:last-child { border-bottom: none; }

table.score-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.score-table th, .score-table td {
  padding: 10px 8px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

.score-table th { color: var(--text-secondary); font-size: 0.8rem; font-weight: 600; }
.score-table td:first-child, .score-table th:first-child { text-align: left; }
.score-table tr.clickable-row { cursor: pointer; transition: background 0.12s ease; }
.score-table tr.clickable-row:hover { background: var(--gridline); }

.history-gap td {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 10px 0;
  border-top: 3px solid var(--baseline);
  border-bottom: 3px solid var(--baseline);
}

.session-subline { color: var(--text-secondary); font-weight: 600; font-size: 0.85rem; margin: 2px 0 0; }
.session-date-info { color: var(--text-muted); font-size: 0.8rem; margin: 2px 0 0; }
.multi-sitting-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--gridline);
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.score-table input[type="number"] { width: 68px; text-align: center; padding: 8px 4px; }

.score-table tr.total-row td { font-weight: 700; border-top: 2px solid var(--baseline); border-bottom: none; }
.score-table tr.total-row.winner td { color: var(--success); }

.checkbox-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--gridline);
  border-radius: var(--radius-m);
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  margin-bottom: 10px;
  flex-wrap: wrap;
  animation: fadeInUp 0.28s ease backwards;
}
.session-row:nth-child(1) { animation-delay: 0.02s; }
.session-row:nth-child(2) { animation-delay: 0.06s; }
.session-row:nth-child(3) { animation-delay: 0.1s; }
.session-row:nth-child(4) { animation-delay: 0.14s; }
.session-row:nth-child(n+5) { animation-delay: 0.16s; }

.session-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.session-meta .game-name { font-weight: 700; display: inline-flex; align-items: center; line-height: 1; gap: 6px; }
.session-meta .date { font-size: 0.8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.date-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary, var(--text-muted));
  letter-spacing: 0.01em;
}
.date-line .icon-svg { opacity: 0.7; flex-shrink: 0; }

.avatar-stack {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 4px;
  scrollbar-width: none;
}
.avatar-stack::-webkit-scrollbar { display: none; }
.avatar-stack-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: -6px;
  position: relative;
}
.avatar-stack-item:first-child { margin-left: 0; }
.avatar-stack-item .player-avatar { transition: transform 0.14s cubic-bezier(.2,.8,.2,1); }
.avatar-stack-item:hover { z-index: 2; }
.avatar-stack-item:hover .player-avatar { transform: scale(1.18); box-shadow: 0 4px 14px color-mix(in srgb, var(--dot-color, var(--series-1)) 55%, transparent), 0 0 0 2px var(--surface-1); }
.avatar-points {
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.3;
  margin-top: 2px;
}

.session-row-finished { transition: background 0.2s ease, border-color 0.2s ease; }
.winner-line { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

.home-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
  margin-top: 40px;
}
@media (max-width: 800px) {
  .home-columns { grid-template-columns: 1fr; gap: 0; }
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeInUp 0.32s ease backwards;
}
.stat-tiles > .stat-tile:nth-child(1) { animation-delay: 0.02s; }
.stat-tiles > .stat-tile:nth-child(2) { animation-delay: 0.06s; }
.stat-tiles > .stat-tile:nth-child(3) { animation-delay: 0.1s; }
.stat-tiles > .stat-tile:nth-child(4) { animation-delay: 0.14s; }
.stat-tiles > .stat-tile:nth-child(5) { animation-delay: 0.18s; }
.stat-tiles > .stat-tile:nth-child(n+6) { animation-delay: 0.2s; }

.stat-tile .value { font-size: 1.6rem; font-weight: 700; }
.stat-tile .label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-tile .sub { font-size: 0.8rem; color: var(--text-muted); }

.tile-icon { font-size: 1.3rem; }

.chart-card { padding: 20px 18px 10px; }
.chart-card h3 { margin: 0 0 10px; font-size: 1.05rem; font-weight: 700; }

.chart-zoomable { cursor: zoom-in; border-radius: var(--radius-m); transition: background 0.15s ease; }
.chart-zoomable:hover { background: var(--gridline); }
.chart-zoom-modal { width: 90vw; max-width: none; }
.chart-zoom-scroll {
  overflow: auto;
  max-height: 76vh;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-m);
  background: var(--page);
}
.chart-zoom-target { min-height: 460px; padding: 14px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 0.8rem; color: var(--text-secondary); }

.chart-end-label {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 100%;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  font-family: "Baloo 2", system-ui, sans-serif;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

.svg-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page);
  font-size: 0.78rem;
  padding: 6px 9px;
  border-radius: 6px;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  opacity: 0;
  transition: opacity 0.08s ease;
  z-index: 20;
}

.chart-wrap { position: relative; overflow: visible; }
.chart-wrap svg { overflow: visible; }

.game-filter { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.game-filter a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--gridline);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
}
.game-filter a.active { border-color: var(--text-primary); color: var(--text-primary); background: var(--gridline); }

.period-filter { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.period-btn {
  border: 1.5px solid var(--gridline);
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
.period-btn.active { border-color: var(--text-primary); color: var(--text-primary); background: var(--gridline); }

.player-filter { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; align-items: center; }
.player-filter-label { font-size: 0.82rem; font-weight: 700; color: var(--text-muted); margin-right: 2px; }

.record-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-m);
  margin-bottom: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, #d4af37 20%, var(--surface-1)), var(--surface-1));
  border: 1.5px solid color-mix(in srgb, #d4af37 55%, transparent);
  color: #b8860b;
  animation: fadeInUp 0.3s ease;
}
.record-banner-title { font-weight: 800; font-size: 0.95rem; margin-bottom: 4px; color: var(--text-primary); }
.record-banner-item { font-size: 0.85rem; color: var(--text-secondary); }
.record-banner-item::before { content: '★ '; }

.stat-tile.clickable {
  cursor: pointer;
  position: relative;
  border: 1.5px solid var(--text-primary);
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--text-primary) 14%, transparent);
  padding-right: 30px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.stat-tile.clickable::after {
  content: '›';
  position: absolute;
  top: 14px;
  right: 12px;
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  color: var(--text-muted);
}
.stat-tile.clickable:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 color-mix(in srgb, var(--text-primary) 18%, transparent); }
.stat-tile.clickable:active { transform: translate(1px, 1px) scale(0.98); box-shadow: 1px 1px 0 color-mix(in srgb, var(--text-primary) 14%, transparent); }

.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

.round-controls { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; align-items: center; }

/* Onglets de la page de partie */
.game-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.game-tab-btn {
  flex-shrink: 0;
  border: 1.5px solid var(--gridline);
  background: var(--surface-1);
  color: var(--text-secondary);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.game-tab-btn.active { border-color: var(--text-primary); background: var(--text-primary); color: var(--page); }
.game-tab-panel { animation: fadeInUp 0.26s cubic-bezier(.2,.8,.2,1); }

/* Barre de saisie flottante, détachée du bas */
.entry-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-l);
  padding: 14px 16px 14px 22px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}
.entry-bar-round { font-weight: 800; font-size: 0.95rem; }
.entry-bar .btn { padding: 14px 24px; font-size: 1.02rem; }
.entry-bar-spacer { height: 92px; }

@media (max-width: 600px) {
  .entry-bar {
    left: 10px;
    right: 10px;
    bottom: 14px;
    padding: 16px 18px 16px 22px;
    border-radius: var(--radius-l);
  }
  .entry-bar-round { font-size: 1rem; }
  .entry-bar .btn { padding: 16px 22px; font-size: 1.1rem; flex: 1; }
}

/* Récap de fin de partie */
.recap-ranking { display: flex; flex-direction: column; gap: 8px; }
.recap-row {
  display: flex;
  align-items: center;
  line-height: 1;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--page);
}
.recap-row .rank-badge { display: flex; align-items: center; justify-content: center; width: 30px; margin-top: 0; flex-shrink: 0; }
.recap-name { flex: 1; font-weight: 700; }
.recap-total { font-weight: 800; font-variant-numeric: tabular-nums; }

.recap-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.recap-table th, .recap-table td { padding: 9px 10px; text-align: center; vertical-align: middle; border-bottom: 1px solid var(--gridline); }
.recap-table th { color: var(--text-muted); font-size: 0.72rem; font-weight: 700; }
.recap-table td.recap-table-player-cell { text-align: left; }
.recap-table-player { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.recap-table td.recap-points { font-size: 1.35rem; font-weight: 900; }

/* Modale générique */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.modal-overlay.show { opacity: 1; }
.modal-overlay.closing { opacity: 0; }

.modal-box {
  background: var(--surface-1);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 20px;
  transform: translateY(28px) scale(0.98);
  transition: transform 0.26s cubic-bezier(.2,.8,.2,1);
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); }
.modal-overlay.closing .modal-box { transform: translateY(28px) scale(0.98); }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-box { border-radius: var(--radius-l); }
}

/* Tableau de score (colonnes = joueurs, lignes = manches) */
.scoreboard-card { padding: 10px; }
.table-scroll { overflow-x: auto; padding: 4px 0 6px; }

table.scoreboard {
  width: 100%;
  min-width: 480px;
  table-layout: fixed;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.scoreboard.rank-evo-table { min-width: 0; }

.scoreboard th, .scoreboard td {
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

.scoreboard th.corner, .scoreboard td.round-num {
  text-align: left;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  width: 32px;
  padding-left: 10px;
  padding-right: 2px;
}

.scoreboard th { padding-top: 12px; padding-bottom: 10px; transition: background 0.15s ease; }
.scoreboard .th-name { font-size: 0.85rem; font-weight: 800; margin-top: 4px; display: flex; align-items: center; justify-content: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.scoreboard th.dealer-col { background: color-mix(in srgb, var(--dot-color, var(--series-1)) 16%, transparent); border-bottom: 3px solid var(--dot-color, var(--series-1)); border-radius: var(--radius-s) var(--radius-s) 0 0; }
.scoreboard td.rank-cell { padding: 6px; cursor: pointer; }

.rank-grid-inner { position: relative; display: block; }
.rank-connectors { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; }
.rank-connectors line { transition: stroke-opacity 0.15s ease, stroke-width 0.15s ease; }
.scoreboard td.rank-cell .player-avatar { position: relative; z-index: 1; }

.scoreboard th.future-col {
  width: 30px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.6;
}
.scoreboard td.future-cell {
  background: repeating-linear-gradient(135deg, var(--gridline) 0, var(--gridline) 3px, transparent 3px, transparent 8px);
  opacity: 0.5;
}
.th-dealer-sub { font-size: 0.64rem; font-weight: 500; margin-top: 2px; white-space: nowrap; }

.scoreboard td.score-cell { font-weight: 600; font-size: 0.95rem; }
.scoreboard td.score-cell.score-zero { color: color-mix(in srgb, var(--text-primary) 80%, transparent); font-weight: 800; font-size: 1.15rem; }
.scoreboard td.score-cell.editable { cursor: pointer; border-radius: var(--radius-s); transition: background 0.1s ease; }
.scoreboard td.score-cell.editable:hover { background: var(--gridline); }
.scoreboard td.score-cell.editable:active { background: var(--baseline); }

.scoreboard .total-row td {
  font-weight: 800;
  border-top: 2px solid var(--baseline);
  border-bottom: none;
  padding-top: 12px;
}

.scoreboard .total-num { font-size: 1.3rem; font-weight: 900; }
.scoreboard .total-num.pop { display: inline-block; animation: popScale 0.3s ease; }
.scoreboard td.winner-cell .total-num { color: var(--success); }

.rank-badge {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 800;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.rank-badge.rank-1 { color: #b8860b; font-size: 0.85rem; }
.rank-badge.rank-2 { color: #8a8a8a; }
.rank-badge.rank-3 { color: #a05a2c; }

/* Actions rapides (renommer / copier / supprimer) */
.icon-actions { display: flex; gap: 6px; align-self: flex-start; }
.icon-btn {
  border: none;
  background: var(--gridline);
  border-radius: var(--radius-s);
  font-size: 1.05rem;
  line-height: 1;
  width: 38px;
  height: 38px;
  min-width: 38px;
  cursor: pointer;
  transition: transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.danger { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.icon-btn.active { background: color-mix(in srgb, #eda100 22%, transparent); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--text-primary);
  color: var(--page);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }


/* Pavé numérique plein écran */
.keypad-title { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 4px; }
.keypad-display {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  margin: 14px 0;
  min-height: 4.8rem;
  letter-spacing: -0.02em;
}

.star-icon, .icon-svg { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.star-icon.gold { color: #d4af37; }
h1 .icon-svg { vertical-align: -4px; margin-right: 2px; }
.cell-running-total { display: block; font-size: 0.68rem; color: var(--text-muted); font-weight: 600; margin-top: 1px; }

.keypad-victory-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: var(--radius-m);
  border: 2px solid var(--gridline);
  background: var(--page);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
}
.keypad-victory-btn.on { border-color: var(--dot-color, var(--series-1)); background: color-mix(in srgb, var(--dot-color, var(--series-1)) 16%, transparent); color: var(--dot-color, var(--series-1)); }

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.keypad-key {
  border: none;
  background: var(--gridline);
  border-radius: var(--radius-m);
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
  padding: 22px 0;
  cursor: pointer;
  color: var(--text-primary);
  transition: transform 0.08s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.keypad-key:active { background: var(--baseline); transform: scale(0.92); }

/* Popup de saisie à onglets */
.score-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.score-modal-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 4px 8px;
  margin-bottom: 10px;
}

.score-tab {
  position: relative;
  border: 2px solid var(--gridline);
  background: var(--page);
  border-radius: var(--radius-m);
  padding: 6px 8px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.score-tab.active { border-color: var(--dot-color, var(--series-1)); transform: translateY(-2px); }
.score-tab.done { opacity: 0.75; }
.tab-name { font-size: 0.68rem; font-weight: 700; color: var(--text-secondary); max-width: 48px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tab-check {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--success);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.score-modal-body, .keypad-body { text-align: center; }
.keypad-body { animation: slideFadeIn 0.2s ease; }

.keypad-grid-modal { grid-template-columns: repeat(3, 1fr); }

.keypad-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.keypad-backspace { background: color-mix(in srgb, var(--danger) 12%, var(--gridline)); }

.keypad-validate {
  background: var(--success);
  color: white;
  font-size: 1.6rem;
}

/* Parties en cours (modale de blocage) */
.blocking-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

/* Liste réordonnable (ordre de jeu / donneur) */
.order-list { display: flex; flex-direction: column; gap: 8px; }

.order-row {
  display: flex;
  align-items: center;
  line-height: 1;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-m);
  touch-action: none;
  transition: transform 0.18s cubic-bezier(.2,.8,.2,1);
  position: relative;
}

.order-row.dragging {
  transition: none;
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
  border-color: var(--dot-color, var(--series-1));
  z-index: 5;
  cursor: grabbing;
}

.drag-handle {
  cursor: grab;
  font-size: 1.3rem;
  color: var(--text-muted);
  padding: 8px;
  touch-action: none;
  user-select: none;
}

.order-badge {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--gridline);
  color: var(--text-primary);
  font-weight: 900;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.order-name { font-weight: 800; flex: 1; }

.starter-btn {
  border: 2px solid var(--gridline);
  background: var(--page);
  border-radius: var(--radius-s);
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px 11px;
  cursor: pointer;
  opacity: 0.5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.starter-btn.active { opacity: 1; border-color: var(--dot-color, var(--series-1)); background: color-mix(in srgb, var(--dot-color, var(--series-1)) 16%, transparent); }

@media (max-width: 600px) {
  .container { padding: 16px 12px 48px; }
  .score-table th, .score-table td { padding: 8px 5px; font-size: 0.85rem; }
  .score-table input[type="number"] { width: 52px; }
  .keypad-display { font-size: 3.2rem; }
}
