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

:root {
    --bg:       #120d1c;
    --surface:  #1c1429;
    --surface2: #251b36;
    --border:   #382a4f;
    --accent:   #a855f7;
    --accent-h: #c084fc;
    --gold:     #fbbf24;
    --green:    #22c55e;
    --red:      #f43f5e;
    --text:     #f4eefc;
    --muted:    #a594bd;
    --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%, #2a1745 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: 860px; }

.logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.75rem; }
.logo svg { flex-shrink: 0; }
.logo-text { font-size: 1.35rem; font-weight: 800; letter-spacing: -.5px; }
.logo-text span { color: var(--accent-h); }
.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.25rem; font-weight: 800; margin-bottom: .35rem; }
h2 { font-size: 1rem; 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); }
.hint { font-size: .78rem; color: var(--muted); margin-top: .4rem; line-height: 1.5; }
section { margin-bottom: 1.75rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }

.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=number], select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-size: 1rem; padding: .75rem 1rem; outline: none; font-family: inherit; transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
select option { background: var(--surface); }
.inline { display: flex; gap: .5rem; align-items: stretch; }
.inline > input, .inline > select { flex: 1; min-width: 0; }
.inline .btn { width: auto; white-space: nowrap; }

/* ── Boutons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; border: none; border-radius: 10px;
    font-size: .95rem; font-weight: 700; 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); }
.btn-ghost:hover { background: var(--surface2); filter: none; }
.btn-gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #2a1a00; }
.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; }
.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(168,85,247,.12); border: 1px solid rgba(168,85,247,.35); color: #d8b4fe; }
.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; }

/* ── Accueil : choix du jeu ── */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-bottom: 1.75rem; }
.mode {
    display: block; text-decoration: none; color: var(--text); background: var(--surface2);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; transition: border-color .15s, transform .15s;
}
.mode:hover { border-color: var(--accent); transform: translateY(-3px); }
.mode-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: .6rem; }
.mode-title { font-weight: 800; font-size: 1.05rem; margin-bottom: .3rem; }
.mode-desc { font-size: .8rem; color: var(--muted); line-height: 1.45; }

.list { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; align-items: center; gap: .75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: .92rem; }
.row-meta { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.row form { margin: 0; }
.empty-state { text-align: center; padding: 1.5rem 1rem; color: var(--muted); font-size: .88rem; border: 1px dashed var(--border); border-radius: var(--radius); }

.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; padding: .22rem .6rem; border-radius: 999px; background: rgba(168,85,247,.18); color: var(--accent-h); white-space: nowrap; }
.pill-cadeau { background: rgba(251,191,36,.16); color: var(--gold); }
.pill-gage   { background: rgba(244,63,94,.16); color: #fda4af; }
.pill-vide   { background: rgba(165,148,189,.16); color: var(--muted); }

/* ── Joueurs ── */
.avatar {
    width: 40px; height: 40px; border-radius: 999px; object-fit: cover; flex-shrink: 0;
    background: var(--surface2); display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; color: var(--accent-h); border: 2px solid var(--border); font-size: 1rem;
}
.avatar-xl { width: 120px; height: 120px; font-size: 3rem; border-width: 4px; border-color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip {
    display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .7rem .3rem .3rem; border-radius: 999px;
    background: var(--bg); border: 2px solid var(--border); cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--muted);
    user-select: none; transition: all .15s; font-family: inherit;
}
.chip .avatar { width: 30px; height: 30px; font-size: .8rem; border-width: 0; }
.chip.on { border-color: var(--accent); color: var(--text); background: rgba(168,85,247,.14); }
.chip .x { margin-left: .15rem; opacity: .5; font-weight: 400; }
.chip .x:hover { opacity: 1; color: var(--red); }
.photo-btn { width: 48px; flex: 0 0 48px; padding: 0; border-radius: 10px; overflow: hidden; }
.photo-btn img { width: 100%; height: 100%; object-fit: cover; }

/* ── Roue ── */
.wheel-wrap { position: relative; width: min(100%, 420px); aspect-ratio: 1; margin: .5rem auto 1.25rem; }
.wheel-wrap svg.wheel { width: 100%; height: 100%; transition: transform 5.5s 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);
}
.wheel-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: .9rem; padding: 3rem; border: 3px dashed var(--border); border-radius: 999px; }

/* ── Résultat ── */
.modal { position: fixed; inset: 0; background: rgba(10,6,18,.82); 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 .35s cubic-bezier(.2,1.6,.4,1); max-height: 95dvh; overflow-y: auto; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-name { font-size: 2rem; font-weight: 900; margin: .8rem 0 .2rem; color: var(--gold); }
.result-task { color: var(--muted); margin-bottom: 1.25rem; }
.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 1rem 0 .75rem; }
.share-grid .btn { font-size: .85rem; padding: .65rem .5rem; }
.copied { font-size: .78rem; color: var(--green); display: none; }
.copied.show { display: block; }

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

/* ── Gobelets : préparation ── */
.cup-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.cup-row select { width: 130px; flex: 0 0 130px; }
.cup-row input { flex: 1; min-width: 0; }
.cup-row input:disabled { opacity: .35; }
.cup-row .del { background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; padding: 0 .3rem; }
.cup-row .del:hover { color: var(--red); }

/* ── Gobelets : jeu ── */
.table {
    display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 1rem .6rem; padding: 2rem .5rem 1rem;
    background: radial-gradient(ellipse at 50% 30%, #3b2163, #1e1430 70%); border-radius: 18px; border: 1px solid var(--border); margin-bottom: 1.25rem;
}
.slot { position: relative; height: 150px; display: flex; align-items: flex-end; justify-content: center; }
.prize {
    position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 92%; text-align: center;
    font-size: .74rem; font-weight: 700; line-height: 1.25; opacity: 0; transition: opacity .3s .25s;
}
.prize .emoji { font-size: 2rem; display: block; margin-bottom: .2rem; }
.slot.up .prize, .slot.shown .prize { opacity: 1; }
.cup {
    position: relative; width: 82px; height: 100px; border: none; background: none; cursor: pointer; padding: 0;
    transition: transform .55s 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(-2deg); }
.cup:disabled { cursor: default; }
.slot.up .cup { transform: translateY(-78px) rotate(-14deg); }
.slot.shown .cup { transform: translateY(-78px); opacity: .45; }
.slot.shown .prize { opacity: .55; }
.table.shuffling .cup { pointer-events: none; }
.counter { text-align: center; font-weight: 700; margin-bottom: 1rem; }
.summary { margin-top: 1rem; }

/* ── Carte à gratter ── */
.scratch {
    position: relative; width: 100%; max-width: 360px; aspect-ratio: 1; margin: 0 auto 1.25rem;
    border-radius: 16px; overflow: hidden; background: linear-gradient(135deg, #2a1a45, #3b2163); 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 .avatar-xl { width: 96px; height: 96px; font-size: 2.4rem; }
.scratch-result .result-name { font-size: 1.7rem; margin: .5rem 0 0; }
.scratch-others { margin-top: .7rem; padding-top: .6rem; border-top: 1px dashed var(--border); width: 100%; font-size: .78rem; }
.scratch-others-list { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem .6rem; margin-bottom: .2rem; }
.scratch-others .other { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; color: var(--text); font-size: .82rem; }
.scratch-others .avatar { width: 24px; height: 24px; font-size: .7rem; border-width: 1px; }
.scratch canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.scratch.done canvas { transition: opacity .6s; opacity: 0; pointer-events: none; }

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

@media (max-width: 560px) {
    body { padding: .75rem; }
    .card { padding: 1.35rem; }
    .modes { grid-template-columns: 1fr; }
    .slot { height: 130px; }
    .cup { width: 68px; height: 84px; }
    .slot.up .cup, .slot.shown .cup { transform: translateY(-64px); }
    .cup-row select { width: 110px; flex-basis: 110px; }
}
