/* =========================================================================
 * Kickoff Tactical — Responsive Katmanı (telefon & tablet)
 *
 * style.css'ten SONRA yüklenir ve oradaki birbirini ezen mobil kurallarını
 * tek bir yerden geçersiz kılar. Masaüstü (≥1181px veya yatay ≥769px) düzenine
 * dokunmaz; yalnızca aşağıdaki aralıklarda devreye girer:
 *
 *   TELEFON  : (max-width: 699px)
 *   TABLET-D : (min-width: 700px) and (max-width: 1180px) and (orientation: portrait)
 *   KOMPAKT  : TELEFON + TABLET-D (kompakt kadro satırları, tam ekran formlar)
 * ========================================================================= */

/* ---------- iPhone ana ekran uygulaması (PWA): çentik / Dynamic Island güvenli alanı ----------
 * index.html'de viewport-fit=cover + black-translucent durum çubuğu kullanıldığı için içerik
 * ekranın en üstünden başlıyordu; üst bar (Yönetici girişi butonu) durum çubuğunun altında
 * kalıp tıklanamıyordu. Üst bar güvenli alanın altına itilir ve durum çubuğunun arkası
 * düz renkle kapatılır (içerik altından kayarken bulanık görünmesin).
 */
.navbar {
    margin-top: env(safe-area-inset-top, 0px) !important;
}
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    background: #060d09;
    z-index: 1200;
    pointer-events: none;
}
#offline-banner {
    top: env(safe-area-inset-top, 0px) !important;
}

/* ---------- Her boyutta: modallar alt gezinme çubuğunun (z-index 1000) üstünde ---------- */
.modal {
    z-index: 1100 !important;
}
#custom-dialog-overlay {
    z-index: 1300 !important;
}
#toast-container {
    z-index: 1400 !important;
}

/* Kadro başlığındaki "Oyuncu Ekle" etiketi */
#add-player-btn .btn-label {
    margin-left: 6px;
    font-weight: 700;
}

/* Saha altı şeridinde mevki filtreleri */
.mbs-pos-filters {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.mbs-pos-filters::-webkit-scrollbar {
    display: none;
}
.mbs-pos-btn {
    flex: 0 0 auto;
    border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-2, #cbd5e1);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    min-height: 30px !important;
    min-width: 0 !important;
}
.mbs-pos-btn.active {
    background: rgba(52, 211, 153, 0.16);
    border-color: rgba(52, 211, 153, 0.5);
    color: #34d399;
}

/* Masaüstünde (geniş ekran) gizli kalacak mobil-öğeler */
@media (min-width: 1181px), (min-width: 769px) and (orientation: landscape) and (min-height: 551px) {
    .mbs-pos-filters {
        display: none !important;
    }
}

/* ---------- Dar masaüstü / tablet yatay: üst araç çubuğu taşmasın ---------- */
@media (min-width: 769px) and (max-width: 1440px) and (orientation: landscape) {
    #tactics-workspace .fm-top-row-main {
        flex-wrap: wrap !important;
        row-gap: 8px !important;
        max-width: 100% !important;
    }
    #tactics-workspace .pitch-kpi-pills {
        flex-wrap: wrap !important;
        max-width: 100% !important;
    }
    #tactics-workspace .draw-group {
        flex-wrap: wrap !important;
        max-width: 100% !important;
    }
}

/* =========================================================================
 * KOMPAKT (telefon + tablet dikey)
 * ========================================================================= */
@media (max-width: 699px), (min-width: 700px) and (max-width: 1180px) and (orientation: portrait) {

    /* --- Kompakt tek satırlık kadro listesi --- */
    #tactics-workspace .squad-table .st-header {
        display: none !important;
    }
    #tactics-workspace .squad-table {
        display: block !important;
        overflow-x: hidden !important;
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
    }
    #squad-table-body {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        min-width: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    #squad-table-body .squad-row {
        display: grid !important;
        grid-template-columns: 24px 42px minmax(0, 1fr) 78px 36px !important;
        grid-template-rows: auto !important;
        column-gap: 6px !important;
        row-gap: 0 !important;
        align-items: center !important;
        min-height: 52px !important;
        padding: 6px 8px !important;
        margin: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
        background: rgba(12, 22, 17, 0.72) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        box-shadow: none !important;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    #squad-table-body .squad-row > div {
        grid-row: 1 !important;
        display: flex !important;
        align-items: center !important;
        min-width: 0 !important;
        border: none !important;
        padding: 0 !important;
    }
    #squad-table-body .squad-row > div:nth-child(1) {
        grid-column: 1 !important;
        justify-content: center !important;
        font-family: 'JetBrains Mono', monospace !important;
        font-weight: 800 !important;
        font-size: 12px !important;
        color: var(--text-3, #94a3b8) !important;
        background: transparent !important;
        height: auto !important;
    }
    #squad-table-body .squad-row > div:nth-child(2) {
        grid-column: 2 !important;
        justify-content: center !important;
    }
    #squad-table-body .squad-row > div.r-name {
        grid-column: 3 !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 2px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        overflow: hidden !important;
    }
    #squad-table-body .squad-row > div.r-name > span:first-child {
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    #squad-table-body .squad-row > div.r-name .r-icons {
        display: flex !important;
        gap: 3px !important;
        transform: scale(0.88);
        transform-origin: left center;
    }
    #squad-table-body .squad-row > div.r-sec {
        display: none !important;
    }
    #squad-table-body .squad-row .r-sec-inline {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 3px !important;
    }
    #squad-table-body .squad-row > div.r-ovr {
        grid-column: 4 !important;
        justify-content: center !important;
        height: 30px !important;
        font-family: 'JetBrains Mono', monospace !important;
        font-size: 15px !important;
        font-weight: 800 !important;
        background: rgba(245, 176, 65, 0.1) !important;
        border: 1px solid rgba(245, 176, 65, 0.26) !important;
        border-radius: 8px !important;
    }
    #squad-table-body .squad-row > div.toggle-att {
        grid-column: 4 !important;
        justify-content: center !important;
        height: 38px !important;
    }
    #squad-table-body .squad-row > div.r-edit {
        grid-column: 5 !important;
        justify-content: center !important;
        height: 38px !important;
        min-width: 0 !important;
        border-radius: 8px !important;
        background: rgba(52, 211, 153, 0.08) !important;
        position: static !important;
    }

    body.readonly-mode #squad-table-body .squad-row {
        grid-template-columns: 24px 42px minmax(0, 1fr) 78px !important;
    }
    body.readonly-mode #squad-table-body .squad-row > div.r-edit {
        display: none !important;
    }
    #squad-table-body .squad-row.on-pitch {
        border-left: 3px solid var(--gold, #f5b041) !important;
        background: linear-gradient(90deg, rgba(245, 176, 65, 0.1) 0%, rgba(12, 22, 17, 0.75) 60%) !important;
    }
    #squad-table-body .squad-row.selected-row {
        border-color: #34d399 !important;
        box-shadow: 0 0 0 1px #34d399 !important;
    }
    #squad-table-body .squad-row.absent {
        opacity: 0.55 !important;
    }

    /* --- Kadro başlığı: büyük "Oyuncu Ekle", geri planda "Sıfırla" --- */
    #tactics-workspace .squad-header {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }
    #tactics-workspace .squad-header .s-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 8px !important;
        margin-left: auto !important;
    }
    #add-player-btn {
        order: 3;
        background: var(--gold, #f5b041) !important;
        color: #080c0a !important;
        border-color: transparent !important;
        padding: 0 14px !important;
        min-height: 40px !important;
        border-radius: 10px !important;
    }
    #reset-default-btn {
        order: 2;
        opacity: 0.75;
        min-height: 40px !important;
    }

    /* --- Oyuncu formu: tam ekran, tek elle kullanılabilir --- */
    #player-modal.show {
        align-items: stretch !important;
        justify-content: stretch !important;
    }
    #player-modal .modal-content {
        width: 100% !important;
        max-width: 640px !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 auto !important;
        border-radius: 0 !important;
        padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }
    #player-modal .close-modal {
        position: sticky !important;
        top: 0 !important;
        float: right !important;
        z-index: 3 !important;
        font-size: 30px !important;
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #player-modal h2 {
        font-size: 20px !important;
        margin: 6px 0 14px !important;
    }
    #player-modal .form-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }
    #player-modal .form-group {
        min-width: 0 !important;
    }
    #player-modal input,
    #player-modal select {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        min-height: 44px !important;
        font-size: 16px !important; /* iOS'ta odaklanınca sayfanın yakınlaşmasını engeller */
    }
    #player-modal .sec-pos-cb {
        width: 18px !important;
        min-height: 18px !important;
    }
    #player-modal .sec-pos-grid {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 6px !important;
    }
    #player-modal .sec-pos-grid label {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        min-height: 40px !important;
        padding: 0 8px !important;
        border-radius: 8px !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        background: rgba(255, 255, 255, 0.03) !important;
        font-size: 13px !important;
    }
    #player-modal .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    #player-modal .form-actions {
        position: sticky !important;
        bottom: 0 !important;
        display: flex !important;
        gap: 10px !important;
        margin: 18px -16px 0 !important;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
        background: rgba(10, 16, 13, 0.97) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        z-index: 3 !important;
    }
    #player-modal .form-actions button {
        min-height: 48px !important;
        font-size: 15px !important;
    }
    #player-modal .form-actions .btn-success {
        flex: 1 !important;
    }
}

/* =========================================================================
 * TELEFON
 * ========================================================================= */
@media (max-width: 699px) {

    /* --- Saha sekmesi: kompakt üst bar --- */
    #tactics-workspace .middle-panel {
        padding: 10px !important;
        gap: 8px !important;
        min-width: 0 !important;
        overflow: visible !important;
    }
    #tactics-workspace .fm-top-bar {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    #tactics-workspace .fm-top-row-main {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
    #tactics-workspace .plans-group {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 4px !important;
        width: 100% !important;
        padding: 3px !important;
    }
    #tactics-workspace .plan-btn {
        min-height: 38px !important;
        min-width: 0 !important;
        padding: 0 !important;
        font-size: 13px !important;
    }
    #tactics-workspace .select-group {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
        margin: 0 !important;
    }
    #tactics-workspace .select-group select {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 40px !important;
        font-size: 15px !important;
    }
    /* KPI rozetleri telefonda Analiz sekmesinde; saha + kadro aynı ekrana sığsın */
    #tactics-workspace .pitch-kpi-pills {
        display: none !important;
    }
    #tactics-workspace .kpi-pill {
        text-align: center !important;
        font-size: 10px !important;
        padding: 4px 2px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    #tactics-workspace .draw-group {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        gap: 6px !important;
        width: 100% !important;
        overflow-x: auto !important;
        scrollbar-width: none;
        margin: 0 !important;
    }
    #tactics-workspace .draw-group::-webkit-scrollbar {
        display: none;
    }
    #tactics-workspace .draw-group .toolbar-btn {
        flex: 0 0 auto !important;
        min-height: 40px !important;
        min-width: 40px !important;
        padding: 0 10px !important;
    }
    /* Çizim rengi/temizleme yalnızca çizim modundayken; saha yönü telefonda gereksiz */
    #tactics-workspace #draw-color,
    #tactics-workspace #draw-clear-btn,
    #tactics-workspace #toggle-pitch-btn {
        display: none !important;
    }
    body.drawing-mode #tactics-workspace #draw-color,
    body.drawing-mode #tactics-workspace #draw-clear-btn {
        display: inline-flex !important;
    }
    #tactics-workspace .am-badge {
        font-size: 11px !important;
        padding: 4px 10px !important;
        min-height: 0 !important;
    }
    #tactics-workspace .plans-group .plan-btn,
    #tactics-workspace .select-group select,
    #tactics-workspace .draw-group .toolbar-btn {
        min-height: 38px !important;
    }

    /* --- Saha: ekranın yaklaşık yarısı, altında kadro görünsün --- */
    #tactics-workspace .pitch-container {
        height: auto !important;
        padding: 0 !important;
        flex: 0 0 auto !important;
        min-height: 0 !important;
    }
    #tactics-workspace #pitch {
        flex: 0 0 auto !important;
        height: min(46dvh, calc((100vw - 32px) / 0.74)) !important;
        max-height: none !important;
        width: auto !important;
        max-width: 100% !important;
        aspect-ratio: 0.74 !important;
        margin: 0 auto !important;
    }

    /* --- Saha altı kadro paneli: 2 sütunlu, kaydırılabilir oyuncu listesi --- */
    #tactics-workspace #mobile-bench-strip {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 10px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        border-radius: 14px !important;
        background: rgba(0, 0, 0, 0.22) !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
    }
    #tactics-workspace .mbs-header {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 6px !important;
    }
    #tactics-workspace .mbs-hint {
        flex: 1 1 100% !important;
        font-size: 11.5px !important;
        line-height: 1.35 !important;
        white-space: normal !important;
    }
    #tactics-workspace .mbs-filters .mbs-filter-btn {
        min-height: 30px !important;
        min-width: 0 !important;
        padding: 4px 12px !important;
        font-size: 11px !important;
    }
    #tactics-workspace .mbs-pos-filters {
        display: flex !important;
    }
    #tactics-workspace #mobile-bench-list {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
        max-height: max(180px, calc(54dvh - 150px)) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        flex-wrap: initial !important;
        padding: 0 !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    #tactics-workspace #mobile-bench-list .mbs-chip {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 44px !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        padding: 6px 8px !important;
        box-sizing: border-box !important;
    }
    #tactics-workspace #mobile-bench-list .mbs-chip-name {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        text-align: left !important;
    }
    #tactics-workspace #mobile-bench-list .mbs-chip-pos {
        flex: 0 0 auto !important;
        font-size: 9.5px !important;
    }
    #tactics-workspace #mobile-bench-list .mbs-chip-tag {
        display: none !important;
    }
    #tactics-workspace #mobile-bench-list .mbs-empty {
        grid-column: 1 / -1 !important;
    }

    /* --- Kadro sekmesi --- */
    #tactics-workspace.mb-show-pool .squad-zone {
        padding: 10px 8px 16px !important;
    }
    #squad-table-body .squad-row > div:nth-child(2) .pos-badge {
        font-size: 10px !important;
        padding: 2px 4px !important;
    }
    #tactics-workspace .squad-header h4 {
        font-size: 16px !important;
    }
}

/* =========================================================================
 * TABLET DİKEY: saha ve kadro yan yana
 * ========================================================================= */
@media (min-width: 700px) and (max-width: 1180px) and (orientation: portrait) {
    html, body {
        overflow-x: hidden !important;
    }
    .navbar .nav-tabs {
        display: none !important; /* Navigasyonu alt bar üstlenir */
    }
    #mobile-bottom-bar.mobile-bottom-bar {
        display: flex !important;
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 1000 !important;
        justify-content: space-around !important;
        padding-top: 8px !important;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important;
        background: rgba(12, 22, 17, 0.95) !important;
        backdrop-filter: blur(16px) !important;
        -webkit-backdrop-filter: blur(16px) !important;
        border-top: 1px solid var(--line, rgba(255, 255, 255, 0.08)) !important;
        box-sizing: border-box !important;
    }
    #mobile-bottom-bar .mb-nav-btn {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        min-height: 50px !important;
        background: transparent !important;
        border: none !important;
        color: var(--text-3, #94a3b8) !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        cursor: pointer;
    }
    #mobile-bottom-bar .mb-nav-btn.active {
        color: var(--gold, #f5b041) !important;
    }

    #tactics-workspace.dashboard-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) !important;
        grid-template-rows: auto !important;
        align-items: start !important;
        gap: 12px !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box !important;
    }
    #tactics-workspace .tactics-zone {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        min-width: 0 !important;
        width: auto !important;
        height: auto !important;
        grid-column: 1 !important;
    }
    #tactics-workspace .left-panel {
        display: none !important;
    }
    #tactics-workspace .middle-panel {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: auto !important;
        min-width: 0 !important;
        height: auto !important;
        padding: 12px !important;
        overflow: visible !important;
    }
    #tactics-workspace .fm-top-bar {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 0 !important;
    }
    #tactics-workspace .fm-top-row-main {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        min-width: 0 !important;
    }
    #tactics-workspace .pitch-kpi-pills {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        width: 100% !important;
    }
    #tactics-workspace .draw-group {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    #tactics-workspace .pitch-container {
        height: auto !important;
        padding: 0 !important;
        flex: 0 0 auto !important;
    }
    #tactics-workspace #pitch {
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        aspect-ratio: 0.74 !important;
        margin: 0 auto !important;
    }
    /* Kadro sağda göründüğü için saha altı şerit gereksiz */
    #tactics-workspace #mobile-bench-strip {
        display: none !important;
    }
    #tactics-workspace .squad-zone {
        display: flex !important;
        flex-direction: column !important;
        grid-column: 2 !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        height: calc(100dvh - 160px) !important;
        max-height: calc(100dvh - 160px) !important;
        position: sticky !important;
        top: 12px !important;
        padding: 12px !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }
    #tactics-workspace .squad-zone .squad-table {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }
    #tactics-workspace .squad-filter-bar {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        gap: 8px !important;
    }
    #tactics-workspace .squad-search-input {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
    #tactics-workspace .squad-sort-group {
        display: flex !important;
        gap: 6px !important;
        min-width: 0 !important;
    }
    #tactics-workspace .squad-sort-group select {
        flex: 1 !important;
        min-width: 0 !important;
    }

    /* Kadro sekmesi: kadro tam genişlik */
    #tactics-workspace.mb-show-pool.dashboard-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    #tactics-workspace.mb-show-pool .tactics-zone {
        display: none !important;
    }
    #tactics-workspace.mb-show-pool .squad-zone {
        grid-column: 1 !important;
        position: static !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Talimat / Analiz sekmesi: sol panel tam genişlik */
    #tactics-workspace.mb-show-panel.dashboard-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    #tactics-workspace.mb-show-panel .middle-panel,
    #tactics-workspace.mb-show-panel .squad-zone {
        display: none !important;
    }
    #tactics-workspace.mb-show-panel .left-panel {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    #tactics-workspace.mb-show-panel .panel-content.active {
        display: flex !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Maç merkezi alt barın altında kalmasın */
    #match-center-workspace {
        padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* =========================================================================
 * Mevki oyuncu seçici (boş/dolu mevkiye dokununca açılan alt sayfa)
 * JS'in ürettiği işaretlemeye (msp-item-top, msp-item-stats...) uygun stiller;
 * style.css'teki eski msp-* kuralları bu işaretlemeyle eşleşmiyordu.
 * ========================================================================= */
#mobile-slot-picker .msp-sheet {
    max-height: 86dvh;
    overflow: hidden;
}
#mobile-slot-picker .msp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
#mobile-slot-picker .msp-title {
    margin: 0 0 4px;
    font-size: 17px;
}
#mobile-slot-picker .msp-subtitle {
    margin: 0;
    font-size: 12px;
    color: var(--text-3, #94a3b8);
    line-height: 1.4;
}
#mobile-slot-picker .msp-close-btn {
    flex: 0 0 auto;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
    background: rgba(255, 255, 255, 0.05);
    color: var(--text, #e2e8f0);
    cursor: pointer;
    padding: 0 !important;
}
#mobile-slot-picker .msp-current-box {
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(245, 176, 65, 0.08);
    border: 1px solid rgba(245, 176, 65, 0.28);
}
#mobile-slot-picker .msp-cur-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
#mobile-slot-picker .msp-cur-info strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#mobile-slot-picker .msp-cur-sub {
    font-size: 11px;
    color: var(--text-3, #94a3b8);
}
#mobile-slot-picker .msp-cur-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}
#mobile-slot-picker .msp-cur-actions .sm-btn {
    min-height: 38px !important;
    min-width: 0 !important;
    padding: 0 10px !important;
    font-size: 12px;
}
#mobile-slot-picker .msp-search-row input {
    width: 100%;
    box-sizing: border-box;
    min-height: 42px;
    font-size: 16px;
}
#mobile-slot-picker .msp-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 4px;
    min-height: 0;
    flex: 1 1 auto;
}
#mobile-slot-picker .msp-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#mobile-slot-picker .msp-item:active {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.4);
}
#mobile-slot-picker .msp-item.absent {
    opacity: 0.5;
}
#mobile-slot-picker .msp-item-top {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
}
#mobile-slot-picker .msp-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-3, #94a3b8);
}
#mobile-slot-picker .msp-name-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
#mobile-slot-picker .msp-name {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#mobile-slot-picker .msp-sec {
    font-size: 10.5px;
    color: var(--text-3, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#mobile-slot-picker .msp-pitch-badge,
#mobile-slot-picker .msp-bench-badge {
    display: inline;
    margin-right: 4px;
    font-weight: 700;
}
#mobile-slot-picker .msp-pitch-badge { color: #f5b041; }
#mobile-slot-picker .msp-bench-badge { color: var(--text-3, #94a3b8); }
#mobile-slot-picker .msp-suit-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
}
#mobile-slot-picker .msp-suit-badge.suit-green { color: #34d399; background: rgba(52, 211, 153, 0.14); }
#mobile-slot-picker .msp-suit-badge.suit-yellow { color: #f5b041; background: rgba(245, 176, 65, 0.14); }
#mobile-slot-picker .msp-suit-badge.suit-red { color: #f87171; background: rgba(248, 113, 113, 0.14); }
#mobile-slot-picker .msp-ovr {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 800;
    min-width: 26px;
    text-align: right;
}
#mobile-slot-picker .msp-item-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    font-size: 10px;
    color: var(--text-3, #94a3b8);
    text-align: center;
}
#mobile-slot-picker .msp-item-stats span {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 3px 0;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
}
#mobile-slot-picker .msp-item-stats b {
    font-size: 12px;
    color: var(--text, #e2e8f0);
}


/* =========================================================================
 * Sade oyuncu modeli (isim + mevkiler) — tüm boyutlar
 * ========================================================================= */

/* Masaüstü kadro tablosu: NO · MEV · İSİM · YAN MEVKİLER · YOKLAMA · DÜZENLE */
@media (min-width: 1181px), (min-width: 769px) and (orientation: landscape) and (min-height: 551px) {
    #tactics-workspace .squad-table .st-header,
    #squad-table-body .squad-row {
        grid-template-columns: 34px 52px minmax(120px, 1.3fr) minmax(90px, 1fr) 88px 56px !important;
        min-width: 0 !important;
    }
    /* Eski 14 sütunlu tablo için konan genişlik zorlamalarını kaldır */
    #squad-table-body,
    #tactics-workspace .squad-table .st-header {
        min-width: 0 !important;
        width: 100% !important;
    }
    #squad-table-body .squad-row > div.r-edit {
        position: static !important;
    }
}
#squad-table-body .squad-row > div {
    min-width: 0;
}
#squad-table-body .squad-row .r-num {
    color: var(--text-muted, #94a3b8);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}
#squad-table-body .squad-row .r-name {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    overflow: hidden;
}
#squad-table-body .squad-row .r-name-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
}
#squad-table-body .squad-row .r-sec-inline {
    display: none;
}
#squad-table-body .squad-row .r-sec {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: flex-start;
}
#squad-table-body .r-muted {
    color: var(--text-muted, #64748b);
}
#squad-table-body .pos-badge-sec {
    font-size: 10px;
    padding: 1px 5px;
}

/* Oyuncu formu: mevki çip seçici */
.pos-field label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.pos-field-hint {
    font-weight: 500;
    font-size: 11px;
    color: var(--text-3, #94a3b8);
}
.pos-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.pos-picker-row {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}
.pos-picker-row-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text-3, #94a3b8);
    text-transform: uppercase;
}
.pos-picker-chips {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}
.pos-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 46px !important;
    min-width: 0 !important;
    padding: 4px 2px !important;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text, #e2e8f0);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.pos-chip b {
    font-size: 13px;
    font-weight: 800;
}
.pos-chip small {
    font-size: 9px;
    color: var(--text-3, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.pos-chip:active {
    transform: scale(0.97);
}
.pos-chip.active {
    background: rgba(52, 211, 153, 0.18);
    border-color: #34d399;
    box-shadow: 0 0 0 1px #34d399 inset;
}
.pos-chip.active small {
    color: #a7f3d0;
}
#p-position-picker .pos-chip.active {
    background: rgba(245, 176, 65, 0.2);
    border-color: #f5b041;
    box-shadow: 0 0 0 1px #f5b041 inset;
}
#p-position-picker .pos-chip.active small {
    color: #fde68a;
}
.pos-chip:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Rol açıklaması ve talimat ipuçları */
.role-desc {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-2, #cbd5e1);
    min-height: 36px;
}
.inst-hint {
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.35;
    color: var(--text-3, #94a3b8);
}

/* Mobil oyuncu kartı: mevkiler */
.mps-positions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.mps-pos {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 14px;
}
.mps-pos-main {
    border-color: rgba(245, 176, 65, 0.4);
    background: rgba(245, 176, 65, 0.08);
    font-weight: 700;
}
.mps-pos small {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-3, #94a3b8);
    font-weight: 600;
}
.mps-pos-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 4px;
}

/* Eski 14 sütunlu mobil kart düzeninden kalan "Yan:" etiketi artık yoklama hücresine denk geliyor */
#squad-table-body .squad-row > div::before {
    content: none !important;
}
@media (max-width: 699px), (min-width: 700px) and (max-width: 1180px) and (orientation: portrait) {
    #player-modal .modal-content {
        background: rgba(10, 16, 13, 0.97) !important;
    }
}

/* Bildirimler: güvenli alanın altında ve dar ekranda taşmadan */
#toast-container {
    top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    max-width: min(420px, calc(100vw - 24px)) !important;
}
#toast-container .custom-toast {
    white-space: normal !important;
    overflow-wrap: anywhere;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
@media (max-width: 699px) {
    #toast-container {
        left: 12px !important;
        right: 12px !important;
        max-width: none !important;
    }
    #toast-container .custom-toast {
        font-size: 13px !important;
        padding: 10px 14px !important;
    }
}


/* =========================================================================
 * Tek dokunuşla yoklama butonu (kadro listesi) ve oyuncu kartındaki seçim
 * ========================================================================= */
#squad-table-body .squad-row > div.toggle-att {
    justify-content: center !important;
}
.att-pill {
    width: 100%;
    max-width: 84px;
    min-height: 32px !important;
    min-width: 0 !important;
    padding: 0 6px !important;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.2px;
    border: 1px solid transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    transition: background-color 0.12s ease, transform 0.08s ease;
}
.att-pill:active {
    transform: scale(0.95);
}
.att-pill.att-yes,
.mps-att-btn.att-yes.active {
    color: #34d399;
    background: rgba(52, 211, 153, 0.14);
    border-color: rgba(52, 211, 153, 0.45);
}
.att-pill.att-no,
.mps-att-btn.att-no.active {
    color: #f87171;
    background: rgba(248, 113, 113, 0.14);
    border-color: rgba(248, 113, 113, 0.45);
}
.att-pill.att-unsure,
.mps-att-btn.att-unsure.active {
    color: #f5b041;
    background: rgba(245, 176, 65, 0.14);
    border-color: rgba(245, 176, 65, 0.45);
}
body.readonly-mode .att-pill {
    cursor: default;
}
.mps-att-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
    text-align: left;
}
.mps-att-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}
.mps-att-btn {
    min-height: 42px !important;
    min-width: 0 !important;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-2, #cbd5e1);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    touch-action: manipulation;
}
.mps-att-btn:disabled {
    cursor: default;
    opacity: 0.7;
}
.mps-att-btn:disabled.active {
    opacity: 1;
}
.mps-cap {
    margin-top: 10px;
    font-weight: 700;
    color: var(--gold, #f5b041);
}
