@import url('https://cdn.fontcdn.ir/Font/Persian/Shabnam.css');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Shabnam', 'B Nazanin', 'Tahoma', 'Arial', sans-serif;
    direction: rtl;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 800px;
    width: 100%;
    animation: fadeIn 0.5s ease-in-out;
    margin-top: 80px; /* Space for fixed header */
}

/* Make hero images responsive inside container (login page) */
.container img {
    max-width: 100%;
    height: auto;
    display: block;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to right, #ffffff, #f8f9fa); /* subtle gradient for modern look */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e1e5e9; /* thin border for separation */
    padding: 15px 20px; /* increased padding for better spacing */
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    flex: 0 0 auto;
    text-align: left;
}

.header-right {
    flex: 0 0 auto;
    text-align: right;
}

.header-right span {
    font-size: 20px; /* slightly larger for emphasis */
    color: #333;
    font-weight: 600; /* bolder for modern feel */
}

.logout-btn {
    background: linear-gradient(135deg, #dc3545, #c82333); /* gradient for modern look */
    color: white;
    padding: 10px 18px; /* slightly larger padding */
    border-radius: 25px; /* more rounded for modern */
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease; /* smooth transition */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* subtle shadow */
}

.logout-btn:hover {
    background: linear-gradient(135deg, #c82333, #a71e2a); /* darker gradient on hover */
    transform: translateY(-1px); /* lift effect */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); /* stronger shadow */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-weight: 700;
}

h2 {
    color: #555;
    margin-bottom: 20px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #666;
    font-weight: 500;
}

input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.member {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
    animation: slideIn 0.3s ease-in-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Mobile adjustments: reduce container padding and prevent overflow from large images */
@media (max-width: 520px) {
    .container {
        padding: 18px;
        margin-top: 100px;
        border-radius: 12px;
    }
    .container img {
        max-width: 100%;
        height: auto;
        box-shadow: none;
    }
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-left: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

button[type="submit"] {
    width: 100%;
    margin-top: 20px;
}

#addMember {
    background: #28a745;
    margin-top: 20px;
}

#addMember:hover {
    background: #218838;
}

.removeMember {
    background: #dc3545;
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.member-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.member-card h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 500;
}

.challenges-section {
    margin-top: 30px;
}

.challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.challenge-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    padding: 18px;
    text-align: center;
}

.challenge-card img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 10px;
    background: transparent !important;
    padding: 0 !important;
}

.challenge-card p {
    margin: 0;
    color: #333;
    font-weight: 500;
    font-size: 16px;
}

/* chalesh3 completed state */
.chalesh3-done { background:#f8d7da !important; border:1px solid #f5c6cb !important; color:#721c24 !important; }
.chalesh3-done p { color:#721c24 !important; }

a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
}

a:hover {
    text-decoration: underline;
}

.edit-btn {
    background: none;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    transition: color 0.3s ease;
    font-weight: 500;
    font-size: 14px;
}

.edit-btn:hover {
    color: #764ba2;
}

.add-btn {
    background: none;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    transition: color 0.3s ease;
    font-weight: 500;
    font-size: 14px;
    margin-left: 10px;
}

.add-btn:hover {
    color: #764ba2;
}

p {
    text-align: center;
    margin-top: 20px;
    color: #666;
    font-size: 16px;
}

.member-edit {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: slideIn 0.3s ease-in-out;
}

.modal h3 {
    margin-bottom: 20px;
    color: #333;
    font-weight: 600;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn.confirm {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.modal-btn.confirm:hover {
    background: linear-gradient(135deg, #c82333, #a71e2a);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.modal-btn.cancel {
    background: #6c757d;
    color: white;
}

.modal-btn.cancel:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Styles specific to the chalesh3 game UI */
.chalesh3-game .stage-box {
    background: linear-gradient(180deg,#ffffff, #fafafa);
    padding: 22px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
.chalesh3-game .timer { font-size:18px;color:#444;font-weight:700 }
.chalesh3-game #sentenceArea { font-size:20px;color:#222;margin-top:8px }
.chalesh3-game .word-boxes { display:flex;gap:10px;flex-wrap:nowrap;overflow-x:auto;justify-content:center;padding:10px 6px }
.chalesh3-game .word-cell { min-width:50px;min-height:44px;background:#f4f6fb;border-radius:8px;padding:8px 10px;display:inline-flex;align-items:center;justify-content:center;font-weight:700;color:#333;border:1px dashed transparent }
.chalesh3-game .word-cell.mask { background:#eef2fb;color:#9aa7d6 }
.chalesh3-game .letter-pool { display:flex;flex-wrap:wrap;gap:10px;margin-top:14px;justify-content:center }
.chalesh3-game .letter { padding:10px 14px;background:#fff;border:1px solid #e6e9f2;border-radius:10px;cursor:pointer;font-weight:700;box-shadow:0 6px 12px rgba(102,126,234,0.06);transition:all .15s ease }
.chalesh3-game .letter:hover { transform:translateY(-3px); box-shadow:0 12px 24px rgba(102,126,234,0.09) }
.chalesh3-game .letter.selected { background:#dff3e6;border-color:#b7e3c4 }
.chalesh3-game .controls { margin-top:18px }
.chalesh3-game .pick-btn { background: linear-gradient(180deg,#28a745,#198754); color:#fff; padding:10px 18px; border-radius:8px; border:0; font-weight:700 }
.chalesh3-game .pick-btn.secondary { background:#6c757d }
.chalesh3-game .pick-btn.success { background: linear-gradient(180deg,#2eb872,#1f8f4f) !important; box-shadow: 0 6px 20px rgba(46,184,114,0.18) !important; color: #fff !important; }
.chalesh3-game .pick-btn.error { background: linear-gradient(180deg,#dc3545,#b02a37) !important; box-shadow: 0 6px 20px rgba(220,53,69,0.18) !important; color: #fff !important; }
.chalesh3-game .reward { margin-top:14px;padding:16px;border-radius:10px;background:linear-gradient(180deg,#fffbe6,#fff4d6);border:1px solid #ffe8a8;display:none }

/* Generic completed challenge card style */
.challenge-done { background:#f8d7da !important; border:1px solid #f5c6cb !important; color:#721c24 !important; }
.challenge-done p { color:#721c24 !important; }

/* be more specific: target the card variant so it applies even if other rules exist */
.challenge-card.challenge-done { background:#f8d7da !important; border:1px solid #f5c6cb !important; color:#721c24 !important; }
.challenge-card.challenge-done p { color:#721c24 !important; }
.challenge-card.challenge-done .done-label { color:#721c24 !important; font-weight:700; margin-top:6px; }
.challenge-card.challenge-done img { background: transparent !important; padding: 0 !important; border-radius: 8px; display:block; }

.challenge-card.chalesh3-done { background:#f8d7da !important; border:1px solid #f5c6cb !important; color:#721c24 !important; }
.challenge-card.chalesh3-done p { color:#721c24 !important; }
.challenge-card.chalesh3-done .done-label { color:#721c24 !important; font-weight:700; margin-top:6px; }
.challenge-card.chalesh3-done img { background:#f8d7da; padding:6px; border-radius:10px; display:block; }
.chalesh3-game .reward strong { display:block;font-size:18px;margin-bottom:6px }
.chalesh3-game .reward .next-btn { background:#198754;color:#fff;padding:10px 16px;border-radius:8px;border:0;font-weight:700 }

@media (max-width:480px) {
    .chalesh3-game .word-cell { min-width:44px;min-height:40px;padding:6px 8px }
    .chalesh3-game .letter { padding:8px 10px;font-size:14px }
    .container { padding:18px }
}

/* Portrait-specific: allow placeholders to wrap so users can scroll vertically to see all words */
@media (max-width:480px) and (orientation: portrait) {
    .chalesh3-game .word-boxes {
        flex-wrap:wrap;
        overflow-x:visible;
        justify-content:flex-start;
        gap:8px;
        padding:8px;
    }
    .chalesh3-game .word-boxes .word-cell {
        flex: 0 1 auto;
        margin-bottom:8px;
    }
}

/* Make the challenge image area show a red background when completed */
.challenge-done img,
.chalesh3-done img {
    background: #f8d7da; /* light red */
    padding: 6px; /* reveal the red frame around the image */
    border-radius: 10px; /* match image rounding */
    display: block;
}