/* ========================================
   RESPONSIVE CSS - Mobile & Tablet
   ======================================== */

/* MOBILE PORTRAIT */
@media (max-width: 1200px) and (orientation: portrait) {
    :root {
        --card-width: 65px;
        --card-height: 91px;
        --zoom-scale: 4.5;
    }
    
    #game-container {
        padding: 5px;
    }
    
    .card-slot, .deck-stack, .hand-card {
        width: var(--card-width);
        height: var(--card-height);
    }
    
    #tutor-slot {
        width: 91px;
        height: 65px;
    }
    
    #playfield {
        gap: 3px;
        max-height: calc(100vh - 100px);
    }
    
    #game-header {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    #turn-info {
        font-size: 14px;
    }
    
    #phase-indicator {
        font-size: 12px;
    }
    
    #hand-area {
        min-height: 110px;
        padding: 5px;
        padding-bottom: 10px;
        padding-top: 80px;
        overflow-y: visible !important;
    }

    #next-phase-btn {
        bottom: 180px;
        right: 10px;
        padding: 10px 20px;
        font-size: 12px;
    }

    #player-zone {
        grid-template-columns: 70px 1fr 70px;
    }
    
    .area-label {
        font-size: 10px;
        padding: 3px 10px;
    }
    
    .phase-title {
        font-size: 40px;
    }
    
    /* Setup screen mobile */
    #start-screen {
        padding: 10px;
        justify-content: flex-start;
    }
    
    .start-title {
        font-size: 28px;
        margin-bottom: 15px;
        margin-top: 30px;
    }
    
    .setup-rules {
        max-width: 95%;
        padding: 12px;
        margin-bottom: 15px;
        max-height: 45vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .setup-rules h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .setup-rules ol {
        font-size: 11px;
        line-height: 1.4;
    }
    
    .setup-rules li {
        margin-bottom: 8px;
    }
    
    #start-game-btn {
        padding: 10px 25px;
        font-size: 14px;
        margin-bottom: 40px;
        width: 80%;
        max-width: 250px;
    }

    /* Zoom touch su mobile */
    .hand-card.touched {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) scale(4.5) !important;
        z-index: 9999 !important;
        transition: transform 0.3s ease;
        border: 3px solid var(--color-primary);
        box-shadow: 0 20px 80px rgba(0, 0, 0, 0.95);
        margin: 0 !important;
    }

    .hand-card.touched::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.85);
        z-index: -1;
    }
    
    /* Adatta font carte mobile */
    .hand-card.touched .card-name {
        font-size: 16px;
    }
    
    .hand-card.touched .effect-text {
        font-size: 10px;
        line-height: 1.4;
    }
    
    .hand-card.touched .stat-value {
        font-size: 14px;
    }
}

/* MOBILE LANDSCAPE */
@media (max-width: 1200px) and (orientation: landscape) {
    :root {
        --card-width: 70px;
        --card-height: 98px;
    }
    
    .card-slot, .deck-stack, .hand-card {
        width: var(--card-width);
        height: var(--card-height);
    }
    
    #playfield {
        gap: 5px;
        max-height: calc(100vh - 120px);
    }
    
    #hand-area {
        min-height: 100px;
        padding: 5px;
        padding-top: 40px;
        overflow-y: visible !important;
    }
    
    #tutor-slot {
        width: 118px;
        height: 84px;
    }
    
    .phase-title {
        font-size: 50px;
    }
    
    #next-phase-btn {
        bottom: 120px;
        right: 20px;
        padding: 10px 25px;
        font-size: 14px;
    }

    #player-zone {
        grid-template-columns: 80px 1fr 80px;
    }
    
    /* Setup screen landscape */
    #start-screen {
        padding: 15px;
        justify-content: flex-start;
    }
    
    .start-title {
        font-size: 32px;
        margin-bottom: 20px;
        margin-top: 20px;
    }
    
    .setup-rules {
        max-width: 90%;
        padding: 15px;
        margin-bottom: 20px;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .setup-rules h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .setup-rules ol {
        font-size: 12px;
        line-height: 1.5;
    }
    
    .setup-rules li {
        margin-bottom: 10px;
    }
    
    #start-game-btn {
        padding: 12px 30px;
        font-size: 16px;
        margin-bottom: 30px;
    }
}

/* TABLET */
@media (min-width: 768px) and (max-width: 1024px) {
    :root {
        --card-width: 90px;
        --card-height: 126px;
    }
    
    #playfield {
        max-height: calc(100vh - 200px);
    }
    
    #player-zone {
        grid-template-columns: 100px 1fr 100px;
    }
    
    #tutor-slot {
        width: 145px;
        height: 103px;
    }
}

/* VERY SMALL SCREENS */
@media (max-width: 480px) and (orientation: portrait) {
    :root {
        --card-width: 55px;
        --card-height: 77px;
    }
    
    .card-slot, .deck-stack, .hand-card {
        width: var(--card-width);
        height: var(--card-height);
    }
    
    #tutor-slot {
        width: 77px;
        height: 55px;
    }
    
    #game-header {
        padding: 5px 10px;
    }
    
    #turn-info {
        font-size: 12px;
    }
    
    #phase-indicator {
        font-size: 10px;
    }
    
    .area-label {
        font-size: 8px;
        padding: 2px 8px;
    }
    
    #player-zone {
        grid-template-columns: 60px 1fr 60px;
        gap: 8px;
    }
    
    #next-phase-btn {
        bottom: 150px;
        right: 5px;
        padding: 8px 15px;
        font-size: 11px;
    }
    
    .phase-title {
        font-size: 32px;
    }
    
    #exit-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 10px;
        right: 10px;
    }
}

/* LANDSCAPE VERY SMALL */
@media (max-width: 667px) and (orientation: landscape) {
    :root {
        --card-width: 60px;
        --card-height: 84px;
    }
    
    #playfield {
        gap: 3px;
        max-height: calc(100vh - 100px);
    }
    
    #game-header {
        padding: 5px 10px;
        margin-bottom: 10px;
    }
    
    #hand-area {
        min-height: 90px;
        padding: 3px;
        padding-top: 30px;
    }
    
    #player-zone {
        grid-template-columns: 65px 1fr 65px;
        gap: 5px;
    }
}

/* HIGH DPI SCREENS */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card-border {
        /* Migliora rendering su schermi retina */
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* DARK MODE SUPPORT */
@media (prefers-color-scheme: dark) {
    /* Già in dark mode di default */
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* PRINT */
@media print {
    #exit-btn,
    #next-phase-btn,
    #start-screen {
        display: none !important;
    }
}
