:root {
  color-scheme: light;
  --ink: #1b2430;
  --muted: #5d6976;
  --line: #e4ddd0;
  --paper: #f6f3ec;
  --card: #fffdf8;
  --navy: #123044;
  --teal: #0f6e6b;
  --amber: #8a5a00;
  --amber-bg: #f4e4c4;
  --green: #0e5c3c;
  --green-bg: #d9f0e4;
  --red: #8d2f2f;
  --shadow: 0 10px 30px rgba(18, 48, 68, 0.06);
  font-family: Aptos, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: var(--navy);
  color: white;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 700; letter-spacing: 0.04em; text-decoration: none; text-transform: uppercase; font-size: 14px; }
nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
nav a { color: rgba(255,255,255,.82); text-decoration: none; font-size: 14px; }
nav a.active { color: white; border-bottom: 2px solid #8fd0c8; }
.chip { border-radius: 999px; padding: 4px 10px; background: rgba(255,255,255,.12); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.chip.live { background: var(--green); }
.chip.err { background: var(--red); }
.banner { background: #e7f3f2; color: var(--navy); padding: 10px 22px; font-weight: 650; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 220px;
}
button, .button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--teal);
  color: white;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
button.ghost, .button.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
button.danger { background: var(--red); }
button:disabled { opacity: .55; cursor: wait; }
h1 { font-size: 32px; line-height: 1.1; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 10px; }
.lede { color: var(--muted); max-width: 68ch; }
.meta { color: var(--muted); font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f3faf8; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: #ece7dc; }
.badge.officiel { background: var(--green-bg); color: var(--green); }
.badge.endirect { background: #e7f3f2; color: var(--teal); }
.badge.enattente { background: #ece7dc; color: var(--muted); }
.lane-center { background: #f3faf8; }
.finals-split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; align-items: start; }
.badge.provisoire { background: var(--amber-bg); color: var(--amber); }
.badge.info { background: #eceff3; color: #526070; }
.place { font-weight: 750; font-size: 18px; }
.crew small, .sub { display: block; color: var(--muted); font-size: 12px; }
.place-control { color: var(--amber); }
.scroll { overflow-x: auto; }
.empty { padding: 28px 8px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.card { background: #f8f5ee; border-radius: 12px; padding: 12px; }
.card b { display: block; font-size: 24px; }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--navy);
  color: white;
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 360px;
}
.exports { display: flex; gap: 8px; flex-wrap: wrap; }
.tight { outline: 2px solid var(--amber); }
body.screen .topbar nav, body.screen .wrap { max-width: none; }
body.screen h1 { font-size: 64px; }
body.screen .place, body.screen .big-time { font-size: 42px; }
body.screen .panel { min-height: 70vh; }
.medal-table .medal-gold, .medal-label-gold { font-weight: 700; color: #8a5a00; }
.medal-label-silver { font-weight: 700; color: #5c6770; }
.medal-label-bronze { font-weight: 700; color: #8a4b32; }
.medal-block { margin-top: 16px; }
.medal-block h3 { margin: 0; font-size: 16px; }

body.public {
  background: #fff;
  color: #16181d;
  font-family: Bahnschrift, "Arial Narrow", "Segoe UI", sans-serif;
  font-stretch: semi-condensed;
}
body.public .topbar, body.public .banner, body.public .toast { display: none; }
body.public .wrap { max-width: none; margin: 0; padding: 0; }
.mast { background: #fff; border-bottom: 3px solid #e30613; }
.mast-logos {
  height: 92px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 40px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.mast-logos img { width: auto; object-fit: contain; }
.logo-ffa { height: 44px; justify-self: start; }
.logo-cnr { height: 34px; justify-self: center; }
.logo-vichy { height: 50px; justify-self: end; }
.sheet {
  max-width: 1360px;
  margin: 0 auto;
  padding: 26px 40px 32px;
  min-height: calc(100vh - 95px);
  display: flex;
  flex-direction: column;
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 18px; }
.kicker { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #8a847c; }
.sheet-head h1 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.live { display: flex; align-items: center; gap: 10px; margin: 0 0 2px; color: #0c7a45; font-size: 13px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
.live time { color: #16181d; letter-spacing: 0; font-size: 20px; font-variant-numeric: tabular-nums; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #12a15a; box-shadow: 0 0 0 0 rgba(18,161,90,.45); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(18,161,90,0); } }
.board { flex: 1; display: flex; flex-direction: column; }
.board-row {
  flex: 1 1 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 84px 104px 104px 88px;
  align-items: center;
  padding: 0 8px 0 0;
  border-bottom: 1px solid #eeeae3;
}
.board-row:last-child { border-bottom: 0; }
.board-labels { flex: 0 0 38px; min-height: 38px; color: #8d877f; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; border-bottom-color: #d9d3c8; }
.board-labels span:nth-child(n+3) { text-align: center; }
.board-row.p1 { box-shadow: inset 4px 0 0 #c6a15a; }
.board-row.p2 { box-shadow: inset 4px 0 0 #b0b8c1; }
.board-row.p3 { box-shadow: inset 4px 0 0 #c48b62; }
.board-row.moved { animation: wash 1.5s ease; }
@keyframes wash { from { background: #f6edd6; } }
.rank { font-size: 22px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; color: #b4aea6; }
.p1 .rank { color: #a8842f; }
.p2 .rank { color: #6d7782; }
.p3 .rank { color: #a56a42; }
.lead .rank { font-size: 28px; }
.crew { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.org { flex: 0 0 58px; font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #9a948c; }
.region { font-size: 24px; font-weight: 600; letter-spacing: .01em; line-height: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead .region { font-size: 30px; }
.n { text-align: center; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; color: #d4cec6; }
.n.on.gold { color: #a37b24; }
.n.on.silver { color: #5c6770; }
.n.on.bronze { color: #8d5a38; }
.n.total { color: #16181d; }
.lead .n { font-size: 32px; }
.board-empty { color: #6f6a64; font-size: 20px; }
@media (max-width: 800px) {
  .mast-logos { height: 72px; padding: 0 16px; }
  .logo-ffa { height: 28px; }
  .logo-cnr { height: 22px; }
  .logo-vichy { height: 32px; }
  .sheet { padding: 18px 16px 28px; }
  .sheet-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .sheet-head h1 { font-size: 26px; }
  .board-row { grid-template-columns: 28px minmax(0, 1fr) 34px 38px 34px 36px; }
  .board-labels { letter-spacing: 0; font-size: 10px; }
  .col-h { font-size: 0; }
  .col-h::after { content: attr(data-short); font-size: 10px; letter-spacing: 0; }
  .region, .lead .region { font-size: 15px; }
  .rank, .lead .rank, .n, .lead .n { font-size: 16px; }
  .org { display: none; }
}
@media (max-width: 800px) {
  .finals-split { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  h1 { font-size: 26px; }
  .topbar { align-items: flex-start; }
}
