/* ============================================================
   player.css — Mobile-first, tactile, responsive
   ============================================================ */

:root {
    --bg:        #0f0f23;
    --bg2:       #1a1a35;
    --bg3:       #252547;
    --border:    rgba(255,255,255,.1);
    --gold:      #f59e0b;
    --text:      #f1f5f9;
    --muted:     #94a3b8;
    --green:     #10b981;
    --red:       #ef4444;
    --purple:    #a855f7;
    --blue:      #3b82f6;
    --amber:     #f59e0b;
    --crimson:   #ef4444;
    --emerald:   #10b981;
    --orange:    #f97316;
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    /* Taille de touche minimum (accessibilité mobile) */
    --touch-min: 48px;
}

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

html {
    /* Évite le zoom iOS sur les inputs */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    /* Défilement fluide sur iOS */
    -webkit-overflow-scrolling: touch;
}

/* ── JOIN PAGE ─────────────────────────────────────────────── */
.join-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px 16px;
    background: radial-gradient(ellipse at 50% 0%, #2d1b69 0%, var(--bg) 65%);
}

.join-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
}

.join-cross {
    font-size: 3rem;
    color: var(--gold);
    filter: drop-shadow(0 0 16px rgba(245,158,11,.55));
    margin-bottom: 10px;
    display: block;
}

.join-title {
    font-family: var(--font-head);
    font-size: clamp(1.8rem, 7vw, 2.4rem);
    letter-spacing: -.03em;
    margin-bottom: 4px;
}

.join-sub {
    color: var(--muted);
    font-size: clamp(.85rem, 3.5vw, 1rem);
    margin-bottom: 24px;
    line-height: 1.5;
}

.join-form { display: flex; flex-direction: column; gap: 12px; }

.join-form input {
    background: var(--bg3);
    border: 2px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    font-family: var(--font-body);
    /* min 16px sur mobile pour éviter le zoom iOS */
    font-size: max(16px, 1.05rem);
    padding: 16px 18px;
    text-align: center;
    outline: none;
    transition: border-color .2s;
    min-height: var(--touch-min);
    width: 100%;
    -webkit-appearance: none;
}
.join-form input:focus { border-color: var(--gold); }
.join-form input::placeholder { color: var(--muted); }

.join-hint { margin-top: 16px; font-size: .85rem; color: var(--muted); }

/* ── WAITING PAGE ──────────────────────────────────────────── */
.waiting-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px;
    background: radial-gradient(ellipse at 50% 50%, #1e1145 0%, var(--bg) 70%);
}

.waiting-card {
    text-align: center;
    padding: 32px 20px;
    max-width: 360px;
    width: 100%;
}

.waiting-cross {
    font-size: clamp(3rem, 12vw, 4.5rem);
    color: var(--gold);
    filter: drop-shadow(0 0 20px rgba(245,158,11,.6));
    margin-bottom: 16px;
    display: block;
}

.waiting-title {
    font-family: var(--font-head);
    font-size: clamp(1.4rem, 6vw, 2rem);
    letter-spacing: -.02em;
    margin-bottom: 8px;
}

.accent { color: var(--gold); }

.waiting-sub  { color: var(--muted); margin-bottom: 28px; font-size: .95rem; }
.waiting-hint { color: var(--muted); font-size: .9rem; line-height: 1.6; }

.waiting-anim {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
}

.dot {
    width: 12px; height: 12px;
    background: var(--gold);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: .2s; background: var(--purple); }
.dot:nth-child(3) { animation-delay: .4s; background: var(--blue); }

@keyframes bounce {
    0%,80%,100% { transform: translateY(0); opacity: .6; }
    40%          { transform: translateY(-14px); opacity: 1; }
}

/* ── QUIZ PAGE ─────────────────────────────────────────────── */
.quiz-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--bg);
    /* Évite que le contenu passe sous la barre iOS */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.quiz-header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    /* Zone sûre iOS haut */
    padding-top: env(safe-area-inset-top);
}

.quiz-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    gap: 8px;
    min-height: 48px;
}

.quiz-pseudo {
    font-size: clamp(.78rem, 3vw, .9rem);
    color: var(--muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiz-score-display {
    font-family: var(--font-head);
    font-size: clamp(.9rem, 3.5vw, 1.05rem);
    color: var(--gold);
    font-weight: 700;
    white-space: nowrap;
}

.quiz-progress {
    font-size: clamp(.72rem, 2.5vw, .85rem);
    color: var(--muted);
    text-align: right;
    white-space: nowrap;
}

/* Timer bar */
.quiz-timer-bar-wrap { height: 5px; background: var(--bg3); }
.quiz-timer-bar {
    height: 100%; width: 100%;
    background: var(--green);
    transition: width .1s linear, background .5s;
}
.timer-warn   { background: var(--amber); }
.timer-danger { background: var(--red); animation: pulse-bar .4s infinite; }

@keyframes pulse-bar { 0%,100%{opacity:1} 50%{opacity:.6} }

/* États */
.quiz-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    gap: 14px;
    text-align: center;
    /* Évite l'overflow sur petits écrans */
    overflow-y: auto;
}

.state-icon { font-size: clamp(2.5rem, 10vw, 3.5rem); }
.state-icon.pulse { animation: pop .6s ease-out; }
@keyframes pop { 0%{transform:scale(.7);opacity:0} 70%{transform:scale(1.1)} 100%{transform:scale(1);opacity:1} }

/* Question */
.question-wrap { width: 100%; max-width: 700px; }

.question-number {
    font-family: var(--font-head);
    font-size: .78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: 6px;
}

.question-img {
    width: 100%;
    max-height: 30vh;
    object-fit: contain;
    border-radius: 12px;
    margin-bottom: 12px;
    background: var(--bg2);
}

.question-text {
    font-family: var(--font-head);
    /* Taille fluide : lisible sur 360px et sur 1440px */
    font-size: clamp(1rem, 3.5vw, 1.6rem);
    line-height: 1.35;
    font-weight: 700;
    margin-bottom: 10px;
}

.question-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: clamp(.78rem, 3vw, .88rem);
    font-weight: 600;
    background: rgba(245,158,11,.12);
    border: 1px solid rgba(245,158,11,.3);
    color: var(--amber);
    margin-bottom: 6px;
}

/* Grille choix */
.choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 700px;
}

/* Sur très petits écrans (<360px) : 1 colonne */
@media (max-width: 359px) {
    .choices-grid { grid-template-columns: 1fr; }
}

.choice-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: clamp(.82rem, 3vw, 1rem);
    font-weight: 500;
    color: #fff;
    text-align: left;
    transition: transform .12s, filter .12s, opacity .15s;
    /* Hauteur minimum tactile */
    min-height: var(--touch-min);
    line-height: 1.3;
    position: relative;
    overflow: hidden;
    /* Évite le flash de sélection sur iOS */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.choice-btn:not(:disabled):active { transform: scale(.97); filter: brightness(.92); }
.choice-btn:not(:disabled):hover  { filter: brightness(1.07); }
.choice-btn:disabled { opacity: .65; cursor: not-allowed; }
.choice-btn.selected { outline: 3px solid #fff; filter: brightness(1.1); transform: scale(1.02); }

.choice-letter {
    background: rgba(0,0,0,.25);
    border-radius: 6px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: clamp(.75rem, 2.5vw, .85rem);
    flex-shrink: 0;
}
.choice-text { flex: 1; word-break: break-word; }

/* Couleurs */
.choice-blue   { background: var(--blue); }
.choice-red    { background: var(--crimson); }
.choice-yellow { background: var(--amber); color: #1a1a1a; }
.choice-yellow .choice-letter { color: #1a1a1a; }
.choice-green  { background: var(--emerald); }
.choice-purple { background: var(--purple); }
.choice-orange { background: var(--orange); }

/* Bouton valider */
.btn-validate {
    margin-top: 10px;
    width: 100%;
    max-width: 700px;
    padding: 16px;
    background: linear-gradient(135deg, #7c3aed, var(--purple));
    color: #fff;
    border: none;
    border-radius: 14px;
    font-family: var(--font-head);
    font-size: clamp(1rem, 4vw, 1.1rem);
    font-weight: 700;
    cursor: pointer;
    min-height: var(--touch-min);
    transition: transform .12s, filter .12s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-validate:hover { filter: brightness(1.1); }
.btn-validate:active { transform: scale(.98); }
.btn-validate:disabled { opacity: .4; cursor: not-allowed; }

/* ── SLIDER ────────────────────────────────────────────────── */
.slider-player-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 500px;
    padding: 8px 0;
}

.slider-player-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.slider-player-row span {
    font-family: var(--font-head);
    font-size: .9rem;
    color: var(--muted);
    min-width: 36px;
    text-align: center;
}

.slider-player-row input[type="range"] {
    flex: 1;
    height: 8px;
    accent-color: var(--gold);
    cursor: pointer;
    /* Agrandir la zone de touche sur mobile */
    padding: 10px 0;
    -webkit-appearance: none;
}

.slider-val-display {
    font-family: var(--font-head);
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(245,158,11,.4);
    min-width: 80px;
    text-align: center;
}

/* ── ÉTAT RÉPONDU ──────────────────────────────────────────── */
.answered-icon {
    font-size: clamp(4rem, 16vw, 5.5rem);
    animation: pop .5s cubic-bezier(.175,.885,.32,1.275);
}
.answered-label {
    font-family: var(--font-head);
    font-size: clamp(1.4rem, 6vw, 1.8rem);
    font-weight: 800;
}
.answered-pts {
    font-family: var(--font-head);
    font-size: clamp(1.1rem, 4.5vw, 1.4rem);
}
.pts-win { color: var(--gold); text-shadow: 0 0 20px rgba(245,158,11,.5); }
.answered-wait { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.correct-reveal {
    background: rgba(16,185,129,.12);
    border: 1px solid rgba(16,185,129,.3);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: clamp(.82rem, 3vw, .95rem);
    color: var(--green);
    max-width: 340px;
    word-break: break-word;
}
.rev-label { font-weight: 600; margin-right: 4px; }

/* Attente révélation */
.waiting-reveal {
    display: flex; flex-direction: column;
    align-items: center; gap: 12px; text-align: center;
}
.waiting-reveal-icon {
    font-size: clamp(3rem, 12vw, 4rem);
    animation: float-icon 2s ease-in-out infinite;
}
@keyframes float-icon { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

.waiting-reveal-text {
    font-family: var(--font-head);
    font-size: clamp(1.3rem, 5vw, 1.7rem);
    font-weight: 800;
}
.waiting-reveal-sub { color: var(--muted); font-size: .9rem; }

.waiting-reveal-dots { display: flex; gap: 8px; margin-top: 4px; }
.wr-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--gold); animation: bounce 1.4s infinite ease-in-out;
}
.wr-dot:nth-child(2) { animation-delay:.2s; background:var(--purple); }
.wr-dot:nth-child(3) { animation-delay:.4s; background:var(--blue); }

/* ── FIN DE QUIZ ───────────────────────────────────────────── */
.finish-cross {
    font-size: clamp(3rem, 12vw, 4.5rem);
    color: var(--gold);
    filter: drop-shadow(0 0 20px rgba(245,158,11,.6));
}
.finish-score { font-size: 1rem; color: var(--muted); margin-top: 6px; }
.finish-score strong {
    font-family: var(--font-head);
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    color: var(--gold);
}
.finish-congrats { color: var(--muted); font-size: .9rem; margin-top: 6px; }

/* Podium final */
.finish-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    margin: 12px 0 6px;
    flex-wrap: wrap;
}
.finish-podium-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 14px;
    min-width: clamp(70px, 22vw, 100px);
    font-size: .82rem; transition: transform .2s;
}
.finish-podium-item.me {
    border-color: var(--gold); background: rgba(245,158,11,.1); transform: scale(1.05);
}
.finish-podium-item > div:first-child { font-size: clamp(1.4rem, 6vw, 2rem); }
.finish-podium-name {
    font-weight: 600; font-size: .8rem;
    max-width: clamp(70px, 20vw, 100px);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center;
}
.finish-podium-pts { color: var(--gold); font-family: var(--font-head); font-size: .78rem; }

.finish-lb { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 340px; margin: 0 auto; }
.finish-lb-row {
    display: flex; gap: 10px; align-items: center;
    background: var(--bg2); border-radius: 8px; padding: 7px 12px; font-size: .82rem;
}
.finish-lb-row.me { border: 1px solid var(--gold); background: rgba(245,158,11,.08); }
.finish-lb-row span:first-child { color: var(--muted); width: 20px; }
.finish-lb-row span:nth-child(2) { flex: 1; }
.finish-lb-row span:last-child { color: var(--gold); font-family: var(--font-head); }

/* ── BOUTONS ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 14px 24px; border-radius: 12px;
    font-family: var(--font-body); font-size: 1rem; font-weight: 600;
    cursor: pointer; border: none; transition: all .15s;
    text-decoration: none; white-space: nowrap;
    min-height: var(--touch-min);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-primary { background: linear-gradient(135deg, #7c3aed, var(--purple)); color: #fff; }
.btn-primary:hover  { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.97); }
.btn-full { width: 100%; }

/* Alerts */
.alert {
    border-radius: 10px; padding: 12px 16px; font-size: .9rem;
    margin-bottom: 14px; line-height: 1.5;
}
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }

/* ── SCORE PAGE ────────────────────────────────────────────── */
.score-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100dvh; padding: 24px 16px;
    background: radial-gradient(ellipse at 50% 0%, #1e1145, var(--bg) 70%);
}
.score-card { width: 100%; max-width: 440px; text-align: center; }
.score-cross {
    font-size: clamp(3rem, 12vw, 4rem);
    color: var(--gold); filter: drop-shadow(0 0 20px rgba(245,158,11,.6)); margin-bottom: 12px;
}
.score-title { font-family: var(--font-head); font-size: clamp(1.6rem, 7vw, 2.2rem); font-weight: 800; }
.score-pseudo { color: var(--muted); margin-bottom: 24px; font-size: .95rem; }
.score-big {
    margin: 0 auto 14px; display: flex;
    align-items: baseline; justify-content: center; gap: 8px;
    animation: pop .6s cubic-bezier(.175,.885,.32,1.275);
}
.score-big span:first-child {
    font-family: var(--font-head); font-size: clamp(4rem, 18vw, 5.5rem);
    font-weight: 800; color: var(--gold); line-height: 1;
    text-shadow: 0 0 40px rgba(245,158,11,.5);
}
.score-unit { font-family: var(--font-head); font-size: clamp(1.2rem, 5vw, 1.6rem); color: var(--muted); }
.score-rank { font-size: 1rem; color: var(--muted); margin-bottom: 6px; }
.score-msg  { font-size: .95rem; margin-bottom: 24px; }
.lb-mini {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 14px; padding: 16px; text-align: left;
}
.lb-mini h3 {
    font-family: var(--font-head); font-size: .85rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px;
}
.lb-mini-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 0;
    border-bottom: 1px solid var(--border); font-size: .9rem;
}
.lb-mini-row:last-child { border-bottom: none; }
.lb-mini-row span:first-child { width: 28px; text-align: center; }
.lb-mini-row span:nth-child(2) { flex: 1; }
.lb-mini-row span:last-child { color: var(--gold); font-family: var(--font-head); font-size: .85rem; }
.lb-me { background: rgba(124,58,237,.1); border-radius: 6px; padding: 8px 6px; margin: 0 -6px; outline: 1px solid rgba(124,58,237,.3); }

/* ── DESKTOP ENHANCEMENTS ──────────────────────────────────── */
@media (min-width: 540px) {
    .join-card   { padding: 40px 36px; }
    .choice-btn  { font-size: .95rem; min-height: 56px; }
    .quiz-state  { padding: 24px; gap: 18px; }
}

@media (min-width: 768px) {
    .quiz-header-inner { padding: 12px 32px; }
    .choices-grid { gap: 14px; }
    .choice-btn   { min-height: 68px; padding: 16px 18px; font-size: 1rem; }
    .question-text { font-size: 1.5rem; }
    .btn-validate { padding: 18px; font-size: 1.1rem; }
}

@media (min-width: 1024px) {
    .quiz-state { gap: 22px; padding: 32px; }
    .choice-btn { min-height: 72px; }
}

/* ── UTILITAIRES ───────────────────────────────────────────── */
.hidden { display: none !important; }
