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

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
    background: repeating-linear-gradient(
        0deg,
        #4CAF50,
        #4CAF50 40px,
        #45a049 40px,
        #45a049 80px
    );
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.name-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 50;
}

.name-card {
    width: min(520px, 92vw);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    padding: 22px 20px;
    border: 4px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.name-title {
    font-size: 2em;
    font-weight: 900;
    color: #0d47a1;
    margin-bottom: 6px;
}

.name-subtitle {
    font-size: 1.15em;
    font-weight: 800;
    color: #424242;
    margin-bottom: 14px;
}

.name-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.35em;
    font-family: inherit;
    font-weight: 900;
    border-radius: 18px;
    border: 4px solid rgba(13, 71, 161, 0.25);
    outline: none;
    text-align: center;
}

.name-input:focus {
    border-color: rgba(13, 71, 161, 0.55);
    box-shadow: 0 0 0 6px rgba(13, 71, 161, 0.15);
}

.name-save-btn {
    margin-top: 14px;
    font-size: 1.55em;
    padding: 12px 30px;
    animation: none;
}

.dictation-letters {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 22px rgba(0,0,0,0.1);
}

.dictation-letter {
    height: clamp(44px, 9.5vw, 56px);
    border-radius: 16px;
    border: 4px solid rgba(94, 53, 177, 0.45);
    background: rgba(255, 255, 255, 0.95);
    color: #0d47a1;
    font-size: clamp(1.25rem, 6vw, 1.9rem);
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: 0.2s;
}

.dictation-letter:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 16px rgba(0,0,0,0.16);
}

.dictation-letter.row-active {
    background: rgba(179, 229, 252, 0.9);
    border-color: rgba(3, 169, 244, 0.65);
    box-shadow: 0 10px 16px rgba(3, 169, 244, 0.16);
}

.dictation-letter.correct {
    pointer-events: none;
}

.dictation-letter.wrong {
    animation: shake 0.5s;
}

.harakat-row {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 22px rgba(0,0,0,0.1);
}

.haraka-btn {
    height: 56px;
    min-width: 86px;
    border-radius: 16px;
    border: 4px solid rgba(13, 71, 161, 0.25);
    background: rgba(255, 255, 255, 0.95);
    color: #0d47a1;
    font-size: 1.8em;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: 0.2s;
}

.haraka-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 16px rgba(0,0,0,0.16);
}

.haraka-btn.active {
    border-color: rgba(156, 39, 176, 0.65);
    box-shadow: 0 0 0 6px rgba(156, 39, 176, 0.18);
}

.stadium-container {
    background: rgba(255, 255, 255, 0.95);
    border: 10px solid #FFF;
    border-radius: 30px;
    padding: 30px;
    width: 95%;
    max-width: 900px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6), inset 0 0 20px rgba(0,0,0,0.1);
}

h1 {
    color: #d32f2f;
    font-size: 2.8em;
    margin-bottom: 5px;
    text-shadow: 3px 3px #ffeb3b;
    animation: floating 3s ease-in-out infinite;
}

p {
    font-size: 1.3em;
    color: #424242;
    font-weight: bold;
}

.mode-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.95);
    color: #0d47a1;
    border: 3px solid rgba(13, 71, 161, 0.25);
    padding: 10px 14px;
    font-size: 1.05em;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 900;
    box-shadow: 0 8px 14px rgba(0,0,0,0.08);
    transition: 0.2s;
    margin-top: 0;
    animation: none;
}

.mode-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(13, 71, 161, 0.45);
}

.mode-btn.active {
    background: #0d47a1;
    color: #fff;
    border-color: #0d47a1;
    box-shadow: 0 10px 18px rgba(13, 71, 161, 0.25);
}

.tts-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.tts-test-btn {
    margin-top: 0;
    padding: 10px 18px;
    font-size: 1.1em;
    border-radius: 18px;
    animation: none;
}

.tts-test-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.tts-status {
    font-size: 1.05em;
    font-weight: 700;
    min-height: 1.2em;
}

.tts-status.tts-ok {
    color: #2e7d32;
}

.tts-status.tts-warn {
    color: #ef6c00;
}

.tts-status.tts-error {
    color: #c62828;
}

.tts-install {
    width: 100%;
    max-width: 520px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 243, 224, 0.9);
    border: 2px solid rgba(239, 108, 0, 0.35);
    box-shadow: 0 10px 18px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.tts-install-text {
    font-size: 1.02em;
    font-weight: 800;
    color: #5d4037;
}

.tts-install-link {
    display: inline-flex;
    align-self: center;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 14px;
    background: #ef6c00;
    color: #fff;
    text-decoration: none;
    font-weight: 900;
}

.tts-install-link:hover {
    background: #e65100;
}

.endgame {
    margin-top: 25px;
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(25, 118, 210, 0.12), rgba(255, 152, 0, 0.12));
    border: 3px solid rgba(25, 118, 210, 0.25);
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

.endgame-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.endgame-title {
    font-size: 1.7em;
    font-weight: 900;
    color: #0d47a1;
    text-shadow: 1px 1px rgba(255, 235, 59, 0.8);
}

.endgame-subtitle {
    font-size: 1.1em;
    font-weight: 800;
    color: #424242;
}

.endgame-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
}

.endgame-btn {
    background: #1e88e5;
    color: white;
    border: none;
    padding: 10px 16px;
    font-size: 1.1em;
    font-family: inherit;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 900;
    box-shadow: 0 8px 16px rgba(30, 136, 229, 0.3);
    transition: 0.2s;
    animation: none;
    margin-top: 0;
}

.endgame-btn:hover {
    background: #1565c0;
    transform: translateY(-2px);
}

.endgame-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.endgame-progress {
    min-width: 140px;
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    color: #2e7d32;
    font-weight: 900;
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}

.endgame-word-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    min-height: 54px;
}

.endgame-letter-slot {
    width: clamp(34px, 8.8vw, 44px);
    height: clamp(34px, 8.8vw, 44px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 5.6vw, 1.6rem);
    font-weight: 900;
    background: rgba(227, 242, 253, 0.95);
    border: 3px solid rgba(13, 71, 161, 0.25);
    color: #0d47a1;
}

.endgame-letter-slot.empty {
    color: rgba(13, 71, 161, 0.25);
    background: rgba(255, 255, 255, 0.85);
}

.endgame-letter-slot.filled {
    border-color: rgba(46, 125, 50, 0.55);
    background: rgba(232, 245, 233, 0.95);
    color: #2e7d32;
}

.endgame-message {
    margin-top: 12px;
    font-size: 1.2em;
    font-weight: 900;
    color: #2e7d32;
    min-height: 1.4em;
}

.progress-container {
    display: flex;
    justify-content: space-around;
    background: #1976d2;
    color: white;
    padding: 15px;
    border-radius: 15px;
    font-size: 1.5em;
    margin: 20px 0;
    box-shadow: 0 5px 15px rgba(25, 118, 210, 0.4);
}

.game-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 45%;
}

.item {
    background: #fff;
    border: 6px solid #2196F3;
    border-radius: 20px;
    height: clamp(64px, 14vw, 90px);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

/* تنسيق الحرف */
.letter-item {
    font-size: clamp(2.3rem, 11vw, 3.5rem);
    font-weight: 900;
    color: #1976d2;
}

/* تنسيق الكلمة (البديل للصور) */
.word-item {
    font-size: clamp(1.45rem, 8vw, 2.2rem);
    font-weight: 900;
    color: #d84315; /* لون مختلف للكلمات لتمييزها */
    background: #fff3e0;
    border-color: #ff9800;
}

.word-item.word-hidden {
    color: #5d4037;
    background: rgba(255, 243, 224, 0.9);
    border-color: rgba(255, 152, 0, 0.9);
}

.word-item.word-hidden::after {
    content: "🔊";
    font-size: 1.15em;
    margin-inline-start: 10px;
}

.item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 20px rgba(0,0,0,0.2);
}

/* التحديد والإجابات */
.selected {
    border-color: #9c27b0;
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(156, 39, 176, 0.6);
}

.correct {
    border-color: #4CAF50 !important;
    background-color: #e8f5e9 !important;
    color: #2e7d32 !important;
    animation: tada 1s;
    pointer-events: none;
    opacity: 0.8;
}

.wrong {
    border-color: #f44336 !important;
    animation: shake 0.5s;
}

.hint {
    animation: pulseHint 1s infinite;
    border-color: #4CAF50 !important;
    box-shadow: 0 0 30px #4CAF50;
}

button {
    background: #ff9800;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.8em;
    font-family: inherit;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 30px;
    font-weight: bold;
    box-shadow: 0 8px 15px rgba(255, 152, 0, 0.4);
    transition: 0.3s;
    animation: pulseHint 1.5s infinite;
}

button:hover {
    background: #f57c00;
    transform: scale(1.05);
}

.hidden {
    display: none;
}

@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes tada {
    0% { transform: scale3d(1, 1, 1); }
    10%, 20% { transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg); }
    30%, 50%, 70%, 90% { transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); }
    40%, 60%, 80% { transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); }
    100% { transform: scale3d(1, 1, 1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-15px); }
    50% { transform: translateX(15px); }
    75% { transform: translateX(-15px); }
}

@keyframes pulseHint {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 15px rgba(76, 175, 80, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

@media (max-width: 480px) {
    .dictation-letters {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .progress-container {
        font-size: 1.1em;
        padding: 10px;
    }
}

@media (min-width: 481px) and (max-width: 820px) {
    .dictation-letters {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .progress-container {
        font-size: 1.25em;
    }
}
