@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    min-height: 100vh;
    min-height: 100dvh;
    color: #fff;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    touch-action: manipulation;
}

.screen { display: none; min-height: 100vh; min-height: 100dvh; width: 100%; }
.screen.active { display: flex; align-items: center; justify-content: center; }

.container { text-align: center; padding: 1.5rem; max-width: 480px; width: 100%; }
.container.center { display: flex; flex-direction: column; align-items: center; }

.hidden { display: none !important; }

/* ===== LOGO ===== */
.logo { margin-bottom: 0.5rem; }
.logo-svg { width: 120px; height: 120px; filter: drop-shadow(0 0 15px rgba(229,62,62,0.3)); }

.title {
    font-size: 2.8rem; font-weight: 900; letter-spacing: 3px;
    background: linear-gradient(135deg, #f56565, #ed64a6, #9f7aea);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.subtitle { color: #718096; font-size: 1rem; margin-bottom: 1.5rem; font-weight: 600; }

/* ===== FORM ===== */
.form-group { margin-bottom: 1rem; text-align: left; width: 100%; }
.form-group label { display: block; color: #a0aec0; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.3rem; }

input[type="text"], input[type="password"] {
    width: 100%; padding: 0.8rem 1rem; border-radius: 12px; border: 2px solid #2d3748;
    background: rgba(255,255,255,0.06); color: #fff; font-family: 'Nunito', sans-serif;
    font-size: 1rem; font-weight: 600; outline: none; transition: border-color 0.3s;
}
input:focus { border-color: #667eea; }
input::placeholder { color: #4a5568; }

/* ===== DİL SEÇİMİ ===== */
.lang-select { display: flex; gap: 0.6rem; justify-content: center; margin-bottom: 1.5rem; }
.lang-btn {
    padding: 0.5rem 1.2rem; border-radius: 10px; border: 2px solid transparent;
    background: rgba(255,255,255,0.06); color: #a0aec0; font-family: 'Nunito', sans-serif;
    font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.lang-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.lang-btn.selected { border-color: #667eea; background: rgba(102,126,234,0.15); color: #fff; }

/* ===== BUTONLAR ===== */
.btn {
    border: none; border-radius: 12px; padding: 0.85rem 1.5rem;
    font-family: 'Nunito', sans-serif; font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: all 0.25s; display: flex; align-items: center;
    justify-content: center; gap: 0.5rem; width: 100%;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.btn:active { transform: translateY(0); }

.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.btn-random { background: linear-gradient(135deg, #f6ad55, #ed8936); color: #fff; }
.btn-accent { background: linear-gradient(135deg, #38b2ac, #319795); color: #fff; }
.btn-secondary { background: linear-gradient(135deg, #f093fb, #f5576c); color: #fff; }
.btn-outline { background: transparent; color: #a0aec0; border: 2px solid #4a5568; }
.btn-outline:hover { border-color: #667eea; color: #fff; }

.btn-easy { background: linear-gradient(135deg, #48bb78, #38a169); color: #fff; }
.btn-medium { background: linear-gradient(135deg, #ed8936, #dd6b20); color: #fff; }
.btn-hard { background: linear-gradient(135deg, #fc5c65, #eb3b5a); color: #fff; }

.btn-small { padding: 0.5rem 1rem; font-size: 0.85rem; width: auto; }

.btn-home { width: auto; margin-bottom: 1rem; align-self: flex-start; }
.btn-back-home { width: auto; margin-top: 1.5rem; }
.menu-btns { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1rem; }
.diff-btns { display: flex; gap: 0.6rem; justify-content: center; }
.diff-btns .btn { width: auto; flex: 1; }

.sub-section { margin-top: 1rem; animation: fadeUp 0.3s ease; }
.section-label { color: #a0aec0; font-weight: 700; margin-bottom: 0.6rem; }

.error { color: #fc8181; font-size: 0.9rem; font-weight: 600; margin-top: 0.5rem; }

/* ===== BEKLEMİ ===== */
.room-code-display { margin-bottom: 2rem; }
.room-code-display p { color: #718096; font-weight: 700; margin-bottom: 0.3rem; }
.room-code-display h1 {
    font-size: 4rem; letter-spacing: 12px; font-weight: 900;
    background: linear-gradient(135deg, #667eea, #9f7aea);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: 0.8rem;
}

.spinner {
    width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.1);
    border-top-color: #667eea; border-radius: 50%; animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}
.spinner.small { width: 24px; height: 24px; border-width: 3px; }

.wait-text { color: #a0aec0; font-weight: 700; font-size: 1.1rem; }
.wait-hint { color: #4a5568; font-size: 0.9rem; margin-top: 0.5rem; }

/* ===== KELİME GİRİŞ ===== */
.screen-title {
    font-size: 1.8rem; font-weight: 800; margin-bottom: 0.3rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.screen-sub { color: #718096; margin-bottom: 1rem; }
.opponent-label { color: #ed8936; font-weight: 700; margin-bottom: 1rem; font-size: 0.95rem; }

/* ===== OYUN ===== */
.game-container {
    width: 100%; max-width: 700px; margin: 0 auto; padding: 1rem;
    min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative;
}

.game-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.5rem; }
.game-info { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.badge {
    padding: 0.25rem 0.7rem; border-radius: 8px; font-size: 0.8rem; font-weight: 700;
}
.badge-blue { background: rgba(102,126,234,0.2); color: #667eea; }
.badge-orange { background: rgba(237,137,54,0.2); color: #ed8936; }

.opponent-status { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: #718096; }
.status-dot { width: 8px; height: 8px; background: #48bb78; border-radius: 50%; animation: pulse 1.5s infinite; }

.game-body { display: flex; gap: 1.5rem; flex: 1; align-items: flex-start; }

/* Hangman */
.hangman-area { flex-shrink: 0; text-align: center; }
.hangman-svg { width: 180px; height: 225px; }

.gallows { stroke: #4a5568; stroke-width: 4; stroke-linecap: round; }
.part { stroke: #e53e3e; stroke-width: 3; fill: none; stroke-linecap: round; opacity: 0; transition: opacity 0.4s; }
.part.show { opacity: 1; animation: pop 0.4s ease; }

.face { transition: opacity 0.3s; }

.hearts { margin-top: 0.5rem; display: flex; justify-content: center; gap: 0.2rem; font-size: 1.1rem; }
.heart { transition: all 0.3s; }
.heart.lost { filter: grayscale(1); opacity: 0.3; transform: scale(0.7); }

/* Kelime */
.word-area { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1rem; }

.word-display { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.letter-box {
    width: 40px; height: 50px; border-bottom: 3px solid #4a5568;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 800; color: #fff; transition: all 0.3s; text-transform: uppercase;
}
.letter-box.revealed { border-bottom-color: #48bb78; animation: revealPop 0.4s ease; }
.letter-box.wrong-reveal { border-bottom-color: #e53e3e; color: #e53e3e; }

.wrong-section { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.wrong-label { color: #718096; font-size: 0.8rem; font-weight: 700; }
.wrong-list { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.wrong-tag {
    background: rgba(229,62,62,0.2); color: #fc8181;
    padding: 0.15rem 0.45rem; border-radius: 6px; font-size: 0.85rem; font-weight: 700;
    animation: pop 0.3s ease;
}

/* Klavye */
.keyboard { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: center; max-width: 500px; }
.key {
    width: 40px; height: 40px; border: none; border-radius: 8px;
    background: rgba(255,255,255,0.1); color: #e2e8f0;
    font-family: 'Nunito', sans-serif; font-size: 0.95rem; font-weight: 700;
    cursor: pointer; transition: all 0.15s; text-transform: uppercase;
}
.key:hover:not(:disabled) { background: rgba(102,126,234,0.4); transform: translateY(-1px); }
.key:active:not(:disabled) { transform: translateY(0); }
.key:disabled { cursor: default; }
.key.correct { background: rgba(72,187,120,0.3); color: #48bb78; }
.key.wrong { background: rgba(229,62,62,0.15); color: #e53e3e; opacity: 0.5; }

/* Sonuç */
.result-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    z-index: 20; background: rgba(15,12,41,0.9); backdrop-filter: blur(6px);
}
.result-box {
    text-align: center; padding: 2rem; background: linear-gradient(135deg, rgba(45,55,72,0.95), rgba(26,32,44,0.95));
    border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); max-width: 380px; width: 90%;
    animation: fadeUp 0.4s ease;
}
.result-icon { font-size: 3.5rem; margin-bottom: 0.8rem; }
.result-box h2 { font-size: 1.6rem; margin-bottom: 0.4rem; }
.result-box p { color: #a0aec0; margin-bottom: 1rem; font-size: 0.95rem; }
.result-btns { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.result-btns .btn { width: auto; min-width: 130px; }

/* Final */
.final-icon { font-size: 3.5rem; margin-bottom: 0.5rem; }
.scoreboard { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; justify-content: center; width: 100%; }
.score-card {
    background: rgba(255,255,255,0.05); border-radius: 14px; padding: 1.2rem;
    flex: 1; max-width: 180px; border: 2px solid rgba(255,255,255,0.08); transition: all 0.3s;
}
.score-card.winner { border-color: #48bb78; box-shadow: 0 0 20px rgba(72,187,120,0.15); }
.score-card h3 { color: #667eea; font-size: 1rem; margin-bottom: 0.4rem; }
.sc-word { font-size: 0.8rem; color: #718096; margin-bottom: 0.3rem; }
.sc-result { font-size: 1.2rem; font-weight: 800; }
.sc-result.win { color: #48bb78; }
.sc-result.lose { color: #e53e3e; }
.vs { font-size: 1.2rem; font-weight: 900; color: #4a5568; }

/* ===== ANİMASYONLAR ===== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes revealPop { 0% { transform: scale(0) rotateX(90deg); } 60% { transform: scale(1.1) rotateX(0); } 100% { transform: scale(1); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shake { animation: shake 0.35s ease; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .game-body { flex-direction: column; align-items: center; }
    .hangman-svg { width: 130px; height: 165px; }
    .title { font-size: 2.2rem; }
    .letter-box { width: 30px; height: 40px; font-size: 1.2rem; border-bottom-width: 2px; }
    .key { width: 32px; height: 38px; font-size: 0.8rem; border-radius: 6px; }
    .keyboard { gap: 0.25rem; }
    .scoreboard { flex-direction: column; }
    .score-card { max-width: 100%; width: 100%; }
    .game-container { padding: 0.8rem; }
    .game-top { margin-bottom: 0.3rem; }
    .container { padding: 1rem; }
    .logo-svg { width: 90px; height: 90px; }
    .btn { padding: 0.75rem 1.2rem; font-size: 0.95rem; }
    .room-code-display h1 { font-size: 3rem; letter-spacing: 8px; }
    .result-box { padding: 1.5rem; }
    .hearts { font-size: 1rem; }
}

/* Çok küçük ekranlar (eski telefonlar) */
@media (max-width: 380px) {
    .letter-box { width: 26px; height: 36px; font-size: 1rem; }
    .key { width: 28px; height: 34px; font-size: 0.75rem; }
    .hangman-svg { width: 110px; height: 140px; }
    .title { font-size: 1.8rem; }
    .word-display { gap: 0.3rem; }
}

/* Yatay telefon */
@media (max-height: 500px) and (orientation: landscape) {
    .game-body { flex-direction: row; align-items: flex-start; }
    .hangman-svg { width: 120px; height: 150px; }
    .screen { min-height: auto; }
    .game-container { min-height: auto; padding: 0.5rem; }
}
