/* ==========================================================================
   Babyfoot Elo — charte Orange
   Palette : orange (#FF7900), encre (#1B1B1B), acier (#4A4A4A), brouillard (#F4F4F4)
   Typo    : display condensé + corps neutre (polices système, pas de police
             propriétaire Orange embarquée — remplacez par la police maison
             de l'entreprise si vous en avez la licence)
   Signature : le "ticket de match" — carte à double colonne avec perforation
             centrale et jeton rond façon pastille Orange, qui rejoue le match
             comme un billet à composter.
   ========================================================================== */

:root {
    --orange: #FF7900;
    --orange-dark: #C25A00;
    --orange-tint: #FFF1E2;
    --ink: #1B1B1B;
    --steel: #4A4A4A;
    --steel-tint: #EDEDED;
    --paper: #FFFFFF;
    --fog: #F4F4F4;
    --line: #E2E2E2;
    --good: #1E7A3D;
    --bad: #B3261E;

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 24px rgba(27, 27, 27, 0.08);
    --font-display: 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--fog);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; }

/* ---------- Header ---------- */

.topbar {
    background: var(--ink);
    color: var(--paper);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 14px 18px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--paper);
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

.brand-mark {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--orange);
    flex-shrink: 0;
}

.brand-text strong { color: var(--orange); }

.burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 10px;
}

.burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--paper);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 35;
}

.nav-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.topnav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(78vw, 300px);
    background: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 84px 20px 24px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.25);
    z-index: 40;
    overflow-y: auto;
}

.topnav.open {
    transform: translateX(0);
}

.topnav a {
    text-decoration: none;
    color: #C9C9C9;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 13px 6px;
    border-radius: var(--radius-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.15s ease, color 0.15s ease;
}

.topnav a:last-child { border-bottom: none; }

.topnav a.active,
.topnav a:hover {
    background: transparent;
    color: var(--orange);
}

/* ---------- Layout ---------- */

.page {
    flex: 1;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px 48px;
}

.footer {
    text-align: center;
    font-size: 0.72rem;
    color: #9A9A9A;
    padding: 18px 0 28px;
}

h1.page-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: -0.01em;
    margin: 4px 0 4px;
}

p.page-subtitle {
    color: var(--steel);
    font-size: 0.9rem;
    margin: 0 0 20px;
}

/* ---------- Match ticket (signature element) ---------- */

.ticket {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: visible;
    position: relative;
    margin-top: 8px;
}

.ticket-teams {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
}

.ticket-teams::before {
    /* perforation line down the middle, like a torn ticket */
    content: "";
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 50%;
    width: 0;
    border-left: 2px dashed var(--line);
    transform: translateX(-1px);
}

.team-col {
    padding: 22px 16px 18px;
}

.team-col.team-1 { border-top: 5px solid var(--orange); border-radius: var(--radius-lg) 0 0 0; }
.team-col.team-2 { border-top: 5px solid var(--steel); border-radius: 0 var(--radius-lg) 0 0; }

.team-label {
    font-family: var(--font-display);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 12px;
}

.team-col.team-1 .team-label { color: var(--orange-dark); }
.team-col.team-2 .team-label { color: var(--steel); }

.vs-badge {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--orange);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 121, 0, 0.45);
    z-index: 2;
}

/* ---------- Player search field ---------- */

.player-field {
    position: relative;
    margin-bottom: 12px;
}

.player-field:last-of-type { margin-bottom: 0; }

.player-input {
    width: 100%;
    padding: 12px 12px;
    font-size: 0.95rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--fog);
    color: var(--ink);
    font-family: var(--font-body);
}

.player-input:focus {
    outline: none;
    border-color: var(--orange);
    background: var(--paper);
}

.player-input.is-selected {
    border-color: var(--good);
    background: #F1FAF3;
    font-weight: 600;
}

.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 20;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.suggestions.open { display: block; }

.suggestion-item {
    padding: 11px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background: var(--orange-tint);
}

.suggestion-elo {
    color: var(--steel);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
}

.suggestion-create {
    color: var(--orange-dark);
    font-weight: 700;
}

/* ---------- Score row ---------- */

.score-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--line);
}

.score-cell {
    padding: 16px;
    text-align: center;
}

.score-cell input {
    width: 100%;
    text-align: center;
    font-family: var(--font-display);
    font-size: 2rem;
    border: none;
    background: transparent;
    color: var(--ink);
    padding: 4px 0;
}

.score-cell input:focus { outline: none; }

.score-cell label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--steel);
    margin-bottom: 2px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 18px;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--orange);
    color: var(--ink);
    margin-top: 18px;
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--steel);
    border: 1.5px solid var(--line);
    margin-top: 10px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
}

/* ---------- Feedback banner ---------- */

.banner {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    display: none;
}

.banner.show { display: block; }
.banner.success { background: #F1FAF3; color: var(--good); border: 1px solid #C9EBD3; }
.banner.error { background: #FCEEED; color: var(--bad); border: 1px solid #F5C6C2; }

/* ---------- Leaderboard ---------- */

.leaderboard {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.lb-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
}

.lb-row:last-child { border-bottom: none; }

.lb-rank {
    font-family: var(--font-display);
    color: var(--steel);
    font-size: 0.9rem;
}

.lb-row.top1 .lb-rank { color: var(--orange); }

.lb-name { font-weight: 600; font-size: 0.95rem; }
.lb-meta { color: var(--steel); font-size: 0.76rem; margin-top: 2px; }

.lb-elo {
    font-family: var(--font-display);
    font-size: 1.05rem;
    text-align: right;
}

.lb-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--steel);
    font-size: 0.9rem;
}

/* ---------- QR page ---------- */

.qr-wrap {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px;
    text-align: center;
}

.qr-wrap canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.qr-url {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--steel);
    word-break: break-all;
}

/* ---------- Gestion des joueurs ---------- */

.add-player-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.add-player-form input {
    flex: 1;
    padding: 12px;
    font-size: 0.9rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
    font-family: var(--font-body);
}

.add-player-form input:focus {
    outline: none;
    border-color: var(--orange);
}

.btn-compact {
    width: auto;
    padding: 12px 18px;
    margin-top: 0;
    white-space: nowrap;
}

.manage-list {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.manage-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.manage-row:last-child { border-bottom: none; }

.manage-name-display {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink);
    padding: 6px 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manage-name-input {
    border: 1.5px solid var(--orange);
    background: var(--orange-tint);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    min-width: 0;
    width: 100%;
}

.manage-name-input:focus { outline: none; }

.manage-row.editing { background: var(--orange-tint); }

.manage-elo {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--steel);
}

.btn-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-icon svg { display: block; }
.btn-edit { background: var(--steel-tint); color: var(--steel); }
.btn-edit.is-confirm,
.btn-edit[title="Valider"] { background: var(--orange); color: var(--ink); }
.btn-danger { background: #FCEEED; color: var(--bad); }

/* ---------- Historique des matchs ---------- */

.match-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-row {
    position: relative;
    background: var(--paper);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 14px 44px 14px 16px;
}

.match-teams {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.88rem;
}

.match-team { color: var(--steel); }

.match-winner {
    color: var(--ink);
    font-weight: 700;
}

.match-meta {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--steel);
}

.match-delete {
    position: absolute;
    top: 12px;
    right: 12px;
}

/* ---------- Utility ---------- */

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    .btn { transition: none; }
}
