/* ============================================================
   Eduplayify — Mode: edu_worm (الدودة التعليمية)
   نمط العرض مطابق لبقية الأطوار: مسرح عمودي داخل بطاقة المحرك،
   ترويسة سؤال + تلميح + صندوق كانفس متجاوب + شريط سفلي متناسق.
   - لا dvh (القاعدة 10) ولا CDN ولا ألوان تكشف الإجابة.
   - تحكم باللمس الانسيابي على الساحة مباشرة مع دعم لوحة المفاتيح.
   ============================================================ */

.ew-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 760px;
    padding: 6px 4px;
    box-sizing: border-box;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    margin-inline: auto;
    align-self: center;
}

#gamePlayArea:fullscreen .ew-stage,
.gpa-fullscreen .ew-stage {
    max-width: 1050px;
    height: 100%;
    max-height: 100%;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 4px 6px;
    box-sizing: border-box;
}

/* ---------- الترويسة ---------- */
.ew-header {
    text-align: center;
    margin-bottom: 8px;
    max-width: 1020px;
    width: 100%;
    flex-shrink: 0;
}

.ew-q-img-wrap {
    display: inline-block;
    margin: 2px auto 6px;
    max-height: 110px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    background: #ffffff;
    padding: 3px;
    cursor: pointer;
    box-sizing: border-box;
}

.ew-q-img {
    max-height: 100px;
    max-width: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

.ew-q-img:hover {
    transform: scale(1.05);
}

.ew-title {
    margin: 0 0 3px;
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
    font-weight: 800;
    color: var(--ink, #1e293b);
    line-height: 1.35;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ew-hint {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-soft, #64748b);
    letter-spacing: -0.01em;
}

/* ---------- صندوق الكانفس ---------- */
.ew-canvas-box {
    position: relative;
    margin: 0 auto;
    border-radius: 20px;
    padding: 6px;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 50%, #fce7f3 100%);
    box-shadow: 0 16px 36px -10px rgba(99, 102, 241, 0.25), 0 4px 18px rgba(15, 23, 42, 0.08);
    border: 2px solid rgba(165, 180, 252, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1020px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.ew-canvas {
    display: block;
    border-radius: 14px;
    background: #FCFDFF;
    touch-action: none;
    max-width: 100%;
    box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.04);
}

/* ---------- نافذة الانطلاق ---------- */
.ew-start-overlay {
    position: absolute;
    inset: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.36);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 14px;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
    padding: 12px;
    z-index: 5;
}

.ew-start-overlay.is-gone {
    opacity: 0;
    transform: scale(0.96);
    pointer-events: none;
}

.ew-start-icon {
    font-size: 2.3rem;
    animation: ewPulse 1.4s ease-in-out infinite alternate;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.ew-start-text {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 800;
    color: #1e293b;
    text-align: center;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

@keyframes ewPulse {
    from { transform: translateY(-4px) scale(0.98); }
    to { transform: translateY(4px) scale(1.05); }
}

/* ---------- رسالة التغذية الراجعة ---------- */
.ew-toast {
    position: absolute;
    top: 14px;
    inset-inline: 0;
    margin: 0 auto;
    width: fit-content;
    max-width: 90%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border-radius: 16px;
    background: #ffffff;
    border: 2px solid;
    box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.18);
    font-weight: 800;
    font-size: 0.82rem;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 6;
}

.ew-toast.is-on {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ew-toast-ok {
    border-color: #10b981;
    background: #ecfdf5;
    color: #064e3b;
}

.ew-toast-no {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #78350f;
}

.ew-toast-emoji {
    font-size: 1.15rem;
    line-height: 1;
}

/* ---------- صورة السؤال (نفس صنف وقواعد بقية القوالب) ---------- */
/* في ملء الشاشة تُخفى: الساحة تحتاج الارتفاع كلّه، ويُقتطع العمود بلا فائدة.
   الإخفاء بـ CSS يخفض ارتفاع الترويسة تلقائيًا فيكبر الكانفس من جديد. */
#gamePlayArea:fullscreen .ew-stage .ws-image,
.gpa-fullscreen .ew-stage .ws-image {
    display: none !important;
}

/* ---------- الشريط السفلي الصغير ---------- */
.ew-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
    width: 100%;
    max-width: 1020px;
}

.ew-score-line {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--ink-soft, #475569);
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ew-pause {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 13px;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ew-speed {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    border-radius: 12px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.ew-speed-btn {
    border: 0;
    background: transparent;
    border-radius: 9px;
    padding: 4px 9px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s ease;
}

.ew-speed-btn.is-on {
    background: #ffffff;
    color: #4338ca;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

/* ---------- شاشات صغيرة والتحسين المتجاوب ---------- */
@media (max-width: 560px) {
    .ew-stage {
        padding: 4px 2px;
    }
    .ew-header {
        margin-bottom: 6px;
    }
    .ew-title {
        font-size: 0.98rem;
    }
    .ew-hint {
        font-size: 0.74rem;
    }
    .ew-canvas-box {
        padding: 4px;
        border-radius: 16px;
    }
    .ew-canvas {
        border-radius: 12px;
    }
    .ew-foot {
        gap: 8px;
        margin-top: 8px;
    }
    .ew-speed-btn {
        font-size: 0.65rem;
        padding: 3px 7px;
    }
    .ew-score-line {
        font-size: 0.78rem;
        padding: 5px 10px;
    }
    .ew-pause {
        font-size: 0.74rem;
        padding: 5px 9px;
    }
    .ew-toast {
        font-size: 0.76rem;
        padding: 6px 12px;
    }
}