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

:root {
    --bg-color: #FCE4EC; /* Pastel Pink */
    --primary: #F8BBD0; /* Princess Pink */
    --primary-dark: #F06292;
    --secondary: #FFF9C4; /* Soft Gold */
    --secondary-dark: #FFF59D;
    --accent: #FFD700; /* Golden Sparkle */
    --accent-dark: #FFB300;
    --success: #69F0AE; /* Bright Green */
    --rose: #FF69B4; /* Hot Pink */
    --text: #4A148C; /* Royal 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(135deg, #FFE4E1, #FFB6C1, #E6E6FA);
    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, #FFE4E1, #FFB6C1, #E6E6FA);
    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;
    z-index: 10;
    animation: float 4s ease-in-out infinite, goldGlow 2s infinite alternate;
}
@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-color: transparent;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><radialGradient id="gem" cx="30%" cy="30%" r="70%"><stop offset="0%" stop-color="%23FFF0F5"/><stop offset="30%" stop-color="%23FF69B4"/><stop offset="80%" stop-color="%23C71585"/><stop offset="100%" stop-color="%23900C3F"/></radialGradient></defs><circle cx="50" cy="50" r="48" fill="url(%23gem)"/><path d="M 20 40 A 35 35 0 0 1 70 20 A 35 35 0 0 0 25 55 Z" fill="%23ffffff" opacity="0.5"/><path d="M 25 15 L 28 22 L 35 25 L 28 28 L 25 35 L 22 28 L 15 25 L 22 22 Z" fill="%23ffffff" opacity="0.9"/><path d="M 75 65 L 77 70 L 82 72 L 77 74 L 75 79 L 73 74 L 68 72 L 73 70 Z" fill="%23ffffff" opacity="0.7"/></svg>');
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    width: 180px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 15px 35px rgba(255, 105, 180, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 12px;
    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: 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;
    }
}
