:root {
  --felt: #14432f;
  --felt-2: #1d5a40;
  --paper: #fbf8f1;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #6b736f;
  --line: #e6e1d6;
  --red: #b3261e;
  --gold: #c9a227;
  --up: #2e7d32;
  --down: #b3261e;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

.top {
  background: var(--felt);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
}
.top h1 { margin: 0; font-size: 1.35rem; letter-spacing: .02em; }
.top p { margin: 2px 0 0; opacity: .75; font-size: .85rem; min-height: 1em; }
.suits { font-size: 1rem; margin-right: 6px; letter-spacing: .1em; }
.suits i { font-style: normal; color: #ff8a80; }

main { max-width: 640px; margin: 0 auto; padding: 14px; }
.view { display: none; }
.view.active { display: block; }

h2 { font-size: 1.05rem; margin: 6px 2px 10px; }
.muted { color: var(--muted); font-size: .85rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

/* Classement */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.name, th.name { text-align: left; }
td.name { font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.rank { text-align: center; width: 2.2em; font-weight: 700; }
tr.r1 td.rank { color: var(--gold); }
td.pts { font-weight: 700; }
.mv { font-size: .7rem; margin-left: 4px; font-weight: 600; }
.mv.up { color: var(--up); } .mv.down { color: var(--down); } .mv.eq { color: var(--muted); }

.legend { font-size: .8rem; color: var(--muted); line-height: 1.45; margin-top: 4px; }

/* Saisie */
label.f { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; font-size: 1rem;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--felt-2); outline-offset: -1px; }
.entry-row {
  display: grid; grid-template-columns: 1fr 96px 72px 44px; gap: 8px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.entry-row:last-child { border-bottom: 0; }
.entry-row.head { font-size: .72rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; padding-top: 0; }
.entry-row .n { font-weight: 600; }
.entry-row .pp { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.entry-row input, .entry-row select { padding: 8px; text-align: right; }

.btn {
  display: inline-block; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--felt); color: #fff; cursor: pointer;
}
.btn.full { width: 100%; }
.btn.ghost { background: transparent; color: var(--felt); border: 1px solid var(--felt); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn.small { padding: 7px 11px; font-size: .85rem; border-radius: 9px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; }
.warn { color: var(--red); font-size: .85rem; margin: 8px 0 0; }
.ok { color: var(--up); font-size: .85rem; margin: 8px 0 0; }

/* Historique */
.ev-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ev-head strong { font-size: 1rem; }
.ev-list { margin: 8px 0 0; padding: 0; list-style: none; columns: 2; column-gap: 16px; font-size: .9rem; }
.ev-list li { padding: 2px 0; break-inside: avoid; display: flex; gap: 6px; }
.ev-list .pl { width: 1.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev-list .sc { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev-actions { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; padding: 8px 2px 10px; font: inherit; font-size: .72rem; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tabs button span { font-size: 1.2rem; line-height: 1.3; }
.tabs button.active { color: var(--felt); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
