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

:root {
    /* Palette colori slot machine */
    --rosso: #E53935;
    --oro: #FFD700;
    --verde: #43A047;
    --blu: #1E88E5;
    --bianco: #FFFFFF;
    --grigio-chiaro: #F5F5F5;
    --grigio-medio: #BDBDBD;
    --grigio-scuro: #424242;
    --nero: #212121;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
    --shadow-xl: 0 12px 24px rgba(0,0,0,0.25);
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, var(--rosso) 0%, var(--blu) 100%);
    min-height: 100vh;
    color: var(--nero);
    overflow-x: hidden;
}

/* ============================================
   HEADER E PUNTEGGIO
   ============================================ */
.game-header {
    background: var(--bianco);
    padding: 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--rosso);
    text-align: center;
}

.score-container {
    display: flex;
    gap: 20px;
}

.score-box {
    background: linear-gradient(135deg, var(--oro) 0%, #FFA000 100%);
    padding: 10px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--grigio-scuro);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--bianco);
}

/* ============================================
   SCHERMATA INTRODUTTIVA
   ============================================ */
.intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--rosso) 0%, var(--blu) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.5s ease;
}

.intro-screen.hidden {
    display: none;
}

.intro-content {
    background: var(--bianco);
    border-radius: 24px;
    padding: 50px 40px;
    max-width: 700px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.intro-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--rosso);
    margin-bottom: 30px;
    line-height: 1.2;
}

.intro-description {
    text-align: left;
    margin-bottom: 35px;
}

.intro-text {
    font-size: 1.2rem;
    color: var(--nero);
    margin-bottom: 15px;
}

.intro-rules {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.intro-rules li {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--grigio-scuro);
    padding: 10px 0;
    border-bottom: 1px solid var(--grigio-chiaro);
}

.intro-rules li:last-child {
    border-bottom: none;
}

.intro-bonus {
    background: linear-gradient(135deg, var(--oro) 0%, #FFA000 100%);
    padding: 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    color: var(--nero);
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
    animation: pulse 2s ease-in-out infinite;
}

.btn-start {
    background: linear-gradient(135deg, var(--verde) 0%, #2E7D32 100%);
    color: var(--bianco);
    border: none;
    border-radius: 16px;
    padding: 20px 50px;
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-start::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.btn-start:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.btn-start:hover::before {
    left: 100%;
}

.btn-start:active {
    transform: translateY(0) scale(1);
}

/* ============================================
   CONTAINER PRINCIPALE
   ============================================ */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

/* ============================================
   SLOT MACHINE
   ============================================ */
.slot-section {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease-out;
    padding: 20px;
}

.slot-machine {
    background: linear-gradient(145deg, #D32F2F, #B71C1C);
    border-radius: 24px;
    padding: 40px;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.4),
        0 0 0 8px var(--oro),
        0 0 0 10px #C62828;
    position: relative;
    overflow: visible;
    max-width: 550px;
    width: 100%;
    transform: translateZ(0);
}

/* Effetto luccichio bordo */
.slot-machine::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: linear-gradient(135deg, var(--oro) 0%, #FFA000 25%, var(--oro) 50%, #FFA000 75%, var(--oro) 100%);
    border-radius: 24px;
    z-index: -1;
    opacity: 0.6;
    animation: glow 3s ease-in-out infinite;
}

/* Titolo slot machine */
.slot-machine::after {
    content: '🎰 SLOT MACHINE 🎰';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--oro);
    color: var(--nero);
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 5px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    letter-spacing: 2px;
}

.slot-display {
    display: flex;
    gap: 20px;
    background: linear-gradient(145deg, #1a1a1a, #000000);
    padding: 30px 25px;
    border-radius: 16px;
    box-shadow:
        inset 0 8px 16px rgba(0,0,0,0.8),
        inset 0 -2px 8px rgba(255,255,255,0.1);
    perspective: 1200px;
    border: 3px solid #333;
}

.reel {
    width: 110px;
    height: 110px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 16px rgba(0,0,0,0.3),
        inset 0 2px 4px rgba(255,255,255,0.5);
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    border: 3px solid #ddd;
}

.reel .symbol {
    font-size: 4.5rem;
    user-select: none;
    transition: transform 0.1s ease;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.2));
}

/* Effetto spinning */
.reel.spinning .symbol {
    animation: spin 0.1s linear infinite;
    filter: blur(2px);
}

/* Effetto quando si ferma */
.reel.stopped .symbol {
    animation: bounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.slot-result {
    margin-top: 25px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #ffffff, #f5f5f5);
    border-radius: 12px;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--rosso);
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 12px rgba(0,0,0,0.2),
        inset 0 2px 4px rgba(255,255,255,0.8);
    border: 2px solid var(--oro);
}

/* ============================================
   BOTTONE SPIN SLOT MACHINE
   ============================================ */
.btn-spin {
    margin-top: 30px;
    width: 100%;
    background: linear-gradient(145deg, var(--oro), #FFA000);
    border: none;
    border-radius: 16px;
    padding: 20px 30px;
    font-family: 'Poppins', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--nero);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 8px 20px rgba(255,215,0,0.4),
        0 0 0 3px #C62828,
        inset 0 2px 4px rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.btn-spin::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s ease;
}

.btn-spin:hover {
    background: linear-gradient(145deg, #FFD700, #FFB300);
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 12px 30px rgba(255,215,0,0.6),
        0 0 0 3px #C62828,
        inset 0 2px 4px rgba(255,255,255,0.6);
}

.btn-spin:hover::before {
    left: 100%;
}

.btn-spin:active {
    transform: translateY(-1px) scale(1);
}

.btn-spin:disabled {
    background: linear-gradient(145deg, #9e9e9e, #757575);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow:
        0 4px 12px rgba(0,0,0,0.2),
        0 0 0 3px #666;
}

.btn-spin-text {
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

/* ============================================
   SEZIONE DOMANDA
   ============================================ */
.question-section {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease-out;
    padding: 20px;
}

.question-card {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 24px;
    padding: 45px 40px;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.15),
        0 0 0 1px rgba(0,0,0,0.05);
    width: 100%;
    border-top: 5px solid var(--blu);
}

.question-info {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-left: 5px solid var(--blu);
    padding: 18px 24px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideIn 0.5s ease-out;
    box-shadow: 0 4px 12px rgba(30,136,229,0.2);
}

.info-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.info-text {
    font-size: 1rem;
    color: var(--grigio-scuro);
    font-weight: 600;
    line-height: 1.5;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-text {
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--nero);
    margin-bottom: 35px;
    line-height: 1.5;
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--grigio-chiaro);
}

.answers-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.answer-btn {
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    border: 3px solid #e0e0e0;
    border-radius: 16px;
    padding: 24px 28px;
    font-family: 'Roboto', sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--nero);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.answer-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(30,136,229,0.2), transparent);
    transition: left 0.5s ease;
}

.answer-btn::after {
    content: '→';
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 1.5rem;
    font-weight: bold;
}

.answer-btn:hover {
    background: linear-gradient(145deg, var(--blu), #1565C0);
    color: var(--bianco);
    border-color: var(--blu);
    transform: translateX(5px) translateY(-3px);
    box-shadow: 0 8px 24px rgba(30,136,229,0.4);
}

.answer-btn:hover::before {
    left: 100%;
}

.answer-btn:hover::after {
    opacity: 1;
    right: 20px;
}

.answer-btn:active {
    transform: translateX(3px) translateY(-1px);
}

.answer-btn.correct {
    background: linear-gradient(145deg, var(--verde), #2E7D32);
    color: var(--bianco);
    border-color: var(--verde);
    animation: pulse 0.5s ease;
    box-shadow: 0 8px 24px rgba(67,160,71,0.4);
}

.answer-btn.incorrect {
    background: linear-gradient(145deg, var(--rosso), #C62828);
    color: var(--bianco);
    border-color: var(--rosso);
    animation: shake 0.5s ease;
    box-shadow: 0 8px 24px rgba(229,57,53,0.4);
}

.answer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* ============================================
   FEEDBACK MODAL
   ============================================ */
.feedback-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.feedback-modal.show {
    display: flex;
}

.feedback-content {
    background: var(--bianco);
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.feedback-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.feedback-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.feedback-title.correct {
    color: var(--verde);
}

.feedback-title.incorrect {
    color: var(--rosso);
}

.feedback-explanation {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--grigio-scuro);
    margin-bottom: 25px;
}

.btn-continue {
    background: var(--blu);
    color: var(--bianco);
    border: none;
    border-radius: 12px;
    padding: 15px 40px;
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.btn-continue:hover {
    background: #1565C0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-continue:active {
    transform: translateY(0);
}

/* ============================================
   SCHERMATA FINALE
   ============================================ */
.final-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.final-screen.show {
    display: flex;
}

.final-content {
    background: var(--bianco);
    border-radius: 24px;
    padding: 50px 40px;
    max-width: 600px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.final-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--rosso);
    margin-bottom: 30px;
}

.final-score {
    background: linear-gradient(135deg, var(--oro) 0%, #FFA000 100%);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.final-score-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--grigio-scuro);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

.final-score-value {
    font-family: 'Poppins', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    color: var(--bianco);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.final-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: var(--grigio-chiaro);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--grigio-scuro);
    font-weight: 500;
}

.stat-value {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--blu);
}

.btn-restart {
    background: var(--verde);
    color: var(--bianco);
    border: none;
    border-radius: 12px;
    padding: 18px 50px;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.btn-restart:hover {
    background: #388E3C;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-restart:active {
    transform: translateY(0);
}

/* ============================================
   CANVAS CONFETTI
   ============================================ */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    display: none;
}

/* ============================================
   ANIMAZIONI
   ============================================ */

/* Animazione spin slot (rotazione simboli) */
@keyframes spin {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.1); }
    100% { transform: translateY(0) scale(1); }
}

/* Animazione pulse per vittoria */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Animazione shake per errore */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* Animazione glow per jackpot */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--oro), 0 0 10px var(--oro);
    }
    50% {
        box-shadow: 0 0 20px var(--oro), 0 0 40px var(--oro), 0 0 60px var(--oro);
    }
}

/* Fade in per elementi */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Slide up per modals */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bounce per rulli slot */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-15px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-7px); }
}

/* Animazione jackpot (glow intenso) */
.slot-machine.jackpot {
    animation: glow 0.5s ease-in-out infinite;
}

.slot-result.jackpot {
    animation: pulse 0.8s ease-in-out infinite;
    background: linear-gradient(135deg, var(--oro) 0%, #FFA000 100%);
    color: var(--bianco);
    font-size: 1.5rem;
}

/* ============================================
   RESPONSIVE - MOBILE (default)
   ============================================ */
@media (max-width: 767px) {
    .game-container {
        padding: 20px 15px;
        min-height: auto;
    }

    .slot-section {
        padding: 10px;
    }

    .slot-machine {
        padding: 25px 20px;
        max-width: 100%;
    }

    .slot-machine::after {
        font-size: 0.75rem;
        padding: 4px 15px;
        top: -12px;
    }

    .slot-display {
        gap: 12px;
        padding: 20px 15px;
    }

    .reel {
        width: 85px;
        height: 85px;
    }

    .reel .symbol {
        font-size: 3.5rem;
    }

    .slot-result {
        font-size: 1rem;
        padding: 12px 15px;
        min-height: 50px;
    }

    /* Bottone spin su mobile */
    .btn-spin {
        padding: 18px 25px;
        font-size: 1.1rem;
    }

    /* Domande */
    .question-section {
        padding: 10px;
    }

    .question-card {
        padding: 30px 25px;
    }

    .question-text {
        font-size: 1.4rem;
        margin-bottom: 25px;
    }

    .answer-btn {
        padding: 18px 20px;
        font-size: 1rem;
    }

    /* Intro */
    .intro-title {
        font-size: 2rem;
    }

    .intro-content {
        padding: 30px 25px;
    }

    .btn-start {
        padding: 15px 30px;
        font-size: 1.2rem;
    }
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (min-width: 768px) {
    .game-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 25px 40px;
    }

    .game-title {
        font-size: 2.2rem;
    }

    .game-container {
        padding: 50px 30px;
    }

    .slot-machine {
        padding: 45px;
    }

    .reel {
        width: 120px;
        height: 120px;
    }

    .reel .symbol {
        font-size: 5rem;
    }

    .answers-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .question-text {
        font-size: 1.9rem;
    }

    .answer-btn {
        padding: 22px 26px;
    }
}

/* ============================================
   RESPONSIVE - DESKTOP
   ============================================ */
@media (min-width: 1024px) {
    .game-container {
        padding: 60px 40px;
        gap: 50px;
    }

    .slot-machine {
        padding: 50px;
        max-width: 600px;
    }

    .reel {
        width: 130px;
        height: 130px;
    }

    .reel .symbol {
        font-size: 5.5rem;
    }

    .slot-result {
        font-size: 1.4rem;
        padding: 20px 25px;
        min-height: 80px;
    }

    .question-card {
        padding: 50px 45px;
    }

    .question-text {
        font-size: 2rem;
    }

    .answer-btn {
        padding: 26px 30px;
        font-size: 1.15rem;
    }

    .answer-btn:hover {
        transform: translateX(8px) translateY(-4px);
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Accessibilità */
:focus-visible {
    outline: 3px solid var(--blu);
    outline-offset: 3px;
}

/* Prevenzione selezione testo durante animazioni */
.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}
