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

body {
    font-family: 'Arial Black', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    overflow: hidden;
    /* Previene zoom su mobile */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.game-container {
    max-width: 1000px;
    width: 100%;
    padding: 20px;
    position: relative;
}

/* Danger warning image in top left corner */
.danger-warning {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 80px;
    height: 80px;
    background-image: url('./danger.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    z-index: 9999;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    opacity: 0.9;
    animation: danger-pulse 2s infinite;
}

@keyframes danger-pulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(255,0,0,0.6);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}

.danger-warning:hover {
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 8px 25px rgba(255,0,0,0.8);
}

/* Bolt.new logo in top right corner */
.bolt-logo {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 80px;
    height: 80px;
    background-image: url('./IMG_2220.PNG');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    z-index: 9999;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    opacity: 0.9;
    animation: bolt-glow 3s infinite;
}

@keyframes bolt-glow {
    0% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    50% { 
        transform: scale(1.05) rotate(2deg);
        box-shadow: 0 6px 20px rgba(102,126,234,0.6);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}

.bolt-logo:hover {
    transform: scale(1.1) rotate(5deg);
    opacity: 1;
    box-shadow: 0 8px 25px rgba(102,126,234,0.8);
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 3rem;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    margin-bottom: 15px;
    color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.score-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.score {
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: bold;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.3);
    transition: all 0.3s ease;
}

/* Schermata iniziale */
.start-screen {
    width: 800px;
    height: 600px;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.1);
    border-radius: 15px;
    border: 3px solid rgba(255,255,255,0.3);
}

.start-image {
    width: 320px;
    height: 240px;
    background-image: url('./pirla.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    border: 3px solid rgba(255,255,255,0.9);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    cursor: pointer;
    animation: start-bounce 1s infinite alternate;
    margin-bottom: 40px;
    /* Ottimizzazione touch mobile */
    touch-action: manipulation;
}

@keyframes start-bounce {
    0% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    }
    100% { 
        transform: scale(1.05) rotate(2deg);
        box-shadow: 0 8px 20px rgba(255,215,0,0.6);
    }
}

.start-message {
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    animation: start-flash 1s infinite;
    background: rgba(255,255,255,0.1);
    padding: 20px 30px;
    border-radius: 15px;
    border: 3px solid rgba(255,215,0,0.5);
    backdrop-filter: blur(10px);
}

@keyframes start-flash {
    0% { 
        opacity: 1; 
        color: #ffd700;
        transform: scale(1);
    }
    25% { 
        opacity: 0.8; 
        color: #ff69b4;
        transform: scale(1.02);
    }
    50% { 
        opacity: 1; 
        color: #00ff00;
        transform: scale(1.05);
    }
    75% { 
        opacity: 0.9; 
        color: #ff4500;
        transform: scale(1.03);
    }
    100% { 
        opacity: 1; 
        color: #ffd700;
        transform: scale(1);
    }
}

.game-board {
    width: 800px;
    height: 600px;
    margin: 0 auto;
    position: relative;
    background: rgba(0,0,0,0.1);
    border-radius: 15px;
    border: 3px solid rgba(255,255,255,0.3);
    overflow: hidden;
    cursor: crosshair;
    /* Ottimizzazioni mobile */
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

/* Bersaglio rettangolare colorato fisso */
.target-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: 
        radial-gradient(ellipse 100% 100% at center, transparent 0%, transparent 85%, white 85%, white 90%, transparent 90%),
        radial-gradient(ellipse 85% 85% at center, transparent 0%, transparent 70%, #ffff00 70%, #ffff00 80%, transparent 80%),
        radial-gradient(ellipse 70% 70% at center, transparent 0%, transparent 55%, #00ff00 55%, #00ff00 65%, transparent 65%),
        radial-gradient(ellipse 55% 55% at center, transparent 0%, transparent 40%, #ffff00 40%, #ffff00 50%, transparent 50%),
        radial-gradient(ellipse 40% 40% at center, #ff0000 0%, #ff0000 100%);
}

.grid-cell {
    position: absolute;
    width: 80px;
    height: 75px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.4rem; /* Aumentato da 2rem a 2.4rem (+20%) */
    transition: all 0.1s ease;
    opacity: 0.8;
    pointer-events: none;
    z-index: 15;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.grid-cell.hidden {
    opacity: 0;
    transform: scale(0.3) rotate(180deg);
}

.bouncing-rectangle {
    position: absolute;
    width: 320px;
    height: 240px;
    background-image: url('./pirla.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    border: 3px solid rgba(255,255,255,0.9);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    z-index: 20;
    animation: bounce-glow 0.3s infinite alternate;
    cursor: pointer;
    /* Ottimizzazioni mobile */
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

@keyframes bounce-glow {
    0% { 
        box-shadow: 0 6px 12px rgba(0,0,0,0.4);
        transform: scale(1) rotate(0deg);
    }
    100% { 
        box-shadow: 0 8px 20px rgba(255,215,0,0.6);
        transform: scale(1.05) rotate(2deg);
    }
}

/* Messaggio di dolore lampeggiante - OTTIMIZZATO PER MOBILE */
.pain-message {
    position: absolute;
    font-size: 1.8rem;
    font-weight: bold;
    color: #ff0000;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    z-index: 1000;
    animation: pain-flash 0.5s infinite;
    background: rgba(255,255,255,0.9);
    padding: 15px 20px;
    border-radius: 12px;
    border: 3px solid #ff0000;
    backdrop-filter: blur(10px);
    text-align: center;
    line-height: 1.2;
    max-width: 90%;
    word-wrap: break-word;
}

@keyframes pain-flash {
    0% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
        color: #ff0000;
        background: rgba(255,255,255,0.9);
        border-color: #ff0000;
    }
    25% { 
        opacity: 0.7; 
        transform: translate(-50%, -50%) scale(1.05);
        color: #ffffff;
        background: rgba(255,0,0,0.8);
        border-color: #ffffff;
    }
    50% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1.1);
        color: #ffff00;
        background: rgba(255,0,0,0.9);
        border-color: #ffff00;
    }
    75% { 
        opacity: 0.8; 
        transform: translate(-50%, -50%) scale(1.05);
        color: #ffffff;
        background: rgba(255,0,0,0.8);
        border-color: #ffffff;
    }
    100% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
        color: #ff0000;
        background: rgba(255,255,255,0.9);
        border-color: #ff0000;
    }
}

/* 🔥 NUOVO: Avviso UNCONTROLLED CHAOS */
.chaos-warning {
    position: absolute;
    font-size: 2.5rem;
    font-weight: bold;
    color: #ff4500;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    z-index: 2000;
    animation: chaos-flash 0.3s infinite;
    background: rgba(255,69,0,0.9);
    padding: 20px 30px;
    border-radius: 15px;
    border: 4px solid #ffffff;
    backdrop-filter: blur(15px);
    text-align: center;
    line-height: 1.2;
    max-width: 90%;
    word-wrap: break-word;
    box-shadow: 0 0 30px rgba(255,69,0,0.8);
}

@keyframes chaos-flash {
    0% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
        color: #ff4500;
        background: rgba(255,69,0,0.9);
        border-color: #ffffff;
        box-shadow: 0 0 30px rgba(255,69,0,0.8);
    }
    25% { 
        opacity: 0.8; 
        transform: translate(-50%, -50%) scale(1.05);
        color: #ffffff;
        background: rgba(255,0,0,0.9);
        border-color: #ffff00;
        box-shadow: 0 0 40px rgba(255,0,0,0.9);
    }
    50% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1.1);
        color: #ffff00;
        background: rgba(255,69,0,0.9);
        border-color: #ff0000;
        box-shadow: 0 0 50px rgba(255,255,0,0.8);
    }
    75% { 
        opacity: 0.9; 
        transform: translate(-50%, -50%) scale(1.05);
        color: #ffffff;
        background: rgba(255,0,0,0.9);
        border-color: #ffff00;
        box-shadow: 0 0 40px rgba(255,0,0,0.9);
    }
    100% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
        color: #ff4500;
        background: rgba(255,69,0,0.9);
        border-color: #ffffff;
        box-shadow: 0 0 30px rgba(255,69,0,0.8);
    }
}

/* Messaggio finale lampeggiante */
.end-message {
    text-align: center;
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    margin: 50px 0;
    line-height: 1.4;
    animation: titillating-blink 0.8s infinite;
    background: rgba(255,255,255,0.1);
    padding: 40px;
    border-radius: 20px;
    border: 3px solid rgba(255,215,0,0.5);
    backdrop-filter: blur(10px);
}

@keyframes titillating-blink {
    0% { 
        opacity: 1; 
        transform: scale(1);
        color: #ffd700;
        text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    }
    25% { 
        opacity: 0.7; 
        transform: scale(1.02);
        color: #ff69b4;
        text-shadow: 0 0 20px rgba(255,105,180,0.8);
    }
    50% { 
        opacity: 1; 
        transform: scale(1.05);
        color: #00ff00;
        text-shadow: 0 0 25px rgba(0,255,0,0.8);
    }
    75% { 
        opacity: 0.8; 
        transform: scale(1.03);
        color: #ff4500;
        text-shadow: 0 0 30px rgba(255,69,0,0.8);
    }
    100% { 
        opacity: 1; 
        transform: scale(1);
        color: #ffd700;
        text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    }
}

.score-popup {
    position: absolute;
    font-weight: bold;
    font-size: 1.5rem;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 1000;
    animation: scoreFloat 1s ease-out forwards;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

/* MEDIA QUERIES OTTIMIZZATE PER MOBILE */
@media (max-width: 900px) {
    body {
        padding: 10px;
        /* Previene zoom su doppio tap */
        touch-action: manipulation;
    }
    
    .game-container {
        padding: 10px;
        max-width: 100%;
    }
    
    .danger-warning {
        width: 60px;
        height: 60px;
        top: 15px;
        left: 15px;
    }
    
    .bolt-logo {
        width: 60px;
        height: 60px;
        top: 15px;
        right: 15px;
    }
    
    .game-board, .start-screen {
        width: 90vw;
        height: 60vh;
        cursor: crosshair;
        /* Ottimizzazioni mobile specifiche */
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }
    
    .header h1 {
        font-size: 2rem;
        margin-bottom: 10px;
    }
    
    .score {
        font-size: 1rem;
        padding: 8px 16px;
    }
    
    .grid-cell {
        font-size: 1.44rem; /* Aumentato da 1.2rem a 1.44rem (+20%) */
        transition: all 0.15s ease; /* Transizione più lenta su mobile */
    }
    
    .bouncing-rectangle, .start-image {
        /* Dimensioni dinamiche gestite da JavaScript */
        min-width: 120px;
        min-height: 90px;
        max-width: 200px;
        max-height: 150px;
    }
    
    .end-message {
        font-size: 1.5rem;
        padding: 20px;
        margin: 20px 0;
        line-height: 1.3;
    }
    
    .start-message {
        font-size: 1.3rem;
        padding: 15px 20px;
        line-height: 1.3;
    }
    
    .pain-message {
        font-size: 1.2rem;
        padding: 12px 15px;
        max-width: 95%;
        line-height: 1.1;
    }
    
    .chaos-warning {
        font-size: 1.8rem;
        padding: 15px 20px;
        max-width: 95%;
        line-height: 1.1;
    }
    
    .score-popup {
        font-size: 1.2rem;
    }
}

/* MEDIA QUERIES PER SCHERMI MOLTO PICCOLI */
@media (max-width: 480px) {
    .danger-warning {
        width: 50px;
        height: 50px;
        top: 10px;
        left: 10px;
    }
    
    .bolt-logo {
        width: 50px;
        height: 50px;
        top: 10px;
        right: 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .game-board, .start-screen {
        width: 95vw;
        height: 55vh;
    }
    
    .grid-cell {
        font-size: 1.2rem; /* Aumentato da 1rem a 1.2rem (+20%) */
    }
    
    .end-message {
        font-size: 1.2rem;
        padding: 15px;
    }
    
    .start-message {
        font-size: 1.1rem;
        padding: 12px 15px;
    }
    
    .pain-message {
        font-size: 1rem;
        padding: 10px 12px;
        max-width: 98%;
    }
    
    .chaos-warning {
        font-size: 1.4rem;
        padding: 12px 15px;
        max-width: 98%;
    }
}

/* ORIENTAMENTO LANDSCAPE SU MOBILE */
@media (max-height: 500px) and (orientation: landscape) {
    .danger-warning {
        width: 45px;
        height: 45px;
        top: 8px;
        left: 8px;
    }
    
    .bolt-logo {
        width: 45px;
        height: 45px;
        top: 8px;
        right: 8px;
    }
    
    .header h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .score-container {
        margin-bottom: 10px;
    }
    
    .game-board, .start-screen {
        height: 70vh;
    }
    
    .end-message, .start-message {
        font-size: 1.2rem;
        padding: 15px;
        margin: 15px 0;
    }
    
    .chaos-warning {
        font-size: 1.5rem;
        padding: 12px 15px;
    }
}