/**
 * Snake Retro Arcade Style (Game Boy Mobile Layout - Large D-Pad Edition)
 * Schermo perfettamente quadrato (zero border-radius) e area pixel-perfect.
 */
.yf-game-snake {
    max-width: 440px;
    width: 100%;
    margin: 10px auto;
    background: #141722;
    border: 3px solid #10b981;
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(16, 185, 129, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #f1f5f9;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.yf-game-snake * {
    box-sizing: border-box;
}

.yf-game-snake .yf-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #242b3d;
}

.yf-game-snake .yf-player-badge {
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.25);
    font-size: 13px;
    font-weight: 600;
}

.yf-game-snake .yf-guest-badge {
    color: #94a3b8;
    font-size: 13px;
}

.yf-game-snake .yf-guest-badge a {
    color: #10b981;
    text-decoration: underline;
}

.yf-game-snake .yf-header-controls {
    display: flex;
    gap: 8px;
}

.yf-game-snake .yf-icon-btn {
    background: #1e2436;
    border: 1px solid #333d59;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.yf-game-yousnake .yf-icon-btn:hover,
.yf-game-snake .yf-icon-btn:hover,
.yf-game-snake .yf-icon-btn:active {
    background: #2b354f;
    border-color: #10b981;
}

.yf-game-snake .yf-game-layout {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: stretch;
}

/* SCHERMO PERFETTAMENTE QUADRATO SENZA ANGOLI ARROTONDATI (1:1 PIXEL PERFECT) */
.yf-game-snake .yf-canvas-wrapper {
    position: relative;
    box-sizing: content-box !important; /* Non mangia lo spazio interno del canvas */
    width: 240px;
    height: 240px;
    border: 2px solid #2a3147;
    border-radius: 0 !important; /* Squadrato netto come richiesto */
    overflow: hidden;
    background: #090c10;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    touch-action: none;
    flex-shrink: 0;
}

#yf-yousnake-canvas,
#yf-snake-canvas {
    display: block;
    width: 240px;
    height: 240px;
    border-radius: 0 !important; /* Squadrato netto */
    touch-action: none;
}

.yf-game-snake .yf-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 18, 0.94);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 14px;
    z-index: 10;
    border-radius: 0 !important; /* Squadrato netto */
}

.yf-game-snake .yf-overlay.yf-show {
    display: flex;
}

.yf-game-snake .yf-overlay h2 {
    margin: 0 0 6px;
    font-size: 20px;
    letter-spacing: 2px;
    color: #10b981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.yf-game-snake .yf-overlay p {
    font-size: 12px;
    color: #cbd5e1;
    margin: 0 0 14px;
    line-height: 1.4;
}

.yf-game-snake .yf-arcade-btn {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transition: all 0.15s ease;
    letter-spacing: 1px;
    touch-action: manipulation;
}

.yf-game-snake .yf-game-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
    flex: 1;
    min-width: 70px;
}

.yf-game-snake .yf-stat-box {
    background: #1a1e2d;
    border: 1px solid #2c344d;
    border-radius: 8px;
    padding: 5px 3px;
    text-align: center;
}

.yf-game-snake .yf-stat-label {
    display: block;
    font-size: 9px;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.yf-game-snake .yf-stat-value {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: #10b981;
    font-family: monospace, monospace;
}

/* ============================================================== */
/* CONTROLLER GAME BOY RETRÒ XL PER SNAKE                         */
/* ============================================================== */
.yf-game-snake .yf-gamepad-controls {
    margin-top: 12px;
    background: #090c14;
    border: 2px solid #222b40;
    border-radius: 18px;
    padding: 12px 10px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.7);
    touch-action: manipulation;
}

.yf-game-snake .yf-gamepad-label {
    display: block;
    text-align: center;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: #475569;
    font-weight: 800;
    margin-top: 6px;
}

.yf-game-snake .yf-dpad-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.yf-game-snake .yf-dpad {
    display: grid;
    grid-template-columns: 54px 54px 54px;
    grid-template-rows: 54px 54px 54px;
    gap: 0;
    background: #181e2e;
    padding: 3px;
    border-radius: 14px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.yf-game-snake .yf-dpad-empty {
    width: 54px;
    height: 54px;
}

.yf-game-snake .yf-dpad-center {
    width: 54px;
    height: 54px;
    background: #20273a;
    border: 1px solid #2d3752;
}

.yf-game-snake .yf-dpad-btn {
    width: 54px;
    height: 54px;
    background: linear-gradient(145deg, #2b354d, #1e2537);
    border: 1px solid #3d4a6c;
    color: #e2e8f0;
    font-size: 20px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.05s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.yf-game-snake .yf-dpad-up { border-radius: 12px 12px 0 0; border-bottom: none; }
.yf-game-snake .yf-dpad-left { border-radius: 12px 0 0 12px; border-right: none; }
.yf-game-snake .yf-dpad-right { border-radius: 0 12px 12px 0; border-left: none; }
.yf-game-snake .yf-dpad-down { border-radius: 0 0 12px 12px; border-top: none; }

.yf-game-yousnake .yf-dpad-btn:active,
.yf-game-snake .yf-dpad-btn:active,
.yf-game-snake .yf-dpad-btn.yf-btn-pressed {
    background: #10b981 !important;
    color: #042f2e !important;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6) !important;
    transform: scale(0.96);
    border-color: #10b981;
}

.yf-game-snake .yf-action-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.yf-game-snake .yf-action-buttons {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 4px;
    min-height: 100px;
}

.yf-game-snake .yf-action-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Stagger Game Boy: B (sinistra) più in basso, A (destra) più in alto */
.yf-game-snake .yf-action-slot:first-child,
.yf-game-snake .yf-action-slot.yf-slot-b {
    transform: translateY(16px);
}

.yf-game-snake .yf-action-slot:last-child,
.yf-game-snake .yf-action-slot.yf-slot-a {
    transform: translateY(-16px);
}

.yf-game-snake .yf-round-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.05s ease;
}

.yf-game-snake .yf-btn-snake-pause {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 6px 0 #92400e, 0 8px 16px rgba(245, 158, 11, 0.4);
}

.yf-game-snake .yf-btn-snake-pause:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #92400e;
}

.yf-game-snake .yf-btn-snake-start {
    background: linear-gradient(145deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 6px 0 #047857, 0 8px 16px rgba(16, 185, 129, 0.4);
}

.yf-game-snake .yf-btn-snake-start:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #047857;
}

.yf-game-snake .yf-btn-name {
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
}

.yf-game-snake .yf-btn-sub {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 1px;
    opacity: 0.95;
    margin-top: 2px;
}

@media (max-width: 370px) {
    .yf-game-snake {
        padding: 8px 6px;
    }
    .yf-canvas-wrapper,
    #yf-yousnake-canvas,
    #yf-snake-canvas {
        width: 210px !important;
        height: 210px !important;
    }
    .yf-dpad {
        grid-template-columns: 48px 48px 48px;
        grid-template-rows: 48px 48px 48px;
    }
    .yf-dpad-empty,
    .yf-dpad-center,
    .yf-dpad-btn {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    .yf-round-btn {
        width: 56px;
        height: 56px;
    }
    .yf-game-snake .yf-action-slot:first-child,
    .yf-game-snake .yf-action-slot.yf-slot-b {
        transform: translateY(12px);
    }
    .yf-game-snake .yf-action-slot:last-child,
    .yf-game-snake .yf-action-slot.yf-slot-a {
        transform: translateY(-12px);
    }
}
