:root {
  color-scheme: dark;
  --bg: #0b0f13;
  --surface: #111820;
  --surface-2: #17212b;
  --surface-3: #1d2935;
  --border: #2c3945;
  --text: #f4f0e6;
  --muted: #9aa7b5;
  --amber: #d89a34;
  --amber-soft: #5c4520;
  --green: #4daf83;
  --green-soft: #163a2e;
  --red: #d86652;
  --red-soft: #48241f;
  --shadow: 0 18px 50px rgb(0 0 0 / 24%);
  --radius: 18px;
  --max: 1280px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% 0%, #162029 0, transparent 38%), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 78px; padding: 14px max(22px, calc((100vw - var(--max)) / 2));
  background: rgb(11 15 19 / 92%); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 46px; height: 46px; }
.brand-copy strong { display: block; font-size: 17px; letter-spacing: .02em; }
.brand-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.mode-nav { display: flex; gap: 8px; }
.mode-link { padding: 10px 14px; border: 1px solid transparent; border-radius: 999px; color: var(--muted); font-weight: 750; text-decoration: none; }
.mode-link:hover, .mode-link.active { color: var(--text); background: var(--surface-2); border-color: var(--border); }

.page { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; padding: 42px 0 70px; }
.page-narrow { width: min(760px, calc(100% - 32px)); }
.eyebrow { color: var(--amber); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(34px, 5vw, 64px); line-height: .98; letter-spacing: -.04em; }
h2 { margin-bottom: 18px; font-size: clamp(22px, 2.5vw, 32px); letter-spacing: -.025em; }
h3 { margin-bottom: 10px; font-size: 18px; }
.lede { max-width: 720px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 28px; }
.page-head-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 10px; }

.panel { background: linear-gradient(145deg, rgb(23 33 43 / 92%), rgb(17 24 32 / 98%)); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 24px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr); gap: 18px; align-items: start; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-head h2, .section-head h3 { margin: 0; }

.btn { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 10px 17px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); color: var(--text); font-weight: 850; cursor: pointer; text-decoration: none; transition: .16s ease; }
.btn:hover { transform: translateY(-1px); border-color: #586879; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #17130d; }
.btn-success { background: var(--green); border-color: var(--green); color: #081a14; }
.btn-danger { color: #ffd9d2; background: var(--red-soft); border-color: #6f3328; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 36px; padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }

.field { display: grid; gap: 7px; }
.field label { color: #c7d0d9; font-size: 13px; font-weight: 800; }
.input { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 11px; outline: 0; background: #0d141b; color: var(--text); }
.input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgb(216 154 52 / 15%); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.badge { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 6px 10px; border-radius: 999px; background: var(--surface-3); color: #b9c4cf; font-size: 12px; font-weight: 850; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-pending { color: #f0bd60; background: #42341d; }
.badge-success { color: #66d5a7; background: var(--green-soft); }
.badge-danger { color: #f28a77; background: var(--red-soft); }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.empty { padding: 28px; border: 1px dashed #374653; border-radius: 14px; color: var(--muted); text-align: center; }
.divider { height: 1px; margin: 20px 0; background: var(--border); }

.stat-card { padding: 20px; }
.stat-value { display: block; margin-top: 7px; font-size: 36px; font-weight: 900; letter-spacing: -.04em; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 750; }
.team-card { padding: 17px; }
.team-title { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.team-title h3 { margin: 0; }
.team-card p { margin: 8px 0 14px; color: var(--muted); }
.team-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.code { padding: 3px 7px; border: 1px solid var(--border); border-radius: 6px; background: #0b1117; color: #d9e0e7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.code-missing { color: var(--muted); font-family: inherit; letter-spacing: 0; }

.qr-card { text-align: center; }
.qr-card img { width: min(240px, 100%); padding: 10px; border-radius: 14px; background: #f7f3e8; }
.qr-card p { margin: 12px auto 0; color: var(--muted); word-break: break-all; font-size: 12px; }
.admin-toolbar { position: sticky; top: 92px; z-index: 8; display: flex; flex-wrap: wrap; gap: 9px; padding: 12px; margin-bottom: 18px; background: rgb(17 24 32 / 92%); backdrop-filter: blur(12px); }
.admin-progress { display: flex; min-width: 210px; flex: 1 1 250px; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 10px; background: #0e151c; }
.admin-progress strong { white-space: nowrap; }
.progress-track { width: min(180px, 40%); height: 7px; overflow: hidden; border-radius: 999px; background: #293642; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--amber); }
.field-help { color: var(--muted); font-size: 12px; }
.pool-preview { padding: 11px 13px; border: 1px solid #6e5524; border-radius: 10px; background: #2d2517; color: #eacb91; font-size: 13px; font-weight: 800; }

.pool-card { overflow: hidden; }
.pool-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.target-pill { color: #1c1509; background: var(--amber); }
.ranking { width: 100%; border-collapse: collapse; }
.ranking th, .ranking td { padding: 11px 13px; border-bottom: 1px solid rgb(44 57 69 / 65%); text-align: center; }
.ranking th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.ranking th:nth-child(2), .ranking td:nth-child(2) { text-align: left; }
.ranking tr:last-child td { border-bottom: 0; }
.rank { color: var(--muted); font-weight: 900; }
.match-list { display: grid; gap: 9px; }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--border); border-radius: 13px; background: #101820; }
.match-row .away { text-align: right; }
.match-score { min-width: 64px; text-align: center; font-size: 20px; font-weight: 950; }
.winner-label, .pending-winner { display: inline-flex; max-width: 260px; align-items: center; justify-content: center; padding: 7px 10px; border-radius: 999px; font-size: 13px; line-height: 1.2; }
.winner-label { color: #61e5a9; background: var(--green-soft); }
.pending-winner { color: #eacb91; background: #2d2517; }
.match-meta { color: var(--muted); font-size: 12px; }
.winner-editor { display: grid; grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 10px; }
.winner-editor > span { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.winner-choice { min-height: 42px; white-space: normal; }
.match-tiebreak { border-color: #88691f; background: linear-gradient(115deg, rgb(216 154 52 / 10%), transparent 45%), #101820; }
.tie-marker { display: inline-block; margin-left: 7px; padding: 2px 5px; border-radius: 999px; background: #3b3019; color: #eacb91; font-size: 9px; text-transform: uppercase; }
.ranking-tied { background: rgb(216 154 52 / 5%); }
.match-row > .btn { grid-column: 1 / -1; justify-self: end; }
.pending-admin-actions { display: flex; grid-column: 1 / -1; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid #6e5524; border-radius: 10px; background: #2d2517; }
.pending-admin-actions p { margin: 0; color: #eacb91; font-size: 13px; }

.player-hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; align-items: stretch; }
.player-next { padding: 26px; border-color: #76591f; background: radial-gradient(circle at 85% 15%, rgb(216 154 52 / 18%), transparent 40%), var(--surface); }
.versus { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 28px 0; }
.versus strong { max-width: 42%; font-size: clamp(20px, 4vw, 32px); }
.versus strong:last-child { text-align: right; }
.versus span { color: var(--amber); font-size: 12px; font-weight: 950; }
.target-number { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 900; }
.target-number b { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; background: var(--amber); color: #16120b; }

.registration-hero { margin-bottom: 20px; text-align: center; }
.registration-hero img { width: 86px; }
.success-code { padding: 22px; border: 1px solid #32674f; border-radius: 14px; background: var(--green-soft); text-align: center; }
.success-code .code { display: block; width: fit-content; margin: 14px auto; padding: 10px 15px; font-size: 26px; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; max-width: min(480px, calc(100% - 32px)); padding: 12px 17px; border: 1px solid var(--border); border-radius: 12px; background: #202b36; color: var(--text); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #804137; background: #3f241f; }

/* Affichage public */
.tv { min-height: 100vh; padding: clamp(22px, 3vw, 52px); background: radial-gradient(circle at 70% -10%, #24333e, transparent 42%), #090d11; }
.tv-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.tv-brand { display: flex; align-items: center; gap: 16px; }
.tv-brand img { width: 62px; height: 62px; }
.tv-brand h1 { margin: 0; font-size: clamp(28px, 4vw, 58px); }
.tv-brand p { margin: 5px 0 0; color: var(--muted); }
.tv-controls { display: flex; align-items: center; gap: 12px; }
.tv-clock { font-size: clamp(24px, 3vw, 42px); font-weight: 900; font-variant-numeric: tabular-nums; }
.tv-screen { min-height: calc(100vh - 180px); padding: clamp(22px, 3vw, 42px); border: 1px solid #334453; border-radius: 24px; background: rgb(17 24 32 / 88%); box-shadow: 0 28px 90px rgb(0 0 0 / 35%); }
.tv-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.tv-title h2 { margin: 0; font-size: clamp(30px, 4vw, 58px); }
.tv-kicker { color: var(--amber); font-weight: 900; text-transform: uppercase; letter-spacing: .14em; }
.tv-dots { display: flex; gap: 8px; }
.tv-dot { width: 34px; height: 6px; border: 0; border-radius: 999px; background: #33404c; cursor: pointer; }
.tv-dot.active { background: var(--amber); }
.tv-pools { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.tv .ranking th, .tv .ranking td { padding: clamp(10px, 1.2vw, 18px); font-size: clamp(14px, 1.25vw, 21px); }
.tv .pool-head { padding: 20px 24px; }
.tv .pool-head h3 { font-size: 26px; }
.upcoming-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 18px; }
.upcoming-pool { padding: 24px; }
.target-big { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.target-big span { color: var(--muted); font-size: 18px; font-weight: 800; }
.target-big b { display: grid; place-items: center; width: 78px; height: 78px; border-radius: 50%; background: var(--amber); color: #15110a; font-size: 34px; }
.next-duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 120px; }
.next-duel strong { font-size: clamp(22px, 2vw, 34px); }
.next-duel strong:last-child { text-align: right; }
.next-duel span { color: var(--amber); font-weight: 950; }
.following { display: grid; gap: 8px; padding-top: 15px; border-top: 1px solid var(--border); }
.following p { display: flex; justify-content: space-between; gap: 12px; margin: 0; color: var(--muted); }
.result-wall { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.result-card { min-height: 245px; padding: clamp(22px, 2.2vw, 34px); border-color: #334453; background: linear-gradient(135deg, rgb(255 255 255 / 2%), transparent 50%), var(--surface); }
.result-meta { display: flex; align-items: center; gap: 11px; color: #aab6c3; font-size: clamp(12px, 1.1vw, 17px); font-weight: 950; letter-spacing: .12em; text-transform: uppercase; }
.result-meta i { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.result-main { display: flex; align-items: center; gap: clamp(18px, 2vw, 30px); margin-top: clamp(24px, 3vw, 40px); }
.result-trophy { flex: 0 0 auto; font-size: clamp(54px, 5vw, 82px); filter: drop-shadow(0 10px 18px rgb(216 154 52 / 16%)); }
.result-copy { min-width: 0; }
.result-copy strong { display: block; overflow-wrap: anywhere; font-size: clamp(28px, 3.2vw, 52px); font-weight: 950; line-height: .98; text-transform: uppercase; }
.result-copy p { margin: 20px 0 0; color: #e7ebef; font-size: clamp(16px, 1.5vw, 23px); }
.result-copy p::before { display: block; width: 38px; height: 5px; margin-bottom: 13px; border-radius: 999px; background: #61e5a9; content: ''; }
.result-copy p b { color: #61e5a9; }
.bracket { display: grid; grid-template-columns: 1fr .8fr; gap: 40px; align-items: center; }
.bracket-column { display: grid; gap: 24px; }
.bracket-match { padding: 18px; }
.bracket-label { color: var(--amber); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.bracket-team { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0 6px; border-bottom: 1px solid var(--border); font-size: 20px; font-weight: 800; }
.bracket-team:last-child { border: 0; }
.stat-wall { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.tv-stat { min-height: 200px; padding: 26px; display: flex; flex-direction: column; justify-content: space-between; }
.tv-stat span { color: var(--muted); font-size: 16px; font-weight: 800; }
.tv-stat strong { font-size: clamp(27px, 3vw, 44px); }
.tv-stat b { color: var(--amber); font-size: 24px; }

@media (max-width: 820px) {
  .topbar { min-height: 68px; padding: 10px 14px; }
  .brand img { width: 40px; height: 40px; }
  .brand-copy span { display: none; }
  .mode-link { padding: 9px 10px; font-size: 13px; }
  .mode-link span { display: none; }
  .page { width: min(100% - 24px, 760px); padding: 28px 0 90px; }
  .page-head { align-items: start; flex-direction: column; }
  .page-head-actions { justify-content: start; }
  .grid-2, .grid-3, .split, .player-hero { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .admin-toolbar { top: 70px; }
  .match-row { grid-template-columns: 1fr auto 1fr; font-size: 14px; }
  .winner-editor { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .winner-editor > span { grid-column: 1 / -1; }
  .ranking th, .ranking td { padding: 9px 7px; font-size: 12px; }
  .tv { padding: 14px; }
  .tv-top { margin-bottom: 14px; }
  .tv-brand img { width: 44px; height: 44px; }
  .tv-brand p { display: none; }
  .tv-clock { display: none; }
  .tv-screen { min-height: calc(100vh - 95px); padding: 18px; border-radius: 18px; }
  .tv-title { align-items: start; flex-direction: column; margin-bottom: 18px; }
  .tv-pools, .upcoming-grid, .result-wall, .stat-wall, .bracket { grid-template-columns: 1fr; }
  .tv .ranking th, .tv .ranking td { font-size: 13px; padding: 9px 7px; }
}

@media (max-width: 520px) {
  .brand-copy strong { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mode-nav { gap: 3px; }
  .mode-link { padding: 8px; }
  .panel-pad { padding: 18px; }
  .stat-value { font-size: 30px; }
  .versus { align-items: start; flex-direction: column; }
  .versus strong { max-width: none; }
  .versus strong:last-child { text-align: left; }
  .result-card { min-height: 0; }
  .result-main { align-items: flex-start; }
  .result-trophy { font-size: 46px; }
  .match-score { grid-column: 1 / -1; grid-row: 2; }
  .winner-label, .pending-winner { max-width: 100%; }
}
