/* Poker Wednesday — mobile d'abord, thème sombre par défaut, utilisable d'une main. */

:root, [data-theme="dark"] {
  --bg: #0d1110;
  --surface: #151b19;
  --surface-2: #1d2522;
  --surface-3: #26302c;
  --border: #2b3632;
  --text: #eef3f0;
  --muted: #94a39d;
  --faint: #66746f;
  --accent: #22c55e;
  --accent-ink: #04210f;
  --accent-soft: rgba(34, 197, 94, .14);
  --gold: #f5c542;
  --gold-soft: rgba(245, 197, 66, .14);
  --pos: #34d399;
  --neg: #f87171;
  --neg-soft: rgba(248, 113, 113, .14);
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --felt: radial-gradient(120% 80% at 50% 0%, #123a2a 0%, #0d1110 60%);
}
[data-theme="light"] {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --surface-3: #e2e8e5;
  --border: #d5ddd9;
  --text: #0f1714;
  --muted: #55635d;
  --faint: #8a9792;
  --accent: #15803d;
  --accent-ink: #ffffff;
  --accent-soft: rgba(21, 128, 61, .12);
  --gold: #b7860b;
  --gold-soft: rgba(183, 134, 11, .12);
  --pos: #059669;
  --neg: #dc2626;
  --neg-soft: rgba(220, 38, 38, .1);
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(0, 0, 0, .15);
  --felt: radial-gradient(120% 80% at 50% 0%, #dcefe4 0%, #f3f5f4 60%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  background-image: var(--felt);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.num, .money { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.gold:not(.btn):not(.badge) { color: var(--gold); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------------------------- Barre du haut ---------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 6px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: .2px; text-decoration: none; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-suit { color: var(--accent); }
.icon-btn {
  min-width: 48px; height: 48px; border-radius: 14px; border: 0;
  background: transparent; display: grid; place-items: center;
  font-size: 1.35rem; text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.unlocked { color: var(--gold); }
.status {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: .78rem; color: var(--muted); white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.live::before { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2s infinite; }
.status.offline::before { background: var(--gold); }
.status.pending { color: var(--gold); border-color: var(--gold); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); } 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

/* ---------------------------- Contenu ---------------------------- */
main {
  padding: 12px 14px calc(env(safe-area-inset-bottom) + 96px);
  max-width: 640px; margin: 0 auto; outline: none;
}
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-head h2 { margin-bottom: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 14px; margin-bottom: 10px;
}
.card.tap { display: block; text-decoration: none; }
.card.tap:active { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty .big { font-size: 3rem; display: block; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); font-size: .75rem; font-weight: 600;
}
.badge.live { background: var(--accent-soft); color: var(--accent); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }

/* ---------------------------- Boutons ---------------------------- */
.btn {
  min-height: 52px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface-2); font-weight: 700; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; text-decoration: none; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.98); filter: brightness(1.15); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.gold { background: var(--gold); color: #241a00; border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 48px; padding: 0 14px; border-radius: 14px; font-size: .92rem; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* Chips (sélection de joueurs, filtres) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  touch-action: manipulation;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"]::before { content: "✓"; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px 4px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }

/* Champs */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 52px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 1.05rem;
}
.input:focus { outline: none; border-color: var(--accent); }
.picker {
  width: 100%; min-height: 56px; padding: 0 14px; border-radius: 14px; text-align: left;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 1.1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.picker::after { content: "›"; color: var(--muted); font-size: 1.4rem; }

/* ---------------------------- Écran session ---------------------------- */
.kpis {
  position: sticky; top: calc(env(safe-area-inset-top) + 61px); z-index: 10;
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px;
  margin: -12px -14px 12px; padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px 10px; }
.kpi b { display: block; font-size: 1.35rem; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi:first-child b { color: var(--gold); }
.kpi small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }

.undo-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 4px 4px 4px 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border);
  font-size: .9rem; color: var(--muted);
}
.undo-bar .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  padding: 10px 10px 10px 14px;
}
.player-name { font-weight: 800; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.player-sub b { color: var(--text); font-variant-numeric: tabular-nums; }
.player.out { opacity: .78; }
.player.out .player-name::after { content: " · parti"; color: var(--muted); font-weight: 600; font-size: .85rem; }
.player-info { min-width: 0; padding: 4px 0; text-align: left; background: none; border: 0; }
.rebuy-btn {
  min-width: 84px; height: 64px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 1.3rem;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-variant-numeric: tabular-nums; position: relative; overflow: hidden;
}
.rebuy-btn:active { transform: scale(.96); }
.rebuy-btn.pressing::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: rgba(0,0,0,.35);
  animation: press 500ms linear forwards;
}
@keyframes press { from { width: 0; } to { width: 100%; } }
.more-btn {
  width: 48px; height: 64px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 1.4rem; font-weight: 800;
}
.counter {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold); font-weight: 800; font-size: .8rem; margin-left: 4px;
}
.session-actions { display: grid; gap: 10px; margin-top: 14px; }
.flash { animation: flash .6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--surface); } }

/* ---------------------------- Listes / tableaux ---------------------------- */
.list-item {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 2px;
  border-bottom: 1px solid var(--border); text-decoration: none;
}
.list-item:last-child { border-bottom: 0; }
.list-item button { flex-shrink: 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.tbl th { text-align: right; color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; padding: 6px 4px; }
.tbl td { text-align: right; padding: 10px 4px; border-top: 1px solid var(--border); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td:first-child { font-weight: 700; }
.transfer { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.transfer:last-child { border-bottom: 0; }
.transfer .arrow { color: var(--muted); }
.transfer .amount { margin-left: auto; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.notice { border-radius: 14px; padding: 12px 14px; margin: 10px 0; font-size: .95rem; }
.notice.ok { background: var(--accent-soft); color: var(--accent); }
.notice.warn { background: var(--gold-soft); color: var(--gold); }
.notice.err { background: var(--neg-soft); color: var(--neg); }
.notice b { color: inherit; }

/* ---------------------------- Stats ---------------------------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px; min-width: 0; }
.tile small { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.tile b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rank { display: block; text-decoration: none; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rank:last-child { border-bottom: 0; }
.rank-top { display: flex; align-items: center; gap: 10px; }
.rank-pos { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.rank-name { font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-net { font-weight: 800; font-variant-numeric: tabular-nums; }
.bar-track { position: relative; height: 10px; margin: 8px 0 6px 36px; }
.bar-track::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border); }
.bar { position: absolute; top: 0; height: 10px; border-radius: 6px; }
.bar.pos { background: var(--pos); left: 50%; }
.bar.neg { background: var(--neg); right: 50%; }
.rank-meta { margin-left: 36px; font-size: .8rem; color: var(--muted); }

.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .zero { stroke: var(--faint); stroke-dasharray: 4 4; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .guide { stroke: var(--muted); stroke-width: 1; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 220px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px;
  box-shadow: var(--shadow); font-size: .82rem; font-variant-numeric: tabular-nums;
}
.tooltip .tt-title { font-weight: 800; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-row span:nth-child(2) { flex: 1; }
.tooltip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.trophies { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.trophy { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px; min-width: 0; }
.trophy .emoji { font-size: 1.8rem; line-height: 1; }
.trophy h3 { margin: 6px 0 2px; font-size: .95rem; }
.trophy .who { font-weight: 800; color: var(--gold); margin-top: 6px; overflow-wrap: anywhere; }
.trophy .val { font-size: .8rem; color: var(--muted); }
.trophy .desc { font-size: .75rem; color: var(--faint); }
.trophy.none { opacity: .55; }

/* ---------------------------- Barre d'onglets ---------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; font-size: .78rem; font-weight: 700; color: var(--muted); border-radius: 14px;
}
.tabbar a .tab-ico { font-size: 1.35rem; filter: grayscale(1); opacity: .75; }
.tabbar a.active { color: var(--text); background: var(--surface-2); }
.tabbar a.active .tab-ico { filter: none; opacity: 1; }

/* ---------------------------- Feuilles (bottom sheets) ---------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 24px 24px 0 0; border: 1px solid var(--border); border-bottom: 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
  animation: up .2s cubic-bezier(.2,.8,.2,1);
}
.sheet.full { height: 92dvh; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.2rem; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Pavé numérique */
.amount-display {
  font-size: 2.6rem; font-weight: 900; text-align: center; padding: 10px 0 4px;
  font-variant-numeric: tabular-nums; min-height: 66px;
}
.amount-display .cursor { color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.keypad button {
  height: 60px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 1.5rem; font-weight: 700; touch-action: manipulation;
}
.keypad button:active { background: var(--surface-3); }
.quick { display: flex; gap: 8px; margin-bottom: 4px; }
.quick button { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; }

/* Toasts */
#toasts {
  position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 80px); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  border-radius: 16px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); min-height: 52px;
  animation: up .2s ease-out;
}
.toast.error { border-color: var(--neg); }
.toast .msg { flex: 1; font-size: .92rem; white-space: pre-line; }
.toast button { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: var(--surface); font-weight: 800; color: var(--gold); }

/* PIN */
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0 8px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--gold); border-color: var(--gold); }
.pin-msg { text-align: center; min-height: 24px; font-size: .92rem; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@media (min-width: 700px) {
  .trophies { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
