/* 1. Main Container */
#kahootContainer {
    position: relative;
    margin-left: 20px;
    max-width: calc(100% - 40px);
    background-color: #fff;
    padding: 0; 
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 500;
    overflow: hidden; 
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for inner flex growth */
}

/* 2. Stats Bar */
.kahoot-stats-bar {
    display: flex;
    justify-content: space-around;
    background: #46178f;
    color: white;
    padding: 15px;
    font-weight: bold;
    margin: 10px 10px 0 10px; 
    border-radius: 8px;
}

/* 3. Question Section - MERGED ID and Class */
#kahoot-questionSection {
    padding: 20px;
    flex: 1 1 0%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center; 
    overflow-y: auto;
}

/* 4. Choices Container */
#kahoot-choicesContainer {
    flex: 1; /* Grow to fill the question section */
    display: flex;
    flex-direction: column;
    justify-content: stretch; /* Stretch children to full width */
    gap: 12px; /* Gap between buttons */
    padding: 10px 0;
}

.kahoot-choice-btn {
    flex: 1; /* This tells the button: "Take up your share of the vertical space" */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: bold;
    color: white; /* Since buttons have dark colors now */
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 5px; /* Small gap if 'gap' property fails in old browsers */
}

/* Hover & Active States */
.kahoot-choice-btn:hover {
    background-color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.1);
}

.kahoot-choice-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 rgba(0,0,0,0.1);
}

.kahoot-choice-btn:disabled {
    cursor: not-allowed;
}

/* 5. Loader Overlay - Refined for Fade effect */
.game-loader-overlay {
    position: absolute;
    top: 0; /* Start from top to cover the stats bar during join */
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #46178f 0%, #250a4d 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* IMPORTANT: Use this specifically for the loader if you want a FADE out */
.game-loader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.game-loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* 7. Animations */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(0.98); } }

.kahoot-loader-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top: 6px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* If you want a specific animation for the Time's Up text */
#loader-message span {
    display: block;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.loader-text {
    margin-top: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    animation: pulse 1.5s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

#rankChart {
    width: 100%;
    display: block;
    margin-top: 10px;
}

.rank-chart-container {
    margin: 15px;
    padding: 20px;
    background: #ffffff;
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 25px rgba(70, 23, 143, 0.1); /* Subtle purple glow */
}

.chart-title {
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 1px;
    color: #46178f;
    font-size: 14px;
    border-bottom: 2px solid #f4f0fa;
    padding-bottom: 8px;
    margin-bottom: 15px;
}

/* 6. Rank History (Bottom Anchored) */
#kahoot-rank-history {
    flex: 0 0 180px;
    height: 180px;
    margin: 10px 15px 15px 15px; /* Reduced top margin */
    padding: 10px 15px; /* Slightly tighter padding */
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(70, 23, 143, 0.1);
    margin-top: auto;
    /* Edge fix: Ensure inner content doesn't bleed out */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Make sure the canvas inside the chart container respects the height */
#kahoot-rank-history .chart-canvas-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
}

.choice-letter {
    margin-right: 12px; /* Adjust this value to get the desired gap */
    font-weight: bold;  /* Makes the letter stand out like Kahoot */
    display: inline-block;
}
