:root {
    --bg-deep: #0a0816; --bg-navy: #151236; --bg-panel: rgba(21, 18, 54, 0.85);
    --primary-purple: #8a2be2; --neon-purple: #a64dff; --lilac: #c8a2c8;
    --lilac-muted: rgba(200, 162, 200, 0.4); --text-main: #f8f9fa;
    --text-muted: #adb5bd; --success: #2ecc71; --danger: #e74c3c;
    --warning: #f1c40f; --glass-border: 1px solid rgba(200, 162, 200, 0.2);
    --glass-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* 1. KURAL: Tarayıcının ana çubuğunun (sağdaki ana scroll) çıkmasını kesinlikle engelliyoruz */
html, body { height: 100%; height: 100dvh; overflow: hidden; } 

body {
    font-family: 'Poppins', sans-serif; 
    background: radial-gradient(circle at top left, var(--bg-navy), var(--bg-deep) 80%);
    color: var(--text-main); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: clamp(0.5rem, 2vw, 1rem);
    padding-bottom: 0;
}

.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--neon-purple); border-radius: 4px; }

.hidden { display: none !important; }
.disabled { opacity: 0.5; pointer-events: none; cursor: not-allowed !important; filter: grayscale(50%); }
.mt-auto { margin-top: auto; }

/* ANA PANEL */
.glass-panel {
    width: 100%; 
    max-width: 1200px; 
    flex-grow: 1; 
    background: var(--bg-panel); 
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); 
    border: var(--glass-border); 
    border-radius: clamp(12px, 2vw, 20px) clamp(12px, 2vw, 20px) 0 0; 
    box-shadow: var(--glass-shadow); 
    padding: clamp(1rem, 2.5vw, 2rem); 
    display: flex; 
    flex-direction: column;
    overflow: hidden; 
    margin-top: 0;
    margin-bottom: 0;
}

.view-state { display: flex; flex-direction: column; height: 100%; animation: fadeIn 0.4s ease; min-height: 0; overflow: hidden; }
.view-state:not(.active) { display: none; }

#login-screen { justify-content: center; align-items: center; overflow-y: auto; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

h1, h2, h3 { color: var(--lilac); margin-bottom: clamp(0.6rem, 1.5vw, 1rem); letter-spacing: 0.5px; }

.gradient-text { 
    background: linear-gradient(45deg, var(--lilac), var(--neon-purple)); 
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
    font-size: clamp(2.2rem, 6vw, 3.5rem); 
    font-weight: 800; text-align: center; margin-bottom: clamp(1.2rem, 3vw, 2.5rem); 
}

.form-group { margin-bottom: clamp(1rem, 2.5vw, 1.5rem); width: 100%; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--lilac); font-weight: 600; font-size: 0.9rem; }

input[type="text"], input[type="number"], select {
    width: 100%; padding: 12px 16px; min-height: 40px; background: rgba(0, 0, 0, 0.25); 
    border: 1px solid var(--lilac-muted); border-radius: 10px;
    color: var(--text-main); font-family: inherit; font-size: 16px; 
    outline: none; transition: all 0.3s ease; 
}

input:focus, select:focus { border-color: var(--neon-purple); background: rgba(0, 0, 0, 0.4); box-shadow: 0 0 10px rgba(166, 77, 255, 0.2); }

.category-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.4rem; overflow-y: auto; max-height: 150px; padding-right: 5px; }
.category-pill {
    background: rgba(0, 0, 0, 0.4); border: 1px solid var(--lilac-muted); border-radius: 20px; 
    padding: clamp(6px, 1.5vw, 8px) clamp(12px, 2.5vw, 16px); 
    font-size: clamp(0.8rem, 2vw, 0.85rem); font-weight: 600;
    color: var(--text-muted); cursor: pointer; transition: all 0.2s ease; user-select: none; 
    display: inline-flex; align-items: center;
}
.category-pill input[type="checkbox"] { display: none; }
.category-pill:has(input:checked) { background: rgba(138, 43, 226, 0.4); border-color: var(--neon-purple); color: white; box-shadow: 0 4px 10px rgba(138, 43, 226, 0.2); }

.btn { 
    padding: 12px 20px; min-height: 40px; border: none; border-radius: 10px; 
    font-size: clamp(0.9rem, 2vw, 1rem); font-weight: 600; cursor: pointer; transition: all 0.2s ease; 
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; 
    color: white; touch-action: manipulation; white-space: nowrap; 
}
.btn-primary { background: var(--primary-purple); }
.btn-primary:hover:not(.disabled) { background: var(--neon-purple); transform: translateY(-2px); box-shadow: 0 6px 15px rgba(138, 43, 226, 0.3); }
.btn-secondary { background: rgba(255,255,255,0.05); border: 1px solid var(--lilac-muted); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--lilac); transform: translateY(-2px); }
.btn-success { background: rgba(46, 204, 113, 0.2); color: var(--success); border: 1px solid var(--success); }
.btn-success:hover { background: rgba(46, 204, 113, 0.3); transform: translateY(-2px); }
.btn-danger { background: rgba(231, 76, 60, 0.2); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(231, 76, 60, 0.3); transform: translateY(-2px); }
.btn-warning { background: rgba(241, 196, 15, 0.2); color: var(--warning); border: 1px solid var(--warning); }
.btn-warning:hover { background: rgba(241, 196, 15, 0.3); transform: translateY(-2px); }
.btn-block { width: 100%; }

.card { 
    background: rgba(0, 0, 0, 0.25); border: var(--glass-border); 
    border-radius: clamp(12px, 2vw, 16px); padding: clamp(1rem, 2.5vw, 1.5rem); 
    overflow: hidden; display: flex; flex-direction: column; min-height: 0;
}

.lobby-header { display: flex; justify-content: center; align-items: center; gap: clamp(0.8rem, 2vw, 1.2rem); margin-bottom: clamp(1rem, 2.5vw, 2rem); background: rgba(0,0,0,0.2); padding: clamp(0.6rem, 1.5vw, 1rem); border-radius: 15px; flex-wrap: wrap; flex-shrink: 0; }
.code-container { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.3); padding: 6px 14px; border-radius: 10px; }

.lobby-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: clamp(1rem, 2.5vw, 2rem); 
    flex-grow: 1; min-height: 0; overflow-y: auto;
}

.kick-link { color: #53fc18; }
.kick-icon { transition: transform 0.3s ease; }
.kick-link svg { width: clamp(20px, 4vw, 24px) !important; height: clamp(20px, 4vw, 24px) !important; }
.kick-link:hover .kick-icon { transform: scale(1.15); }

.players-panel ul { list-style: none; overflow-y: auto; flex-grow: 1; padding-right: 5px; margin-top: 10px; }
.players-panel li { padding: 10px 12px; margin-bottom: 8px; background: rgba(255,255,255,0.03); border-radius: 8px; border-left: 3px solid var(--lilac); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; transition: background 0.2s; font-size: 0.95rem; }
.players-panel li:hover { background: rgba(255,255,255,0.06); }

.game-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: clamp(0.8rem, 2vw, 1.5rem); padding: clamp(0.6rem, 1.5vw, 1rem) clamp(0.8rem, 2vw, 1.5rem); flex-wrap: wrap; gap: 0.8rem; background: rgba(0,0,0,0.2); flex-shrink: 0; }
.score-board { display: flex; gap: clamp(0.8rem, 2.5vw, 2rem); font-weight: bold; font-size: clamp(1rem, 2vw, 1.2rem); align-items: center; }
.team-a { color: #3498db; } .team-b { color: #e74c3c; }
.timer { font-size: clamp(2rem, 4vw, 2.5rem); font-weight: 800; color: var(--lilac); min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; transition: transform 0.1s ease, color 0.3s ease; }

.game-layout { 
    display: grid; 
    grid-template-columns: 1fr 350px; 
    gap: clamp(1rem, 2.5vw, 2rem); 
    flex-grow: 1; min-height: 0; overflow: hidden; 
}

/* 2. KURAL: Oyun Alanı artık kendisi kaydırılamaz (overflow: hidden). 
   Böylece butonlar her zaman görünür kalmak zorunda! */
.play-area { 
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; 
    position: relative; height: 100%; text-align: center; 
    overflow: hidden; /* SIKI KONTROL */
    width: 100%;
}

.status-badge { 
    margin-bottom: clamp(0.8rem, 2vw, 1.5rem); font-size: clamp(0.95rem, 2vw, 1.1rem); 
    color: var(--text-main); padding: 10px 20px; background: rgba(138, 43, 226, 0.2); 
    border-radius: 10px; border: 1px solid var(--primary-purple); 
    font-weight: 600; text-align: center; 
    flex-shrink: 0; /* Başlık asla küçülmez */
    width: 100%; max-width: 450px; /* Kartla aynı hizada durması için */
}

/* 3. KURAL: Kelime Kartı esnek yapıya büründü. Kalan tüm boşluğa yayılır. */
.taboo-card { 
    background: linear-gradient(145deg, rgba(30, 25, 70, 0.95), rgba(20, 15, 50, 0.95)); 
    border: 2px solid var(--neon-purple); border-radius: 16px; 
    width: 100%; max-width: 450px; text-align: center; 
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    
    display: flex; 
    flex-direction: column; 
    flex: 1; /* Boşluğu kaplar */
    min-height: 0; /* Küçülmesine ve sığmasına tam izin verir */
    margin-bottom: clamp(0.6rem, 1.5vw, 1rem); 
}

.card-header { background: rgba(138, 43, 226, 0.2); padding: clamp(1rem, 2.5vw, 1.4rem); border-bottom: 2px solid var(--primary-purple); border-radius: 14px 14px 0 0; flex-shrink: 0; }
.card-header h2 { font-size: clamp(1.4rem, 3.5vw, 1.8rem); color: #fff; margin: 0; letter-spacing: 1px; }

/* 4. KURAL: Eğer kart çok uzarsa SADECE KELİMELER kendi içinde kaydırılır. */
#forbidden-words { 
    list-style: none; padding: clamp(1rem, 2.5vw, 1.4rem); 
    overflow-y: auto; /* Magic Touch: Kelimeler çoksa burası scrolldur */ 
    flex: 1; 
    min-height: 0; 
}
#forbidden-words li { font-size: clamp(1rem, 2.5vw, 1.2rem); margin-bottom: 8px; color: var(--lilac); font-weight: 600; letter-spacing: 0.5px; }
#forbidden-words li:last-child { margin-bottom: 0; }

/* 5. KURAL: Aksiyon Butonları (Doğru/Tabu/Pas) ekrana ÇİVİLENDİ */
.narrator-actions { 
    display: flex; 
    flex-wrap: wrap; 
    gap: clamp(0.6rem, 1.5vw, 0.8rem); 
    width: 100%; 
    max-width: 450px; 
    justify-content: center; 
    flex-shrink: 0; /* BUTONLAR ASLA YOK OLMAZ VEYA TAŞMAZ */
    padding-bottom: 5px;
}

.narrator-actions .btn {
    flex: 1 1 110px; 
    padding: clamp(10px, 1.5vw, 14px) 10px !important; 
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.chat-panel { display: flex; flex-direction: column; height: 100%; padding: clamp(0.8rem, 2vw, 1.2rem); background: rgba(0,0,0,0.2); min-height: 0; }
.messages-container { flex-grow: 1; overflow-y: auto; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; padding-right: 5px; }
.chat-msg { background: rgba(255,255,255,0.05); padding: 8px 12px; border-radius: 8px; border-bottom-left-radius: 0; align-self: flex-start; max-width: 90%; word-break: break-word; line-height: 1.35; }
.chat-msg.self { background: rgba(138, 43, 226, 0.2); border-bottom-left-radius: 8px; border-bottom-right-radius: 0; align-self: flex-end; }
.chat-input-wrapper { display: flex; gap: 8px; flex-shrink: 0; }
.chat-input-wrapper input { flex-grow: 1; min-height: 36px; padding: 10px 14px; font-size: 15px; }

.toast-container { position: fixed; bottom: 25px; right: 25px; display: flex; flex-direction: column; gap: 12px; z-index: 10000; }
.toast { background: rgba(20, 15, 50, 0.95); color: white; padding: 12px 20px; border-radius: 10px; border-left: 4px solid var(--primary-purple); box-shadow: 0 6px 16px rgba(0,0,0,0.4); animation: slideIn 0.3s ease; font-weight: 500; font-size: clamp(0.85rem, 2vw, 0.95rem); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.guesser-mode { border-color: var(--success); background: rgba(46, 204, 113, 0.1); color: var(--success); }
.opponent-mode { border-color: var(--danger); background: rgba(231, 76, 60, 0.1); color: var(--danger); }
.toggle-btn { background: transparent; border: none; font-size: 1.2rem; cursor: pointer; opacity: 0.8; transition: opacity 0.2s; }
.toggle-btn:hover { opacity: 1; }

.pop-animation { animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { transform: scale(0.95); opacity: 0.5; } 100% { transform: scale(1); opacity: 1; } }

.app-footer {
    width: 100%; max-width: 1200px; display: flex; justify-content: space-between; align-items: center;
    padding: clamp(0.6rem, 1.5vw, 1rem) clamp(1rem, 2.5vw, 2rem); margin-top: clamp(0.4rem, 1vw, 0.8rem); margin-bottom: clamp(0.4rem, 1vw, 0.8rem); background: rgba(0,0,0,0.25); border-radius: clamp(10px, 1.5vw, 16px) clamp(10px, 1.5vw, 16px) 0 0;
    border: var(--glass-border); flex-wrap: wrap; gap: 0.8rem; box-shadow: 0 -2px 10px rgba(0,0,0,0.2); flex-shrink: 0;
}
.footer-text { color: var(--text-muted); font-size: clamp(0.8rem, 1.5vw, 0.9rem); letter-spacing: 0.5px; margin: 0.2rem 0; font-weight: 400; text-align: center; }
.footer-links { display: flex; gap: clamp(0.6rem, 1.5vw, 1.2rem); flex-wrap: wrap; justify-content: center; align-items: center; margin: 0.2rem 0; }
.social-link {
    display: inline-flex; align-items: center; gap: 6px; color: var(--text-main); text-decoration: none;
    background: rgba(255,255,255,0.05); padding: 6px 14px; border-radius: 10px; transition: all 0.3s ease; font-weight: 600; font-size: clamp(0.85rem, 1.5vw, 0.95rem); border: 1px solid transparent;
}
.social-link:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); transform: translateY(-2px); box-shadow: 0 3px 8px rgba(0,0,0,0.2); }
.social-link.kick-link span:first-child { color: #53fc18; font-weight: 900; font-size: clamp(0.9rem, 1.5vw, 1rem); letter-spacing: 0.45px; }
.social-link.kick-link span:last-child { color: #bb88d0; font-family: 'Pacifico', cursive; font-weight: 400; font-size: clamp(1rem, 2vw, 1.2rem); letter-spacing: 1.5px; line-height: 1; }

@media (max-width: 900px) {
    body { padding-bottom: env(safe-area-inset-bottom); }
    .glass-panel { height: auto; min-height: 0; flex-grow: 1; max-height: none; border-radius: clamp(12px, 2vw, 20px); margin-bottom: clamp(0.5rem, 2vw, 1rem); }
    .app-footer { justify-content: center; flex-direction: column; text-align: center; border-radius: clamp(10px, 1.5vw, 16px); }
    
    /* Mobilde yapısal olarak normal akışa izin verdik */
    .game-layout { grid-template-columns: 1fr; overflow-y: auto; display: flex; flex-direction: column; }
    .chat-panel { min-height: 250px; flex-shrink: 0; }
    .play-area { overflow: visible; flex-grow: 1; min-height: 400px; }
    .settings-grid { grid-template-columns: 1fr !important; gap: 0.8rem !important; }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.error-shake { 
    animation: errorShake 0.4s ease; 
    border-color: var(--danger) !important; 
    color: var(--danger) !important; 
}