:root {
    --primary: #00ff88;
    --secondary: #00c3ff;
    --bg-dark: #0f172a;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.15);
    --text: #e2e8f0;
    --success-bg: #22c55e;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }

body {
    background: radial-gradient(circle at top, #1e293b, #020617);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 50px;
}

.main-wrapper { max-width: 900px; margin: 0 auto; padding: 2rem; }

header { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 3rem; margin-bottom: 0.5rem; color: var(--primary); animation: pulse 2s infinite; }

/* 🔥 New Stats Panel Design - Inverted Triangle Shape */
.stats-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.3) !important;
    gap: 15px;
}

.stats-panel .stats-row-top {
    display: flex;
    justify-content: center;
    gap: 30px;
    width: 100%;
    flex-wrap: wrap;
}

.stats-panel .stats-row-bottom {
    display: flex;
    justify-content: center;
    width: 100%;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item i {
    font-size: 1.5rem;
    color: var(--secondary);
}

.stat-item div {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.stat-item small {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.stat-item span {
    font-weight: bold;
    font-size: 1.1rem;
    color: white;
}

/* Glass Panel & Inputs (Old with improvements) */
.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    margin-bottom: 2rem;
}

.control-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.number-control { display: flex; align-items: center; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 5px; border: 1px solid var(--border); }

.editable-num {
    width: 80px; background: transparent; border: none; color: var(--primary);
    text-align: center; font-size: 1.2rem; font-weight: bold; padding: 5px;
}
.editable-num:focus { outline: none; background: rgba(255,255,255,0.05); }

.adjust-btn { width: 35px; height: 35px; border: none; background: var(--glass); color: white; border-radius: 8px; cursor: pointer; transition: 0.2s; }
.adjust-btn:hover { background: var(--primary); color: #000; }

.grid-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-height: 300px; overflow-y: auto; padding-right: 5px; margin-top: 15px; }
.player-input { width: 100%; padding: 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 8px; color: white; }
.player-input:focus { border-color: var(--primary); outline: none; }
textarea { width: 100%; height: 150px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); color: white; padding: 10px; border-radius: 8px; resize: vertical; }

/* Buttons */
.action-area { text-align: center; margin-top: 2rem; }
.cta-btn {
    padding: 15px 50px; border-radius: 50px; border: none;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: #000; font-weight: 800; font-size: 1.2rem; cursor: pointer;
    transition: 0.3s; display: inline-flex; align-items: center; gap: 10px;
}
.cta-btn:hover { transform: scale(1.05); box-shadow: 0 0 30px rgba(0,255,136,0.4); }

/* 🔥 Updated Sticky Bar */
.sticky-winner {
    background: var(--success-bg); color: white; padding: 0.8rem 1.5rem;
    border-radius: 12px; margin-bottom: 1.5rem;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.4);
    position: sticky; top: 20px; z-index: 50;
    animation: slideDown 0.5s ease;
}

.winner-info { display: flex; align-items: center; gap: 15px; }
.winner-label { font-weight: 600; opacity: 0.9; }
.winner-name-display { font-size: 1.5rem; font-weight: 800; text-transform: uppercase; }

/* Sticky Bar Buttons */
.sticky-actions { display: flex; gap: 10px; }
.icon-btn {
    background: rgba(255,255,255,0.2); border: none; color: white;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    transition: 0.2s; font-size: 1rem; display: flex; justify-content: center; align-items: center;
}
.icon-btn:hover { background: white; color: var(--success-bg); transform: rotate(15deg); }

/* Results */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.player-card {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    padding: 10px; border-radius: 8px; text-align: center; font-size: 0.9rem; transition: 0.2s;
}
.player-card.active { background: var(--primary); color: #000; transform: scale(1.1); font-weight: bold; box-shadow: 0 0 15px var(--primary); border-color: transparent; }
.player-card.winner-card { background: var(--success-bg); color: white; border: 2px solid #fff; transform: scale(1.15); z-index: 2; }

/* Updated Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.modal-content { background: #1e293b; padding: 3rem; border-radius: 20px; text-align: center; border: 2px solid var(--primary); box-shadow: 0 0 50px rgba(0,255,136,0.2); width: 90%; max-width: 500px; animation: popIn 0.5s; }
.winner-reveal { font-size: 2.5rem; font-weight: 800; color: var(--primary); margin: 20px 0; word-wrap: break-word; }

/* 🔥 New Modal Buttons */
.modal-actions { display: flex; justify-content: center; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
.action-btn {
    padding: 12px 25px; border-radius: 10px; font-weight: 600; cursor: pointer; border: none; display: flex; align-items: center; gap: 8px; transition: 0.2s;
}
.primary-btn { background: var(--primary); color: #000; }
.primary-btn:hover { background: #00d470; }
.secondary-btn { background: rgba(255,255,255,0.1); color: white; border: 1px solid var(--border); }
.secondary-btn:hover { background: rgba(255,255,255,0.2); }

.close-btn-text { background: transparent; border: none; color: #94a3b8; text-decoration: underline; cursor: pointer; font-size: 0.9rem; }
.close-btn-text:hover { color: white; }

/* Dropdown for Export */
.dropdown-btn { position: relative; display: inline-block; }
.dropdown-content {
    display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background-color: #1e293b; border: 1px solid var(--primary); min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; border-radius: 8px; overflow: hidden; margin-bottom: 10px;
}
.dropdown-content a { color: white; padding: 12px 16px; text-decoration: none; display: block; text-align: left; font-size: 0.9rem; }
.dropdown-content a:hover { background-color: rgba(0, 255, 136, 0.1); }
.dropdown-btn:hover .dropdown-content { display: block; }

.hidden { display: none !important; }
.input-section { display: none; }
.input-section.active { display: block; }
.mode-switch { display: flex; gap: 10px; margin-bottom: 20px; }
.mode-btn { flex: 1; padding: 10px; background: transparent; border: 1px solid var(--border); color: white; cursor: pointer; border-radius: 8px; }
.mode-btn.active { background: var(--primary); color: #000; border-color: var(--primary); font-weight: bold; }
#confettiCanvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99; }

@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* Small Screen Improvements */
@media (max-width: 600px) {
    .stats-panel {
        padding: 1rem;
        gap: 8px;
    }
    
    .stats-row-top {
        gap: 10px;
    }
    
    .stat-item {
        min-width: 110px;
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    .stat-item i {
        font-size: 1.1rem;
    }
    
    .stat-item small {
        font-size: 0.65rem;
    }
    
    .stat-item span {
        font-size: 0.95rem;
    }
    /* Fix Winners Count Section on Mobile */
.winners-count-section {
    padding: 1rem;
}

.winners-count-section label {
    font-size: 0.9rem;
}

.winner-options {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
}

.win-opt {
    padding: 8px 15px;
    font-size: 0.85rem;
    flex: 1;
    min-width: 90px;
    text-align: center;
}
    
    
}

/* 🔥 Winners Count Selection Section Design */
.winners-count-section {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.winner-options {
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px;
    border-radius: 50px;
    border: 1px solid var(--border);
}

.winner-options input[type="radio"] {
    display: none;
}

.win-opt {
    padding: 10px 25px;
    border-radius: 40px;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 600;
    color: #94a3b8;
}

/* Selection Effect */
.winner-options input:checked + .win-opt {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

/* 🔥 Winners List in Modal Styling */
.winners-list-display {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.winner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px; /* Space between elements */
    padding-right: 10px; /* Space for the button */
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideIn 0.5s ease forwards;
    opacity: 0;
    transform: translateX(-20px);
}

.winner-row:nth-child(1) { animation-delay: 0.1s; border-color: #ffd700; } /* Gold */
.winner-row:nth-child(2) { animation-delay: 0.3s; border-color: #c0c0c0; } /* Silver */
.winner-row:nth-child(3) { animation-delay: 0.5s; border-color: #cd7f32; } /* Bronze */

.rank-badge {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-weight: bold; font-size: 1.2rem;
    margin-right: 15px;
}

.rank-1 { background: linear-gradient(45deg, #ffd700, #ffaa00); color: #000; box-shadow: 0 0 15px #ffd700; }
.rank-2 { background: linear-gradient(45deg, #c0c0c0, #e0e0e0); color: #000; }
.rank-3 { background: linear-gradient(45deg, #cd7f32, #b87333); color: white; }

.winner-name-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-align: right;
    flex-grow: 1;
}

/* Custom PDF Button */
.pdf-btn {
    background: #ef4444; /* Red */
    color: white;
}
.pdf-btn:hover { background: #dc2626; box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }

/* Individual Certificate Download Button */
.mini-pdf-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ef4444;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.mini-pdf-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

@keyframes slideIn {
    to { opacity: 1; transform: translateX(0); }
}
مسافة بين العناصر */
    padding-right: 10px; 
}

/* زر تحميل الشهادة الفردية */
.mini-pdf-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ef4444;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.mini-pdf-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}