:root {
    --primary:       #a855f7;   /* éclair */
    --primary-mid:   #7c3aed;   /* base */
    --primary-dark:  #1a0533;   /* fond */
    --primary-light: #c084fc;   /* clair */
    --accent:        #e879f9;   /* lueur */
    --accent-light:  #c084fc;   /* clair */
    --foam:          #f3e8ff;   /* light bg */
    --text:          #1a0533;
    --muted:         #7c6897;
    --white:         #ffffff;

    --u1-color:  #2563eb;
    --u1-bg:     #dbeafe;
    --u1-border: #93c5fd;
    --u2-color:  #dc2626;
    --u2-bg:     #fee2e2;
    --u2-border: #fca5a5;

    --ok:      #16a34a; --ok-bg:     #dcfce7;
    --warn:    #d97706; --warn-bg:   #fef3c7;
    --danger:  #dc2626; --danger-bg: #fee2e2;

    --font-display: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
    --font-body:    'Open Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
    background: var(--foam);
    font-family: var(--font-body);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
}
a { color: var(--primary-mid); }
a:hover { color: var(--primary-dark); }

/* ── Header ── */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-mid) 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(26,5,51,0.35);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-accent-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}
.app-logo { font-size: 1.3rem; }
.app-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: white;
    letter-spacing: -0.3px;
}
.btn-header-nav {
    background: rgba(255,255,255,.12);
    border: none;
    color: rgba(255,255,255,.85);
    padding: 6px 9px;
    border-radius: 8px;
    line-height: 1;
    font-size: 1rem;
    transition: background .15s;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-header-nav:hover { background: rgba(255,255,255,.22); color: white; }

.joueur-chip {
    display: inline-flex;
    align-items: center;
    font-size: .78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1.5px solid;
}

/* ── Login ── */
.login-body {
    background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary-mid) 60%, var(--primary) 100%);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-app-name {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    color: white;
    letter-spacing: -1px;
}
.login-subtitle { color: rgba(255,255,255,.55); font-size: .9rem; }
.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    overflow: hidden;
}
.login-body-inner { padding: 1.5rem; }

.joueur-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.joueur-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    background: white;
    cursor: pointer;
    transition: all .15s;
    min-height: 48px;
}
.joueur-btn:hover { border-color: var(--j-border); background: var(--j-bg); }
.joueur-btn.active { border-color: var(--j-color); background: var(--j-bg); }
.joueur-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.15rem;
}
.joueur-name { font-size: .85rem; font-weight: 600; color: var(--text); }

.pin-display {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 1.2rem 0;
    cursor: text;
}
.pin-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: white;
    transition: all .12s;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }

.pin-native-wrap {
    display: none;
    margin-bottom: .75rem;
}
@media (hover: none) and (pointer: coarse) {
    .pin-native-wrap { display: block; }
    .pin-pad { display: none; }
}
.pin-native-input {
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 8px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    outline: none;
    -webkit-appearance: none;
}
.pin-native-input:focus { border-color: var(--primary); }

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: .5rem;
}
.pin-btn {
    background: #f8fafc;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 0;
    height: 52px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .1s;
    color: var(--text);
}
.pin-btn:active { background: #e5e7eb; transform: scale(.96); }
.pin-clear { color: var(--muted); font-size: 1rem; }
.pin-submit { background: #f1f5f9; color: var(--muted); }
.pin-submit.pin-submit-ready { background: var(--primary); color: white; border-color: var(--primary); }
.pin-submit.pin-submit-ready:active { background: var(--primary-mid); }

/* ── Score ── */
.score-section { }
.score-label { }
.score-cards {
    display: flex;
    align-items: center;
    gap: 10px;
}
.score-card {
    flex: 1;
    background: var(--j-bg);
    border: 2px solid var(--j-border);
    border-radius: 16px;
    padding: 14px 10px;
    text-align: center;
}
.score-name {
    font-size: .78rem;
    font-weight: 700;
    color: var(--j-color);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.score-pts {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--j-color);
    line-height: 1;
    transition: transform .2s;
}
.score-pts.score-bump { transform: scale(1.2); }
.score-unit { font-size: .72rem; color: var(--j-color); opacity: .7; margin-top: 2px; }
.score-vs {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1rem;
    color: var(--muted);
    flex-shrink: 0;
}
.score-cumul { font-size: .78rem; }

/* ── Actions ── */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.action-btn {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 18px;
    padding: 18px 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all .15s;
    min-height: 108px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.action-btn:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(168,85,247,.18); }
.action-btn:active { transform: scale(.97); }
.action-btn.action-done { background: #f0fdf4; border-color: var(--ok); opacity: .75; }
.action-btn:disabled { cursor: default; }
.action-btn.action-loading { opacity: .6; pointer-events: none; }
.action-btn.action-flash { border-color: var(--primary); background: #faf5ff; }
.action-emoji { font-size: 2rem; line-height: 1; }
.action-count {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-mid);
    line-height: 1;
}
.action-label { font-size: .7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.action-food-badge {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

/* ── Summary ── */
.daily-summary {
    background: white;
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.summary-title {
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 10px;
}
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.summary-col { }
.summary-player { font-weight: 700; font-size: .82rem; margin-bottom: 6px; }
.summary-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: .82rem;
    color: var(--text);
    padding: 2px 0;
    border-bottom: 1px solid #f1f5f9;
}
.summary-row:last-child { border-bottom: none; }

/* ── Poids progress ── */
.poids-progress {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

/* ── Stats ── */
.period-tabs {
    display: flex;
    gap: 6px;
    background: white;
    padding: 4px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.period-tab {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: 9px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: all .15s;
}
.period-tab.active { background: var(--primary); color: white; }
.period-tab:not(.active):hover { background: #f1f5f9; color: var(--text); }

.stats-card {
    background: white;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.stats-card-title {
    font-weight: 700;
    font-size: .85rem;
    margin-bottom: 10px;
    color: var(--primary-dark);
}
.stats-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.stats-table th {
    font-weight: 700;
    padding: 4px 8px;
    text-align: right;
    border-bottom: 2px solid #f1f5f9;
}
.stats-table th:first-child { text-align: left; }
.stats-table td {
    padding: 6px 8px;
    text-align: right;
    border-bottom: 1px solid #f8fafc;
}
.stats-table td:first-child { text-align: left; }
.stats-table td.winner { color: var(--ok); }

.scores-hist { font-size: .82rem; }
.score-hist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid #f8fafc;
}
.score-hist-date { color: var(--muted); min-width: 40px; }
.score-hist-pts { font-weight: 600; }
.score-hist-sep { color: var(--muted); }

/* ── Config ── */
.config-section {
    background: white;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.config-section-title {
    font-weight: 700;
    font-size: .9rem;
    margin-bottom: 12px;
    color: var(--primary-dark);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--foam);
}
.challenge-info {
    background: var(--foam);
    border-radius: 10px;
    padding: 10px;
}
.defi-period { }

/* ── Modals ── */
.alc-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.alc-type-btn {
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
}
.alc-type-btn:hover { border-color: var(--primary); background: #faf5ff; }
.alc-type-btn.active { border-color: var(--primary); background: #f3e8ff; color: var(--primary-mid); }

.qty-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.qty-btn {
    padding: 6px 12px;
    background: #f8fafc;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
}
.qty-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

.food-choice-grid { display: flex; flex-direction: column; gap: 10px; }
.food-choice-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    background: white;
    cursor: pointer;
    transition: all .15s;
    text-align: left;
}
.food-choice-btn:hover { background: #f8fafc; }
.food-choice-btn.food-green.active  { border-color: #16a34a; background: #f0fdf4; }
.food-choice-btn.food-yellow.active { border-color: #d97706; background: #fefce8; }
.food-choice-btn.food-red.active    { border-color: #dc2626; background: #fff1f2; }
.food-emoji  { font-size: 1.5rem; }
.food-label  { font-weight: 700; display: block; }
.food-sub    { font-size: .78rem; color: var(--muted); display: block; }

/* ── Toast ── */
.defi-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all .25s;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.defi-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.defi-toast-success  { background: var(--primary); color: white; }
.defi-toast-danger   { background: #dc2626; color: white; }
.defi-toast-warning  { background: #d97706; color: white; }

/* ── Bootstrap overrides ── */
.btn-primary {
    --bs-btn-bg:                  var(--primary);
    --bs-btn-border-color:        var(--primary);
    --bs-btn-hover-bg:            var(--primary-mid);
    --bs-btn-hover-border-color:  var(--primary-mid);
    --bs-btn-active-bg:           var(--primary-mid);
    --bs-btn-active-border-color: var(--primary-mid);
    --bs-btn-focus-shadow-rgb:    168,85,247;
}
.btn-outline-primary {
    --bs-btn-color:               var(--primary-mid);
    --bs-btn-border-color:        var(--primary);
    --bs-btn-hover-bg:            var(--primary);
    --bs-btn-hover-border-color:  var(--primary);
    --bs-btn-active-bg:           var(--primary);
}
.progress { background: #f1f5f9; }

/* ── PWA Banner ── */
.pwa-banner {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--primary-dark);
    border-top: 3px solid var(--primary);
    padding: 14px 16px 22px;
    z-index: 9998;
    box-shadow: 0 -4px 24px rgba(26,5,51,0.5);
}
.pwa-banner-inner {
    max-width: 520px; margin: 0 auto;
    display: flex; align-items: flex-start; gap: 14px;
}
.pwa-banner-icon { width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0; overflow: hidden; }
.pwa-banner-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pwa-banner-text { flex: 1; min-width: 0; }
.pwa-banner-title { font-size: .95rem; font-weight: 700; color: #fff; margin-bottom: 5px; }
.pwa-banner-steps { font-size: .8rem; color: rgba(255,255,255,.72); line-height: 1.55; }
.pwa-banner-steps strong { color: var(--accent-light); }
.pwa-banner-close {
    background: none; border: none; color: rgba(255,255,255,.45);
    font-size: 1.45rem; cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0;
}
.pwa-banner-close:hover { color: rgba(255,255,255,.85); }
.pwa-banner-arrow {
    max-width: 520px; margin: 8px auto 0; text-align: center;
    font-size: .72rem; color: var(--primary-light); letter-spacing: .07em; text-transform: uppercase;
}
.pwa-arrow-anim { display: inline-block; animation: pwa-bounce 1.5s ease-in-out infinite; font-size: 1.1rem; margin-left: 5px; }
@keyframes pwa-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
