:root {
    --bg-color: #1a202c;
    --card-bg: #2d3748;
    --text-color: #edf2f7;
    --primary-color: #e53e3e; /* Red for danger/hangman */
    --accent-color: #48bb78; /* Green for success */
    --key-bg: #4a5568;
    --key-hover: #718096;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
}

.container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: center;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.home-btn-sm {
    text-decoration: none;
    font-size: 1.5rem;
    padding: 5px;
    border: none;
    background: none;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 5px;
}

.level-badge {
    display: inline-block;
    background: var(--card-bg);
    padding: 5px 15px;
    border-radius: 20px;
    margin-top: 10px;
    font-weight: bold;
}

.game-area {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Drawing Area */
.hangman-draw {
    min-height: 250px;
}

svg {
    stroke: var(--text-color);
    stroke-width: 4;
    fill: none;
    stroke-linecap: round;
}

.draw {
    transition: opacity 0.5s;
}

.hidden {
    opacity: 0;
}

/* Word Display */
.word-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    direction: ltr; /* To handle Arabic words correctly if needed, but flex-row-reverse usually better for whole phrases? */
}
/* Reversing flow to make arabic read right to left visually but DOM order matches string */
.word-display {
    flex-direction: row-reverse;
}

.letter-slot {
    width: 40px;
    height: 50px;
    border-bottom: 3px solid var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.letter-slot.space {
    border-bottom: none;
    width: 20px;
}

.letter-slot.revealed {
    color: var(--text-color);
    animation: popIn 0.3s;
}

.letter-slot.missed {
    color: var(--primary-color);
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    direction: rtl; /* Arabic keyboard layout */
}

.key {
    background: var(--key-bg);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
}

.key:hover:not(:disabled) {
    background: var(--key-hover);
    transform: translateY(-2px);
}

.key:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.key.correct {
    background: var(--accent-color);
}

.key.wrong {
    background: var(--primary-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 15px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 2px solid var(--text-color);
}

.action-btn {
    background: var(--accent-color);
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1.2rem;
    margin-top: 20px;
    cursor: pointer;
    display: block;
    width: 100%;
    font-family: inherit;
    font-weight: bold;
}

.action-btn:hover {
    filter: brightness(1.1);
}

.home-link {
    display: inline-block;
    margin-top: 15px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.7;
}

.home-link:hover {
    opacity: 1;
}

@media (max-width: 500px) {
    .letter-slot {
        width: 30px;
        font-size: 1.2rem;
    }
    .key {
        padding: 8px 10px;
        font-size: 1rem;
    }
}
