* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #0b0f19; /* Dark Night Sky */
    --primary: #E23636; /* Spidey Red */
    --primary-dark: #B11313;
    --secondary: #0D47A1; /* Spidey Blue */
    --secondary-dark: #002171;
    --accent: #FFFFFF; /* White Webs */
    --accent-dark: #B0BEC5;
    --success: #69F0AE; /* Bright Green */
    --rose: #E23636; /* Replaced Pink with Red */
    --text: #ffffff; /* White text for dark mode */
    --white: #ffffff;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5); 
    --border-dark: 2px solid rgba(255, 255, 255, 0.2);
}

body {
    font-family: 'Baloo Bhaijaan 2', cursive;
    background: linear-gradient(135deg, #0b0f19, #001a33, #330000);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: var(--text);
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding: 2rem 1rem;
}

/* خلفية التطبيق - عالم البطل */
.enchanted-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2;
    background: linear-gradient(135deg, #0b0f19, #001a33, #330000);
    overflow: hidden;
}

.magic-sparkle {
    position: absolute;
    color: #FFCA28;
    opacity: 0.8;
    font-size: 2rem;
    z-index: -1;
    animation: twinkle infinite alternate ease-in-out;
}

.bg-shell {
    position: absolute;
    font-size: 3rem;
    color: rgba(129, 212, 250, 0.6);
    z-index: -1;
    opacity: 0.6;
    animation: floatUp infinite linear;
}

@keyframes twinkle {
    0% { transform: scale(0.8); opacity: 0.3; }
    100% { transform: scale(1.2); opacity: 1; }
}

@keyframes floatUp {
    0% { transform: translateY(100vh) scale(0.5); opacity: 0; }
    20% { opacity: 0.8; }
    100% { transform: translateY(-200px) scale(1.5); opacity: 0; }
}

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 80vh;
}

.container {
    background: rgba(15, 23, 42, 0.85);
    border: 4px solid var(--primary);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(226, 54, 54, 0.3);
    width: 90%;
    max-width: 500px;
    text-align: center;
    transition: all 0.4s ease;
    z-index: 10;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.profile-avatar-container {
    margin-top: -80px; /* سحب الصورة للأعلى لتعطي تداخلاً جميلاً */
    margin-bottom: 20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-color); /* لتغطية الخلفية المربعة للصورة */
    border: 4px solid var(--primary);
    box-shadow: 0 10px 25px rgba(226, 54, 54, 0.8);
    overflow: hidden; /* قص الصورة على شكل دائرة */
    display: flex;
    justify-content: center;
    align-items: center;
    animation: spideyGlow 2s infinite alternate;
}

.captain-avatar {
    width: 100%;
    height: 100%;
}

.captain-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes spideyGlow {
    from { box-shadow: 0 10px 15px rgba(226, 54, 54, 0.4); }
    to { box-shadow: 0 10px 30px rgba(226, 54, 54, 1); }
}

/* Audio & Text wrappers */
.text-with-audio {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 0.5rem;
}
.subtitle-audio {
    margin-bottom: 2.5rem;
}

.title {
    font-size: 3rem;
    color: var(--text);
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin: 0;
}

.subtitle {
    font-size: 1.4rem;
    color: var(--accent-dark);
    line-height: 1.6;
    font-weight: 700;
    margin: 0;
}

/* أزرار السماعة */
.speak-btn {
    background: rgba(226, 54, 54, 0.2);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(226, 54, 54, 0.2);
    padding: 0;
}
.speak-btn:hover {
    transform: scale(1.1);
    background: var(--primary);
    color: white;
}
.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 2rem;
    width: 100%;
}

.input-audio-wrapper {
    position: relative;
    width: 100%;
    max-width: 350px;
}

input {
    width: 100%;
    padding: 15px 20px 15px 60px; /* مسافة لليسار لوضع زر الصوت */
    font-size: 1.6rem;
    border: 3px solid var(--primary-dark);
    border-radius: 15px;
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    color: #0b0f19;
    transition: all 0.3s;
    font-family: 'Baloo Bhaijaan 2', cursive;
    text-align: center;
    font-weight: 800;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(226, 54, 54, 0.5), inset 0 2px 5px rgba(0,0,0,0.1);
    transform: scale(1.02);
}

.input-speak {
    position: absolute;
    left: 10px; /* وضع الزر داخل المربع من الجهة اليسرى */
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
}
.input-speak:hover {
    transform: translateY(-50%) scale(1.1);
    background: var(--primary-dark);
}

.magic-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border: none;
    width: 100%;
    height: 60px;
    border-radius: 15px;
    font-size: 1.8rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Baloo Bhaijaan 2', cursive;
    box-shadow: 0 8px 20px rgba(226, 54, 54, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap; /* منع النص من الالتفاف لسطرين */
}
.magic-btn-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}
.magic-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 25px rgba(226, 54, 54, 0.7);
    background: linear-gradient(135deg, #ff4747, #d31616);
}
.magic-btn:active {
    transform: scale(0.95);
}

.error-message {
    color: #D81B60;
    font-weight: 800;
    font-size: 1.5rem;
    min-height: 40px;
    opacity: 0;
    transition: opacity 0.3s;
    background: rgba(255,255,255,0.8);
    padding: 10px 20px;
    border-radius: 15px;
    margin-top: 15px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 2px dashed #D81B60;
}
.error-message.show {
    opacity: 1;
}

.hidden {
    display: none !important;
}

.cards-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* بطاقات المواد - فقاعات سحرية */
.magical-card {
    text-decoration: none;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 3px solid var(--primary);
    border-radius: 20px;
    width: 200px;
    height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(226, 54, 54, 0.2);
    transition: all 0.3s ease;
    padding: 20px;
    border: 6px solid #FFD700;
    animation: gentleSwing 4s infinite alternate ease-in-out;
}

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

.magical-card .glass {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text);
    transition: all 0.4s ease;
}

.magical-card:hover {
    animation: softPulse 1.5s infinite;
    border-color: #FFF;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.9), 0 15px 40px rgba(255, 105, 180, 0.6), inset 0 0 20px rgba(255,255,255,1);
    transform: scale(1.1);
}

@keyframes softPulse {
    0% { transform: scale(1.05); box-shadow: 0 0 10px rgba(255, 202, 40, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 0 25px rgba(255, 202, 40, 0.8); }
    100% { transform: scale(1.05); box-shadow: 0 0 10px rgba(255, 202, 40, 0.4); }
}

.icon {
    font-size: 3.5rem;
    text-shadow: 0 5px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}
.magical-card:hover .icon {
    transform: scale(1.2) rotate(5deg);
}

.magical-card h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.card-speak {
    width: 35px;
    height: 35px;
    font-size: 1rem;
    background: rgba(255,255,255,0.7);
    border: none;
}
.card-speak:hover {
    background: var(--accent);
}

/* التجاوب مع جميع أحجام الشاشات */
@media screen and (max-width: 768px) {
    .container {
        padding: 2rem 1rem;
        width: 95%;
        border-width: 4px;
        border-radius: 30px;
        margin-top: 50px;
    }
    .captain-avatar {
        font-size: 3.5rem;
        top: 15px;
        right: 15px;
    }
    .title { font-size: 2.5rem; }
    .subtitle { font-size: 1.2rem; }
    input {
        font-size: 1.4rem;
        padding: 15px 50px 15px 15px;
    }
    .magic-btn {
        width: 100%;
        max-width: 300px;
        height: 55px;
        font-size: 1.5rem;
        border-radius: 12px;
    }
    .cards-container {
        gap: 15px;
        flex-direction: row;
        align-items: center;
    }
    .magical-card {
        width: 150px;
        height: 150px;
        border-width: 4px;
    }
    .icon { font-size: 2.5rem; }
    .magical-card h3 { font-size: 1.2rem; }
    .text-with-audio h2.title { font-size: 2rem !important; }
}

@media screen and (max-width: 480px) {
    .captain-avatar {
        font-size: 2.5rem;
        top: 10px;
        right: 10px;
    }
    .title { font-size: 2rem; }
    .subtitle { font-size: 1rem; }
    .container {
        padding: 1.5rem 1rem;
        border-radius: 20px;
    }
    input {
        font-size: 1.2rem;
        padding: 12px 45px 12px 12px;
        border-width: 4px;
    }
    .speak-btn {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
    .input-speak {
        width: 30px;
        height: 30px;
    }
    .cards-container {
        flex-direction: column;
    }
}
