* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --vs-gradient: linear-gradient(135deg, #FF7A00 0%, #FF004D 50%, #B200FF 100%);
    --vs-card: rgba(255, 255, 255, 0.05);
    --vs-card-br: rgba(255, 255, 255, 0.12);
    --vs-muted: #907d9e;
    --vs-ok: #7be07b;
    --vs-err: #ff7a93;
    --vs-gold: #FFD700;
}
body {
    font-family: 'Fredoka', system-ui, sans-serif;
    background: #07030f;
    background-image:
        radial-gradient(circle at 18% 12%, rgba(178, 0, 255, 0.22), transparent 50%),
        radial-gradient(circle at 82% 88%, rgba(255, 0, 77, 0.20), transparent 50%),
        linear-gradient(180deg, #14082a 0%, #07030f 100%);
    color: #f5f0ff;
    min-height: 100dvh;
    padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}
#app { max-width: 460px; margin: 0 auto; }
.hidden { display: none !important; }

/* Header */
.vs-header { display: flex; align-items: center; gap: 14px; padding: 4px 0 18px; }
.vs-back {
    flex-shrink: 0; width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 14px;
    background: var(--vs-card);
    border: 1px solid var(--vs-card-br);
    color: #fff; font-size: 1rem; text-decoration: none;
}
.vs-back:active { transform: scale(0.92); background: rgba(255,255,255,0.14); }
.vs-title-wrap { flex: 1; min-width: 0; }
.vs-title-wrap h1 {
    font-size: 1.45rem; font-weight: 900; line-height: 1;
    background: var(--vs-gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.vs-title-wrap p { color: #cab5e6; font-size: 0.82rem; margin-top: 4px; }
.vs-spacer { width: 42px; flex-shrink: 0; }

.vs-main { display: flex; flex-direction: column; gap: 28px; }
/* Les cartes sont à l'intérieur de <section> (lobbyView, questionView,
   revealView, finalView, joinEntry), donc le gap de .vs-main ne tombe PAS
   entre les cartes elles-mêmes. On force chaque section à appliquer le rythme. */
.vs-main > section {
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.vs-main > section.hidden { display: none !important; }

/* Carte de base — padding et gap internes généreux + grand écart entre cartes
   (parent gap 28) pour éliminer toute sensation de "compression". */
.vs-card {
    background: var(--vs-card);
    border: 1px solid var(--vs-card-br);
    border-radius: 20px;
    padding: 24px 22px;
    display: flex; flex-direction: column; gap: 16px;
}
.vs-big-icon { font-size: 2.4rem; color: #FF004D; align-self: center; }
.vs-h2 { font-size: 1.2rem; font-weight: 900; text-align: center; }
.vs-sub { color: #cab5e6; font-size: 0.9rem; text-align: center; }
.vs-error { color: var(--vs-err); font-size: 0.86rem; text-align: center; min-height: 1em; }
.vs-global-error { margin-top: 6px; }
.vs-hint { color: var(--vs-muted); font-size: 0.84rem; text-align: center; }

/* Form join */
.vs-form { display: flex; flex-direction: column; gap: 10px; }
.vs-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--vs-card-br);
    border-radius: 14px;
    padding: 14px 16px;
    color: #fff; font-family: inherit; font-size: 1.1rem;
    text-align: center; letter-spacing: 6px; font-weight: 800;
    text-transform: uppercase;
}
.vs-input:focus { outline: none; border-color: #B200FF; background: rgba(178, 0, 255, 0.10); }
.vs-submit, .vs-start {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: var(--vs-gradient); color: #fff; border: none;
    border-radius: 16px; padding: 14px;
    font-family: inherit; font-weight: 900; font-size: 1rem;
    text-transform: uppercase; letter-spacing: 0.4px;
    cursor: pointer; transition: transform 0.12s, box-shadow 0.2s;
    box-shadow: 0 8px 22px rgba(255, 0, 77, 0.28);
}
.vs-submit:active, .vs-start:active { transform: scale(0.97); }
.vs-start:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.vs-leave {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: transparent; color: var(--vs-muted);
    border: 1px solid rgba(144, 125, 158, 0.4); border-radius: 14px;
    padding: 12px; font-family: inherit; font-size: 0.92rem; cursor: pointer;
}
.vs-leave:active { color: #fff; border-color: rgba(255,255,255,0.4); }

.vs-mini-btn {
    align-self: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #cab5e6; border-radius: 12px;
    padding: 8px 14px; font-family: inherit; font-size: 0.84rem; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.vs-mini-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.vs-host-action { background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 122, 0, 0.18));
    border-color: rgba(255, 215, 0, 0.35); color: var(--vs-gold); }

/* Code de partie */
.vs-code-card { align-items: center; text-align: center; }
.vs-code-label {
    font-size: 0.74rem; letter-spacing: 2px; color: var(--vs-muted);
    text-transform: uppercase; font-weight: 700;
}
.vs-code-value {
    font-size: 2rem; font-weight: 900; letter-spacing: 8px; color: #fff;
    text-shadow: 0 0 18px rgba(178, 0, 255, 0.45);
}

/* QR */
.vs-qr-card summary {
    cursor: pointer; list-style: none;
    font-size: 0.9rem; font-weight: 700; color: #cab5e6;
    display: flex; align-items: center; gap: 8px;
}
.vs-qr-card summary::-webkit-details-marker { display: none; }
.vs-qr-img { width: 200px; height: 200px; margin: 10px auto 0; border-radius: 12px; display: block; }

/* Players list (lobby) */
.vs-players-title {
    font-weight: 800; font-size: 0.95rem;
    display: flex; align-items: center; gap: 8px;
}
.vs-players-count {
    background: rgba(178, 0, 255, 0.22);
    color: #fff; padding: 2px 9px; border-radius: 999px;
    font-size: 0.78rem;
}
.vs-players-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.vs-players-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 0.9rem;
}
.vs-pl-avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    background: var(--vs-gradient);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.78rem; color: #fff;
    background-size: cover; background-position: center;
}
.vs-pl-name { flex: 1; }
.vs-pl-tag {
    font-size: 0.7rem; padding: 2px 7px; border-radius: 999px;
    background: rgba(255, 215, 0, 0.18); color: var(--vs-gold);
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700;
}

/* Setup card — chaque "row" (Ambiance, Manches, Voter pour soi-même) est
   désormais un VRAI bloc indépendant avec son propre fond + padding.
   Plus aucune sensation de "collé" : on dirait 3 cartes empilées. */
.vs-setup-card { gap: 14px !important; padding: 22px 18px; }
.vs-setup-title {
    font-size: 1.05rem; font-weight: 900;
    display: flex; align-items: center; gap: 10px;
    padding-bottom: 4px;
    color: #fff;
}
.vs-setup-title i { color: #B200FF; }
.vs-setup-row {
    display: flex; flex-direction: column; gap: 12px;
    padding: 16px 16px 18px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}
.vs-setup-label {
    font-size: 0.78rem; color: var(--vs-muted); font-weight: 800;
    text-transform: uppercase; letter-spacing: 1px;
    display: flex; align-items: center; gap: 6px;
}
.vs-setup-label::before {
    content: '';
    width: 4px; height: 14px;
    background: var(--vs-gradient); border-radius: 2px;
}
.vs-seg {
    display: flex; gap: 6px; flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px; padding: 5px;
}
.vs-seg button {
    flex: 1; min-width: 60px;
    background: transparent; border: none; color: #cab5e6;
    padding: 8px 10px; font-family: inherit; font-weight: 700; font-size: 0.86rem;
    border-radius: 10px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.vs-seg button.active {
    background: var(--vs-gradient); color: #fff;
    box-shadow: 0 4px 12px rgba(255, 0, 77, 0.25);
}
.vs-seg button:not(.active):hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

/* Loading */
.vs-loading-card { align-items: center; gap: 14px; }
.vs-loading-text { color: #cab5e6; font-size: 0.9rem; }
.vs-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #FF004D;
    border-radius: 50%;
    animation: vsSpin 0.85s linear infinite;
}
@keyframes vsSpin { to { transform: rotate(360deg); } }

/* ============== QUESTION PHASE ============== */
.vs-question-card {
    background: linear-gradient(160deg, rgba(178, 0, 255, 0.16), rgba(255, 0, 77, 0.12));
    border-color: rgba(255, 0, 77, 0.32);
    align-items: center; text-align: center; gap: 8px;
    box-shadow: 0 14px 40px rgba(178, 0, 255, 0.25);
}
.vs-round-tag {
    font-size: 0.74rem; letter-spacing: 2px; color: var(--vs-gold);
    text-transform: uppercase; font-weight: 800;
}
.vs-question-text {
    font-size: 1.35rem; font-weight: 900; line-height: 1.25;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.vs-vote-card { gap: 14px; }
.vs-vote-title {
    font-size: 0.95rem; font-weight: 800;
    color: #cab5e6; text-align: center;
}
.vs-vote-grid {
    list-style: none;
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.vs-vote-grid li {
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    padding: 12px 10px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    cursor: pointer;
    transition: transform 0.12s, background 0.15s, border-color 0.15s;
    text-align: center;
}
.vs-vote-grid li:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-2px); }
.vs-vote-grid li:active { transform: scale(0.96); }
.vs-vote-grid li.is-selected {
    border-color: #FF004D;
    background: linear-gradient(160deg, rgba(255, 0, 77, 0.18), rgba(178, 0, 255, 0.12));
    box-shadow: 0 0 0 4px rgba(255, 0, 77, 0.15);
}
.vs-vote-grid li.is-disabled {
    opacity: 0.4; cursor: not-allowed; pointer-events: none;
}
.vs-vote-grid li .vs-pl-avatar { width: 48px; height: 48px; font-size: 1rem; }
.vs-vote-grid li .vs-vote-name { font-size: 0.88rem; font-weight: 800; color: #fff; }
.vs-vote-grid li .vs-vote-self {
    font-size: 0.66rem; color: var(--vs-gold);
    background: rgba(255, 215, 0, 0.15);
    padding: 1px 7px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700;
}
.vs-vote-status {
    text-align: center; color: var(--vs-muted); font-size: 0.84rem;
    min-height: 1em;
}
.vs-vote-status.is-locked { color: var(--vs-ok); font-weight: 700; }

/* ============== REVEAL PHASE ============== */
.vs-reveal-card { gap: 14px; }
.vs-reveal-question {
    font-size: 1.05rem; font-weight: 800; color: #fff;
    text-align: center; line-height: 1.3;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 14px;
}
.vs-reveal-list {
    list-style: none; display: flex; flex-direction: column; gap: 8px;
}
.vs-reveal-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    animation: vsRevealIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes vsRevealIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
.vs-reveal-list li:nth-child(1) { animation-delay: 0.05s; }
.vs-reveal-list li:nth-child(2) { animation-delay: 0.18s; }
.vs-reveal-list li:nth-child(3) { animation-delay: 0.31s; }
.vs-reveal-list li:nth-child(4) { animation-delay: 0.44s; }
.vs-reveal-list li:nth-child(5) { animation-delay: 0.57s; }
.vs-reveal-list li:nth-child(6) { animation-delay: 0.70s; }
.vs-reveal-list li:nth-child(7) { animation-delay: 0.83s; }
.vs-reveal-list li:nth-child(8) { animation-delay: 0.96s; }
.vs-reveal-list li.is-winner {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 122, 0, 0.18));
    border-color: var(--vs-gold);
}
.vs-reveal-name { flex: 1; font-weight: 700; font-size: 0.95rem; }
.vs-reveal-count {
    background: var(--vs-gradient);
    color: #fff; padding: 4px 12px; border-radius: 999px;
    font-weight: 900; font-size: 0.85rem;
    min-width: 36px; text-align: center;
}
.vs-reveal-list li.is-zero .vs-reveal-count {
    background: rgba(255, 255, 255, 0.1); color: var(--vs-muted);
}
.vs-reveal-voters {
    font-size: 0.74rem; color: var(--vs-muted);
    width: 100%; margin-top: 4px;
    flex-basis: 100%;
}
.vs-reveal-summary {
    font-size: 0.86rem; color: #cab5e6; text-align: center;
    padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============== FINAL ============== */
.vs-final-card {
    background: linear-gradient(160deg, rgba(255, 215, 0, 0.12), rgba(255, 0, 77, 0.10));
    border-color: rgba(255, 215, 0, 0.35);
    align-items: center;
}
.vs-final-tag {
    font-size: 0.78rem; letter-spacing: 3px; color: var(--vs-gold);
    text-transform: uppercase; font-weight: 900;
}
.vs-final-title { font-size: 1.5rem; font-weight: 900; text-align: center; color: #fff; }

.vs-podium { list-style: none; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.vs-podium li {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
}
.vs-podium-rank {
    font-size: 1.4rem; font-weight: 900; min-width: 36px; text-align: center;
}
.vs-podium li:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.28), rgba(255, 122, 0, 0.20));
    border-color: var(--vs-gold);
}
.vs-podium li:nth-child(1) .vs-podium-rank { color: var(--vs-gold); font-size: 1.7rem; }
.vs-podium li:nth-child(2) { background: linear-gradient(135deg, rgba(180, 180, 200, 0.22), rgba(140, 140, 160, 0.16)); }
.vs-podium li:nth-child(2) .vs-podium-rank { color: #d0d0e0; }
.vs-podium li:nth-child(3) { background: linear-gradient(135deg, rgba(205, 127, 50, 0.22), rgba(170, 90, 30, 0.16)); }
.vs-podium li:nth-child(3) .vs-podium-rank { color: #cd7f32; }
.vs-podium-name { flex: 1; font-weight: 800; font-size: 1rem; }
.vs-podium-score {
    background: rgba(0, 0, 0, 0.3); color: #fff;
    padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: 0.88rem;
}

.vs-history-card summary {
    cursor: pointer; list-style: none;
    font-size: 0.9rem; font-weight: 700; color: #cab5e6;
    display: flex; align-items: center; gap: 8px;
}
.vs-history-card summary::-webkit-details-marker { display: none; }
.vs-history-list {
    list-style: none; counter-reset: history;
    display: flex; flex-direction: column; gap: 10px; margin-top: 10px;
}
.vs-history-list li {
    background: rgba(255, 255, 255, 0.04); border-radius: 10px; padding: 10px 12px;
    counter-increment: history;
}
.vs-history-list li::before {
    content: 'Manche ' counter(history);
    display: block;
    font-size: 0.7rem; color: var(--vs-gold); font-weight: 800;
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 4px;
}
.vs-history-q { font-size: 0.88rem; color: #fff; font-weight: 700; margin-bottom: 4px; }
.vs-history-top { font-size: 0.78rem; color: #cab5e6; }
