/* --- إعدادات عامة --- */
:root {
    --primary-color: #4A148C;
    --secondary-color: #7B1FA2;
    --accent-color: #00BCD4;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --text-color: #E0E0E0;
    --bg-gradient: linear-gradient(135deg, #1a237e, #4A148C, #7B1FA2);
    --cup-glow: 0 0 15px currentColor;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* --- الحاوية الرئيسية وشاشات اللعبة --- */
.game-container {
    width: 90%;
    max-width: 700px;
    background: rgba(30, 30, 60, 0.9);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    padding: 30px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 3em;
    font-weight: 700;
    background: linear-gradient(45deg, var(--accent-color), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(0, 188, 212, 0.5);
}

header p {
    font-size: 1.2em;
    color: #B0BEC5;
}

.screen {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen.hidden {
    display: none;
}

/* --- شاشة اختيار المستوى --- */
.buttons-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn-level {
    padding: 15px 30px;
    font-size: 1.3em;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    color: white;
    border: none;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(123, 31, 162, 0.4);
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-level:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(123, 31, 162, 0.6);
}

.btn-level i {
    font-size: 1.2em;
}

/* --- شاشة اللعبة --- */
.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1em;
}

.info-item i {
    color: var(--accent-color);
}

.instruction-text {
    font-size: 1.5em;
    font-weight: 700;
    min-height: 50px;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    margin-bottom: 30px;
    transition: all 0.4s ease;
}

.cups-area {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    min-height: 200px;
    margin: 20px 0;
    padding: 20px;
    perspective: 1000px;
}

/* --- تصميم الأكواب الجديد والمحسّن --- */
.cup {
    width: 90px;
    height: 110px;
    margin: 0 15px;
    position: relative;
    cursor: grab;
    transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.cup.dragging {
    cursor: grabbing;
    transform: scale(1.2) translateY(-30px) rotate(10deg);
    z-index: 1000;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.7));
}

.cup-body {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 85%;
    background: inherit; /* يرث اللون */
    border-radius: 0 0 45px 45px;
    box-shadow: var(--cup-glow),
                inset 0 -15px 25px rgba(255, 255, 255, 0.25),
                inset 0 15px 25px rgba(0, 0, 0, 0.4),
                0 10px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.cup-body::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 25%;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.6), transparent);
    border-radius: 50%;
    filter: blur(6px);
}

.cup-top {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 25px;
    background: linear-gradient(145deg, #e0e0e0, #a0a0a0);
    border-radius: 50%;
    box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.cup-base {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 65%;
    height: 18px;
    background: linear-gradient(145deg, #c0c0c0, #808080);
    border-radius: 50%;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

.action-btn {
    margin-top: 30px;
    padding: 12px 35px;
    font-size: 1.2em;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(45deg, var(--accent-color), #0097A7);
    color: white;
    border: none;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 188, 212, 0.4);
    transition: all var(--transition-speed) ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 188, 212, 0.6);
}

.action-btn.hidden {
    display: none;
}

.action-btn.secondary {
    background: linear-gradient(45deg, #757575, #424242);
    box-shadow: 0 5px 15px rgba(66, 66, 66, 0.4);
}

/* --- النافذة المنبثقة --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #283593, #1a237e);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    border: 2px solid var(--accent-color);
    transform: scale(0.7);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
}

.modal.show .modal-content {
    transform: scale(1);
}

#modal-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

#modal-message {
    font-size: 1.5em;
    margin-bottom: 30px;
    font-weight: 700;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* --- الرسوم المتحركة --- */
@keyframes shake-hard {
    0%, 100% { transform: translateX(0) scale(1); filter: brightness(1); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-15px) scale(1.05); }
    20%, 40%, 60%, 80% { transform: translateX(15px) scale(1.05); }
  15%, 45%, 75% { filter: brightness(1.5) hue-rotate(320deg) saturate(3); }
  50% { opacity: 0.4; transform: scale(0.95); }
}

@keyframes pulse-success {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.25) translateY(-20px); filter: brightness(1.5) drop-shadow(0 0 25px var(--success-color)); }
    100% { transform: scale(1); filter: brightness(1); }
}

@keyframes mix-cups {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(100px) rotate(10deg); }
    75% { transform: translateX(-100px) rotate(-10deg); }
}

.animate-error .cup {
    animation: shake-hard 0.8s ease-in-out;
}

.animate-success .cup {
    animation: pulse-success 0.7s ease-in-out;
}

/* --- التصميم المتجاوب --- */
@media (max-width: 768px) {
    .game-container {
        padding: 20px;
    }
    header h1 {
        font-size: 2.2em;
    }
    .cup {
        width: 70px;
        height: 90px;
        margin: 0 8px;
    }
    .btn-level, .action-btn {
        font-size: 1.1em;
        padding: 12px 25px;
    }
    .instruction-text {
        font-size: 1.3em;
    }
    .modal-content {
        padding: 30px 20px;
    }
    #modal-message {
        font-size: 1.3em;
    }
}