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

:root {
    --bg:       #071413;
    --surface:  #0e201e;
    --surface2: #142c29;
    --border:   #234541;
    --accent:   #14b8a6;
    --accent-h: #2dd4bf;
    --gold:     #fbbf24;
    --green:    #22c55e;
    --red:      #f43f5e;
    --text:     #ecfdf9;
    --muted:    #8fb3ad;
    --radius:   14px;
    --shadow:   0 4px 32px rgba(0,0,0,.45);
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: radial-gradient(circle at 20% 0%, #0f3a35 0%, var(--bg) 55%) fixed;
    color: var(--text);
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center;
    padding: 1.5rem;
}
a { color: var(--accent-h); }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 2.25rem; width: 100%; max-width: 560px; margin: auto;
}
.card-wide { max-width: 960px; }
.card + .card { margin-top: 1.25rem; }

.logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.75rem; text-decoration: none; color: var(--text); }
.logo svg { flex-shrink: 0; }
.logo-text { font-size: 1.35rem; font-weight: 800; letter-spacing: -.5px; }
.logo-text span { color: var(--gold); }
.dash-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.dash-header .logo { margin-bottom: 0; }

h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: .35rem; overflow-wrap: anywhere; }
h2 { font-size: 1.02rem; font-weight: 700; margin-bottom: .75rem; }
.subtitle { font-size: .9rem; color: var(--muted); margin-bottom: 1.5rem; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hint { font-size: .78rem; color: var(--muted); margin-top: .4rem; line-height: 1.5; }
section { margin-bottom: 1.75rem; scroll-margin-top: 1rem; }
section:last-child { margin-bottom: 0; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }
.prewrap { white-space: pre-line; }

.back-link { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); text-decoration: none; margin-bottom: 1.25rem; }
.back-link:hover { color: var(--text); }

/* ── Formulaires ── */
.field { margin-bottom: 1rem; }
label, .label { display: block; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .45rem; }
input[type=text], input[type=email], input[type=number], input[type=datetime-local], select, textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-size: 1rem; padding: .7rem .9rem; outline: none; font-family: inherit; transition: border-color .15s;
    color-scheme: dark;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); cursor: pointer; margin-bottom: 1rem; line-height: 1.45; }
.check input { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; accent-color: var(--accent); }

/* ── Boutons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: linear-gradient(135deg, var(--accent), #0d9488); color: #03201c; border: none; border-radius: 10px;
    font-size: .95rem; font-weight: 800; padding: .8rem 1.3rem; cursor: pointer; text-decoration: none;
    width: 100%; font-family: inherit; transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 700; }
.btn-ghost:hover { background: var(--surface2); filter: none; }
.btn-gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #2a1a00; }
.btn-danger { background: transparent; border: 1px solid rgba(244,63,94,.5); color: #fda4af; }
.btn-danger:hover { background: rgba(244,63,94,.12); filter: none; }
.btn-sm { font-size: .82rem; padding: .5rem .9rem; width: auto; }
.btn-xs { font-size: .74rem; padding: .3rem .6rem; width: auto; border-radius: 7px; }
.btn-big { font-size: 1.15rem; padding: 1rem 1.4rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }

.alert { border-radius: 10px; padding: .85rem 1rem; font-size: .875rem; margin-bottom: 1.25rem; display: flex; gap: .6rem; align-items: flex-start; line-height: 1.5; }
.alert svg { flex-shrink: 0; margin-top: 2px; }
.alert-error   { background: rgba(244,63,94,.12); border: 1px solid rgba(244,63,94,.35); color: #fda4af; }
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-info    { background: rgba(20,184,166,.12); border: 1px solid rgba(20,184,166,.35); color: #99f6e4; }
.alert-warn    { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.35); color: #fcd34d; }
#error { display: none; }
#error.show { display: flex; }

.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; padding: .22rem .6rem; border-radius: 999px; background: rgba(20,184,166,.16); color: var(--accent-h); white-space: nowrap; }
.pill-a_venir  { background: rgba(251,191,36,.14); color: var(--gold); }
.pill-terminee { background: rgba(143,179,173,.16); color: var(--muted); }
.pill-win      { background: rgba(251,191,36,.16); color: var(--gold); }
.pill-lose     { background: rgba(143,179,173,.14); color: var(--muted); }
.pill-wait     { background: rgba(56,189,248,.14); color: #7dd3fc; }

.empty-state { text-align: center; padding: 1.5rem 1rem; color: var(--muted); font-size: .88rem; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ── Liste des jeux ── */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }
.game {
    display: block; text-decoration: none; color: var(--text); background: var(--bg); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem 1.1rem; transition: border-color .15s, transform .15s;
}
.game:hover { border-color: var(--accent); transform: translateY(-2px); }
.game .t { font-weight: 800; margin: .45rem 0 .25rem; overflow-wrap: anywhere; }
.game .m { font-size: .78rem; color: var(--muted); line-height: 1.5; }

/* ── Tableau de bord d'un jeu ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1.5rem; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; }
.stat .v { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.nav-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.nav-tabs a { font-size: .82rem; font-weight: 700; padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; }
.nav-tabs a:hover { color: var(--text); border-color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .6rem .7rem; background: var(--bg); white-space: nowrap; }
td { padding: .55rem .7rem; border-top: 1px solid var(--border); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .actions { display: flex; gap: .3rem; justify-content: flex-end; flex-wrap: wrap; }
td .actions form { margin: 0; }
td code { font-size: .8rem; color: var(--gold); }

.lot-form { display: grid; grid-template-columns: 1fr 110px 130px auto; gap: .5rem; align-items: end; }
.lot-form .field { margin-bottom: 0; }
.lot-form input { padding: .55rem .7rem; font-size: .92rem; }
.lot-row { padding: .6rem .7rem; border-top: 1px solid var(--border); }
.lot-row:first-child { border-top: none; }
.lot-row .meta { font-size: .76rem; color: var(--muted); margin-top: .35rem; }
.lot-row .meta strong { color: var(--text); }
.lot-add { background: var(--bg); border: 1px dashed var(--border); border-radius: 12px; padding: .9rem; margin-top: .8rem; }
.total { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .86rem; margin-top: .8rem; padding: .7rem .9rem; background: var(--bg); border-radius: 10px; }
.total strong { font-variant-numeric: tabular-nums; }

.share-link { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.share-link .qr { width: 150px; height: 150px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: #fff; }
.share-link .qr svg { width: 100%; height: 100%; display: block; }
.share-link .url { flex: 1; min-width: 220px; }
.url-box { display: flex; gap: .4rem; margin-bottom: .6rem; }
.url-box input { font-size: .82rem; padding: .55rem .7rem; }
.copied { font-size: .78rem; color: var(--green); display: none; }
.copied.show { display: block; }

details.box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1.25rem; }
details.box summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
details.box[open] summary { margin-bottom: .6rem; }
details.box .content { font-size: .85rem; color: var(--muted); line-height: 1.6; max-height: 320px; overflow-y: auto; }

/* ── Page de jeu ── */
.play { text-align: center; }
.play .logo { justify-content: center; }
.dates { font-size: .82rem; color: var(--muted); margin-bottom: 1.25rem; }
.preview-banner { background: repeating-linear-gradient(-45deg, rgba(251,191,36,.12) 0 12px, rgba(251,191,36,.05) 12px 24px); border: 1px solid rgba(251,191,36,.4); color: var(--gold); border-radius: 10px; padding: .6rem .8rem; font-size: .82rem; font-weight: 600; margin-bottom: 1.25rem; }
.prizes { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-bottom: 1.25rem; }
.prize-chip { font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.prize-chip b { color: var(--gold); }

.machine { position: relative; width: min(100%, 400px); aspect-ratio: 1; margin: 0 auto 1rem; }
.machine canvas { width: 100%; height: 100%; display: block; }
.play .check { justify-content: center; text-align: left; max-width: 420px; margin-left: auto; margin-right: auto; }

/* ── Personnalisation : en-tête de l'organisateur et fond ── */
body.fond-perso { background: linear-gradient(160deg, var(--fond1), var(--fond2)) fixed; }
.org { display: flex; flex-direction: column; align-items: center; gap: .55rem; margin-bottom: 1.4rem; }
.org a { display: inline-block; }
.org-logo { display: block; max-width: min(240px, 70%); max-height: 110px; object-fit: contain; margin: 0 auto; }
.org-name { font-size: .85rem; color: var(--muted); }
.org-name a, .org-name strong { color: var(--text); font-weight: 700; }
.powered { margin-top: 1rem; font-size: .72rem; color: rgba(236,253,249,.85); background: rgba(0,0,0,.35); padding: .25rem .7rem; border-radius: 999px; }

.logo-field { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .5rem; }
.logo-preview {
    width: 120px; height: 120px; flex-shrink: 0; border-radius: 12px; border: 1px dashed var(--border);
    display: flex; align-items: center; justify-content: center; padding: .5rem; text-align: center;
    background: repeating-conic-gradient(#1a2e2b 0 25%, #142624 0 50%) 0 0 / 16px 16px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
input[type=file] { width: 100%; font-size: .85rem; color: var(--muted); }
input[type=file]::file-selector-button { font-family: inherit; font-weight: 700; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .8rem; margin-right: .6rem; cursor: pointer; }
.colors { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.colors input[type=color] { width: 52px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); padding: 3px; cursor: pointer; }
.fond-sample { width: 110px; height: 42px; border-radius: 10px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.fond-sample span { font-size: .7rem; font-weight: 700; background: var(--surface); padding: .15rem .5rem; border-radius: 6px; }
.swatches { display: flex; gap: .35rem; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.swatch:hover { border-color: var(--gold); }

/* ── Choix de l'animation ── */
.anim-choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: 1rem; }
.anim-tile {
    display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; cursor: pointer;
    background: var(--bg); border: 2px solid var(--border); border-radius: 12px; padding: .75rem .4rem;
    text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; transition: border-color .15s, background .15s;
}
.anim-tile input { position: absolute; opacity: 0; pointer-events: none; }
.anim-tile:hover { border-color: var(--accent); }
.anim-tile:has(input:checked) { border-color: var(--gold); background: rgba(251,191,36,.08); }
.anim-tile:has(input:focus-visible) { outline: 2px solid var(--accent-h); outline-offset: 2px; }
.anim-emoji { font-size: 1.8rem; line-height: 1; }
.anim-label { font-size: .78rem; font-weight: 700; line-height: 1.3; }
.preview-switch { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin-top: .55rem; }
.preview-switch a { font-size: .76rem; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; border: 1px solid rgba(251,191,36,.4); color: var(--gold); text-decoration: none; }
.preview-switch a.on { background: var(--gold); color: #2a1a00; }

/* ── Roue ── */
.wheel-wrap { position: relative; width: min(100%, 400px); aspect-ratio: 1; margin: .5rem auto 1.25rem; }
.wheel-wrap svg.wheel { width: 100%; height: 100%; transition: transform 6s cubic-bezier(.12,.68,.08,1); filter: drop-shadow(0 8px 24px rgba(0,0,0,.5)); }
.wheel-pointer {
    position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 0; height: 0; z-index: 2;
    border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 30px solid var(--gold);
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.6));
}
.wheel-hub {
    position: absolute; inset: 41%; border-radius: 999px; background: var(--surface); border: 4px solid var(--gold);
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; z-index: 2; box-shadow: 0 0 0 4px rgba(0,0,0,.25);
}

/* ── Carte à gratter ── */
.scratch {
    position: relative; width: 100%; max-width: 340px; aspect-ratio: 1.2; margin: 0 auto 1rem;
    border-radius: 16px; overflow: hidden; background: linear-gradient(135deg, #0f3a35, #14524b); border: 3px solid var(--gold);
    touch-action: none; user-select: none; -webkit-user-select: none;
}
.scratch-result { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1rem; }
.scratch-result .result-title { font-size: 1.6rem; margin-bottom: .2rem; }
.scratch-result .result-lot { font-size: 1.05rem; margin-bottom: .2rem; }
.scratch-result .emoji { font-size: 2.6rem; line-height: 1; margin-bottom: .4rem; }
.scratch-wait { font-size: 3rem; opacity: .4; }
.scratch canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.scratch.done canvas { transition: opacity .6s; opacity: 0; pointer-events: none; }
#reveal-all { margin-bottom: 1rem; }

/* ── Gobelets ── */
.cups {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.6rem .4rem; padding: 2.2rem .5rem 1rem;
    background: radial-gradient(ellipse at 50% 30%, #155e56, #0b2421 70%); border-radius: 18px; border: 1px solid var(--border); margin-bottom: 1.25rem;
}
.slot { position: relative; height: 104px; display: flex; align-items: flex-end; justify-content: center; }
.slot .prize {
    position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 120%; text-align: center;
    font-size: .7rem; font-weight: 800; line-height: 1.2; opacity: 0; transition: opacity .3s .3s; color: var(--gold);
}
.slot .prize .emoji { font-size: 1.7rem; display: block; margin-bottom: .15rem; }
.slot.up .prize { opacity: 1; }
.cup {
    position: relative; width: 62px; height: 78px; border: none; background: none; cursor: pointer; padding: 0;
    transition: transform .6s cubic-bezier(.3,1.4,.5,1); z-index: 2;
}
.cup svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 8px rgba(0,0,0,.45)); }
.cup:not(:disabled):hover { transform: translateY(-6px) rotate(-3deg); }
.cup:disabled { cursor: default; }
.cups.played .slot:not(.up) .cup { opacity: .45; }
.slot.up .cup { transform: translateY(-64px) rotate(-14deg); }
.cups.shuffling .cup { pointer-events: none; }

/* ── Résultat ── */
.modal { position: fixed; inset: 0; background: rgba(2,10,9,.84); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 2rem 1.5rem 1.5rem; max-width: 440px; width: 100%; text-align: center; animation: pop .45s cubic-bezier(.2,1.6,.4,1); max-height: 95dvh; overflow-y: auto; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-card { background: var(--bg); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem 1.25rem; margin-bottom: 1rem; }
.big-ball {
    --c: var(--accent);
    width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 32% 28%, #fff 0 6%, color-mix(in srgb, var(--c) 55%, #fff) 14%, var(--c) 48%, color-mix(in srgb, var(--c) 55%, #000) 100%);
    box-shadow: 0 12px 30px rgba(0,0,0,.5), inset 0 -8px 18px rgba(0,0,0,.25);
}
.big-ball span { width: 62%; height: 62%; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; box-shadow: inset 0 2px 6px rgba(0,0,0,.2); }
.result-title { font-size: 1.8rem; font-weight: 900; margin-bottom: .3rem; }
.result-title.win { color: var(--gold); }
.result-lot { font-size: 1.2rem; font-weight: 800; margin-bottom: .8rem; overflow-wrap: anywhere; }
.code { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-size: 1.35rem; font-weight: 800; letter-spacing: .12em; color: var(--gold); background: rgba(251,191,36,.08); border: 1px dashed rgba(251,191,36,.5); border-radius: 10px; padding: .45rem .9rem; margin: .3rem 0 .8rem; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

footer { margin-top: 2rem; font-size: .78rem; color: var(--muted); text-align: center; max-width: 760px; line-height: 1.6; }

@media (max-width: 720px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .lot-form { grid-template-columns: 1fr 1fr; }
    .lot-form .field:first-child { grid-column: 1 / -1; }
    .lot-form .btn { grid-column: 1 / -1; width: 100%; }
}
@media (max-width: 560px) {
    body { padding: .75rem; }
    .card { padding: 1.35rem; }
    .grid2 { grid-template-columns: 1fr; }
    .anim-choice { grid-template-columns: 1fr 1fr; }
    .cups { gap: 1.4rem .2rem; }
    .cup { width: 52px; height: 66px; }
    .slot { height: 92px; }
    .slot.up .cup { transform: translateY(-56px) rotate(-14deg); }
    .hide-sm { display: none; }
}
