/* =====================================================
   style.css — عجلة الحظ
   ===================================================== */

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

:root {
    --primary:       #6c63ff;
    --primary-dark:  #4f46e5;
    --gold:          #f59e0b;
    --gold-light:    #fef3c7;
    --gold-dark:     #92400e;
    --success:       #22c55e;
    --success-dark:  #16a34a;
    --danger:        #ef4444;
    --bg:            #0d0d1f;
    --bg2:           #181830;
    --card-bg:       #ffffff;
    --text:          #1e1e2e;
    --text-muted:    #6b7280;
    --border:        #e5e7eb;
    --radius:        18px;
    --shadow-card:   0 8px 32px rgba(0,0,0,0.22);
    --shadow-btn:    0 4px 20px rgba(108,99,255,0.38);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(ellipse at top, #1e1240 0%, var(--bg) 60%);
    min-height: 100vh;
    padding: 16px 12px 32px;
    color: var(--text);
    direction: rtl;
}

/* =====================================================
   Layout
   ===================================================== */
.page-wrapper {
    max-width: 960px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

/* =====================================================
   Header
   ===================================================== */
.site-header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px 12px 4px;
    color: white;
}

.site-header h1 {
    font-size: clamp(1.7rem, 5.5vw, 2.6rem);
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 2px 16px rgba(108,99,255,0.55);
    margin-bottom: 6px;
}

.site-header .tagline {
    color: rgba(255,255,255,0.6);
    font-size: 0.93rem;
}

/* =====================================================
   عداد المشاركين والفائزين
   ===================================================== */
.stats-bar {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-box {
    flex: 1;
    min-width: 140px;
    background: linear-gradient(135deg, #1c1c3a, #252550);
    border-radius: 14px;
    padding: 16px 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.stat-icon { font-size: 1.9rem; }

.stat-info { line-height: 1.3; }

.stat-value {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--gold);
}

.stat-label {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

/* =====================================================
   Card
   ===================================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 26px 22px;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .badge {
    background: var(--gold-light);
    color: var(--gold-dark);
    font-size: 0.76rem;
    padding: 3px 10px;
    border-radius: 50px;
    font-weight: 700;
}

/* =====================================================
   خصم 50% banner
   ===================================================== */
.discount-banner {
    background: linear-gradient(135deg, #16a34a, #15803d);
    border-radius: 12px;
    padding: 14px 18px;
    color: white;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    box-shadow: 0 4px 14px rgba(22,163,74,0.3);
}

.discount-banner .disc-icon { font-size: 2rem; }

.discount-banner .disc-text strong {
    display: block;
    font-size: 1.02rem;
    margin-bottom: 2px;
}

.discount-banner .disc-text span {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
}

/* =====================================================
   Input
   ===================================================== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.91rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 0.97rem;
    font-family: inherit;
    color: var(--text);
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    direction: rtl;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
    background: white;
}

.form-group input::placeholder { color: #adb5bd; }
.form-group input:disabled { opacity: 0.55; cursor: not-allowed; }

/* =====================================================
   Spin Button
   ===================================================== */
#spinBtn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.4px;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
    box-shadow: var(--shadow-btn);
}

#spinBtn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(108,99,255,0.5); }
#spinBtn:active:not(:disabled) { transform: translateY(0); }
#spinBtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =====================================================
   Wheel
   ===================================================== */
.wheel-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.wheel-outer {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ظل ضوئي خلف العجلة */
.wheel-glow {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(108,99,255,0.25) 0%, transparent 70%);
    pointer-events: none;
}

/* مثلث المؤشر */
.wheel-pointer {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 30px solid var(--gold);
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.45));
    z-index: 10;
}

#wheelCanvas {
    display: block;
    border-radius: 50%;
    max-width: 100%;
    height: auto;
}

/* رسالة الحالة */
#statusMsg {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    min-height: 26px;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.25s;
}
#statusMsg.info     { color: var(--primary); background: rgba(108,99,255,0.08); }
#statusMsg.success  { color: var(--success-dark); background: #f0fdf4; }
#statusMsg.error    { color: var(--danger); background: #fef2f2; }
#statusMsg.spinning { color: #b45309; background: var(--gold-light); }
#statusMsg.warning  { color: #9a3412; background: #fff7ed; }

/* =====================================================
   نافذة النتيجة
   ===================================================== */
.result-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: overlayFadeIn 0.2s ease;
}
.result-overlay.show { display: flex; }

@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }

.result-card {
    background: white;
    border-radius: 22px;
    padding: 36px 28px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 28px 70px rgba(0,0,0,0.55);
    animation: cardPop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardPop {
    from { transform: scale(0.65); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.result-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 12px;
    animation: emojiBounce 0.5s ease 0.2s both;
}
@keyframes emojiBounce {
    0%   { transform: scale(0); }
    65%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.result-title {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 14px;
}
.result-title.winner { color: var(--success-dark); }
.result-title.loser  { color: #374151; }

/* رسالة النتيجة الكاملة */
.result-message {
    font-size: 0.97rem;
    color: #374151;
    line-height: 1.7;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    text-align: right;
}
.result-message.winner { background: #f0fdf4; border: 1.5px solid #86efac; }
.result-message.loser  { background: #f9fafb; border: 1.5px solid #e5e7eb; }

/* شارة خصم 50% */
.discount-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--gold-light);
    color: var(--gold-dark);
    border: 2px solid var(--gold);
    border-radius: 50px;
    padding: 7px 18px;
    font-weight: 800;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.btn-close-result {
    padding: 13px 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s;
}
.btn-close-result:hover { opacity: 0.9; }

/* =====================================================
   قائمة الفائزين
   ===================================================== */
.winners-list-ul { list-style: none; }

.winner-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 0;
    border-bottom: 1px solid #f3f4f6;
}
.winner-item:last-child { border-bottom: none; }

.winner-rank {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 0.82rem;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.winner-details { flex: 1; }

.winner-name {
    font-weight: 700;
    font-size: 0.97rem;
    color: var(--text);
}

.winner-prize-text {
    font-size: 0.82rem;
    color: var(--success-dark);
    font-weight: 600;
    margin-top: 2px;
}

.no-winners-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 24px 0;
}

/* بطاقة معلومات المسابقة */
.contest-info {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.contest-info p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.contest-info strong { color: var(--text); }

/* =====================================================
   رسالة "شاركت من قبل"
   ===================================================== */
#alreadyPlayedBanner {
    display: none;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-radius: 12px;
    padding: 16px 18px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 14px;
    box-shadow: 0 4px 14px rgba(245,158,11,0.35);
    line-height: 1.6;
}
#alreadyPlayedBanner.show { display: block; }

/* =====================================================
   Footer
   ===================================================== */
.site-footer {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(255,255,255,0.25);
    font-size: 0.78rem;
    padding: 4px 0 8px;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (min-width: 640px) {
    .page-wrapper {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
    .site-header, .stats-bar, .site-footer {
        grid-column: 1 / -1;
    }
    .winners-section {
        grid-column: 1 / -1;
    }
}

@media (max-width: 400px) {
    .card { padding: 18px 14px; }
    #spinBtn { font-size: 0.95rem; padding: 13px; }
    .result-card { padding: 28px 16px; }
    .discount-banner { flex-direction: column; text-align: center; gap: 8px; }
}
