/* ==========================================================================
   ODISYNC — JETPACK COMPOSE M3 NATIVE DESIGN SYSTEM (WEB & MOBILE ADAPTIVE)
   Sıfır tarayıcı varsayılan kontrolü, akıcı yay (spring) animasyonları,
   Masaüstü (NavigationRail) ve Mobil (BottomDock) için ayrı özel arayüz
   ========================================================================== */

:root {
    --bg-base: #070a12;
    --bg-surface: #0f1523;
    --bg-surface-2: #172033;
    --bg-surface-3: #212d45;
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-highlight: rgba(52, 211, 153, 0.42);

    --primary: #10b981;
    --primary-glow: rgba(16, 185, 129, 0.28);
    --primary-container: rgba(16, 185, 129, 0.15);

    --secondary: #38bdf8;
    --secondary-container: rgba(56, 189, 248, 0.15);

    --accent: #f59e0b;
    --accent-container: rgba(245, 158, 11, 0.15);

    --danger: #f43f5e;
    --danger-container: rgba(244, 63, 94, 0.15);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-2xl: 26px;
    --radius-xl: 20px;
    --radius-lg: 15px;
    --radius-md: 12px;
    --radius-pill: 999px;

    --spring: cubic-bezier(0.22, 1, 0.36, 1);
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background: var(--bg-base);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13.5px;
    line-height: 1.42;
    overflow-x: hidden;
    min-height: 100vh;
    user-select: none;
}

/* Açılır pencere aktifken arka planı tamamen kilitle */
body.modal-locked {
    overflow: hidden !important;
    touch-action: none !important;
    overscroll-behavior: none !important;
}

body.modal-locked .layout-wrapper {
    pointer-events: none !important;
    user-select: none !important;
    filter: blur(4px) brightness(0.75);
    transition: filter 0.25s var(--spring);
}

input, textarea, button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
    border: none;
    background: none;
}

/* ==========================================================================
   ADAPTIVE SHELL: DESKTOP (SIDEBAR RAIL) vs MOBILE (TOPBAR + BOTTOM DOCK)
   ========================================================================== */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 1360px;
    margin: 0 auto;
    transition: filter 0.25s var(--spring);
}

/* Masaüstü Sol Navigation Rail */
.desktop-rail {
    width: 230px;
    flex-shrink: 0;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--border-subtle);
    background: rgba(15, 21, 35, 0.72);
    backdrop-filter: blur(20px);
}

.rail-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 6px 8px;
    cursor: pointer;
}

.brand-logo-img {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 12px rgba(16, 185, 129, 0.35));
    transition: transform 0.3s var(--bounce);
}

.rail-brand:hover .brand-logo-img,
.mobile-brand:active .brand-logo-img {
    transform: rotate(12deg) scale(1.07);
}

.brand-wordmark {
    font-size: 19px;
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #ffffff 30%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.rail-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.rail-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    position: relative;
    transition: all 0.22s var(--spring);
}

.rail-btn:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.rail-btn.active {
    background: var(--primary-container);
    color: #34d399;
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.28);
}

.rail-btn i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

/* Ana Çalışma Alanı */
.main-stage {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 20px calc(104px + env(safe-area-inset-bottom, 0px));
}

/* Üst Bar (Sadece Logo+İsim ve sağda Kullanıcı/Bakiye) */
.top-header {
    position: sticky;
    top: calc(8px + env(safe-area-inset-top, 0px));
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 14px;
    background: rgba(15, 21, 35, 0.90);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-2xl);
    margin-bottom: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    min-width: 0;
    max-width: 100%;
}

.mobile-brand {
    display: none;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-right::-webkit-scrollbar {
    display: none;
}

/* Mobil Alt Dock (Sadece Mobilde Görünür) */
.mobile-dock {
    display: none;
    position: fixed;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 16px);
    max-width: 540px;
    background: rgba(15, 21, 35, 0.95);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 24px;
    padding: 5px 4px;
    z-index: 90;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
    justify-content: space-between;
    align-items: center;
}

.dock-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
}

.dock-pill {
    width: 36px;
    height: 24px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    transition: background 0.25s var(--spring), transform 0.25s var(--bounce);
}

.dock-btn.active {
    color: var(--text-main);
}

.dock-btn.active .dock-pill {
    background: var(--primary-container);
    color: #34d399;
    transform: translateY(-2px) scale(1.05);
}

.dock-lbl {
    font-size: 9.5px;
    font-weight: 800;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.badge-dot {
    position: absolute;
    top: 1px;
    right: 6px;
    background: var(--danger);
    color: #fff;
    font-size: 8.5px;
    font-weight: 900;
    min-width: 15px;
    height: 15px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* Mobil ve Masaüstü Medya Sorguları */
@media (max-width: 859px) {
    .desktop-rail {
        display: none;
    }
    .mobile-brand {
        display: flex;
    }
    .mobile-dock {
        display: flex;
    }
    .main-stage {
        padding: calc(8px + env(safe-area-inset-top, 0px)) 10px calc(92px + env(safe-area-inset-bottom, 0px));
    }
    .top-header {
        padding: 8px 11px;
        margin-bottom: 10px;
    }
    .brand-logo-img {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }
    .brand-wordmark {
        font-size: 16.5px;
    }
}

/* ==========================================================================
   JETPACK COMPOSE SURFACES, CHIPS, AVATARS & ANIMATIONS
   ========================================================================== */
.view-animate {
    animation: viewSpringIn 0.3s var(--spring);
}

@keyframes viewSpringIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.m3-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 13px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
    transition: transform 0.22s var(--spring), border-color 0.22s ease, box-shadow 0.22s ease;
}

.m3-card-clickable {
    cursor: pointer;
}
.m3-card-clickable:hover {
    border-color: rgba(52, 211, 153, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}
.m3-card-clickable:active {
    transform: scale(0.98);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: transform 0.18s var(--bounce), background 0.18s ease, border-color 0.18s ease;
    white-space: nowrap;
    max-width: 100%;
}
.chip:active {
    transform: scale(0.93);
}
.chip-primary { background: var(--primary-container); color: #34d399; border-color: rgba(16, 185, 129, 0.3); }
.chip-secondary { background: var(--secondary-container); color: #38bdf8; border-color: rgba(56, 189, 248, 0.3); }
.chip-accent { background: var(--accent-container); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
.chip-danger { background: var(--danger-container); color: #fb7185; border-color: rgba(244, 63, 94, 0.3); }

.pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
}
.pos-KL { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.pos-DF { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.pos-OS { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.pos-FV { background: rgba(244, 63, 94, 0.2); color: #fb7185; }

.cap-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    font-weight: 900;
    font-size: 9.5px;
    padding: 1px 5px;
    border-radius: 5px;
}

/* Avatar ve Takım Logosu Bileşenleri */
.odi-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-surface-3);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}
.odi-avatar img, .team-crest img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.team-crest {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* Segmented Tabs */
.seg-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--bg-surface);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
}

.seg-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 7px 9px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.22s var(--spring);
}
.seg-btn.active {
    background: var(--bg-surface-3);
    color: var(--text-main);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.grid-2 > *, .grid-3 > * {
    min-width: 0;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
@media (max-width: 680px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   CUSTOM NATIVE CONTROLS (SIFIR TARAYICI VARSAYILANI!)
   Custom Select, Custom Slider, Custom Switch, Custom Stepper, Custom Color
   ========================================================================== */
.m3-input {
    width: 100%;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-main);
    font-weight: 600;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.m3-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.m3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.18s var(--bounce), filter 0.18s ease;
}
.m3-btn:active:not(:disabled) { transform: scale(0.94); }
.m3-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.m3-btn-primary { background: linear-gradient(135deg, #10b981, #059669); color: #03221c; }
.m3-btn-secondary { background: var(--secondary); color: #061926; }
.m3-btn-accent { background: var(--accent); color: #1a1002; }
.m3-btn-danger { background: var(--danger); color: #fff; }
.m3-btn-tonal { background: var(--bg-surface-3); color: var(--text-main); }

/* 1. OdiSync Native Custom Dropdown */
.odi-dropdown {
    position: relative;
    width: 100%;
}
.odi-dropdown-trigger {
    width: 100%;
    min-width: 0;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 9px 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.odi-dropdown-trigger > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.odi-dropdown.open .odi-dropdown-trigger {
    border-color: var(--primary);
}
.odi-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #151e30;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    padding: 5px;
    z-index: 250;
    max-height: 210px;
    overflow-y: auto;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65);
    display: none;
    animation: popScale 0.18s var(--bounce);
}
.odi-dropdown.open .odi-dropdown-menu {
    display: block;
}
.odi-dropdown-opt {
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.odi-dropdown-opt:hover {
    background: rgba(255, 255, 255, 0.06);
}
.odi-dropdown-opt.selected {
    background: var(--primary-container);
    color: #34d399;
    font-weight: 800;
}

@keyframes popScale {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 2. OdiSync Native Custom Slider */
.odi-slider-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}
.odi-slider-track {
    position: relative;
    height: 10px;
    border-radius: 99px;
    background: var(--bg-surface-3);
    cursor: pointer;
    touch-action: none;
}
.odi-slider-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 99px;
    background: linear-gradient(90deg, #10b981, #38bdf8);
    pointer-events: none;
}
.odi-slider-thumb {
    position: absolute;
    top: 50%;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--primary);
    transform: translate(-50%, -50%);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: transform 0.12s var(--bounce);
}
.odi-slider-track:active .odi-slider-thumb {
    transform: translate(-50%, -50%) scale(1.2);
}

/* 3. OdiSync Native Toggle Switch */
.odi-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
}
.odi-switch {
    width: 44px;
    height: 24px;
    border-radius: 99px;
    background: var(--bg-surface-3);
    position: relative;
    transition: background 0.22s var(--spring);
    flex-shrink: 0;
}
.odi-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #94a3b8;
    transition: transform 0.22s var(--bounce), background 0.22s ease;
}
.odi-switch.on {
    background: rgba(16, 185, 129, 0.32);
}
.odi-switch.on::after {
    transform: translateX(20px);
    background: #10b981;
}

/* 4. OdiSync Native Swatch Color Picker */
.odi-swatch-row {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}
.odi-swatch {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.18s var(--bounce), border-color 0.18s ease;
}
.odi-swatch.active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

/* ==========================================================================
   2D DRAG-AND-DROP İLK 7 SAHA DİZİLİŞİ (SÜRÜKLE-BIRAK + TIKLAYINCA PROFİL)
   ========================================================================== */
.pitch-wrapper {
    position: relative;
    width: 100%;
    max-width: 430px;
    aspect-ratio: 3 / 4.05;
    margin: 0 auto;
    border-radius: 22px;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(16, 185, 129, 0.11) 0px,
            rgba(16, 185, 129, 0.11) 36px,
            rgba(5, 150, 105, 0.17) 36px,
            rgba(5, 150, 105, 0.17) 72px
        ),
        radial-gradient(circle at 50% 50%, #065f46 0%, #064e3b 65%, #022c22 100%);
    border: 2px solid rgba(52, 211, 153, 0.35);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    touch-action: none;
}

.pitch-line-mid { position: absolute; top: 50%; left: 0; right: 0; height: 1.5px; background: rgba(255,255,255,0.22); pointer-events: none; }
.pitch-circle { position: absolute; top: 50%; left: 50%; width: 82px; height: 82px; transform: translate(-50%,-50%); border: 1.5px solid rgba(255,255,255,0.22); border-radius: 50%; pointer-events: none; }
.pitch-box-top { position: absolute; top: 0; left: 22%; width: 56%; height: 16%; border: 1.5px solid rgba(255,255,255,0.22); border-top: none; pointer-events: none; }
.pitch-box-bottom { position: absolute; bottom: 0; left: 22%; width: 56%; height: 16%; border: 1.5px solid rgba(255,255,255,0.22); border-bottom: none; pointer-events: none; }

.pitch-player {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    transition: left 0.35s var(--spring), top 0.35s var(--spring), transform 0.2s var(--bounce);
    z-index: 5;
    width: 74px;
    touch-action: none;
}
.pitch-player:active { cursor: grabbing; }
.pitch-player.drop-target .pitch-avatar {
    box-shadow: 0 0 0 4px #fbbf24, 0 0 22px rgba(251, 191, 36, 0.85);
    transform: scale(1.16);
}

.pitch-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    border: 2.5px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 13.5px;
    color: #fff;
    position: relative;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.48);
    overflow: visible;
}
.pitch-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.pitch-cap-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fbbf24;
    color: #000;
    font-size: 9px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #090d16;
}
.pitch-pos-dot {
    position: absolute;
    bottom: -4px;
    left: -4px;
    padding: 1px 4px;
    border-radius: 4px;
    background: #070a12;
    color: #cbd5e1;
    font-size: 8.5px;
    font-weight: 800;
    border: 1px solid rgba(255,255,255,0.2);
}
.pitch-num-dot {
    position: absolute;
    bottom: -4px;
    right: -4px;
    padding: 1px 4px;
    border-radius: 4px;
    background: #10b981;
    color: #03221c;
    font-size: 8.5px;
    font-weight: 900;
}
.pitch-name {
    margin-top: 4px;
    background: rgba(7, 10, 18, 0.88);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 0.92;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.65));
}

/* ==========================================================================
   NATIVE MODAL / BOTTOM SHEET (ARKA PLAN KİLİTLİ)
   ========================================================================== */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 12, 0.76);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overscroll-behavior: contain;
}
.sheet-backdrop.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.sheet-box {
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 26px;
    padding: 18px 20px 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
    animation: modalPopIn 0.28s var(--spring);
    position: relative;
}

@media (max-width: 640px) {
    .sheet-backdrop {
        align-items: flex-end;
        padding: env(safe-area-inset-top, 0px) 0 0;
    }
    .sheet-box {
        border-radius: 24px 24px 0 0;
        border-bottom: none;
        max-height: calc(90vh - env(safe-area-inset-top, 0px));
        padding: 16px 14px calc(22px + env(safe-area-inset-bottom, 0px));
    }
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.sheet-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
}

@keyframes modalPopIn {
    from { opacity: 0; transform: translateY(28px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Native Image Cropper Viewport */
.cropper-stage {
    width: 220px;
    height: 220px;
    margin: 0 auto 14px;
    border-radius: 24px;
    border: 2.5px solid var(--primary);
    background: #050811;
    overflow: hidden;
    position: relative;
    cursor: move;
    touch-action: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Oyun Sahaları (ZbaCrash, Mines, XOX) */
.crash-stage {
    position: relative;
    height: 260px;
    border-radius: var(--radius-xl);
    background: radial-gradient(circle at 75% 20%, rgba(16, 185, 129, 0.16), transparent 55%),
                linear-gradient(180deg, #131c2e 0%, #070a12 100%);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#crash-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crash-mult-big { position: relative; z-index: 3; font-size: 50px; font-weight: 900; letter-spacing: -0.03em; }
.crash-state-pill { position: relative; z-index: 3; margin-top: 6px; font-size: 11.5px; font-weight: 800; padding: 4px 12px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.07); }

.mines-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 340px; margin: 0 auto; }
.mine-tile {
    aspect-ratio: 1;
    border-radius: 14px;
    background: linear-gradient(145deg, #1e293b, #0f1523);
    border: 1px solid rgba(255, 255, 255, 0.09);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    cursor: pointer;
    transition: transform 0.2s var(--bounce), background 0.2s ease, border-color 0.2s ease;
}
.mine-tile:hover:not(.open):not(.disabled) { transform: translateY(-2px); border-color: var(--primary); }
.mine-tile.gem { background: radial-gradient(circle, rgba(16,185,129,0.35), rgba(6,78,59,0.5)); border-color: #10b981; }
.mine-tile.bomb { background: radial-gradient(circle, rgba(244,63,94,0.45), rgba(127,29,29,0.6)); border-color: #f43f5e; }
.mine-tile.dimmed { opacity: 0.4; }

.xox-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 290px; margin: 0 auto; }
.xox-tile {
    aspect-ratio: 1;
    border-radius: 18px;
    background: var(--bg-surface-2);
    border: 1.5px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s var(--bounce);
}
.xox-tile.x-mark { color: #38bdf8; border-color: rgba(56, 189, 248, 0.45); }
.xox-tile.o-mark { color: #fb7185; border-color: rgba(244, 63, 94, 0.45); }

/* Sanal Kura Küresi Animasyonu */
.draw-orb {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    margin: 0 auto 12px;
    background: radial-gradient(circle at 30% 30%, #34d399, #059669 60%, #022c22 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 900;
    color: #fff;
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.45);
    animation: orbPulse 2s infinite ease-in-out;
}
@keyframes orbPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.07); }
}

.m3-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.m3-table th { text-align: left; color: var(--text-muted); font-weight: 700; padding: 7px 5px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.m3-table td { padding: 8px 5px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); font-weight: 600; }

#toast-box {
    position: fixed;
    top: calc(68px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: calc(100vw - 24px);
}
.toast-pill {
    background: #172033;
    color: #fff;
    border: 1px solid rgba(52, 211, 153, 0.35);
    padding: 9px 15px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
    animation: popScale 0.22s var(--bounce);
    text-align: center;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ==========================================================================
   KIRMIZI KURA / GRUP UYARI IŞIĞI & SIRALI KURA KUYRUĞU
   ========================================================================== */
@keyframes redGlowPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.55), inset 0 0 12px rgba(244, 63, 94, 0.22);
        border-color: rgba(244, 63, 94, 0.75);
    }
    50% {
        box-shadow: 0 0 18px 3px rgba(244, 63, 94, 0.45), inset 0 0 18px rgba(244, 63, 94, 0.36);
        border-color: #fb7185;
    }
}

.red-pulse-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f43f5e;
    box-shadow: 0 0 10px #f43f5e;
    animation: orbPulse 1.1s infinite ease-in-out;
    flex-shrink: 0;
}

.rail-btn.nav-alert-red {
    border: 1px solid rgba(244, 63, 94, 0.65);
    background: linear-gradient(90deg, rgba(244, 63, 94, 0.18), rgba(244, 63, 94, 0.05));
    color: #fda4af;
    animation: redGlowPulse 1.8s infinite ease-in-out;
}
.rail-btn.nav-alert-red i {
    color: #fb7185 !important;
}

.dock-btn.nav-alert-red .dock-pill {
    background: rgba(244, 63, 94, 0.24);
    border: 1px solid rgba(244, 63, 94, 0.7);
    box-shadow: 0 0 14px rgba(244, 63, 94, 0.45);
}
.dock-btn.nav-alert-red i,
.dock-btn.nav-alert-red .dock-lbl {
    color: #fb7185 !important;
}

.seg-btn.seg-alert-red {
    border: 1px solid rgba(244, 63, 94, 0.65) !important;
    background: rgba(244, 63, 94, 0.16);
    color: #fecdd3;
    animation: redGlowPulse 1.8s infinite ease-in-out;
}
.seg-btn.seg-alert-red.active {
    background: linear-gradient(135deg, #e11d48, #be123c) !important;
    color: #fff !important;
}

.draw-queue-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 2px 10px;
}
.draw-queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.22s ease;
}
.draw-queue-item.current-turn {
    border-color: #f43f5e;
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.22), rgba(16, 185, 129, 0.12));
    animation: redGlowPulse 1.6s infinite ease-in-out;
}
.draw-queue-item.drawn {
    opacity: 0.72;
    border-color: rgba(16, 185, 129, 0.35);
}

/* ==========================================================================
   GELİŞMİŞ GÖRSEL ELEME AĞACI (TOURNAMENT BRACKET TREE)
   ========================================================================== */
.bracket-tree-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    align-items: stretch;
    position: relative;
}

.bracket-stage-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 14px;
    position: relative;
}

.bracket-stage-hdr {
    text-align: center;
    padding: 8px 14px;
    border-radius: 12px;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.14), rgba(56, 189, 248, 0.12));
    border: 1px solid rgba(52, 211, 153, 0.28);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 4px;
}

.bracket-node {
    background: linear-gradient(165deg, rgba(23, 32, 51, 0.96), rgba(11, 16, 28, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
    position: relative;
    transition: transform 0.2s var(--bounce), border-color 0.2s ease;
}
.bracket-node:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}
.bracket-node.final-node {
    border: 1.5px solid rgba(251, 191, 36, 0.55);
    background: radial-gradient(circle at top right, rgba(251, 191, 36, 0.15), transparent 65%),
                linear-gradient(165deg, #172033, #0b101c);
    box-shadow: 0 16px 38px rgba(251, 191, 36, 0.15);
}

.bracket-team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.18s ease;
}
.bracket-team-row + .bracket-team-row {
    margin-top: 6px;
}
.bracket-team-row.winner {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.45);
}
.bracket-score-box {
    min-width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg-surface-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 13.5px;
}
.bracket-team-row.winner .bracket-score-box {
    background: var(--primary);
    color: #04130d;
}

.champion-podium-card {
    margin-top: 14px;
    padding: 18px;
    border-radius: 22px;
    text-align: center;
    background: radial-gradient(circle at 50% 0%, rgba(251, 191, 36, 0.28), transparent 70%),
                linear-gradient(180deg, #1a2236 0%, #0b101c 100%);
    border: 1.5px solid rgba(251, 191, 36, 0.55);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
