/* Chrono Clash — style « jeu de société » : papier crème, traits d'encre épais, ombres décalées, couleurs vives. */

@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka-ext.woff2') format('woff2'); font-weight: 300 700; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Mono'; src: url('/fonts/space-mono-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('/fonts/space-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --ink: #1d1a2f;
  --ink-2: #4a4560;
  --paper: #fff4dc;
  --card: #fffdf7;
  --line: #1d1a2f;
  --red: #ff5a5f;
  --gold: #ffb400;
  --mint: #00c2a8;
  --blue: #3d7bff;
  --violet: #a259ff;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --radius: 18px;
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background-color: var(--paper); }
html:has(body[data-view=board]) { background-color: #120f24; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(29, 26, 47, .12) 1.2px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 641px) { body.modal-open { overflow: hidden; } }
body.modal-open #toasts { bottom: auto; top: max(12px, env(safe-area-inset-top)); }
h1, h2, h3 { margin: 0; line-height: 1.1; font-weight: 700; }
p { line-height: 1.45; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .85em; background: rgba(29, 26, 47, .08); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--ink-2); }
.center { text-align: center; }
button, input { font: inherit; color: inherit; }
.btn, .menu-list .btn { font-family: var(--font), var(--emoji); }

/* ---------- Mise en page ---------- */

.page { max-width: 760px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px 60px; }
.page.wide { max-width: 1180px; }
.page.narrow { max-width: 460px; }
.page.center { display: grid; justify-items: center; gap: 12px; padding-top: 18vh; text-align: center; }
.card { background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.loading { display: grid; place-items: center; min-height: 40vh; font-size: 1.1rem; gap: 10px; color: var(--ink-2); }
.spin { display: inline-block; font-size: 2.4rem; animation: spin 1.2s linear infinite; font-family: var(--emoji); }
@keyframes spin { to { transform: rotate(360deg); } }
.big-emoji { font-size: 3.6rem; font-family: var(--emoji); line-height: 1; }
.wobble { animation: wobble 2.4s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) scale(1.06); } }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 2.5px solid var(--line); border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow-sm);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: var(--red); color: #fff; }
.btn.gold { background: var(--gold); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: rgba(29, 26, 47, .07); transform: none; }
.btn.danger { color: #d62839; }
.btn.danger-fill { background: #e63946; color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .92rem; border-radius: 11px; }
.btn.xl { min-height: 60px; padding: 0 28px; font-size: 1.25rem; border-radius: 18px; box-shadow: var(--shadow); }
.btn.icon { width: 44px; padding: 0; font-size: 1.3rem; }
.btn.dark { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .5); box-shadow: none; }
.btn.dark:hover { background: rgba(255, 255, 255, .16); box-shadow: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Accueil ---------- */

.hero { text-align: center; padding: 34px 0 30px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 700; letter-spacing: -.02em; }
.logo b { color: var(--red); -webkit-text-stroke: 0; }
.logo-icon { font-family: var(--emoji); display: inline-block; animation: wobble 3s ease-in-out infinite; }
.tagline { margin: 6px 0 24px; color: var(--ink-2); font-size: 1.1rem; }
.section-title { font-size: 1.2rem; margin: 10px 4px 14px; }
.game-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.game-card { display: grid; gap: 10px; padding: 16px 18px; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease; }
.game-card:hover { transform: translate(-2px, -2px) rotate(-.4deg); box-shadow: 6px 6px 0 var(--ink); }
.game-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.game-name { font-size: 1.2rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { font-weight: 700; }
.avatars { display: flex; gap: 4px; min-height: 30px; align-items: center; }
.meta { font-size: .9rem; color: var(--ink-2); }
.empty { text-align: center; padding: 34px 20px; display: grid; gap: 8px; justify-items: center; }
.empty h2 { font-size: 1.35rem; }
.empty p { margin: 0; color: var(--ink-2); max-width: 36ch; }
.foot { margin-top: 40px; text-align: center; color: var(--ink-2); font-size: .9rem; line-height: 1.8; }

/* ---------- Avatars ---------- */

.avatar {
  --c: var(--blue);
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--c); border: 2px solid var(--line);
  font-family: var(--emoji); font-size: 1.15rem; line-height: 1;
}
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: .9rem; }
.avatar.lg { width: 58px; height: 58px; border-radius: 18px; font-size: 1.9rem; box-shadow: var(--shadow-sm); }

/* ---------- Partie ---------- */

.topbar { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.title-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px; border-radius: 10px; cursor: pointer; text-align: left; }
.title-btn:hover { background: rgba(29, 26, 47, .06); }
.title-btn h1 { font-size: clamp(1.4rem, 5vw, 2rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen { opacity: .5; font-size: 1rem; font-family: var(--emoji); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); border: 2px solid var(--line); flex: none; transition: background .3s; }
body[data-sync=error] .sync-dot { background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.toolbar .gold { margin-left: auto; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 16px; border: 2.5px dashed var(--line); border-radius: 14px; background: #fff; font-weight: 500; }

/* Tableau : 1re colonne (équipe) et dernière (total) collantes, défilement horizontal sur mobile */
.table-wrap { overflow: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; max-height: 70vh; }
.score-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: max-content; }
.score-table th, .score-table td { padding: 6px; border-bottom: 2px solid rgba(29, 26, 47, .12); text-align: center; vertical-align: middle; }
.score-table tbody tr:last-child > * { border-bottom: 0; }
.score-table thead th { position: sticky; top: 0; z-index: 2; background: var(--ink); color: #fff; font-weight: 600; font-size: .9rem; padding: 8px 6px; }
.score-table thead th.col-team { z-index: 3; text-align: left; padding-left: 14px; background: var(--ink); }
.score-table .col-team { position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left; min-width: 150px; max-width: 210px; border-right: 2px solid rgba(29, 26, 47, .12); }
.score-table .col-total { position: sticky; right: 0; z-index: 1; background: #fff8e6; min-width: 120px; border-left: 2.5px solid var(--line); }
.score-table thead .col-total { background: var(--gold); color: var(--ink); z-index: 3; border-left-color: var(--ink); }
.score-table tbody th.col-team { box-shadow: inset 6px 0 0 var(--c); padding-left: 12px; }
.col-round { min-width: 108px; }
.col-add { min-width: 0; }
.add-col { width: 38px; height: 38px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .7); background: transparent; color: #fff; font-size: 1.4rem; font-weight: 700; line-height: 1; cursor: pointer; }
.add-col:hover { background: rgba(255, 255, 255, .15); border-style: solid; }
.score-table tbody .col-add { padding: 0; }

.round-head { display: grid; gap: 1px; width: 100%; background: none; border: 0; color: inherit; cursor: pointer; padding: 2px 4px; border-radius: 8px; }
.round-head:hover { background: rgba(255, 255, 255, .14); }
.round-num { font-family: var(--mono); font-size: .72rem; opacity: .7; }
.round-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.team-cell { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 4px; border-radius: 10px; cursor: pointer; text-align: left; }
.team-cell:hover { background: rgba(29, 26, 47, .06); }
.team-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.time-cell {
  position: relative; width: 100%; min-height: 46px; padding: 0 10px;
  font-family: var(--mono); font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums;
  background: #fff; border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.time-cell:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.time-cell.empty { background: transparent; border-style: dashed; border-color: rgba(29, 26, 47, .35); color: rgba(29, 26, 47, .4); }
.time-cell.empty:hover { border-color: var(--line); color: var(--ink); background: #fff; }
.time-cell .plus { font-family: var(--font); font-size: 1.2rem; }
.time-cell.best { background: #fff1c2; border-color: #c98a00; box-shadow: 0 0 0 3px rgba(255, 180, 0, .35); }
.crown { position: absolute; top: -9px; right: -6px; font-size: .95rem; font-family: var(--emoji); filter: drop-shadow(1px 1px 0 var(--ink)); }
.total { display: block; font-family: var(--mono); font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.rank-pill { display: inline-block; margin-top: 2px; font-size: .85rem; font-weight: 700; font-family: var(--font), var(--emoji); color: var(--ink-2); }
.total-sub { display: block; font-size: .72rem; color: var(--ink-2); font-weight: 500; }

/* Classement en direct */
.live { margin-top: 22px; padding: 18px; }
.live-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.live-head h2 { font-size: 1.35rem; }
.live-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.live-row { display: grid; grid-template-columns: 36px 28px minmax(0, 1fr) minmax(60px, 2fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: #fff; border: 2px solid rgba(29, 26, 47, .15); animation: pop .35s ease both; }
.live-row.first { border-color: var(--line); background: #fff6d6; box-shadow: var(--shadow-sm); }
.live-rank { font-size: 1.25rem; font-weight: 700; text-align: center; font-family: var(--font), var(--emoji); }
.live-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-bar { height: 12px; border-radius: 99px; background: rgba(29, 26, 47, .08); overflow: hidden; border: 1.5px solid rgba(29, 26, 47, .25); }
.live-bar i { display: block; height: 100%; width: var(--w); background: var(--c); border-radius: 99px; transition: width .6s cubic-bezier(.2, 1.4, .4, 1); }
.live-total { font-family: var(--mono); font-weight: 700; text-align: right; display: grid; line-height: 1.15; font-variant-numeric: tabular-nums; }
.live-total small { font-size: .74rem; color: var(--ink-2); font-weight: 400; }
.hint { font-size: .85rem; color: var(--ink-2); margin: 12px 2px 0; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

/* ---------- Fenêtres (feuille en bas sur mobile) ---------- */

.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(29, 26, 47, .55); backdrop-filter: blur(3px); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--card); border: 2.5px solid var(--line); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); padding: 20px; display: grid; gap: 16px; animation: rise .22s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes drop-in { from { transform: translateY(-16px); opacity: 0; } }
@keyframes rise { from { transform: translateY(24px) scale(.97); opacity: 0; } }
.sheet h2 { font-size: 1.4rem; }
.sheet p { margin: 0; }
.sheet-head { display: flex; align-items: center; gap: 14px; }
.eyebrow { font-size: .85rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.sheet-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }
.sheet-actions > :first-child { justify-self: start; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field input:not([type=radio]) { min-height: 50px; padding: 0 14px; border: 2.5px solid var(--line); border-radius: 14px; background: #fff; font-size: 1.1rem; font-weight: 500; }
.field input:focus { outline: none; box-shadow: 0 0 0 4px rgba(61, 123, 255, .3); }
.emoji-grid, .color-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.color-grid { gap: 10px; padding: 6px 4px; }
.emoji-grid label, .color-grid label { cursor: pointer; }
.emoji-grid input, .color-grid input { position: absolute; opacity: 0; pointer-events: none; }
.emoji-grid span { display: grid; place-items: center; width: 42px; height: 42px; font-size: 1.4rem; font-family: var(--emoji); border-radius: 12px; border: 2px solid transparent; transition: transform .1s; }
.emoji-grid span:hover { transform: scale(1.12); }
.emoji-grid input:checked + span { border-color: var(--line); background: #fff1c2; box-shadow: var(--shadow-sm); }
.color-grid span { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 2.5px solid var(--line); transition: transform .1s; }
.color-grid input:checked + span { transform: scale(1.15); box-shadow: 0 0 0 3px var(--card), 0 0 0 5.5px var(--ink); }
.emoji-grid input:focus-visible + span, .color-grid input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.row-btns .gold { flex: 1; }
.menu-list { display: grid; gap: 8px; }
.menu-list .btn { justify-content: flex-start; }

/* Saisie du temps : gros chiffres façon chronomètre */
.time-sheet { border-top: 10px solid var(--c); }
.time-inputs { display: flex; align-items: flex-start; justify-content: center; gap: 6px; }
.time-inputs > b { font-family: var(--mono); font-size: 2.4rem; line-height: 72px; }
.time-inputs label { display: grid; gap: 4px; justify-items: center; font-size: .78rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.time-inputs input {
  width: 92px; height: 76px; text-align: center;
  font-family: var(--mono); font-weight: 700; font-size: 2.3rem; font-variant-numeric: tabular-nums;
  border: 2.5px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow-sm);
}
.time-inputs .cs input { width: 76px; font-size: 1.8rem; background: #fafafa; }
.time-inputs input:focus { outline: none; background: #fff6d6; box-shadow: 0 0 0 4px rgba(255, 180, 0, .45), var(--shadow-sm); }
.time-inputs input::placeholder { color: rgba(29, 26, 47, .2); }
.form-error { color: #d62839; font-weight: 600; text-align: center; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- Notifications ---------- */

#toasts { position: fixed; z-index: 80; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 500; box-shadow: 3px 3px 0 var(--gold); animation: rise .25s cubic-bezier(.2, 1.3, .4, 1); transition: opacity .3s, transform .3s; text-align: center; }
.toast.error { box-shadow: 3px 3px 0 var(--red); }
.toast.out { opacity: 0; transform: translateY(10px); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

/* ---------- Scoreboard ---------- */

body[data-view=board] { background: #120f24; color: #fff; }
.board { position: relative; z-index: 0; min-height: 100dvh; max-width: 1100px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) clamp(14px, 4vw, 40px) 60px; display: grid; gap: clamp(18px, 3vh, 30px); align-content: start; }
.board-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background:
  radial-gradient(60% 45% at 50% 0%, rgba(255, 180, 0, .30), transparent 70%),
  radial-gradient(45% 40% at 5% 95%, rgba(162, 89, 255, .30), transparent 70%),
  radial-gradient(45% 40% at 95% 85%, rgba(0, 194, 168, .22), transparent 70%), #120f24; }
.rays { position: absolute; left: 50%; top: -60vmax; width: 160vmax; height: 160vmax; margin-left: -80vmax; opacity: .9;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .05) 0 6deg, transparent 6deg 14deg); animation: spin 120s linear infinite; }
.floater { position: absolute; bottom: -60px; left: var(--x); font-family: var(--emoji); font-size: 2.2rem; opacity: .16; animation: float var(--s) linear var(--d) infinite; }
@keyframes float { from { transform: translateY(0) rotate(-10deg); } to { transform: translateY(-115vh) rotate(25deg); } }

/* 1fr | titre | 1fr : le titre reste au centre exact de l'écran quelle que soit la largeur des boutons */
.board-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 12px; }
.board-top > .btn { justify-self: start; }
.board-title { display: grid; justify-items: center; gap: 6px; min-width: 0; max-width: min(760px, 70vw); text-align: center; }
.board-eyebrow { font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-family: var(--font), var(--emoji); }
.board-title h1 { max-width: 100%; font-size: clamp(1.6rem, 5vw, 3rem); letter-spacing: -.01em; text-shadow: 3px 3px 0 var(--red); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { padding: 4px 12px; border-radius: 99px; font-size: .85rem; font-weight: 600; background: rgba(255, 255, 255, .1); border: 1.5px solid rgba(255, 255, 255, .25); font-family: var(--font), var(--emoji); }
.status-pill.done { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.board-actions { display: flex; gap: 8px; justify-self: end; }
.board-card { background: rgba(255, 255, 255, .06); border: 1.5px solid rgba(255, 255, 255, .14); border-radius: 22px; padding: clamp(14px, 2.5vw, 22px); backdrop-filter: blur(6px); }
.board-h2 { font-size: 1.15rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.board-h2.out { margin: 4px 4px 12px; }
.board-hint { text-align: center; color: rgba(255, 255, 255, .6); margin: 0; }
.suspense { text-align: center; font-size: 1.4rem; font-weight: 700; margin: 0; animation: blink 1.2s ease-in-out infinite; font-family: var(--font), var(--emoji); }

/* États vides */
.board-empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 40px 20px; margin-top: 4vh; }
.board-empty h2 { font-size: 1.6rem; }
.board-empty p { margin: 0 0 6px; color: rgba(255, 255, 255, .7); }
.lineup-head { text-align: center; }
.lineup-head h2 { font-size: clamp(1.4rem, 4vw, 2.2rem); }
.lineup-head p { color: rgba(255, 255, 255, .7); margin: 6px 0 0; }
.lineup { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 220px)); justify-content: center; }
.lineup-card { display: grid; justify-items: center; gap: 6px; padding: 22px 12px 18px; border-radius: 22px; text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 40%, transparent), rgba(255, 255, 255, .04)); border: 2px solid color-mix(in srgb, var(--c) 70%, #fff);
  animation: drop .6s cubic-bezier(.2, 1.4, .4, 1) var(--d) both; }
.lineup-avatar { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 26px; background: var(--c); border: 3px solid #fff; font-family: var(--emoji); font-size: 2.8rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: bounce 2.2s ease-in-out var(--d) infinite; }
.lineup-card b { font-size: 1.15rem; }
.lineup-card small { color: rgba(255, 255, 255, .65); }

/* Podium */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: clamp(8px, 2vw, 22px); width: 100%; max-width: 820px; margin: 0 auto; }
.podium.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 560px; }
.podium.n1 { grid-template-columns: minmax(0, 1fr); max-width: 300px; }
.podium-col { display: grid; justify-items: center; gap: 8px; text-align: center; min-width: 0; }
.podium-col.in { animation: drop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.podium-col.hidden .podium-block { filter: grayscale(.8) brightness(.6); }
@keyframes drop { from { transform: translateY(-40px) scale(.8); opacity: 0; } }
.podium-avatar { position: relative; display: grid; place-items: center; width: clamp(64px, 14vw, 116px); aspect-ratio: 1; border-radius: 28%; background: var(--c); border: 3px solid #fff; font-family: var(--emoji); font-size: clamp(2rem, 7vw, 3.6rem); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.podium-col.hidden .podium-avatar { background: #2c2747; }
.podium-avatar.champion { animation: bounce 1.6s ease-in-out infinite; box-shadow: 0 0 0 6px rgba(255, 180, 0, .35), 0 0 60px rgba(255, 180, 0, .6); }
.podium-avatar.champion::before { content: '👑'; position: absolute; top: -.62em; left: 50%; transform: translateX(-50%) rotate(-10deg); font-size: .55em; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .35)); }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.podium-name { font-weight: 700; font-size: clamp(1rem, 2.6vw, 1.45rem); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-time { font-family: var(--mono); font-weight: 700; font-size: clamp(1.05rem, 3vw, 1.8rem); color: var(--gold); font-variant-numeric: tabular-nums; }
.podium-sub { font-family: var(--mono); font-size: .8rem; color: rgba(255, 255, 255, .6); margin-top: -6px; }
.podium-block { width: 100%; display: grid; place-items: start center; padding-top: 10px; border-radius: 18px 18px 0 0;
  background: linear-gradient(180deg, var(--c), color-mix(in srgb, var(--c) 45%, #120f24)); border: 3px solid rgba(255, 255, 255, .85); border-bottom: 0;
  font-size: clamp(2rem, 7vw, 3.8rem); font-weight: 700; text-shadow: 3px 3px 0 rgba(0, 0, 0, .35); box-shadow: inset 0 -30px 40px rgba(0, 0, 0, .25); }
.p1 .podium-block { height: clamp(120px, 24vh, 220px); }
.p2 .podium-block { height: clamp(86px, 16vh, 160px); }
.p3 .podium-block { height: clamp(60px, 11vh, 110px); }

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; padding: 14px 16px; border-radius: 18px; background: rgba(255, 255, 255, .07); border: 1.5px solid rgba(255, 255, 255, .14); min-width: 0; }
.stat-icon { font-family: var(--emoji); font-size: 1.3rem; }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .6); font-weight: 600; }
.stat-value { font-weight: 700; font-size: 1.15rem; font-family: var(--font), var(--emoji); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value small { font-weight: 500; font-size: .8rem; color: rgba(255, 255, 255, .6); }

/* Classement complet */
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 40px 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, .06); border: 1.5px solid rgba(255, 255, 255, .1); box-shadow: inset 5px 0 0 var(--c); }
.rank-row.first { background: linear-gradient(90deg, rgba(255, 180, 0, .22), rgba(255, 255, 255, .05)); border-color: rgba(255, 180, 0, .55); }
.rank-row.in { animation: slide .45s ease both; animation-delay: var(--d); }
.rank-row.hidden { opacity: .35; }
@keyframes slide { from { transform: translateX(-24px); opacity: 0; } }
.rank-num { font-size: 1.35rem; font-weight: 700; text-align: center; font-family: var(--font), var(--emoji); color: rgba(255, 255, 255, .8); }
.rank-row .avatar { width: 40px; height: 40px; border-color: #fff; font-size: 1.3rem; }
.rank-main { display: grid; gap: 6px; min-width: 0; }
.rank-main b { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-family: var(--mono); font-size: .78rem; background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .85); }
.pill i { font-style: normal; font-size: .68rem; opacity: .6; }
.pill.none { background: transparent; border: 1px dashed rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .4); }
.pill.best { background: var(--gold); color: var(--ink); font-weight: 700; }
.rank-total { display: grid; justify-items: end; line-height: 1.2; }
.rank-total b { font-family: var(--mono); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.rank-total small { font-family: var(--mono); font-size: .78rem; color: rgba(255, 255, 255, .55); }

/* Manche par manche */
.rounds-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.round-card { padding: 14px 16px; border-radius: 18px; background: rgba(255, 255, 255, .06); border: 1.5px solid rgba(255, 255, 255, .14); }
.round-card.todo { border-style: dashed; opacity: .7; }
.round-card h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 10px; }
.round-card h3 span { font-family: var(--mono); font-size: .75rem; padding: 2px 7px; border-radius: 8px; background: var(--gold); color: var(--ink); }
.round-card ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.round-card li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: .9rem; }
.rb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font), var(--emoji); }
.rb-time { grid-row: 1; grid-column: 2; font-family: var(--mono); font-weight: 700; text-align: right; }
.rb-bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.rb-bar i { display: block; height: 100%; width: var(--w); background: var(--c); border-radius: 99px; animation: grow .8s cubic-bezier(.2, 1, .3, 1) both; }
@keyframes grow { from { width: 0; } }
.rb-empty { color: rgba(255, 255, 255, .5); font-style: italic; display: block !important; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  /* Mobile : boutons sur la 1re ligne (← à gauche, actions à droite), titre centré sur toute la largeur en dessous */
  .board-top { grid-template-columns: auto minmax(0, 1fr); row-gap: 10px; }
  .board-top > .btn { grid-column: 1; grid-row: 1; }
  .board-actions { grid-column: 2; grid-row: 1; }
  .board-title { grid-column: 1 / -1; grid-row: 2; max-width: 100%; }
  .board-title h1 { white-space: normal; overflow-wrap: anywhere; line-height: 1.05; }
  .rank-row { grid-template-columns: 30px 34px minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
  .rank-row .avatar { width: 34px; height: 34px; font-size: 1.1rem; }
  .rank-total b { font-size: 1.05rem; }
  .stat { padding: 12px; }
  .lineup { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
  .lineup-card { width: calc(50% - 5px); }
  .lineup-card { padding: 16px 8px 14px; }
  .lineup-avatar { width: 64px; height: 64px; font-size: 2.1rem; border-radius: 20px; }
  .lineup-card b { font-size: 1rem; }
  .stat-value { font-size: 1rem; }
}

/* ---------- Connexion et comptes ---------- */

.home-top { display: flex; justify-content: flex-end; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 5px; border: 2px solid var(--line); border-radius: 99px; background: var(--card); box-shadow: var(--shadow-sm); font-family: var(--font), var(--emoji); font-weight: 600; cursor: pointer; }
.user-chip:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.user-dot { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--violet); color: #fff; font-weight: 700; border: 2px solid var(--line); flex: none; }
.user-dot.lg { width: 48px; height: 48px; font-size: 1.3rem; }
.login-page { display: grid; justify-items: center; gap: 22px; padding-top: max(10vh, 30px); }
.login-page .logo { font-size: clamp(2.3rem, 10vw, 3.2rem); }
.login-card { width: 100%; padding: 24px 20px; display: grid; gap: 16px; transform: rotate(-.6deg); }
.login-card h1 { font-size: 1.5rem; }
.login-card .btn.xl { width: 100%; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 54px !important; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 38px; border: 0; border-radius: 10px; background: transparent; font-family: var(--emoji); font-size: 1.2rem; cursor: pointer; }
.pw-eye:hover { background: rgba(29, 26, 47, .07); }
.field input:disabled { background: rgba(29, 26, 47, .06); color: var(--ink-2); }
.page-title { font-size: clamp(1.5rem, 5vw, 2rem); flex: 1; }
.user-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.user-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.user-row.off { opacity: .6; }
.user-row.off .user-dot { background: #8a8698; }
.user-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.user-info b { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; }
.user-info small { color: var(--ink-2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; border: 1.5px solid var(--line); font-size: .78rem; font-weight: 600; background: #fff; font-family: var(--font), var(--emoji); }
.badge.gold { background: var(--gold); }
.badge.red { background: var(--red); color: #fff; }
.creds { margin: 0; padding: 14px; border: 2px dashed var(--line); border-radius: 14px; background: #fff; font-family: var(--mono); font-size: .9rem; white-space: pre-wrap; word-break: break-all; user-select: all; }
.big-emoji.center { text-align: center; }

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  body { font-size: 16px; }
  .page { padding-left: 12px; padding-right: 12px; }
  .toolbar { gap: 8px; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar .ghost { order: 5; flex-basis: 100%; }
  .toolbar .gold { margin-left: 0; }
  .score-table .col-team { min-width: 118px; max-width: 128px; }
  .score-table tbody th.col-team { padding-left: 10px; padding-right: 4px; }
  .team-cell { gap: 6px; }
  .team-name { font-size: .88rem; line-height: 1.12; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .team-cell .avatar { width: 26px; height: 26px; font-size: .9rem; border-radius: 8px; }
  .col-round { min-width: 92px; }
  .time-cell { font-size: .92rem; padding: 0 6px; }
  .score-table .col-total { min-width: 92px; }
  .total { font-size: .98rem; }
  .live { padding: 14px 12px; }
  .live-row { grid-template-columns: 30px 28px minmax(0, 1fr) auto; gap: 8px; }
  .live-bar { display: none; }
  /* Fenêtres sur mobile = écran normal en haut de la page (pas de position fixe) : la page est masquée derrière.
     Le clavier iOS ne réduit pas la page et déplace les éléments fixes : seul un contenu dans le flux, en haut, reste fiable. */
  body.modal-open #view { display: none; }
  body.modal-open #toasts { display: none; }
  .overlay { position: static; display: block; padding: 0; background: none; backdrop-filter: none; animation: none; }
  .sheet { width: 100%; max-height: none; overflow: visible; border: 0; border-bottom: 2.5px solid var(--line); border-radius: 0 0 24px 24px;
    box-shadow: 0 4px 0 var(--ink); padding: max(16px, env(safe-area-inset-top)) 16px 18px; gap: 14px; animation: drop-in .18s ease; }
  .time-sheet { border-top: 0; box-shadow: inset 0 8px 0 var(--c), 0 4px 0 var(--ink); padding-top: max(24px, calc(env(safe-area-inset-top) + 8px)); }
  .time-sheet .hint { display: none; }
  .time-sheet .avatar.lg { width: 48px; height: 48px; font-size: 1.6rem; border-radius: 15px; }
  .sheet-actions .btn { min-height: 48px; }
  .time-inputs input { width: 84px; height: 72px; font-size: 2.1rem; }
  .time-inputs .cs input { width: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
