:root {
    --bg: #FAFAF9;
    --surface: #FFFFFF;
    --surface-alt: #F5F5F0;
    --border: #E8E5E0;
    --text: #1A1A18;
    --text-secondary: #7A7A72;
    --accent: #2563EB;
    --accent-light: #EFF6FF;
    --green: #16A34A;
    --green-light: #F0FDF4;
    --red: #DC2626;
    --red-light: #FEF2F2;
    --orange: #EA580C;
    --orange-light: #FFF7ED;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* Header */
.header {
    padding: 20px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.header-sub {
    font-size: 13px;
    color: var(--text-secondary);
}
.back-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    font-family: inherit;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: #1D4ED8; }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-danger {
    background: var(--red-light);
    color: var(--red);
}
.btn-success {
    background: var(--green);
    color: white;
}
.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}
.btn-ghost {
    background: none;
    border: none;
    color: var(--accent);
    padding: 8px 12px;
}
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    font-size: 18px;
    flex-shrink: 0;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }
.card-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Input */
.input-group { margin-bottom: 14px; }
.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    background: var(--surface);
    transition: border-color 0.15s;
    outline: none;
}
.input:focus { border-color: var(--accent); }
.input-row {
    display: flex;
    gap: 8px;
}
.input-row .input { flex: 1; }

/* Lists */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-name {
    font-weight: 500;
    font-size: 15px;
}
.list-item-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Chips / Tags */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.chip-green { background: var(--green-light); color: var(--green); }
.chip-red { background: var(--red-light); color: var(--red); }
.chip-orange { background: var(--orange-light); color: var(--orange); }
.chip-blue { background: var(--accent-light); color: var(--accent); }

/* Player select */
.player-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.player-toggle.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.player-toggle .check {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: all 0.15s;
}
.player-toggle.active .check {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Scoreboard */
.score-row {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    gap: 12px;
}
.score-row:nth-child(1) { background: #FEF9C3; }
.score-row:nth-child(2) { background: var(--surface-alt); }
.score-rank {
    font-weight: 700;
    font-size: 16px;
    font-weight: 700;
    width: 28px;
    text-align: center;
}
.score-name { flex: 1; font-weight: 500; }
.score-total {
    font-weight: 700;
    font-size: 18px;
    font-weight: 700;
}
.score-streak {
    font-size: 11px;
    color: var(--orange);
    font-weight: 600;
}

/* Events log */
.event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 14px;
}
.event-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.event-icon.sortie { background: var(--red-light); }
.event-icon.bus { background: var(--orange-light); }

/* Ranking input */
.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.rank-number {
    font-weight: 700;
    font-weight: 700;
    font-size: 16px;
    width: 28px;
    text-align: center;
    color: var(--text-secondary);
}
.rank-name { flex: 1; font-weight: 500; }
.rank-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.rank-arrows button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 28px;
    height: 22px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rank-arrows button:active { background: var(--surface-alt); }

/* Points detail */
.points-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
}
.points-detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 8px;
    background: var(--surface-alt);
    border-radius: 4px;
}

/* Variant select */
.variant-option {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
}
.variant-option.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.variant-option .variant-name { font-weight: 600; }
.variant-option .variant-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Select dropdown */
.select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    background: var(--surface);
    outline: none;
    appearance: none;
    cursor: pointer;
}

/* Spacing utils */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-secondary); }
.w-full { width: 100%; }
.hidden { display: none; }

/* Section divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

/* Game card */
.game-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: box-shadow 0.15s;
    box-shadow: var(--shadow);
}
.game-card:active { box-shadow: var(--shadow-lg); }
.game-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.game-card-date {
    font-size: 13px;
    color: var(--text-secondary);
}
.game-card-players {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
}
.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    transition: all 0.15s;
    color: var(--text-secondary);
}
.tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* Boules input */
.boules-input {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    margin: 12px 0;
}
.boules-input button {
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.boules-input button:active { background: var(--surface-alt); }
.boules-input .count {
    font-weight: 700;
    font-size: 28px;
    font-weight: 700;
    width: 40px;
    text-align: center;
}

/* Manual edit */
.edit-score-input {
    width: 60px;
    padding: 6px;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
    font-weight: 700;
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    outline: none;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    animation: toast-in 0.3s ease;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; line-height: 1.5; }
