:root {
  --bordeaux: #7a1f2b;
  --bordeaux-dark: #5a1520;
  --or: #c9a227;
  --or-light: #f6ecc8;
  --bg: #f7f4ef;
  --card: #fff;
  --text: #2a2024;
  --muted: #7b6f72;
  --line: #e7dfd6;
  --ok: #2e7d4f;
  --ok-bg: #e5f3ea;
  --warn: #a8640b;
  --warn-bg: #fdf1dc;
  --err: #b3261e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* En-tête */
.top {
  background: linear-gradient(135deg, var(--bordeaux), var(--bordeaux-dark));
  color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.top img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
.top .title { flex: 1; min-width: 0; }
.top .title b { display: block; font-size: 15px; }
.top .title small { opacity: .85; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.top button { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.offline { background: var(--err); color: #fff; text-align: center; font-size: 13px; padding: 4px; }

/* Onglets */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px;
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 64px; z-index: 9;
}
.tabs button {
  background: none; border: none; color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-radius: 999px; white-space: nowrap; position: relative; flex: 1 0 auto; font-size: 14px;
}
.tabs button.on { background: var(--bordeaux); color: #fff; }
.tabs .dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: var(--or); border-radius: 50%; }

main { max-width: 860px; margin: 0 auto; padding: 16px 12px 60px; }
h2 { font-size: 19px; margin: 8px 0 12px; color: var(--bordeaux); }
h3 { font-size: 16px; margin: 0 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.card.hl { border: 2px solid var(--or); background: linear-gradient(180deg, var(--or-light), #fff 60%); }
.card.live { border: 2px solid var(--bordeaux); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* Formulaires */
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px;
  border: 1px solid #d6ccc2; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--or); border-color: var(--or); }
textarea { min-height: 70px; resize: vertical; }
input.pin { letter-spacing: 10px; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text);
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--bordeaux); color: #fff; border-color: var(--bordeaux); }
.btn-gold { background: var(--or); color: #2a2024; border-color: var(--or); }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-danger { color: var(--err); border-color: #efc7c4; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 14px; padding: 13px; }

.seg { display: flex; background: #efe8e0; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: none; background: none; padding: 9px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--bordeaux); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.choices { display: flex; gap: 8px; }
.choices button { flex: 1; }
.choices button.on { background: var(--bordeaux); color: #fff; border-color: var(--bordeaux); }

/* Badges */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eee; color: #555; }
.b-pending { background: #eee; color: #666; }
.b-live { background: var(--bordeaux); color: #fff; animation: pulse 1.6s infinite; }
.b-done { background: var(--ok-bg); color: var(--ok); }
.b-fil { background: var(--or-light); color: #6d5410; }
.b-win { background: var(--or); color: #2a2024; }
@keyframes pulse { 50% { opacity: .65; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #f3eee8; border-radius: 999px; padding: 4px 10px; font-size: 14px; }
.chip.me { background: var(--or-light); font-weight: 700; }
.chip .x { margin-left: 4px; }

/* Grille de notation */
.crit { display: grid; grid-template-columns: 1fr 110px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.crit span small { color: var(--muted); }
.crit input { text-align: center; font-size: 18px; padding: 8px; }
.total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 800; padding: 12px 0 0; color: var(--bordeaux); }

/* Tableau */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.final { font-weight: 800; color: var(--bordeaux); }

/* Vote */
.vote-opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; margin-bottom: 8px; padding: 14px; }
.vote-opt.on { border: 2px solid var(--or); background: var(--or-light); }
.vote-opt .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c9bdb0; flex: none; }
.vote-opt.on .radio { border: 7px solid var(--bordeaux); }
.bar { height: 8px; background: #efe8e0; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--or); }

.big { font-size: 42px; font-weight: 800; color: var(--bordeaux); text-align: center; margin: 4px 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: #faf7f3; border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; color: var(--bordeaux); }
.stat small { color: var(--muted); font-size: 12px; }

.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Connexion */
.auth { max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.auth .logo { text-align: center; margin: 10px 0 18px; }
.auth .logo img { width: 110px; height: 110px; object-fit: contain; }
.auth .logo h1 { font-size: 21px; color: var(--bordeaux); margin: 8px 0 2px; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px);
  background: #2a2024; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: 90vw;
  transition: transform .25s; z-index: 50; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--ok); }
#toast.err { background: var(--err); }

details summary { cursor: pointer; font-weight: 600; color: var(--bordeaux); padding: 4px 0; }
.filter { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filter button.on { background: var(--bordeaux); color: #fff; border-color: var(--bordeaux); }
