/* ═══════════════════════════════════════════════════════════
   DEUCE — Design System dark
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg:      #0e0b09;
    --surface: #1a1310;
    --border:  #2e2018;
    --accent:  #c8522a;
    --text:    #f5ede8;
    --muted:   #9e8678;
    --danger:  #f85149;
    --gold:    #e8a830;
    --nav-h:   64px;
    --header-h:52px;
    --radius:  12px;
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent; scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { display: none; width: 0; height: 0; }

html { touch-action: manipulation; scrollbar-width: none; -ms-overflow-style: none; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased; overscroll-behavior: none; }

/* position:fixed;inset:0 = couvre exactement le viewport, fiable sur tous les iOS PWA */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── Shell ──────────────────────────────────────────────────── */
.app-header { height: calc(var(--header-h) + var(--safe-top)); padding-top: var(--safe-top);
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding-left: 16px; padding-right: 16px;
    flex-shrink: 0; z-index: 100; }
.app-header .logo { font-size: 20px; font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.logo-img { height: 32px; width: auto; display: block; }
.notif-btn { background: none; border: none; cursor: pointer; position: relative;
    font-size: 22px; line-height: 1; color: var(--text); }
.notif-btn .badge { position: absolute; top: -4px; right: -6px; background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; border-radius: 50%; min-width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px; }
#content { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 8px); scrollbar-width: none; }
#content::-webkit-scrollbar { display: none; }
.bottom-nav { height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; }
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; background: none; border: none; cursor: pointer; color: var(--muted);
    font-size: 10px; font-weight: 500; transition: color .2s; padding: 8px 0; }
.nav-btn .icon { font-size: 22px; line-height: 1; }
.nav-btn.active { color: var(--accent); }

/* ── Cards ──────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 12px; }
.border-accent { border-color: var(--accent) !important; }
.notif-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; padding: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; padding: 0; }
.text-muted  { color: var(--muted); font-size: 13px; }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-gold   { color: var(--gold); }
.text-sm     { font-size: 12px; }
.text-center { text-align: center; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; transition: opacity .15s; text-decoration: none;
    -webkit-tap-highlight-color: transparent; -webkit-appearance: none; }
.btn:active { opacity: .8; border-radius: 8px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost   { background: transparent; color: var(--muted); }
.btn-sm      { padding: 6px 12px; font-size: 12px; }
.btn-md      { padding: 8px 14px; font-size: 13px; }
.btn-full    { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Inputs ──────────────────────────────────────────────────── */
.input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 16px; padding: 11px 13px; outline: none; transition: border-color .2s; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
.input-group { margin-bottom: 12px; }
.input-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

/* ── Modal ───────────────────────────────────────────────────── */
.match-toast { position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%) translateY(12px);
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    padding: 10px 20px; font-size: 14px; font-weight: 600; color: var(--text);
    box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 200;
    opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; }
.match-toast.match-toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 200; display: flex; align-items: flex-end; }
.modal-box { background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px; padding-bottom: calc(24px + var(--safe-bottom)); width: 100%;
    max-height: 80vh; overflow-y: auto; border-top: 2px solid var(--accent); position: relative;
    transform: translateY(0); transition: transform .25s ease-out; }
@starting-style { .modal-box { transform: translateY(100%); } }

/* ── Avatar ──────────────────────────────────────────────────── */
.avatar { border-radius: 50%; object-fit: cover; background: var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--text); flex-shrink: 0; overflow: hidden; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 52px; height: 52px; font-size: 20px; }
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }

/* ── Pill ────────────────────────────────────────────────────── */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill-pending   { background: rgba(139,148,158,.2); color: var(--muted); }
.pill-progress  { background: rgba(16,185,129,.2);  color: var(--accent); }
.pill-finished  { background: rgba(255,215,0,.15);  color: var(--gold); }
.pill-cancelled { background: rgba(248,81,73,.15);  color: var(--danger); }
.pill-paused    { background: rgba(139,148,158,.2); color: var(--muted); }

/* ── Stats ───────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 10px; margin-bottom: 12px; }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge-card { border-radius: 12px; display: flex; flex-direction: column;
    align-items: center; padding: 6px 6px 8px;
    border: 1px solid var(--border); background: var(--bg); text-align: center;
    position: relative; height: 110px; justify-content: flex-end; gap: 6px; }
.badge-earned { border-color: var(--border); }
.badge-locked { opacity: .3; }
.badge-card { overflow: hidden; }
.badge-flip-front::after { content: ''; position: absolute; top: -50%; left: -75%;
    width: 40%; height: 200%; transform: skewX(-20deg);
    background: linear-gradient(to right, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
    animation: badge-shine 6s ease-in-out infinite; }
.badge-locked::after { display: none; }
@keyframes badge-shine {
    0%   { left: -75%; }
    15%  { left: 125%; }
    100% { left: 125%; }
}
.badge-icon { font-size: 26px; line-height: 1; }
.badge-img-wrap { width: 100%; height: 48px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.badge-svg { width: 42px; height: 42px; object-fit: contain; display: block; }
.badge-name { font-size: 8px; font-weight: 600; color: var(--muted); text-transform: uppercase;
    letter-spacing: .3px; width: 100%; padding: 0 4px; height: 22px; flex-shrink: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; line-height: 1.3; }
.badge-hidden { display: none; }
.badge-see-more { display: block; width: 100%; margin-top: 10px; background: none; border: none;
    color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
    text-align: center; padding: 6px 0; letter-spacing: .3px; }
.badge-see-more:hover { color: var(--text); }
/* Flip animation */
.badge-flip { perspective: 600px; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; }
.badge-flip-inner { position: relative; width: 100%; height: 110px;
    transform-style: preserve-3d; transition: transform .4s ease; }
.badge-flip-front, .badge-flip-back { position: absolute; inset: 0;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: 12px; }
.badge-flip-back { transform: rotateY(180deg); background: var(--surface);
    border: 1px solid var(--accent); display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start; padding: 8px 6px 6px; text-align: center; }
.badge-back-title { font-size: 10px; font-weight: 800; color: var(--accent);
    text-transform: uppercase; margin-bottom: 6px; letter-spacing: .3px; }
.badge-back-desc { font-size: 10px; color: var(--text); line-height: 1.4; flex: 1; display: flex; align-items: center; }
.badge-flip-locked .badge-flip-back { border-color: var(--border); }
.badge-flip-locked .badge-back-title { color: var(--muted); font-weight: 400; }
.stat-box { background: var(--bg); border-radius: 10px; padding: 12px 8px; text-align: center; border: 1px solid var(--border); }
.stat-box .val { font-size: 22px; font-weight: 800; }
.stat-box .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
/* 4 grandes stats du profil */
.stat-grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-box-lg { background: var(--bg); border-radius: 12px; padding: 16px 12px; text-align: center; border: 1px solid var(--border); }
.val-lg { font-size: 28px; font-weight: 900; line-height: 1; }
.lbl-lg { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
/* ── Win Rate card ───────────────────────────────────────────── */
.winrate-card { background: var(--surface); border-radius: 16px; overflow: hidden; border: 1px solid var(--border); }
.winrate-top { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 18px 10px; }
.winrate-lbl { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 6px; }
.winrate-big { font-size: 48px; font-weight: 900; line-height: 1; color: var(--accent); }
.winrate-big span { font-size: 20px; font-weight: 700; vertical-align: top; margin-left: 1px; opacity: .65; }
.winrate-sub { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.winrate-pill { font-size: 12px; font-weight: 700; padding: 6px 13px; border-radius: 20px; letter-spacing: .2px; margin-top: 4px; }
.pill-up { background: rgba(74,222,128,.13); color: #4ade80; }
.pill-dn { background: rgba(248,113,113,.12); color: #f87171; }
.winrate-chart-wrap { position: relative; height: 148px; }
.winrate-empty { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); text-align: center; padding: 0 20px; }

/* ── Championship picker dans modal défi ────────────────────────── */
.champ-pick-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    cursor: pointer; margin-bottom: 8px;
    -webkit-tap-highlight-color: transparent; outline: none; }
.champ-pick-item:last-child { margin-bottom: 0; }
.champ-pick-item.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.champ-pick-icon { width: 36px; height: 36px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 15%, var(--bg));
    display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--accent); flex-shrink: 0; }
.champ-pick-info { flex: 1; min-width: 0; }
.champ-pick-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.champ-pick-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.champ-pick-check { font-size: 20px; color: var(--accent); opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.champ-pick-item.selected .champ-pick-check { opacity: 1; }

/* ── Visibility toggle (profil) ──────────────────────────────── */
.visibility-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.vis-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 12px 8px; border-radius: 12px; cursor: pointer;
    background: var(--surface-alt); border: 2px solid transparent;
    color: var(--text); transition: border-color .2s, background .2s;
    -webkit-appearance: none;
}
.vis-btn i { font-size: 22px; color: var(--muted); transition: color .2s; }
.vis-btn .vis-label { font-size: 14px; font-weight: 600; }
.vis-btn .vis-desc { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.3; }
.vis-btn.vis-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.vis-btn.vis-active i { color: var(--accent); }
.vis-btn.vis-active .vis-label { color: var(--accent); }

/* ── Match detail modal ──────────────────────────────────────── */
.mdd-players { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 20px; }
.mdd-player { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.mdd-pname { font-size: 13px; font-weight: 700; text-align: center; max-width: 90px; word-break: break-word; overflow-wrap: break-word; white-space: normal; }
.mdd-pelo { font-size: 11px; color: var(--muted); }
.mdd-vs { font-size: 13px; font-weight: 800; color: var(--muted); flex-shrink: 0; }
.mdd-result { display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 15px; font-weight: 700; border-radius: 12px; padding: 10px 0; margin-bottom: 16px; }
.mdd-win { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--accent); }
.mdd-loss { background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger); }
.mdd-cancelled { background: color-mix(in srgb, var(--muted) 12%, var(--bg)); color: var(--muted); }
.mdd-scoreboard { background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    overflow: hidden; margin-bottom: 16px; }
.mdd-sb-header { display: grid; grid-template-columns: 1fr 48px 48px; padding: 8px 14px;
    border-bottom: 1px solid var(--border); }
.mdd-sb-avatar { display: flex; justify-content: center; align-items: center; }
.mdd-sb-row { display: grid; grid-template-columns: 1fr 48px 48px; padding: 10px 14px;
    border-bottom: 1px solid var(--border); }
.mdd-sb-row:last-child { border-bottom: none; }
.mdd-sb-lbl { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.mdd-sb-score { font-size: 20px; font-weight: 700; text-align: center; color: var(--muted); }
.mdd-sb-win { color: var(--text); }
.mdd-meta { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; }
.mdd-meta::-webkit-scrollbar { display: none; }
.mdd-meta span { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted);
    background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
    padding: 3px 8px; white-space: nowrap; flex-shrink: 0; }

/* ── Theme picker ────────────────────────────────────────────── */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-swatch { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    cursor: pointer; transition: border-color .15s; position: relative; }
.theme-swatch:hover { border-color: var(--muted); }
.theme-swatch.theme-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.theme-logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.theme-label { font-size: 13px; font-weight: 600; flex: 1; text-align: left; color: #ffffff; }
.theme-check { font-size: 14px; color: var(--accent); }

/* ── List items ──────────────────────────────────────────────── */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); -webkit-tap-highlight-color: transparent; outline: none; }
.list-item:last-child { border-bottom: none; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .info .sub  { font-size: 12px; color: var(--muted); }

/* ── ELO Chart ───────────────────────────────────────────────── */
.elo-chart { width: 100%; height: 80px; display: block; overflow: visible; }
.elo-chart path.line { fill: none; stroke: var(--accent); stroke-width: 2; }
.elo-chart path.area { fill: rgba(16,185,129,.1); stroke: none; }

/* ── Match score ─────────────────────────────────────────────── */
.match-score { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.match-score .set { background: var(--border); border-radius: 6px; padding: 2px 7px; }
.match-score .set.win { background: rgba(16,185,129,.2); color: var(--accent); }
.list-item .pill { font-size: 9px; padding: 2px 7px; }
.list-item .match-score { font-size: 11px; gap: 4px; }
.list-item .match-score .set { padding: 1px 5px; }

/* ── Live match ──────────────────────────────────────────────── */
.match-hero { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px 20px 24px; margin-bottom: 12px; }
.mh-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.mh-timer { font-size: 30px; font-weight: 900; color: var(--accent);
    font-variant-numeric: tabular-nums; letter-spacing: 2px; line-height: 1; }
.mh-timer.paused { color: var(--muted); }
.mh-info { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.mh-players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
    margin-bottom: 28px; }
.mh-player { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mh-player.mh-winner .avatar { box-shadow: 0 0 0 3px var(--accent), 0 6px 20px rgba(200,82,42,.2); }
.mh-name { font-size: 13px; font-weight: 700; text-align: center;
    max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-player.mh-winner .mh-name { color: var(--accent); }
.mh-elo  { font-size: 11px; color: var(--muted); }
.mh-center { text-align: center; }
.mh-global { font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: -2px;
    display: flex; align-items: center; justify-content: center; }
.mh-sep { font-size: 24px; font-weight: 200; color: var(--border); padding: 0 6px; }
.match-sets { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ms-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    padding: 6px 12px; text-align: center; min-width: 52px; }
.ms-chip.ms-live { border-color: var(--accent); background: rgba(200,82,42,.07); }
.ms-label { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase;
    letter-spacing: .5px; margin-bottom: 4px; }
.ms-chip.ms-live .ms-label { color: var(--accent); }
.ms-chip.ms-pending { border-color: var(--gold); opacity: .75; }
.ms-chip.ms-pending .ms-label { color: var(--gold); }
.ms-score { font-size: 13px; font-weight: 800; letter-spacing: -.5px; }

.match-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.match-action-primary { display: flex; flex-direction: column; gap: 8px; }
.match-action-row { display: flex; gap: 10px; }

.match-result { text-align: center; padding: 28px 0 8px; }
.match-result-icon { font-size: 52px; color: var(--gold); display: block; margin-bottom: 14px; }
.match-result-title { font-size: 13px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.match-result-winner { font-size: 22px; font-weight: 900; margin-bottom: 24px; }
.contest-info { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.contest-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; }
.match-result-btns { display: flex; gap: 10px; justify-content: center; }

.score-entry { padding: 20px 0 8px; }
.score-entry-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
    letter-spacing: .5px; text-align: center; margin-bottom: 20px; }
.score-entry-inputs { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 16px; }
.score-entry-player { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.score-entry-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.score-entry-sep { font-size: 32px; font-weight: 200; color: var(--border); }
.tb-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: 999px; border: 1.5px solid var(--border);
    background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
    cursor: pointer; margin-bottom: 16px; width: 100%; justify-content: center;
    outline: none; -webkit-tap-highlight-color: transparent;
    transition: border-color .15s, color .15s, background .15s;
}
.tb-toggle.active {
    border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}
.score-input { width: 80px; text-align: center; font-size: 36px; font-weight: 900;
    padding: 8px 4px; }

/* ── Search ──────────────────────────────────────────────────── */
.search-bar { position: relative; margin-bottom: 16px; }
.search-bar .input { padding-left: 38px; }
.search-bar .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: 16px; pointer-events: none; }

/* ── Option Group (chips de sélection) ───────────────────────── */
.option-group { display: flex; flex-wrap: wrap; gap: 8px; }
.option-btn { flex: 1; min-width: 56px; padding: 9px 8px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg); color: var(--muted);
    font-size: 13px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    outline: none; -webkit-tap-highlight-color: transparent; -webkit-appearance: none; }
.option-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(16,185,129,.12); }

/* ── Ranking ─────────────────────────────────────────────────── */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-pos { width: 24px; text-align: center; font-weight: 700; color: var(--muted); font-size: 14px; }
.rank-info { flex: 1; min-width: 0; }
.rank-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.rank-elo { font-weight: 700; font-size: 15px; min-width: 40px; text-align: right; }
.rank-delete { color: var(--danger); padding: 4px 6px; min-width: 0; }
button.rank-delete { width: 18px; height: 18px; padding: 0; border: 1px solid var(--danger) !important; border-radius: 50%; font-size: 10px; }
div.rank-delete { width: 18px; height: 18px; padding: 0; font-size: 10px; }

/* ── Auth screen ─────────────────────────────────────────────── */
#auth-screen { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 32px 24px; }
.auth-logo    { font-size: 40px; font-weight: 900; letter-spacing: 4px; color: var(--accent); margin-bottom: 6px; }
.auth-logo-img { height: 80px; width: auto; display: block; margin: 0 auto 16px; }
.auth-tagline { color: var(--muted); font-size: 14px; margin-bottom: 40px; text-align: center; }
.auth-form    { width: 100%; max-width: 360px; }
.auth-tabs    { display: flex; margin-bottom: 24px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.auth-tab     { flex: 1; padding: 10px; background: none; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--muted); transition: all .2s; }
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-error   { color: var(--danger); font-size: 13px; margin-bottom: 12px; text-align: center; min-height: 18px; }

/* ── Recadrage avatars preset ────────────────────────────────── */
img[src*="preset_tiafoe"],
img[src*="preset_bublik"],
img[src*="preset_murray"] { object-position: top; }
img[src*="preset_sinner"] { object-position: top; transform: scale(1.1); transform-origin: top center; }

/* ── Avatar edit ─────────────────────────────────────────────── */
.avatar-edit-wrap { position: relative; display: inline-block; cursor: pointer;
    -webkit-tap-highlight-color: transparent; outline: none; user-select: none; }
.avatar-edit-wrap .avatar-lg { width: 90px; height: 90px; font-size: 34px; }
.avatar-edit-btn { position: absolute; bottom: 2px; right: 2px;
    background: var(--accent); color: #fff; border-radius: 50%;
    width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
    font-size: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.4); pointer-events: none; }
.avatar-pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.avatar-pick-item { background: none; border: 2px solid var(--border); border-radius: 12px;
    padding: 10px 6px; cursor: pointer; display: flex; flex-direction: column;
    align-items: center; gap: 8px; transition: border-color .15s;
    -webkit-tap-highlight-color: transparent; outline: none; }
.avatar-pick-item:hover, .avatar-pick-item.selected { border-color: var(--accent); }
.avatar-pick-img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.avatar-pick-name { font-size: 12px; font-weight: 600; color: var(--text); }

/* ── QR Scanner ──────────────────────────────────────────────── */
.scanner-viewport { position: relative; width: 100%; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: #000; }
.scanner-overlay { position: absolute; inset: 0; pointer-events: none;
    box-shadow: inset 0 0 0 9999px rgba(0,0,0,.45); border-radius: 16px; }
.scanner-overlay::before { content: '';
    position: absolute; top: 20%; left: 20%; right: 20%; bottom: 20%;
    border: 2.5px solid var(--accent); border-radius: 14px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.0); }

/* ── Loading / Empty ─────────────────────────────────────────── */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { font-size: 48px; margin-bottom: 12px; }

/* ── Transitions ─────────────────────────────────────────────── */
#content > .screen { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Utils ───────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.flex-between > h1,
.flex-between > h2 { margin: 0; padding: 0; line-height: 1; align-self: center; }
.flex-center  { display: flex; align-items: center; gap: 10px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.champ-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.champ-table th { color: var(--muted); font-weight: 600; padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--border); }
.champ-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.champ-table tr:last-child td { border-bottom: none; }
.champ-table .pts { font-weight: 700; color: var(--accent); }

/* ── Home — Hero ─────────────────────────────────────────────── */
.home-hero { padding: 16px; }

/* ── Home — Feed match card ───────────────────────────────────── */
.feed-match-card { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px;
    cursor: pointer; user-select: none; position: relative;
    -webkit-tap-highlight-color: transparent; outline: none; }
.feed-match-card:focus { outline: none; }
.feed-match-card *, .feed-match-card *:active { -webkit-tap-highlight-color: transparent; }
.fmc-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.fmc-label { font-size: 11px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .5px; background: var(--bg);
    padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); }
.fmc-players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.fmc-player { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.fmc-player.fmc-winner .avatar { box-shadow: 0 0 0 2.5px var(--accent); }
.fmc-name { font-size: 12px; font-weight: 600; color: var(--muted); max-width: 80px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.fmc-player.fmc-winner .fmc-name { color: var(--accent); }
.fmc-score { text-align: center; position: relative; padding: 8px 10px; }
.fmc-global { font-size: 32px; font-weight: 900; letter-spacing: 3px; line-height: 1; }
.fmc-global span { color: var(--muted); font-weight: 300; font-size: 28px; letter-spacing: 0; }
.fmc-detail { font-size: 11px; color: var(--muted); margin-top: 5px; letter-spacing: .3px; }
.fmc-reactions { display: flex; gap: 5px; justify-content: center; margin-top: 6px; flex-wrap: wrap; height: 26px; overflow: hidden; align-items: center; }
.rpick-clear { background: none; border: none; font-size: 18px; cursor: pointer;
    padding: 2px 4px; border-radius: 50%; line-height: 1; opacity: .5;
    -webkit-tap-highlight-color: transparent; transition: opacity .1s; }
.rpick-clear:active { opacity: 1; }

/* Reaction picker bubble */
.reaction-picker { position: absolute; top: calc(100% + 8px); left: 50%;
    transform: translateX(-50%) scale(0.85); transform-origin: top center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
    padding: 5px 10px; display: flex; gap: 2px;
    box-shadow: 0 12px 32px rgba(0,0,0,.6);
    z-index: 50; pointer-events: none; opacity: 0;
    transition: opacity .15s, transform .15s; }
.reaction-picker.open { opacity: 1; transform: translateX(-50%) scale(1); pointer-events: auto; }

@media (min-width: 500px) {
    .reaction-picker { top: auto; bottom: calc(100% + 8px); transform-origin: bottom center; }
}
.rpick-btn { background: none; border: none; font-size: 20px; cursor: pointer;
    padding: 2px 4px; border-radius: 50%; line-height: 1; transition: transform .1s;
    -webkit-tap-highlight-color: transparent; }
.rpick-btn:active { transform: scale(1.3); }
.rpick-btn.selected { background: rgba(200,82,42,.2); }
.rxn-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    padding: 3px 8px; font-size: 13px; display: inline-flex; align-items: center; gap: 3px;
    cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent;
    animation: popIn .18s cubic-bezier(.17,.67,.3,1.4); }
.rxn-mine { border-color: var(--accent); background: rgba(200,82,42,.12); }

/* Bottom sheet réactions */
.rxn-sheet-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 1000; display: flex; align-items: flex-end;
    animation: fadeIn .2s ease;
}
.rxn-sheet {
    width: 100%; background: var(--surface);
    border-radius: 20px 20px 0 0;
    max-height: 65vh; display: flex; flex-direction: column;
    animation: slideUp .25s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.rxn-sheet-handle {
    width: 40px; height: 4px; background: var(--border);
    border-radius: 2px; margin: 10px auto 0;
}
.rxn-sheet-header {
    display: flex; align-items: center; padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.rxn-sheet-title { flex: 1; font-size: 15px; font-weight: 700; }
.rxn-sheet-body { overflow-y: auto; padding: 4px 0 16px; }
.rxn-sheet-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
}
.rxn-sheet-row + .rxn-sheet-row { border-top: 1px solid var(--border); }
.rxn-sheet-name { flex: 1; font-size: 14px; font-weight: 600; }
.rxn-sheet-icon { font-size: 18px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Toast notifications ─────────────────────────────────────── */
.toast-notif {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 16px; min-width: 260px; max-width: 340px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 9999;
    animation: fadeIn .2s ease;
}
.toast-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.toast-body  { font-size: 13px; color: var(--muted); }

/* ── Legal pages ─────────────────────────────────────────────── */
.legal-content { padding: 16px; }
.legal-block { margin-bottom: 20px; }
.legal-block:last-child { margin-bottom: 0; }
.legal-section-title { font-size: 13px; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.legal-p { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 6px; }
.legal-list { font-size: 13px; color: var(--muted); line-height: 1.7;
    padding-left: 18px; list-style: disc; }
.legal-list li { margin-bottom: 2px; }
.legal-row { display: flex; justify-content: space-between; align-items: flex-start;
    gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.legal-row:last-child { border-bottom: none; }
.legal-lbl { color: var(--muted); flex-shrink: 0; }
.legal-val { color: var(--text); text-align: right; }

/* ── Legal nav buttons ───────────────────────────────────────── */
.legal-nav { display: flex; flex-direction: column; gap: 2px; }
.legal-nav-btn { display: flex; align-items: center; gap: 10px; padding: 13px 4px;
    background: none; border: none; border-bottom: 1px solid var(--border);
    color: var(--text); font-size: 14px; cursor: pointer; width: 100%; text-align: left; }
.legal-nav-btn:last-child { border-bottom: none; }
.legal-nav-btn i { color: var(--muted); font-size: 18px; }
.legal-nav-btn .legal-nav-arrow { margin-left: auto; color: var(--muted); font-size: 16px; }
