.game-container {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    max-width: 100%;
}

.game-info {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin: 0 auto 20px;
    max-width: 500px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-item .label {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 5px;
}

.info-item .value {
    font-size: 24px;
    font-weight: bold;
    color: #ffff00;
}

.canvas-container {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

#gameCanvas {
    background: #000;
    border: 4px solid #1e90ff;
    border-radius: 10px;
    display: block;
    width: 100%;
    height: auto;
    max-width: 560px;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    z-index: 10;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
}

.overlay-content h2 {
    font-size: 48px;
    color: #ffff00;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.overlay-content p {
    font-size: 20px;
    color: #fff;
    margin-bottom: 10px;
}

.overlay-content .controls {
    font-size: 16px;
    color: #aaa;
    margin-top: 20px;
}

/* Touch Controls */
.touch-controls {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
}

.touch-controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
}

.control-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(145deg, #2a2a5a, #1a1a3a);
    border: 3px solid #1e90ff;
    border-radius: 15px;
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    background: linear-gradient(145deg, #1e90ff, #1c7ed6);
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Grid positioning for controls - Layout 2 righe */
.control-btn[data-direction="up"] {
    grid-column: 2;
    grid-row: 1;
}

.control-btn[data-direction="left"] {
    grid-column: 1;
    grid-row: 2;
}

.control-btn[data-direction="down"] {
    grid-column: 2;
    grid-row: 2;
}

.control-btn[data-direction="right"] {
    grid-column: 3;
    grid-row: 2;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Su mobile nella hero section: nascondi solo game-info e touch-controls */
    .hero-image .game-info {
        display: none;
    }

    .hero-image .touch-controls {
        display: none;
    }

    /* Nella modale: mostra tutto */
    .game-modal-content .game-info {
        display: flex;
    }

    .game-modal-content .touch-controls {
        display: block;
    }

    .game-container {
        padding: 20px;
        border-radius: 15px;
    }

    .game-info {
        padding: 10px;
        max-width: 100%;
    }

    .info-item .label {
        font-size: 12px;
    }

    .info-item .value {
        font-size: 20px;
    }

    .touch-controls {
        display: block;
    }

    .overlay-content h2 {
        font-size: 36px;
    }

    .overlay-content p {
        font-size: 18px;
    }

    .overlay-content .controls {
        font-size: 14px;
    }

    /* Mobile-specific: Show GIOCA button, hide desktop messages */
    .mobile-play-btn {
        display: inline-block;
    }

    .desktop-message {
        display: none;
    }

    /* Close button visible on mobile */
    .close-modal-btn {
        display: flex;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 15px;
        border-radius: 10px;
    }

    .game-info {
        padding: 8px;
        gap: 10px;
    }

    .info-item .label {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .info-item .value {
        font-size: 18px;
    }

    #gameCanvas {
        border-width: 2px;
    }

    .touch-controls {
        padding: 15px;
        margin-top: 15px;
    }

    .control-btn {
        width: 70px;
        height: 70px;
        font-size: 24px;
    }

    .overlay-content h2 {
        font-size: 28px;
    }

    .overlay-content p {
        font-size: 16px;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        padding: 10px;
    }

    .touch-controls-grid {
        max-width: 250px;
    }

    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
}

/* Mobile Play Button */
.mobile-play-btn {
    display: none;
    padding: 18px 50px;
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(145deg, #00cc66, #00ff88);
    border: 3px solid #00ff88;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 255, 136, 0.4);
    transition: all 0.3s ease;
    margin-top: 20px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-play-btn:active {
    transform: scale(0.95);
    box-shadow: 0 4px 10px rgba(0, 255, 136, 0.3);
}

.mobile-play-btn:hover {
    background: linear-gradient(145deg, #00ff88, #00cc66);
    box-shadow: 0 10px 25px rgba(0, 255, 136, 0.5);
}

/* Fullscreen Game Modal */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 20px;
}

.game-modal.hidden {
    display: none;
}

.game-modal-content {
    width: 100%;
    max-width: 620px;
    max-height: 95vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Close Modal Button */
.close-modal-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 59, 48, 0.9);
    border: 3px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.close-modal-btn:active {
    transform: scale(0.9);
    background: rgba(255, 89, 78, 1);
}

.close-modal-btn:hover {
    background: rgba(255, 89, 78, 1);
    box-shadow: 0 6px 15px rgba(255, 59, 48, 0.5);
}

/* Desktop message hidden on mobile */
.desktop-message {
    display: block;
}

/* Desktop-only: Hide close button and mobile play button */
@media (min-width: 769px) {
    .close-modal-btn {
        display: none !important;
    }

    .mobile-play-btn {
        display: none !important;
    }
}
