/* Değişkenler: Renkleri, boyutları ve fontları buradan kolayca yönetebiliriz */
:root {
    --tile-size: 50px;
    --tile-font: 'Helvetica Neue', Arial, sans-serif;
    --tile-font-weight: 700;
    --tile-font-size: 28px;
    --green: #6aaa64;
    --yellow: #c9b458;
    --gray: #787c7e;
    --text-on-colored-tile: #fff;
    --easing: ease-in-out;
}

/* Mobil için küçük tile boyutu */
@media (max-width: 768px) {
    :root {
        --tile-size: 35px;
        --tile-font-size: 20px;
    }
}

@media (max-width: 480px) {
    :root {
        --tile-size: 34px;
        --tile-font-size: 20px;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px 40px 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background: #fafaf8;
    font-family: var(--tile-font);
    overflow-x: hidden;
}

@media (max-width: 768px) {
    body {
        padding: 12px 20px 20px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px 10px 10px;
    }
}

.crossword-container {
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: none;
    margin: 0 auto;
    max-width: 100%;
    width: fit-content;
    display: inline-block;
}

@media (max-width: 768px) {
    .crossword-container {
        padding: 20px;
        border-radius: 15px;
    }
}

@media (max-width: 480px) {
    .crossword-container {
        padding: 10px;
        border-radius: 10px;
    }
}

.crossword-grid {
    display: grid;
    /* Grid boyutları JavaScript tarafından dinamik olarak ayarlanır */
    gap: 4px;
    /* Sürüklenen klonun konumlandırılması için referans noktası */
    position: relative;
    width: fit-content;
    margin: 0 auto;
}

@media (max-width: 480px) {
    .crossword-grid {
        gap: 2px;
    }
}

.tile {
    font-family: var(--tile-font);
    font-weight: var(--tile-font-weight);
    font-size: var(--tile-font-size);
    background-color: #f8f8f8;
    cursor: grab; /* Sürükleme imleci */
    height: var(--tile-size);
    width: var(--tile-size);
    border-bottom: 5px solid rgba(0,0,0,.1);
    border-radius: 12%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    color: #333;
    box-sizing: border-box;
    user-select: none; /* Sürüklerken metin seçilmesini engelle */
    -webkit-user-select: none; /* Safari için */
    touch-action: none; /* Touch sürükleme için */
}

@media (max-width: 768px) {
    .tile {
        border-bottom: 3px solid rgba(0,0,0,.1);
    }
}

@media (max-width: 480px) {
    .tile {
        border-bottom: 2px solid rgba(0,0,0,.1);
    }
}

/* Grid yapısının bozulmaması için orijinal kutucuğu görünmez yapan sınıf */
.tile.placeholder {
    visibility: hidden;
    cursor: default;
}

/* Sürüklenen KLONUN stili */
.tile.dragging {
    position: absolute;
    z-index: 1000;
    transform: scale(1.3);
    cursor: grabbing;
    pointer-events: none; /* Altındaki hedefi bulabilmek için fare olaylarını yok say */
    transition: none; /* Fareyi anında takip etmesi için geçiş animasyonunu kaldır */
}

/* Yer değiştirme animasyonuna sahip kutucuk */
.tile.swapping {
    transition: transform 0.2s var(--easing);
}

/* Boş kutucukların stili */
.tile.blank {
    background-color: transparent;
    border: none;
    cursor: default;
}

/* Renk sınıfları */
.green { 
    background-color: var(--green); 
    color: var(--text-on-colored-tile); 
    cursor: not-allowed !important; /* Yeşil kutucuklar sürüklenemez */
}
.yellow { background-color: var(--yellow); color: var(--text-on-colored-tile); }
.gray { background-color: var(--gray); color: var(--text-on-colored-tile); }

h1 {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    h1 {
        font-size: 2em;
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
}

h2 {
    text-align: center;
    text-transform: capitalize;
    margin: 0 0 16px;
    color: #333;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.help-btn {
    width: 28px;
    height: 28px;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.help-btn:hover {
    transform: scale(1.1);
}

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.modal-close:hover {
    color: #000;
}

.modal h3 {
    margin: 0 0 20px;
    font-size: 24px;
    color: #333;
}

.example {
    margin: 20px 0;
}

.example-text {
    margin-bottom: 12px;
    color: #333;
    font-size: 16px;
}

.example-tiles {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 8px;
}

.example-tile {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    border-radius: 4px;
    text-transform: uppercase;
}

.example-tile.demo-green {
    background-color: var(--green);
    color: white;
}

.example-tile.demo-yellow {
    background-color: var(--yellow);
    color: white;
}

.example-tile.demo-gray {
    background-color: var(--gray);
    color: white;
}
