:root {
    --bg-color: #121212;
    --off-color: #444444;
    --on-color: #00adb5;
    --text-color: #eeeeee;
    --hint-color: #ff4757;
    --rules-color: #5765f2;
}

@font-face {
    font-family: 'Shabnam';
    src: url('fonts/Shabnam.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

* {
    font-family: 'Shabnam', Tahoma, sans-serif;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    direction: rtl;
    display: flex;
    justify-content: center;
    align-items: center; 
    min-height: 100vh;
    overflow-y: auto; 
	color-scheme: dark;
}

.container {
    text-align: center;
    padding: 10px;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- لوگو و انيميشن ورودي --- */
.game-header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 5px;
    flex-shrink: 0;
}

.game-logo {
    height: 60px !important; /* فشرده شده براي موبايل */
    width: auto !important;
    max-width: 200px !important;
    object-fit: contain;
    margin-bottom: 2px !important;
    filter: drop-shadow(0 0 10px rgba(0, 173, 181, 0.4));
    animation: logoFadeIn 1.2s ease-out forwards;
}

@keyframes logoFadeIn {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-title {
    font-size: 0.95rem !important;
    margin: 0 !important;
    line-height: 1.2;
}

.stats-container {
    display: flex;
    justify-content: space-between; /* يکي راست، يکي چپ */
    width: 82vmin;
    max-width: 380px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: bold;
}

.stat-item {
    background: rgba(0, 173, 181, 0.1);
    padding: 5px 12px;
    border-radius: 20px;
    color: var(--on-color);
    border: 1px solid rgba(0, 173, 181, 0.3);
    display: flex;
    gap: 5px;
}

#optimal-count {
    color: var(--hint-color); /* عدد بهينه را با رنگ متفاوت نشان مي‌دهيم */
}

/* --- بورد بازي (فشرده شده) --- */
.board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 6px; /* فاصله کمتر بين خانه‌ها */
    width: 82vmin;
    height: 82vmin;
    max-width: 380px;
    max-height: 380px;
    margin: 5px auto !important;
    touch-action: none;
}
.board {
    background-color: #1a1a1a;
    padding: 10px;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.cell {
    background-color: var(--off-color);
    border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.cell.is-on {
    background-color: var(--on-color);
    box-shadow: 0 0 15px var(--on-color);
}

.cell:active { transform: scale(0.92); }

/* --- استايل دايره راهنما --- */
.hint-dot {
    width: 14px;
    height: 14px;
    background-color: var(--hint-color);
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
    z-index: 10;
}

/* --- دکمه‌ها (فشرده شده) --- */
.controls-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 8px;
    width: 82vmin;
    max-width: 380px;
    margin: 10px auto !important;
}

button {
    height: 44px !important;
    font-size: 0.8rem !important;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    padding: 0 4px;
}

#reset-btn { background-color: #247A60; }
#hint-btn { background-color: #D78C65; }
#rules-btn { background-color: #247A60; }

button:active { transform: scale(0.96); }

/* --- تنظيمات مخصوص موبايل --- */
/* --- تنظيمات مخصوص موبايل با قابليت اسکرول امن --- */
@media (max-width: 600px) {
    body {
        /* تغيير از fixed به relative براي اجازه دادن به اسکرول */
        position: relative; 
        width: 100%;
        height: auto;
        min-height: 100vh;
        /* فعال کردن اسکرول عمودي و غيرفعال کردن اسکرول افقي */
        overflow-y: auto;
        overflow-x: hidden;
        /* جلوگيري از پرش صفحه در iOS */
        -webkit-overflow-scrolling: touch;
    }
    
    .container {
        /* حذف height: 100% براي اينکه کانتينر با محتوا رشد کند */
        height: auto;
        padding: 10px 10px 30px 10px; /* پدينگ بيشتر در پايين براي راحتي اسکرول */
        justify-content: flex-start;
    }
}

/* گوشي‌هاي خيلي کوتاه */
@media (max-height: 600px) {
    .game-logo { height: 45px !important; }
    .board { width: 75vmin; height: 75vmin; }
    button { height: 40px !important; }
}

/* --- مودال راهنما --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-color);
    border: 2px solid var(--on-color);
    margin: 10vh auto;
    padding: 20px;
    width: 85%;
    max-width: 380px;
    border-radius: 15px;
    position: relative;
    color: white;
    text-align: right;
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-btn {
    position: absolute;
    left: 15px;
    top: 5px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--hint-color);
}

/* دسکتاپ */
@media (min-width: 601px) {
    .container {
        padding: 20px;
    }
    .game-logo {
        height: 80px !important;
    }
}