html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #222;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* --- YÜKLEME EKRANI (LOADING SCREEN) --- */
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #222;
    /* Uygulama arkaplanı ile aynı renk */
    z-index: 9999;
    /* Her şeyin en üstünde durur */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease-out;
    /* Kaybolurken yumuşakça silinecek */
}

/* Dönen Şık Animasyon Hilesi */
.loader {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #007bff;
    /* Vizyon mavisi */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- BİLGİSAYAR İÇİN KONTROL PANELİ (KOMPAKT ARAÇ KUTUSU) --- */
#controls {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: white;
    display: flex;
    flex-direction: column;
    width: 180px;
    gap: 15px;
}

#controls label {
    font-size: 12px;
    font-weight: 800;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: -5px;
}

#colorPalette {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* --- PREMIUM RENK PALETİ (HEPSİ KUSURSUZ DAİRE) --- */
.color-swatch {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    /* İŞTE OVAL OLMAYI ENGELLEYEN SİHİRLİ KOD */
    border-radius: 50%;
    /* Artık hepsi kusursuz birer daire */
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

.color-swatch:hover {
    transform: translateY(-2px) scale(1.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.color-swatch.selected {
    border: 3px solid #ffffff !important;
    transform: scale(1.25) translateY(-3px) !important;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6) !important;
    z-index: 10 !important;
}

/* --- AKSİYON BUTONLARI --- */
#controls button:not(.color-swatch) {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    /* Daha tatlı, modern köşeler */
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

#placeButton {
    /* Düz mavi yerine lüks bir degrade (gradient) mavi */
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
}

#placeButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6);
}

#placeButton:disabled {
    background: #444 !important;
    color: #888 !important;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#resetButton {
    background-color: rgba(255, 255, 255, 0.08);
    color: #eee;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

#resetButton:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4) !important;
}

/* Bilgisayarda görünen sarı bekleme metni */
#cooldownText {
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    color: #ffcc00;
    width: 100%;
    display: block;
}

/* --- POZİSYON GÖSTERGESİ --- */
#position {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    /* Hap şeklinde tasarım */
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 0.5px;
}

/* --- CANVAS --- */
#canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    background-color: #fff;
}

#canvas:active {
    cursor: grabbing;
}

/* =========================================================
   MOBİL UYUMLULUK (TELEFONLAR İÇİN YÜZEN ADA TASARIMI)
   ========================================================= */
@media (max-width: 768px) {
    #controls {
        flex-direction: row;
        flex-wrap: wrap;
        top: auto;
        /* Ekranın en altından hafif yukarıda yüzen bir ada yapıyoruz */
        bottom: 20px;
        /* Ekranın sağından ve solundan eşit boşluk bırakıyoruz */
        left: 15px;
        right: 15px;
        width: auto;
        /* Genişliği %100 yerine sağ/sol boşluklara göre kendi ayarlar */
        border-radius: 24px;
        /* Sadece üstleri değil, 4 köşeyi de yusyuvarlak yaptık */
        padding: 15px;
        box-sizing: border-box;
        border: 1px solid rgba(255, 255, 255, 0.15);
        /* Çerçeveyi tam tur çevirdik */
        gap: 12px;
        /* Elemanlar arasına otomatik kusursuz boşluk */
    }

    #controls label {
        display: none;
    }

    #colorPalette {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 10px 5px;
        margin-bottom: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        gap: 12px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    #colorPalette::-webkit-scrollbar {
        display: none;
    }

    /* Mobilde Butonlar (Artık Sıfır Taşma, Kusursuz Eşitlik) */
    #placeButton,
    #resetButton {
        flex: 1 !important;
        /* İkisine de "eşit alan al" emri verdik */
        width: auto !important;
        min-width: 0 !important;
        padding: 14px 5px !important;
        font-size: 15px !important;
        border-radius: 14px !important;
        white-space: nowrap !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    /* Mobilde butonda zaten "Bekle: 27s" yazdığı için, alttaki çirkin sarı metni SİLİYORUZ */
    #cooldownText {
        display: none !important;
    }

    #position {
        top: 20px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        font-size: 13px;
        padding: 8px 18px;
        background: rgba(15, 15, 15, 0.7);
        white-space: nowrap !important;
    }
}