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

:root {
    --bg-color: #F3E5F5; /* Pastel Purple */
    --primary: #E0F7FA; /* Turquoise Light */
    --primary-dark: #B2EBF2;
    --secondary: #FCE4EC; /* Soft Sugar Pink */
    --secondary-dark: #F8BBD0;
    --accent: #FFCA28; /* Golden Sparkle */
    --accent-dark: #FFB300;
    --success: #69F0AE; /* Bright Green */
    --rose: #FF80AB; /* Pink Highlight */
    --text: #311B92; /* Strict Dark Purple */
    --white: #ffffff;
    --shadow: 0 8px 30px rgba(49, 27, 146, 0.15); 
    --border-dark: 2px solid rgba(49, 27, 146, 0.2);
}

body {
    font-family: 'Baloo Bhaijaan 2', cursive;
    background: linear-gradient(to bottom, #FF80AB 0%, #FCE4EC 25%, #E0F7FA 100%);
    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(to bottom, #FF80AB 0%, #FCE4EC 25%, #E0F7FA 100%);
    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; }
}

.captain-avatar {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 5rem;
    z-index: 10;
    animation: float 4s ease-in-out infinite, goldGlow 2s infinite alternate;
    filter: drop-shadow(0 10px 15px rgba(255,128,171,0.5));
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes goldGlow {
    from { filter: drop-shadow(0 0 10px #FFD54F); }
    to { filter: drop-shadow(0 0 20px #FFC107); }
}

.container {
    background: rgba(255, 255, 255, 0.85);
    border: 6px solid var(--secondary-dark);
    backdrop-filter: blur(10px);
    border-radius: 40px;
    padding: 3rem;
    box-shadow: 0 20px 50px rgba(142,68,173,0.2), inset 0 0 25px rgba(255, 255, 255, 0.9);
    width: 90%;
    max-width: 700px;
    text-align: center;
    transition: all 0.4s ease;
    z-index: 10;
    position: relative;
    margin: auto;
}

/* 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: 4rem;
    color: var(--text);
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(255,255,255,0.8);
    margin: 0;
}

.subtitle {
    font-size: 1.8rem;
    color: #4A148C;
    line-height: 1.6;
    font-weight: 700;
    margin: 0;
}

/* أزرار السماعة */
.speak-btn {
    background: var(--primary-dark);
    color: var(--text);
    border: 2px solid white;
    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 8px rgba(0,0,0,0.1);
    padding: 0;
}
.speak-btn:hover {
    transform: scale(1.1);
    background: var(--accent);
}
.speak-btn:active {
    transform: scale(0.95);
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-bottom: 1.5rem;
}

.input-audio-wrapper {
    position: relative;
    width: 85%;
}

input {
    width: 100%;
    padding: 20px 60px 20px 25px; /* مسافة إضافية للسماعة */
    font-size: 1.8rem;
    border: 6px solid var(--primary-dark);
    border-radius: 25px;
    outline: none;
    background: var(--white);
    color: var(--text);
    transition: all 0.3s;
    font-family: 'Baloo Bhaijaan 2', cursive;
    text-align: center;
    font-weight: 800;
}
input:focus {
    border-color: var(--secondary-dark);
    box-shadow: 0 0 20px rgba(248, 187, 208, 0.8);
    transform: scale(1.02);
}

.input-speak {
    position: absolute;
    left: 15px; /* RTL meaning left is inside the input end */
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
}
.input-speak:hover {
    transform: translateY(-50%) scale(1.1);
}

.magic-btn {
    background: linear-gradient(135deg, #FCE4EC, #F8BBD0);
    color: var(--text);
    border: none;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    font-size: 2.2rem;
    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;
    border: 8px solid var(--white);
    box-shadow: 0 10px 25px rgba(248,187,208,0.6), inset 0 0 15px rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}
.magic-btn-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.btn-speak {
    width: 35px;
    height: 35px;
    font-size: 1rem;
    background: rgba(255,255,255,0.7);
    border: none;
}
.btn-speak:hover {
    background: white;
}
.magic-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 35px rgba(248, 187, 208, 0.8), 0 0 20px var(--accent);
    background: linear-gradient(135deg, #E1BEE7, #CE93D8);
    border-color: var(--accent);
}
.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: #F3E5F5;
    border-radius: 50%;
    width: 180px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 20px rgba(255,128,171,0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 12px;
    border: 6px solid #FF80AB;
    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: #FFCA28;
    background: linear-gradient(135deg, #FFFFFF, #FCE4EC, #E0F7FA);
    box-shadow: 0 0 15px rgba(255, 202, 40, 0.6), inset 0 0 10px 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: #4A148C;
}

.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: 100px;
        height: 100px;
        font-size: 1.5rem;
        border-width: 5px;
    }
    .magic-btn-content .btn-speak {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    .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;
    }
}
