/* ==========================================================
   MOBILE RESPONSIVE — Telefon ve tablet uyumu
   ========================================================== */

/* --- Telefon (portrait & landscape, max 768px) --- */
@media (max-width: 768px) {
    /* Body: mobil 100vh fix (adres cubugu sorunu) */
    body { height: 100dvh; }
    .screen { height: 100dvh; }
    #duel { height: 100dvh; }

    /* --- AUTH EKRANI --- */
    #auth-screen { padding: 20px; }
    #auth-screen h1 { font-size: 2rem; letter-spacing: 0.2em; }
    .auth-form { width: 100%; max-width: 100%; }
    .auth-form input { font-size: 1rem; padding: 12px 14px; }

    /* --- ANA SAYFA --- */
    #home-screen { padding: 16px; overflow-y: auto; justify-content: center; }
    .home-nav { flex-direction: column; gap: 12px; width: 100%; max-width: 100%; padding: 0 16px; }
    .home-card { padding: 18px 20px; flex-direction: row; gap: 16px; min-width: unset; width: 100%; height: auto; }
    .home-card-icon { font-size: 1.8rem; }
    img.home-card-icon { width: 72px; max-height: 56px; flex-shrink: 0; }
    .home-card-title { font-size: 0.95rem; }
    .home-card-desc { font-size: 0.72rem; text-align: left; padding: 0; }

    /* --- LOBI --- */
    .lobby-form { width: 90%; max-width: 100%; }
    .lobby-buttons { flex-direction: column; }
    .join-section { flex-direction: column; }
    #lobby h1 { font-size: 2rem; letter-spacing: 0.15em; }

    /* --- MACERALAR MENU --- */
    .adv-menu { padding: 20px 16px; }
    .adv-banner { padding: 16px 18px; gap: 14px; }

    /* Maceralar — tile hub */
    .adv-tagline { padding: 24px 16px 4px; }
    .adv-tagline-main { font-size: 1.3rem; letter-spacing: 0.08em; }
    .adv-tagline-sub { font-size: 0.72rem; letter-spacing: 1px; }
    .mode-grid, .secondary-grid { padding: 0 16px; gap: 14px; margin: 20px auto; grid-template-columns: 1fr; }
    .mode-tile { height: 210px; }
    .mode-tile.locked { height: 170px; }
    .tile-content { left: 20px; right: 20px; bottom: 18px; }
    .tile-name { font-size: 1.3rem; margin-bottom: 6px; }
    .tile-desc { font-size: 0.82rem; margin-bottom: 12px; }
    .tile-meta { font-size: 0.65rem; margin-bottom: 6px; }
    .adv-header-spacer { display: none; }
    .banner-name { font-size: 1rem; }

    /* --- ANTRENMAN (bot grid) --- */
    .adv-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 16px; }
    .adv-card { padding: 16px 10px; gap: 6px; }
    .adv-icon { font-size: 1.8rem; }
    .adv-name { font-size: 0.82rem; }
    .adv-subtitle { margin-top: 16px; font-size: 0.85rem; }

    /* --- DUELLO ADASI (harita) --- */
    .island-map-wrap { padding: 8px; }
    .stage { padding: 5px 8px; min-width: 72px; border-radius: 8px; }
    .stage-icon { font-size: 1.1rem; }
    .stage-label { font-size: 0.45rem; }
    .stage-name { font-size: 0.62rem; }
    .stage-reward { font-size: 0.5rem; }

    /* --- KOLEKSIYON --- */
    .coll-header { height: auto; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
    .coll-title { font-size: 1.1rem; }
    .coll-toolbar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
    .coll-search { flex: 1 1 100%; }
    .coll-filters { flex-wrap: wrap; }
    .coll-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
    .coll-deck-header { flex-wrap: wrap; gap: 4px; }
    .coll-deck-header input { font-size: 0.8rem; width: 100px; }
    #btn-duel-with-deck { font-size: 0.7rem; padding: 6px 10px; }
    .coll-slot-tab { font-size: 0.62rem; padding: 8px 2px; }
    .slot-active-badge { font-size: 0.42rem; padding: 1px 3px; }

    /* Koleksiyon mobil tab layout */
    .coll-mobile-tabs {
        display: flex; flex-shrink: 0;
        border-bottom: 1px solid var(--gold-border); background: var(--bg-hud);
    }
    .coll-mob-tab {
        flex: 1; padding: 10px 0; background: transparent; border: none;
        border-bottom: 2px solid transparent;
        color: var(--text-muted); font-family: inherit; font-size: 0.82rem;
        letter-spacing: 1px; cursor: pointer; transition: all 0.2s;
    }
    .coll-mob-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
    .coll-main { flex-direction: column; min-height: 0; overflow: hidden; flex: 1; }
    .coll-main .coll-grid-area { display: none; flex: 1; overflow-y: auto; }
    .coll-main .coll-sidebar { display: none; width: 100%; max-height: unset; border-left: none; border-top: none; flex: 1; overflow-y: auto; }
    .coll-main[data-active-tab="grid"] .coll-grid-area { display: block; }
    .coll-main[data-active-tab="deck"] .coll-sidebar { display: flex; }

    /* --- DUELLO HUD --- */
    .duel-hud { height: 42px; padding: 0 8px; gap: 4px; }
    .player-info { gap: 6px; }
    .p-emblem { width: 28px; height: 28px; font-size: 12px; }
    .player-name { font-size: 9px; letter-spacing: 1px; }
    .player-lp { font-size: 18px; letter-spacing: 1px; }
    .turn-info { padding: 0 10px; }
    #turn-counter { font-size: 14px; letter-spacing: 2px; }
    #phase-name { font-size: 8px; }
    .btn-surrender { font-size: 0.6rem; padding: 1px 5px; }

    /* --- DUELLO SAHA --- */
    .field { padding: 2px 2px; gap: 2px; }
    .field-row { gap: 1.2vw; }
    .card-slot { width: 16vw; height: 21.8vw; border-radius: 3px; }
    .card-slot::before, .card-slot::after { display: none; } /* Rune dekorasyonlari kaldir */
    .card-stats-bar .atk, .card-stats-bar .def { font-size: 1.6vw; padding: 0 2px; }
    .counter-badge { width: 3.5vw; height: 3.5vw; min-width: 14px; min-height: 14px; font-size: 1.6vw; border-width: 1px; }
    .status-strip { padding: 4px 8px; gap: 8px; }
    #status-text { font-size: 0.7rem; padding: 2px 10px; white-space: normal; text-align: center; }

    /* --- MEZARLIK ZONE MOBIL --- */
    .grave-zone { width: 10vw; height: 21.8vw; margin-left: 2vw; }
    .grave-icon { font-size: 3.5vw; }
    .grave-count { font-size: 2.5vw; }
    .grave-viewer-cards { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; }
    .grave-card-tile img { width: 60px; height: 87px; }
    .grave-card-name { font-size: 0.5rem; max-width: 60px; }

    /* --- DUELLO EL --- */
    .hand-area { padding: 0 4px 2px; }
    .hand-card { width: 13vw; height: 17.8vw; margin-left: -2vw; border-width: 1px; }
    .hand-card:first-child { margin-left: 0; }
    .hand-card:hover { transform: translateY(-2vw) scale(1.12) rotate(0deg) !important; }
    .hand-card .card-stats-bar .atk, .hand-card .card-stats-bar .def { font-size: 1.3vw; }

    /* --- FLOAT PANELLER — mobilde drawer ile degistir --- */
    .float-panel { display: none !important; }

    /* --- MOBIL DRAWER — log/efekt tab sistemi --- */
    .mobile-drawer {
        display: flex; flex-direction: column;
        background: var(--panel-bg); border-top: 1px solid var(--gold-border);
        max-height: 28vh; flex-shrink: 0; z-index: 30;
    }
    .drawer-tabs {
        display: flex; flex-shrink: 0;
        border-bottom: 1px solid rgba(180,140,60,0.08);
    }
    .drawer-tab {
        flex: 1; padding: 8px 0; background: transparent; border: none;
        border-bottom: 2px solid transparent;
        color: var(--text-muted); font-family: inherit; font-size: 0.75rem;
        letter-spacing: 1px; cursor: pointer; transition: all 0.2s;
    }
    .drawer-tab.active {
        color: var(--gold); border-bottom-color: var(--gold);
    }
    .drawer-body { flex: 1; overflow: hidden; min-height: 0; }
    .drawer-pane {
        display: none; height: 100%; overflow-y: auto;
        padding: 2px;
    }
    .drawer-pane.active { display: block; }
    .drawer-pane::-webkit-scrollbar { width: 3px; }
    .drawer-pane::-webkit-scrollbar-thumb { background: var(--gold-border); border-radius: 2px; }

    /* Drawer icindeki log/efekt bantlari mobil boyut */
    .drawer-pane .log-banner img { width: 32px; min-height: 40px; }
    .drawer-pane .log-banner .lb-text { font-size: 0.72rem; padding: 4px 8px; }
    .drawer-pane .effect-banner img { width: 60px; min-height: 72px; }
    .drawer-pane .effect-banner .eb-name { font-size: 0.85rem; }
    .drawer-pane .effect-banner .eb-desc { font-size: 0.7rem; }

    /* --- RAKIP EL (mobil boyutlari) --- */
    .opp-hand-area { padding: 0 4px; height: 5.5vw; }
    .opp-hand-card { width: 8vw; height: 11vw; margin-left: -1.5vw; }

    /* --- EL KARTLARI — trap zone ile overlap, yukari tasi --- */
    .hand-area { margin-top: -5vw; position: relative; z-index: 20; }

    /* --- MOTOR PANEL — akilli yukseklik bottom sheet --- */
    .motor-panel { width: 100%; min-width: unset; max-height: 50vh; height: auto; right: 0; bottom: 0;
        border-radius: 12px 12px 0 0; border-left: none; border-top: 2px solid rgba(232,200,64,0.15);
        transition: transform 0.3s ease; overflow: visible; }
    .motor-panel.minimized { transform: translateY(calc(100% - 44px)); }
    .mp-actions { max-height: calc(50vh - 120px); }
    .mp-swipe-handle { display: flex !important; align-items: center; justify-content: center;
        padding: 10px 0 6px; cursor: pointer; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
    .mp-handle-bar { width: 50px; height: 5px; background: rgba(232,200,64,0.4); border-radius: 3px; }
    .motor-panel.minimized .mp-handle-bar { background: rgba(232,200,64,0.7); }
    .motor-panel .mp-minimize-btn { display: block !important; position: absolute; top: 6px; right: 10px;
        background: none; border: none; color: var(--gold); font-size: 1.4rem; cursor: pointer; z-index: 5;
        padding: 4px 8px; opacity: 0.7; }
    .motor-panel .mp-minimize-btn:active { opacity: 1; }
    /* Kompakt kart tile'lari */
    .mp-action-card { min-height: unset; }
    .mp-card-img { width: 40px; }
    .mp-card-info-text { padding: 4px 8px 2px; }
    .mp-card-name { font-size: 10px; }
    .mp-card-stats { font-size: 9px; }
    .mp-card-location { font-size: 8px; }
    .mp-card-buttons { gap: 0; }
    .mp-btn { min-height: 36px; font-size: 10px; }
    .mp-group-header { font-size: 8px; padding: 4px 8px 2px; }
    .mp-footer-actions .mp-btn { min-height: 40px; font-size: 11px; }

    /* --- POPUP MENU (kart uzerindeki) --- */
    .card-popup { min-width: 100px; }
    .popup-btn { padding: 10px 14px; font-size: 12px; min-height: 44px; }

    /* --- TOUCH TARGET BOYUTLARI (min 44px) --- */
    .mp-footer-actions .mp-btn { min-height: 44px; }
    .drawer-tab { min-height: 44px; }
    .coll-mob-tab { min-height: 44px; }
    .coll-filter { min-height: 40px; padding: 8px 12px; }

    /* --- SONUC EKRANI --- */
    #result { padding: 32px 20px; text-align: center; }
    #result h2 { font-size: 2rem; }
    .reward-box { padding: 12px 16px; margin: 12px auto; max-width: 320px; }

    /* --- HOME sticky header --- */
    .home-header { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 16px 20px; }
    .home-header h1 { font-size: 1.4rem; letter-spacing: 0.2em; }

    /* --- LOBBY buton full-width --- */
    .lobby-buttons .btn { width: 100%; }
    .join-section .btn { width: 100%; }

    /* --- FOOTER mobil konum --- */
    .lobby-footer { position: static; padding: 20px 0; justify-content: center; }
}

/* --- Cok kucuk telefonlar (max 400px) --- */
@media (max-width: 400px) {
    .card-slot { width: 17vw; height: 23.2vw; }
    .hand-card { width: 14vw; height: 19.2vw; margin-left: -2.5vw; }
    .duel-hud { height: 38px; }
    .player-lp { font-size: 15px; }
    .p-emblem { width: 24px; height: 24px; font-size: 10px; }
    .stage { padding: 4px 6px; min-width: 60px; }
    .stage-name { font-size: 0.55rem; }
    .adv-grid { grid-template-columns: 1fr; gap: 8px; padding: 12px; }
    .adv-card { flex-direction: row; gap: 12px; padding: 12px 14px; }
}

/* --- Yatay telefon (landscape) --- */
@media (max-height: 500px) and (orientation: landscape) {
    /* HUD: ultra-kompakt */
    .duel-hud { height: 30px; padding: 0 8px; }
    .player-lp { font-size: 13px; }
    .player-name { font-size: 7px; }
    .p-emblem { display: none; }
    .turn-info { padding: 0 8px; }
    #turn-counter { font-size: 11px; }
    .btn-surrender { display: none; }

    /* Saha: vh birimleri (yukseklik kisitli) */
    .field { padding: 1px 8vw; gap: 1px; }
    .field-row { gap: 0.6vh; }
    .card-slot { width: 8vh; height: 11vh; }
    .card-stats-bar .atk, .card-stats-bar .def { font-size: max(7px, 0.8vh); }
    .hand-area { padding: 0 10vw 1px; margin-top: -2vh; }
    .hand-card { width: 7vh; height: 9.6vh; margin-left: -1vh; }
    .hand-card:hover { transform: translateY(-1.5vh) scale(1.1) rotate(0deg) !important; }
    .opp-hand-area { height: 4vh; padding: 0 10vw; }
    .opp-hand-card { width: 4.5vh; height: 6vh; margin-left: -0.8vh; }
    .grave-zone { width: 5vh; height: 11vh; margin-left: 1vh; }
    .grave-icon { font-size: 1.5vh; }
    .grave-count { font-size: 1.2vh; }
    .status-strip { padding: 1px 8vw; }
    #status-text { font-size: 0.55rem; padding: 1px 6px; }

    /* Motor panel: yandan gelen panel */
    .motor-panel {
        width: 40vw; max-width: 320px; max-height: 100%; height: 100%;
        right: 0; bottom: 0;
        border-radius: 0; border-left: 1px solid rgba(232,200,64,0.15); border-top: none;
        transition: transform 0.3s ease;
    }
    .motor-panel.minimized { transform: translateX(calc(100% - 36px)); }
    .mp-swipe-handle { display: none !important; }
    .mp-minimize-btn { display: block !important; }
    .mp-actions { max-height: calc(100vh - 120px); }

    /* Drawer: landscape'de yeterli yukseklik yok */
    .mobile-drawer { display: none !important; }

    /* Float paneller: genis ekranda log goster */
    .float-panel { display: none !important; }
    #log-panel { display: block !important; max-width: 12vw; left: 4px; top: 34px; max-height: calc(100vh - 40px); }
}
