/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --blush: #f7e3e6;
    --cream: #fdf6ee;
    --rose: #c98a97;
    --rose-dark: #a86775;
    --gold: #cba15c;
    --gold-light: #e6cd9a;
    --ink: #3b2b30;
    --ink-soft: #6d5b61;
    --success: #4caf7d;
    --success-dark: #2f8f5f;
    --error: #e0616f;
    --error-dark: #c23f4d;
    --shadow: 0 20px 45px -20px rgba(59, 43, 48, 0.35);
    --radius: 22px;
    --font-title: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
    --font-script: 'Snell Roundhand', 'Brush Script MT', cursive;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: radial-gradient(circle at 20% 20%, var(--blush), transparent 55%),
                radial-gradient(circle at 80% 0%, var(--gold-light), transparent 45%),
                linear-gradient(180deg, var(--cream), #f9ede0 60%, var(--blush));
    min-height: 100dvh;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#app {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* ============ SCREENS ============ */
.screen {
    display: none;
    width: 100%;
    max-width: 460px;
}

.screen--active {
    display: block;
}

/* ============ CARD ============ */
.card {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px 22px;
    text-align: center;
}

.card--enter {
    animation: cardEnter 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.eyebrow {
    font-family: var(--font-script);
    font-size: 1.4rem;
    color: var(--rose-dark);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.title {
    font-family: var(--font-title);
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    color: var(--ink);
    margin-bottom: 14px;
    line-height: 1.25;
}

.subtitle {
    color: var(--ink-soft);
    font-size: 1.02rem;
    margin-bottom: 28px;
    line-height: 1.5;
}

.subtitle--chrono {
    margin-top: -18px;
    font-size: 0.92rem;
    font-weight: 600;
}

/* ============ FORM ============ */
#form-name {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#input-name {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1rem;
    border-radius: 14px;
    border: 2px solid rgba(201, 138, 151, 0.35);
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
    text-align: center;
    font-family: var(--font-body);
}

#input-name:focus {
    border-color: var(--rose);
    box-shadow: 0 0 0 5px rgba(201, 138, 151, 0.18);
    transform: translateY(-2px);
}

/* ============ BUTTONS ============ */
.btn {
    border: none;
    border-radius: 14px;
    padding: 16px 28px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background 0.25s ease;
    position: relative;
    overflow: hidden;
}

.btn--primary {
    background: linear-gradient(135deg, var(--rose), var(--rose-dark));
    color: #fff;
    box-shadow: 0 12px 25px -10px rgba(168, 103, 117, 0.6);
}

.btn--primary:hover {
    box-shadow: 0 18px 30px -10px rgba(168, 103, 117, 0.7);
}

.btn--primary:active {
    transform: scale(0.97);
}

.btn--ghost {
    background: transparent;
    color: var(--rose-dark);
    border: 2px solid var(--rose);
    margin-top: 10px;
}

.btn--ghost:hover,
.btn--ghost:active {
    background: var(--rose);
    color: #fff;
}

.btn--ghost:active {
    transform: scale(0.97);
}

/* ============ QUIZ HEADER ============ */
.quiz-header {
    max-width: 460px;
    width: 100%;
    margin: 0 auto 22px;
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 20px;
    background: rgba(201, 138, 151, 0.18);
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 20px;
    background: linear-gradient(90deg, var(--gold), var(--rose));
    transition: width 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.92rem;
    color: var(--ink-soft);
}

.player-badge {
    background: rgba(255, 255, 255, 0.6);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    color: var(--rose-dark);
}

/* ============ QUESTION STAGE ============ */
.question-stage {
    perspective: 1400px;
}

.question-card {
    width: 100%;
    max-width: 460px;
}

.question-text {
    font-family: var(--font-title);
    font-size: clamp(1.3rem, 3.6vw, 1.7rem);
    margin-bottom: 30px;
    line-height: 1.4;
}

/* Transition states applied via JS */
.question-card.q-enter {
    animation: qEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-card.q-exit {
    animation: qExit 0.35s ease-in both;
}

@keyframes qEnter {
    from {
        opacity: 0;
        transform: translateX(60px) rotateY(-8deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) rotateY(0);
    }
}

@keyframes qExit {
    from {
        opacity: 1;
        transform: translateX(0) rotateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-60px) rotateY(8deg);
    }
}

/* ============ ANSWERS ============ */
.answers {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.answer-btn {
    padding: 18px 16px;
    font-size: 1rem;
    min-height: 56px;
    font-weight: 500;
    text-align: left;
    border-radius: 16px;
    border: 2px solid rgba(201, 138, 151, 0.3);
    background: rgba(255, 255, 255, 0.65);
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-body);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease,
                background 0.25s ease;
    position: relative;
    animation: answerIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.answer-btn:nth-child(1) { animation-delay: 0.05s; }
.answer-btn:nth-child(2) { animation-delay: 0.12s; }
.answer-btn:nth-child(3) { animation-delay: 0.19s; }
.answer-btn:nth-child(4) { animation-delay: 0.26s; }

@keyframes answerIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.answer-btn:hover:not(:disabled),
.answer-btn:active:not(:disabled) {
    border-color: var(--gold);
    background: #fff;
    box-shadow: 0 14px 24px -12px rgba(203, 161, 92, 0.55);
}

.answer-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.answer-btn:disabled {
    cursor: default;
}

.answer-btn.is-correct {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    border-color: var(--success-dark);
    color: #fff;
    animation: correctPulse 0.5s ease;
}

.answer-btn.is-wrong {
    background: linear-gradient(135deg, var(--error), var(--error-dark));
    border-color: var(--error-dark);
    color: #fff;
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* ============ RESULT ============ */
.result-card {
    max-width: 560px;
}

.score-big {
    font-family: var(--font-title);
    font-size: 3rem;
    color: var(--rose-dark);
    margin-bottom: 10px;
    animation: popScore 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popScore {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.save-status {
    font-size: 0.9rem;
    color: var(--ink-soft);
    min-height: 20px;
    margin-bottom: 6px;
}

/* ============ MEME OVERLAY ============ */
.meme-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 43, 48, 0);
    pointer-events: none;
    transition: background 0.35s ease;
    padding: 20px;
}

.meme-overlay.is-visible {
    background: rgba(59, 43, 48, 0.55);
    pointer-events: auto;
}

.meme-card {
    background: #fff;
    border-radius: 24px;
    padding: 30px 30px 26px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
    transform: translateY(40px) scale(0.85) rotate(-3deg);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.meme-overlay.is-visible .meme-card {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
}

.meme-verdict {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 1.2rem;
}

.meme-icon {
    font-size: 1.6rem;
}

.meme-verdict-text.good { color: var(--success-dark); }
.meme-verdict-text.bad { color: var(--error-dark); }

.meme-visual {
    border-radius: 16px;
    background: #111;
    padding: 20px 14px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 220px;
    position: relative;
    overflow: hidden;
}

.meme-gif {
    max-width: 100%;
    max-height: 260px;
    border-radius: 10px;
    animation: gifPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes gifPop {
    0% { transform: scale(0) rotate(-8deg); opacity: 0; }
    70% { transform: scale(1.05) rotate(2deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); }
}

.meme-caption {
    font-family: Impact, 'Arial Black', sans-serif;
    color: #fff;
    text-transform: uppercase;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
    -webkit-text-stroke: 1.5px #000;
    text-shadow: 2px 2px 0 #000;
    line-height: 1.2;
}

.meme-correct-answer {
    font-size: 0.95rem;
    color: var(--ink-soft);
    margin-bottom: 18px;
}

.meme-correct-answer strong {
    color: var(--ink);
}

/* ============ RESPONSIVE (petits ecrans) ============ */
@media (max-width: 360px) {
    .card {
        padding: 26px 16px;
    }
}
