.game-container {
    padding: 1rem 5%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    animation: fadeInDown 0.6s ease-out;
}

.btn-back {
    align-self: flex-start;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 1.5rem;
    transition: color 0.2s ease;
    display: inline-block;
}

.header-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.header-section h2 {
    font-size: 2.2rem;
    color: #fff;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-section p {
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 0 10px;
}

.dashboard {
    width: 100%;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap; /* Fix layout shifting on mobile */
    justify-content: center;
}

select {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-action {
    background: var(--accent-color);
    color: #fff;
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    box-shadow: 0 4px 15px var(--accent-glow);
    font-size: 0.95rem;
    min-width: 130px;
}

.btn-action.stop {
    background: #ef4444;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.stats {
    display: flex;
    gap: 1rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-color);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    min-width: 100px;
}

.stat-box.best {
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.05);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.stat-value.highlight {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-glow);
}

.message {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    min-height: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.message.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.message.error { color: #ef4444; }
.message.success { color: #10b981; }

.canvas-wrapper {
    position: relative;
    width: 100%;
    /* Impostiamo l'altezza in base al viewport mobile e disabilitiamo opzioni di touch del browser default */
    height: 60vh;
    min-height: 350px;
    max-height: 600px;
    background-color: #070b14;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: inset 0 0 50px rgba(0,0,0,0.8), 0 0 30px rgba(59, 130, 246, 0.1);
    touch-action: none; /* Critico per bloccare lo scrolling su mobile sul canvas */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.touch-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.7);
    font-size: 1.2rem;
    font-weight: 600;
    pointer-events: none;
    transition: opacity 0.3s;
    text-align: center;
    background: rgba(0,0,0,0.5);
    padding: 1rem 2rem;
    border-radius: 30px;
    backdrop-filter: blur(5px);
}

.touch-overlay.hidden {
    opacity: 0;
}

@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
        align-items: stretch;
    }
    .controls {
        justify-content: space-between;
    }
    select { flex: 1; }
    .btn-action { flex: 1; }
    .stats {
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .stat-box { flex: 1; }
    
    .canvas-wrapper {
        border-radius: 8px; /* Più spazioso su mobile */
        height: 55vh;
        border-width: 2px;
    }
}

.screenshot-area {
    width: 100%;
}

/* Modifiche per Countdown & Condividi */
.countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 11, 20, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.countdown-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#countdown-text {
    font-size: 8rem;
    font-weight: 800;
    color: var(--accent-color);
    text-shadow: 0 0 30px var(--accent-glow);
    animation: popIn 1s ease infinite;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

.btn-share {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    font-size: 1rem;
    min-width: unset;
}

.btn-share:hover {
    background: linear-gradient(135deg, #059669, #047857);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-share.hidden {
    display: none;
}
