:root {
    --duo-green: #58cc02; --duo-green-dark: #46a302;
    --duo-blue: #1cb0f6; --duo-blue-dark: #1899d6;
    --duo-bg: #ffffff; --duo-text: #4b4b4b; --duo-gray: #e5e5e5;
}

/* ================= تنظیمات پایه ================= */
html, body {
    margin: 0; padding: 0; 
    font-family: Tahoma, Arial, sans-serif;
    background-color: var(--duo-bg); 
    color: var(--duo-text);
    height: 100%; /* حتما 100 درصد باشد تا با آی‌فریم هماهنگ شود */
    overflow: hidden; /* قفل کردن کل صفحه برای جلوگیری از لرزش */
    touch-action: manipulation;
}

.app-container {
    width: 100%; max-width: 800px; 
    height: 100%;
    position: relative; margin: 0 auto;
    display: flex; flex-direction: column;
}

/* مدیریت صفحات */
.screen {
    display: none; flex-direction: column; 
    height: 100%;
    padding: 15px; box-sizing: border-box;
    animation: fadeIn 0.3s ease;
    overflow-y: auto; 
}
.screen.active { display: flex; }

/* قفل کردن صفحه بازی برای میخکوب کردن دکمه‌ها در پایین */
#game-screen {
    overflow: hidden !important; 
}

@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ================= استایل‌های منو ================= */
.menu-content {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center;
    width: 100%; margin: auto;
}

.game-logo { font-size: 70px; margin-bottom: 10px; animation: bounceIn 1s ease; }
.game-title { font-size: 28px; font-weight: 900; color: var(--duo-text); margin: 0 auto 10px auto; text-align: center; width: 100%; }
.welcome-text { font-size: 16px; margin: 0 auto 20px auto; color: #777; text-align: center; width: 100%; }

.user-stats-box {
    display: flex; justify-content: center; gap: 15px;
    width: 100%; max-width: 300px; margin: 0 auto 30px auto;
}
.stat-item {
    background: var(--duo-gray); padding: 10px; border-radius: 15px;
    flex: 1; display: flex; flex-direction: column; align-items: center;
    border: 2px solid #ddd;
}
.stat-label { font-size: 12px; color: #888; margin-bottom: 5px; font-weight: bold; }
.stat-value { font-size: 16px; font-weight: 900; color: var(--duo-text); }

.menu-buttons { 
    display: flex; flex-direction: column; gap: 15px; 
    width: 100%; max-width: 300px; margin: 0 auto;
}

button {
    font-family: Tahoma, Arial, sans-serif; font-size: 16px; font-weight: bold;
    padding: 15px; border-radius: 15px; border: none; cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s; user-select: none;
    width: 100%; text-align: center;
}

.btn-primary { background: var(--duo-green); color: white; box-shadow: 0 5px 0 var(--duo-green-dark); }
.btn-primary:active { transform: translateY(5px); box-shadow: 0 0 0 var(--duo-green-dark); }
.btn-secondary { background: var(--duo-blue); color: white; box-shadow: 0 5px 0 var(--duo-blue-dark); }
.btn-secondary:active { transform: translateY(5px); box-shadow: 0 0 0 var(--duo-blue-dark); }
.btn-multiplayer { background: #ff4b4b; color: white; box-shadow: 0 5px 0 #cc0000; }
.btn-multiplayer:active { transform: translateY(5px); box-shadow: 0 0 0 #cc0000; }

.credit-footer {
    text-align: center; font-size: 12px; color: #aaa; padding: 15px 0;
    border-top: 2px dashed var(--duo-gray); margin: auto auto 0 auto; line-height: 1.8;
    width: 100%; flex-shrink: 0;
}
.credit-footer strong { color: var(--duo-blue); font-size: 14px; }
.credit-footer span { color: var(--duo-green); font-weight: bold; }

/* ================= استایل‌های بازی ================= */
.header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; background: var(--duo-gray); border-radius: 15px; font-weight: bold;
    flex-shrink: 0;
}

.btn-back {
    background: transparent; border: 2px solid #ccc; color: var(--duo-text);
    padding: 8px 15px; border-radius: 10px; box-shadow: none; font-size: 14px; width: auto;
}
.btn-back:active { background: #ddd; transform: translateY(2px); }

/* بخش کلمات (این بخش به صورت هوشمند اسکرول می‌خورد) */
.words-container { 
    flex: 1; /* پر کردن تمام فضای خالی وسط صفحه */
    margin-top: 15px; 
    display: flex; flex-wrap: wrap; gap: 10px; 
    justify-content: center; align-content: flex-start; 
    direction: ltr;
    overflow-y: auto; /* اسکرول فقط برای این بخش */
    padding-bottom: 10px;
}
.words-container::-webkit-scrollbar { width: 0px; background: transparent; }

.word-box { display: flex; gap: 5px; flex-direction: column; align-items: center; }
.empty-letter { width: 30px; height: 35px; background: var(--duo-gray); border-radius: 8px; border: 2px solid #ccc; display: inline-block; }

.word-box.found { 
    background: var(--duo-green); color: white; border: none; 
    box-shadow: 0 4px 0 var(--duo-green-dark); animation: bounceIn 0.5s ease; 
    padding: 5px 10px; letter-spacing: 5px; justify-content: center; 
    align-items: center; font-size: 18px; font-weight: bold; border-radius: 10px; 
    width: auto; display: inline-flex; margin-bottom: 5px;
}
.word-meaning {
    font-size: 11px; color: #e0f7fa; margin-top: 5px;
    font-weight: normal; letter-spacing: normal;
    background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px;
}

/* ================= بخش پایینی بازی (میخکوب شده) ================= */
.action-buttons { 
    display: flex; justify-content: center; gap: 8px; 
    margin-top: 10px; width: 100%; padding: 0 5px; box-sizing: border-box;
    flex-shrink: 0; /* جلوگیری از فشرده شدن */
}
.btn-action, .btn-hint {
    border: none; padding: 8px 10px; border-radius: 15px;
    font-weight: bold; font-size: 12px; cursor: pointer;
    transition: transform 0.1s; flex: 1; max-width: 120px;
}
.btn-clear { background: #ff4b4b; color: white; box-shadow: 0 4px 0 #cc0000; }
.btn-clear:active { transform: translateY(4px); box-shadow: 0 0 0 #cc0000; }
.btn-shuffle { background: #af52de; color: white; box-shadow: 0 4px 0 #8b38b8; }
.btn-shuffle:active { transform: translateY(4px); box-shadow: 0 0 0 #8b38b8; }
.btn-hint { background: #ffc800; color: #b37700; box-shadow: 0 4px 0 #d9a000; }
.btn-hint:active { transform: translateY(4px); box-shadow: 0 0 0 #d9a000; }

.input-area { 
    min-height: 50px; display: flex; justify-content: center; gap: 8px; 
    margin: 10px 0; padding: 5px; border-bottom: 3px dashed var(--duo-gray); 
    direction: ltr; flex-shrink: 0;
}

.letters-row { 
    display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; 
    margin-bottom: 15px; direction: ltr; flex-shrink: 0;
}

.letter-btn { 
    width: 45px; height: 45px; background: var(--duo-blue); color: white; 
    border-radius: 12px; display: flex; justify-content: center; align-items: center; 
    font-size: 22px; font-weight: bold; box-shadow: 0 5px 0 var(--duo-blue-dark); 
    cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; 
}
.letter-btn:active { transform: translateY(5px); box-shadow: 0 0 0 var(--duo-blue-dark); }

/* ================= افکت‌ها ================= */
.hint-revealed { background: #fff3c4 !important; color: #d9a000 !important; border-color: #ffc800 !important; font-size: 20px; font-weight: bold; display: flex; justify-content: center; align-items: center; }
.error-shake { animation: simple-shake 0.4s ease-in-out; border-bottom: 3px solid #ff4b4b !important; background-color: #ffebeb !important; border-radius: 15px; }

@keyframes simple-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
@keyframes bounceIn { 0% { transform: scale(0.5); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes fall { 0% { transform: translateY(-100px) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

.confetti { position: absolute; width: 10px; height: 10px; background-color: #f00; z-index: 999; animation: fall 1s linear forwards; }

/* ================= استایل‌های لابی و لیدربورد ================= */
.leaderboard-container { margin-top: 20px; background: #f7f7f7; border-radius: 15px; padding: 15px; border: 2px solid var(--duo-gray); overflow-y: auto; flex: 1; }
#leaderboard-list { list-style: none; padding: 0; margin: 0; }
#leaderboard-list li { display: flex; justify-content: space-between; padding: 12px 5px; border-bottom: 1px solid #ddd; font-weight: bold; font-size: 16px;}

.lobby-container { margin-top: 20px; background: #fff; border-radius: 15px; padding: 20px; border: 2px solid var(--duo-gray); flex: 1; display: flex; flex-direction: column; }
.lobby-status { text-align: center; font-weight: bold; color: #ff9800; margin-bottom: 15px; animation: pulse 1.5s infinite; }
.player-list { list-style: none; padding: 0; margin: 0; flex: 1; overflow-y: auto; }
.player-list li { background: var(--duo-gray); padding: 10px 15px; border-radius: 10px; margin-bottom: 10px; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.player-list li::before { content: '🟢'; font-size: 12px; }

.join-box { background: var(--duo-gray); padding: 15px; border-radius: 15px; display: flex; flex-direction: column; gap: 10px; margin-top: 20px; border: 2px dashed #ccc; }
#join-code-input { padding: 12px; border-radius: 10px; border: 2px solid #ccc; font-size: 18px; text-align: center; font-weight: bold; letter-spacing: 5px; font-family: Tahoma, Arial, sans-serif; outline: none; }
#join-code-input:focus { border-color: var(--duo-blue); }

/* ================= بهینه‌سازی نهایی برای موبایل ================= */
@media (max-width: 450px) {
    .letter-btn { width: 42px; height: 42px; font-size: 20px; }
    .empty-letter { width: 26px; height: 32px; }
    .word-box.found { font-size: 15px; padding: 4px 8px; }
    .word-meaning { font-size: 9px; }
    .btn-action, .btn-hint { font-size: 11px; padding: 8px 5px; }
}
/* --- استایل‌های لیست لابی آنلاین --- */
.player-list {
    list-style: none !important; /* حذف نقطه پیش‌فرض مرورگر */
    padding: 0;
    margin: 0;
}

.player-list li {
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--duo-text, #333);
    margin-bottom: 12px;
    background: #f7f7f7;
    padding: 10px 15px;
    border-radius: 10px;
}

/* ساخت دایره سبز با CSS به جای ایموجی */
.status-dot {
    width: 12px;
    height: 12px;
    background-color: #58cc02; /* رنگ سبز */
    border-radius: 50%; /* تبدیل به دایره */
    display: inline-block;
    margin-left: 10px; /* فاصله از اسم */
    box-shadow: 0 0 8px rgba(88, 204, 2, 0.6); /* افکت درخشش ملایم */
    animation: pulseDot 1.5s infinite; /* انیمیشن چشمک‌زن */
}

/* انیمیشن نفس کشیدن دایره سبز */
@keyframes pulseDot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(88, 204, 2, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(88, 204, 2, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(88, 204, 2, 0); }
}