body {
    font-family: 'Montserrat', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Ekranın minimum yüksekliği kadar olsun */
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
    color: #e0e0e0;
    margin: 0;
    /* ÖNEMLİ: Tüm içeriğin sığmasını sağlamak için overflow ayarları */
    overflow-y: auto; /* Dikeyde taşma olduğunda kaydırma çubuğu çıksın */
    overflow-x: hidden; /* Yatay kaymayı kesinlikle engelle */
    position: relative;
    padding: 10px 0; /* Üst ve alttan biraz boşluk bırakalım */
    box-sizing: border-box; /* Padding'in genişliğe dahil olmasını sağlar */
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://www.transparenttextures.com/patterns/clean-gray-paper.png'); /* Hafif doku */
    opacity: 0.05;
    pointer-events: none;
    z-index: 0; /* Arka planda kalsın */
}

.container {
    background-color: rgba(25, 25, 40, 0.95);
    padding: 20px; /* Her yönden padding'i tek değerle ayarlayalım */
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
    max-width: 550px; /* Konteynerin maksimum genişliğini biraz artıralım, kelimeler için daha fazla alan */
    width: 95%; /* Ekranın %95'ini kaplasın */
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: auto;
    height: auto;
    box-sizing: border-box;
}

h1 {
    color: #92e6e6;
    margin-bottom: 15px;
    font-size: clamp(24px, 5.5vw, 40px); /* Min, viewport tabanlı, Max değer */
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(146, 230, 230, 0.3);
    word-break: break-word;
}

#word-display {
    /* Eski: font-size: clamp(30px, 8vw, 70px); */
    font-size: clamp(30px, 7vw, 60px); /* Maksimum font boyutunu 60px'e düşürdük */
    letter-spacing: clamp(3px, 0.7vw, 10px);
    margin-bottom: 25px;
    color: #f7b731;
    min-height: 1.5em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    word-break: break-word;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

#word-display span {
    border-bottom: 3px solid #f7b731;
    margin: 0 3px; /* Harfler arası boşluğu daha da azaltalım */
    padding-bottom: 5px;
    min-width: 18px; /* Her harf için minimum genişliği daha da düşürelim */
    text-align: center;
    /* Flex özelliklerini daha dikkatli ayarlayalım */
    flex-grow: 1; /* Mevcut alanı doldurmaya çalışsın */
    flex-shrink: 1; /* Gerektiğinde küçülsün */
    flex-basis: auto; /* Kendi içeriğine göre temel genişlik alsın */
}

#keyboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
    gap: 6px;
    margin-bottom: 20px;
    padding: 0 5px;
    width: 100%; /* Klavye genişliği tam olsun */
    max-width: 450px; /* Klavye maksimum genişliği */
}

.key {
    background-color: #3e2f5b;
    color: #e0e0e0;
    border: none;
    border-radius: 6px;
    padding: 10px 5px;
    font-size: clamp(14px, 4vw, 24px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    aspect-ratio: 1 / 1; /* Tuşların kare olmasını sağlar, bu da sığdırmaya yardımcı olabilir */
}

.key:hover:not(.disabled) {
    background-color: #5d4585;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.key:active:not(.disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.key.disabled {
    background-color: #555;
    color: #bbb;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

#guesses-left {
    font-size: clamp(16px, 4.5vw, 28px);
    color: #ff6b6b;
    margin-bottom: 15px;
    font-weight: bold;
}

#message {
    font-size: clamp(18px, 5vw, 32px);
    font-weight: bold;
    margin-top: 20px;
    margin-bottom: 15px;
    word-break: break-word;
}

#message.win {
    color: #6eff6e;
}

#message.lose {
    color: #ff6b6b;
}

#hint-button, #reset-button {
    background-color: #f7b731;
    color: #1a1a2e;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: clamp(16px, 4.5vw, 28px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin: 8px;
    white-space: nowrap;
}

#hint-button:hover:not(:disabled), #reset-button:hover {
    background-color: #ffd166;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.4);
}

#hint-button:disabled {
    background-color: #555;
    color: #bbb;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

.hangman-drawing {
    height: 130px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.hangman-drawing img {
    max-height: 100%;
    width: auto;
    image-rendering: crisp-edges;
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.4));
}

/* responsive ayarlarımız, clamp() ile zaten çoğu durumu ele alıyoruz */
/* Eğer hala özel durumlar varsa burayı kullanabiliriz */
@media (max-width: 480px) {
    .container {
        padding: 15px; /* Daha küçük ekranlarda daha az boşluk */
    }
    .hangman-drawing {
        height: 100px; /* Küçük ekranlarda görseli daha da küçültelim */
    }
    #keyboard {
        gap: 4px; /* Tuş aralıklarını daha da azaltalım */
    }
}

@media (max-width: 320px) {
    .container {
        padding: 10px;
    }
    .hangman-drawing {
        height: 80px;
    }
}