/* Charte Atelier 1912 : vert, vert clair, gris (couleurs du logo) */
:root {
    --green: #45ac34;
    --gray: #706f6f;
    --green-ink: #2f7d22;          /* vert assombri pour le texte (contraste AA) */
    --ink: #262626;
    --ink-2: #5c5b5b;
    --bg: #eef3ea;

    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.85);
    --hairline: rgba(112, 111, 111, 0.16);
    --shadow-sm: 0 8px 24px rgba(38, 60, 30, 0.14), 0 1px 3px rgba(38, 60, 30, 0.08);
    --radius: 14px;

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, Roboto, sans-serif;
    --font-rounded: ui-rounded, "SF Pro Rounded", var(--font-display);

    --spring: cubic-bezier(0.22, 1, 0.36, 1); /* approximation d'un ressort amorti */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font: 100%/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

#scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- HUD : pastilles en verre au-dessus de la scène ---------- */
.hud {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 36px);
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}
.hud[hidden] { display: none; }
.hud-block {
    display: flex;
    flex-direction: column;
    padding: 8px 16px 9px;
    min-width: 92px;
    border-radius: var(--radius);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
}
.hud-right { text-align: right; }
.hud-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-2);
}
.hud-value {
    font-family: var(--font-rounded);
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    display: inline-block;
}
.hud-value.bump { animation: bump 420ms var(--spring); }
@keyframes bump {
    30% { transform: scale(1.14); color: var(--green-ink); }
}

.timer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(24px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    overflow: hidden;
    background: rgba(112, 111, 111, 0.32);
    pointer-events: none;
}
.timer[hidden] { display: none; }
.timer-fill {
    height: 24px;
    background: var(--green);
    transform-origin: left center;
    border-radius: 0 3px 3px 0;
    will-change: transform;
}
/* Compte à rebours en secondes, centré dans la barre */
.timer-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-family: var(--font-rounded);
    font-size: 0.875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    /* Reste lisible quand la partie verte s'est vidée sous le texte */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.timer-text::after { content: " s"; font-weight: 600; }

/* Dernières secondes : la barre passe au gris du logo et pulse */
.timer.low .timer-fill { background: var(--gray); animation: pulse 0.6s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.45; } }

/* ---------- Écrans ---------- */
/* Pages pleines (pas de fenêtre flottante) */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, #e3ecdc 0%, var(--bg) 55%, #f7f9f5 100%);
}
.screen[hidden] { display: none; }

.page {
    width: min(400px, 100%);
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: enter 560ms var(--spring) both;
}
@keyframes enter {
    from { opacity: 0; transform: translateY(16px); }
}
.page > .btn { width: 100%; }

.logo { display: block; width: 112px; height: auto; margin: 0 0 28px; }

.eyebrow {
    margin: 0 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--green-ink);
}
h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.125rem, 9vw, 2.75rem);
    line-height: 1.04;
    letter-spacing: -0.03em;
    margin: 0 0 14px;
}
.lead { color: var(--ink-2); font-size: 1.0625rem; line-height: 1.5; margin: 0 0 32px; }
.lead[hidden] { display: none; }
.start-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.start-form[hidden] { display: none; }
input {
    font: inherit;
    font-size: 1.0625rem;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--hairline);
    background: rgba(255, 255, 255, 0.85);
    color: var(--ink);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
input::placeholder { color: #9a9999; }
input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px rgba(69, 172, 52, 0.18); }

.btn {
    font: inherit;
    font-weight: 600;
    font-size: 1.0625rem;
    letter-spacing: -0.01em;
    border: 0;
    border-radius: 12px;
    padding: 15px 20px;
    min-height: 50px;
    cursor: pointer;
    touch-action: manipulation;
    /* Retour instantané à l'appui, relâchement en douceur */
    transition: transform 380ms var(--spring), filter 150ms ease;
}
.btn:active { transform: scale(0.97); transition-duration: 80ms; filter: brightness(0.94); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: 3px solid rgba(69, 172, 52, 0.45); outline-offset: 2px; }
.btn-primary {
    background: var(--green);
    color: #fff;
    width: 100%;
    box-shadow: 0 6px 18px rgba(69, 172, 52, 0.32);
}
.btn-ghost {
    background: transparent;
    color: var(--green-ink);
    margin-top: 6px;
}
.btn-ghost:active { background: rgba(69, 172, 52, 0.1); }

.error { color: #b5412f; min-height: 1.2em; margin: 10px 0 0; font-size: 0.875rem; font-weight: 500; }

.result { display: flex; gap: 40px; justify-content: center; margin: 8px 0 20px; }
.result > div { display: flex; flex-direction: column; }
.big {
    font-family: var(--font-rounded);
    font-size: 3.25rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.035em;
    color: var(--green);
    font-variant-numeric: tabular-nums;
}

.board-list {
    list-style: none;
    width: 100%;
    margin: 0 0 28px;
    padding: 0;
    text-align: left;
    counter-reset: rank;
    font-size: 0.9375rem;
}
.board-list li {
    counter-increment: rank;
    display: grid;
    grid-template-columns: 26px 1fr auto;
    gap: 8px;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px solid var(--hairline);
}
.board-list li:last-child { border-bottom: 0; }
.board-list li::before {
    content: counter(rank);
    color: var(--ink-2);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.board-list li:nth-child(-n+3)::before { color: var(--green); }
.board-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.board-list .meta { color: var(--ink-2); font-size: 0.75rem; font-weight: 400; margin-left: 6px; }
.board-list .pts { font-variant-numeric: tabular-nums; font-weight: 700; }
.board-list li.me { color: var(--green-ink); }
.board-empty { color: var(--ink-2); font-size: 0.9375rem; margin: 0 0 28px; text-align: center; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Accessibilité ---------- */
@media (prefers-reduced-motion: reduce) {
    .page { animation: fade 200ms ease both; }
    .hud-value.bump, .timer.low .timer-fill { animation: none; }
    .btn, .btn:active { transition: filter 150ms ease; }
    .btn:active { transform: none; }
}
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-transparency: reduce) {
    .hud-block {
        background: #fff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (prefers-contrast: more) {
    :root { --ink-2: #3a3a3a; --hairline: rgba(38, 38, 38, 0.45); }
    .hud-block { background: #fff; border-color: #262626; }
}
