/* AIGinex Competition System - Vibrant Version */

/* ... Existing Styles ... */

#aiginex-participant-screen {
    /* Full Screen Override */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000; /* High z-index to cover WP Admin bar/Header */
    
    background: #000;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#ap-topic-heading {
    position: absolute;
    top: 0; left: 0; width: 100%;
    text-align: center;
    font-size: 3.5rem;
    font-weight: 800;
    color: #00e5ff;
    padding: 20px 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
    z-index: 100;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.8);
    display: none;
    letter-spacing: 2px;
}

.ap-state { display: none; width: 100%; height: 100%; }
.ap-state.active { display: flex; justify-content: center; align-items: center; animation: fadeIn 0.5s ease-in-out; }

/* Display State Styles */
#ap-state-display .ap-logo-area {
    text-align: center;
    animation: pulseSlow 3s infinite;
}

#ap-display-title {
    font-size: 7rem; /* Larger than default */
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 10px;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
    background: -webkit-linear-gradient(#eee, #333);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#ap-display-sub {
    font-size: 3rem;
    color: #00e5ff;
    font-weight: 300;
    letter-spacing: 5px;
    text-transform: uppercase;
}

@keyframes pulseSlow {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.02); opacity: 1; }
    100% { transform: scale(1); opacity: 0.9; }
}

.ap-logo-area h1 { font-size: 5rem; color: #ff00de; text-transform: uppercase; letter-spacing: 5px; text-align: center; text-shadow: 0 0 20px rgba(255, 0, 222, 0.6); }
.ap-logo-area p { color: #aaa; font-size: 1.5rem; text-align: center; }

.ap-profile-card-center {
    text-align: center;
    background: rgba(255,255,255,0.05);
    padding: 50px;
    border-radius: 20px;
    border: 2px solid #333;
    min-width: 50%;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    display: flex; flex-direction: column; align-items: center;
    position: relative;
    z-index: 10; 
}

/* UPDATED PHOTO FRAME STYLE FOR ROTATING SPARKS */
.ap-photo-frame { 
    width: 280px; 
    height: 280px; 
    border-radius: 50%; 
    border: 10px solid #fff; 
    /* overflow: hidden; REMOVED to allow sparks outside */
    margin-bottom: 30px; 
    box-shadow: 0 0 40px rgba(255,255,255,0.2); 
    position: relative; /* Context for sparks */
}

/* Image now handles its own clipping */
.ap-photo-frame img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 50%;
}

/* ROTATING SPARK RING 1 - ORANGE */
.ap-photo-frame::before {
    content: '';
    position: absolute;
    top: -20px; left: -20px; right: -20px; bottom: -20px;
    border-radius: 50%;
    border: 5px solid transparent;
    /* Updated to Orange */
    border-top-color: #ff8800;
    border-bottom-color: #ff8800;
    animation: ap-spin 3s linear infinite;
    z-index: -1;
}

/* ROTATING SPARK RING 2 - YELLOW (Opposite direction) */
.ap-photo-frame::after {
    content: '';
    position: absolute;
    top: -10px; left: -10px; right: -10px; bottom: -10px;
    border-radius: 50%;
    border: 5px solid transparent;
    /* Updated to Yellow */
    border-left-color: #ffff00;
    border-right-color: #ffff00;
    animation: ap-spin-rev 4s linear infinite;
    z-index: -1;
    opacity: 0.8; /* Increased opacity slightly for better visibility */
}

@keyframes ap-spin { 100% { transform: rotate(360deg); } }
@keyframes ap-spin-rev { 100% { transform: rotate(-360deg); } }


#ap-ready-name { font-size: 4rem; margin: 10px 0; color: #fff; text-shadow: 0 2px 5px #000; }
#ap-ready-class { font-size: 2rem; color: #ccc; margin-bottom: 20px; }
.ap-badge { display: inline-block; background: #444; color: #fff; padding: 15px 40px; border-radius: 50px; font-weight: 800; font-size: 2.5rem; margin-top: 10px; text-transform: uppercase; box-shadow: 0 0 20px rgba(0,0,0,0.5); border: 2px solid rgba(255,255,255,0.2); }

.ap-layout-split { display: flex; width: 100%; height: 100%; padding-top: 100px; }
.ap-sidebar-left { width: 25%; background: #111; border-right: 2px solid #333; display: flex; flex-direction: column; align-items: center; padding-top: 50px; }
.ap-sidebar-left img { width: 180px; height: 180px; border-radius: 50%; border: 5px solid #fff; margin-bottom: 20px; box-shadow: 0 0 20px rgba(255,255,255,0.3); }
#ap-active-name { font-size: 1.8rem; color: #fff; text-align: center; }
.ap-score-live { font-size: 3rem; font-weight: bold; color: #ffff00; margin-top: 40px; border: 4px solid #ffff00; padding: 20px 50px; border-radius: 15px; background: rgba(255, 255, 0, 0.1); box-shadow: 0 0 30px rgba(255, 255, 0, 0.4); }

.ap-main-content { width: 75%; padding: 50px; display: flex; justify-content: center; align-items: center; }
.ap-question-box { background: #1a1a1a; padding: 50px; border-radius: 20px; border-left: 15px solid #00ff00; width: 90%; box-shadow: 0 20px 50px rgba(0,0,0,0.8); }
.ap-q-tag { background: #333; color: #00ff00; padding: 5px 15px; text-transform: uppercase; font-size: 1.2rem; border-radius: 4px; letter-spacing: 2px; }
#ap-question-text { font-size: 3.5rem; line-height: 1.2; margin-top: 30px; color: #fff; text-shadow: 0 2px 4px #000; }
#ap-options-list li { font-size: 2.2rem; padding: 15px 30px; background: #222; margin-bottom: 15px; border-radius: 10px; list-style: none; color: #00e5ff; border: 1px solid #333; transition: transform 0.2s; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Manager Interface Styles */
.am-student-meta { background: #fdfdfd; padding: 10px; border-radius: 6px; border: 1px solid #eee; margin-bottom: 15px; }
.am-meta-item { margin-bottom: 5px; font-size: 14px; color: #555; border-bottom: 1px dashed #eee; padding-bottom: 5px; }
.am-meta-item:last-child { border-bottom: none; }
.am-label { font-weight: 600; color: #333; display: inline-block; width: 80px; }
.am-tabs { display: flex; border-bottom: 2px solid #ddd; margin-bottom: 20px; }
.am-tab-btn { background: #f1f1f1; border: none; outline: none; cursor: pointer; padding: 14px 20px; transition: 0.3s; font-size: 16px; font-weight: bold; color: #666; border-top-left-radius: 5px; border-top-right-radius: 5px; margin-right: 5px; }
.am-tab-btn:hover { background-color: #ddd; }
.am-tab-btn.active { background-color: #fff; color: #2c3e50; border: 2px solid #ddd; border-bottom: 2px solid #fff; margin-bottom: -2px; }
.am-results-container { margin-top: 20px; overflow-x: auto; }
.am-table { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.am-table th, .am-table td { border: 1px solid #ddd; padding: 12px; text-align: left; }
.am-table th { background-color: #2c3e50; color: white; }
.am-table tr:nth-child(even){background-color: #f9f9f9;}
.am-table tr:hover {background-color: #f1f1f1;}

/* --- NEW: WINNER SCREEN STYLES --- */
#aiginex-winner-screen {
    /* Full Screen Override */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000; /* High z-index to cover WP Admin bar/Header */
    
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
    color: white;
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.aw-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgb3BhY2l0eT0iMC4wNSI+CiAgPGNpcmNsZSBjeD0iMjUiIGN5PSIyNSIgcj0iMiIgZmlsbD0iI2ZmZiIgLz4KPC9zdmc+');
    z-index: 1;
}

.aw-content {
    z-index: 10;
    width: 100%;
    text-align: center;
}

.aw-title {
    font-size: 4rem;
    color: #ffd700;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin-bottom: 10px;
    letter-spacing: 5px;
}

#aw-group-title {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 50px;
    font-weight: 300;
    opacity: 0.8;
}

#aw-cards-container {
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Aligns bottoms so taller center card sticks up */
    gap: 30px;
    height: 500px;
    padding: 0 50px;
}

.aw-msg {
    font-size: 2rem;
    color: #666;
    animation: pulse 2s infinite;
}

.aw-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s;
    transform-origin: bottom center; /* Ensures scaling grows UP, not down */
}

.aw-card.center-big {
    width: 350px;
    padding: 40px 20px;
    transform: scale(1.1);
    z-index: 5;
    /* Removed order: 2 to ensure it stays in Middle (between left and right) */
}

.aw-card.side {
    width: 280px;
    padding: 30px 20px;
    opacity: 0.9;
}

.aw-card.mt-up {
    /* Optional: Can add margin-bottom here if we want them floating, 
       but currently relying on center-big height difference */
}

/* Rank Styling */
.aw-rank-badge {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 10px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.2rem;
    text-transform: uppercase;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    /* Updates for single line and width */
    white-space: nowrap; 
    min-width: 180px; 
    display: flex; 
    justify-content: center; 
    align-items: center;
}

/* Gold Theme & Name Color */
.aw-card.gold { border-top: 5px solid #ffd700; background: linear-gradient(to bottom, rgba(255, 215, 0, 0.1), transparent); }
.aw-card.gold .aw-rank-badge { background: #ffd700; color: #000; }
.aw-card.gold .aw-score { color: #ffd700; }
.aw-card.gold .aw-name { color: #ffd700; text-shadow: 0 0 15px rgba(255, 215, 0, 0.6); }

/* Silver Theme & Name Color */
.aw-card.silver { border-top: 5px solid #c0c0c0; background: linear-gradient(to bottom, rgba(192, 192, 192, 0.1), transparent); }
.aw-card.silver .aw-rank-badge { background: #c0c0c0; color: #000; }
.aw-card.silver .aw-score { color: #c0c0c0; }
.aw-card.silver .aw-name { color: #e0e0e0; text-shadow: 0 0 15px rgba(224, 224, 224, 0.6); }

/* Bronze Theme & Name Color */
.aw-card.bronze { border-top: 5px solid #cd7f32; background: linear-gradient(to bottom, rgba(205, 127, 50, 0.1), transparent); }
.aw-card.bronze .aw-rank-badge { background: #cd7f32; color: #fff; }
.aw-card.bronze .aw-score { color: #cd7f32; }
.aw-card.bronze .aw-name { color: #ffab76; text-shadow: 0 0 15px rgba(205, 127, 50, 0.6); }

.aw-photo-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 20px auto;
    border: 4px solid #fff;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.center-big .aw-photo-wrapper { width: 160px; height: 160px; }

.aw-photo-wrapper img { width: 100%; height: 100%; object-fit: cover; }

.aw-name { margin: 10px 0 5px 0; font-size: 1.8rem; }
.center-big .aw-name { font-size: 2.2rem; }

.aw-house { font-size: 1.2rem; font-weight: bold; text-transform: uppercase; margin-bottom: 15px; }
.aw-score { font-size: 2.5rem; font-weight: 800; margin-bottom: 10px; }
.aw-class { color: #888; font-size: 1rem; }

@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
@keyframes popIn { 
    0% { transform: scale(0.5); opacity: 0; } 
    70% { transform: scale(1.1); opacity: 1; } 
    100% { transform: scale(1); opacity: 1; } 
}

.animate-pop { animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.center-big.animate-pop { animation-delay: 0.2s; } /* 1st place pops slightly later for effect */

/* --- Winner Fireworks Animation --- */
.confetti-piece {
    position: absolute;
    top: 100%; /* Start below screen */
    opacity: 0; 
    z-index: 9999;
    pointer-events: none;
    border-radius: 2px;
}

@keyframes rise-l {
    0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-110vh) translateX(-20vw) rotate(720deg); opacity: 0; }
}

@keyframes rise-c {
    0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-110vh) translateX(0) rotate(720deg); opacity: 0; }
}

@keyframes rise-r {
    0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-110vh) translateX(20vw) rotate(-720deg); opacity: 0; }
}

/* --- Participant 'READY' Firework Bursts --- */
.ap-firework-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    /* Uses CSS variables assigned in JS */
    animation: ap-burst 1s ease-out forwards;
}

@keyframes ap-burst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* --- NEW: FEEDBACK LAYER --- */
#ap-feedback-layer {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 200; /* Above question/split layout but below confetti if any */
    pointer-events: none;
}

#ap-feedback-icon {
    font-size: 25rem;
    font-weight: 900;
    text-shadow: 0 10px 50px rgba(0,0,0,0.8);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.show-correct #ap-feedback-icon { 
    color: #00ff00; 
    opacity: 1; 
    transform: scale(1); 
    text-shadow: 0 0 50px rgba(0, 255, 0, 0.6);
}

.show-wrong #ap-feedback-icon { 
    color: #ff0000; 
    opacity: 1; 
    transform: scale(1);
    text-shadow: 0 0 50px rgba(255, 0, 0, 0.6);
}