/* =========================================================
   ROUE DE LA FORTUNE EVG — Feuille de style
   Style : moderne, épuré, mobile-first, fond sombre élégant
   ========================================================= */

/* ---- Variables de thème ---- */
:root {
    --bg-deep:      #14102b;          /* fond sombre profond            */
    --bg-grad-1:    #1f1640;          /* dégradé festif discret (haut)  */
    --bg-grad-2:    #2b1d52;          /* dégradé festif discret (bas)   */
    --surface:      #241a47;          /* surfaces (cartes, modales)     */
    --surface-soft: #2e2356;          /* surfaces secondaires           */
    --accent:       #ff4d8d;          /* rose festif principal          */
    --accent-2:     #ffb84d;          /* doré secondaire                */
    --text:         #f5f2ff;          /* texte principal                */
    --text-muted:   #b7afd6;          /* texte atténué                  */
    --danger:       #ff5a5a;          /* actions destructrices          */
    --radius:       18px;
    --shadow:       0 18px 40px rgba(0, 0, 0, 0.45);
    --transition:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset léger ---- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    color: var(--text);
    /* Dégradé festif discret sur fond sombre */
    background: radial-gradient(circle at 50% 0%, var(--bg-grad-2) 0%, var(--bg-grad-1) 45%, var(--bg-deep) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 18px 48px;
    overflow-x: hidden;
}

/* =========================================================
   EN-TÊTE
   ========================================================= */
.app-header {
    text-align: center;
    position: relative;
    width: 100%;
    max-width: 520px;
    margin-bottom: 18px;
}

.app-title {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
}
.app-title span {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 6px;
}

/* Bouton engrenage discret en haut à droite */
.admin-toggle {
    position: absolute;
    top: -4px;
    right: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: var(--transition);
}
.admin-toggle:hover { background: rgba(255, 255, 255, 0.14); }
.admin-toggle:active { transform: scale(0.9) rotate(40deg); }

/* =========================================================
   SECTION ROUE
   ========================================================= */
.wheel-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 520px;
}

.wheel-wrapper {
    position: relative;
    width: min(86vw, 420px);
    height: min(86vw, 420px);
    margin: 8px 0 4px;
}

/* La roue (canvas) */
#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* Cadre festif + ombre profonde pour faire ressortir les couleurs */
    box-shadow:
        0 0 0 10px var(--surface),
        0 0 0 14px rgba(255, 255, 255, 0.06),
        var(--shadow);
    display: block;
    /* La rotation est pilotée en JS via transform */
    transition: transform 5.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Indicateur / flèche en haut de la roue */
.wheel-pointer {
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 30px solid var(--accent-2);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
    margin-bottom: -14px;
    z-index: 5;
    position: relative;
}

/* Bouton central SPIN */
.spin-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 86px;
    height: 86px;
    border-radius: 50%;
    border: 5px solid #fff;
    background: linear-gradient(135deg, var(--accent), #ff7eb3);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(255, 77, 141, 0.55);
    transition: var(--transition);
    z-index: 4;
}
.spin-btn:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.06); }
.spin-btn:active:not(:disabled) { transform: translate(-50%, -50%) scale(0.94); }
.spin-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Bouton secondaire sous la roue */
.spin-btn-alt {
    margin-top: 22px;
    padding: 14px 30px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--accent-2), #ffd27a);
    color: #3a2400;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(255, 184, 77, 0.4);
    transition: var(--transition);
}
.spin-btn-alt:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(255, 184, 77, 0.5); }
.spin-btn-alt:active:not(:disabled) { transform: translateY(1px); }
.spin-btn-alt:disabled { opacity: 0.5; cursor: not-allowed; }

.wheel-hint {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* =========================================================
   PAGE "PAUSE" (roue désactivée)
   ========================================================= */
.pause-screen {
    display: none;            /* affichée via JS quand la roue est désactivée */
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 460px;
    width: 100%;
    margin-top: 30px;
    padding: 34px 26px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: pop 0.4s ease;
}
.pause-emoji {
    font-size: 3.4rem;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.pause-title {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 14px;
}
.pause-text {
    color: var(--text);
    font-size: 1.02rem;
    line-height: 1.6;
}
.pause-text strong { color: var(--accent-2); }
.pause-wink {
    display: inline-block;
    margin-top: 8px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.92rem;
}
.pause-hint {
    margin-top: 20px;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}

/* =========================================================
   MODALES (résultat + mot de passe)
   ========================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 5, 20, 0.78);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 30px 26px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow);
    transform: scale(0.85) translateY(10px);
    transition: transform var(--transition);
}
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); }

.modal-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 10px; }
.modal-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; }

/* Modale de résultat festive */
.result-box { border: 2px solid var(--accent); }
.confetti-emoji { font-size: 3rem; animation: pop 0.5s ease; }
.result-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 14px 0 24px;
    color: var(--accent-2);
}

/* ---- Carte à gratter ---- */
.scratch-card {
    position: relative;
    width: 100%;
    max-width: 260px;
    aspect-ratio: 1 / 1;
    margin: 16px auto 12px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
    /* Empêche le scroll de la page pendant qu'on gratte au doigt */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Fond de secours (visible si une image ne charge pas) */
.scratch-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 4rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* L'image surprise révélée par le grattage */
.scratch-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Le calque gris que l'on gratte */
.scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    transition: opacity 0.45s ease;
}
.scratch-canvas:active { cursor: grabbing; }

.scratch-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
    transition: opacity 0.3s ease;
}

/* Bloc résultat : masqué tant que la carte n'est pas grattée */
.result-reveal {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(8px);
    transition: opacity 0.4s ease, max-height 0.4s ease, transform 0.4s ease;
}
.result-reveal.show {
    opacity: 1;
    max-height: 460px;
    transform: translateY(0);
    margin-top: 6px;
}

@keyframes pop {
    0%   { transform: scale(0) rotate(-30deg); }
    60%  { transform: scale(1.25) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

/* =========================================================
   PANNEAU ADMIN
   ========================================================= */
.admin-panel {
    position: fixed;
    inset: 0;
    background: var(--bg-deep);
    z-index: 120;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}
.admin-panel.open { transform: translateX(0); }

.admin-content {
    max-width: 560px;
    margin: 0 auto;
    padding: 24px 18px 60px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.admin-header h2 { font-size: 1.4rem; font-weight: 700; }

.admin-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
}
.admin-close:hover { background: rgba(255, 255, 255, 0.16); }

/* Ligne interrupteur "Roue active" */
.admin-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 20px;
}
.admin-toggle-info strong { font-size: 1rem; }
.admin-toggle-info p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 3px;
}

/* Interrupteur (switch) */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    inset: 0;
    background: var(--surface-soft);
    border-radius: 30px;
    cursor: pointer;
    transition: var(--transition);
}
.slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 4px;
    top: 4px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
}
.switch input:checked + .slider {
    background: linear-gradient(135deg, #5ce6a8, #4de0d0);
}
.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.admin-form {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
}
.admin-form .text-input { flex: 1; }
.admin-form-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    min-height: 18px;
    margin-bottom: 14px;
}

/* Liste des gages */
.gage-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.gage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 12px 14px;
    animation: slideIn 0.25s ease;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gage-color-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.gage-text { flex: 1; font-size: 0.92rem; line-height: 1.3; word-break: break-word; }

.gage-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
    width: 34px; height: 34px;
    border: none;
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--transition);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.15); }
.icon-btn.delete:hover { background: var(--danger); }

.admin-footer { margin-top: 26px; text-align: center; }

/* =========================================================
   ÉLÉMENTS PARTAGÉS (boutons, inputs)
   ========================================================= */
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 22px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn:active { transform: scale(0.96); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #ff7eb3);
    color: #fff;
    box-shadow: 0 6px 16px rgba(255, 77, 141, 0.4);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.16); }
.btn-danger { color: var(--danger); }

.text-input {
    background: var(--bg-deep);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 13px 15px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    transition: var(--transition);
}
.text-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 77, 141, 0.2);
}

.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.modal-actions .btn { flex: 1; }

.error-msg {
    color: var(--danger);
    font-size: 0.82rem;
    min-height: 18px;
    margin: 8px 0;
}

/* =========================================================
   RESPONSIVE — petits écrans
   ========================================================= */
@media (max-width: 360px) {
    .spin-btn { width: 72px; height: 72px; font-size: 0.85rem; }
    .app-title { font-size: 1.6rem; }
}
