/* --- GLOBAL STYLES (Player & Host) --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #ffffff; /* White background like 9Letters */
    color: #333;
}

.hidden { display: none !important; }

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;    /* Center horizontally */
    justify-content: center; /* Center vertically */
    flex: 1;                /* Take up all available space */
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.card {
    background: white;
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    text-align: center;
    border: 1px solid #eee;
}

.primary-btn { 
    width: 100%; padding: 15px; background: #27ae60; color: white; 
    border: none; border-radius: 8px; font-weight: bold; cursor: pointer;
    font-size: 1rem;
}
.primary-btn:hover { background: #219150; }
.primary-btn:disabled { background: #7f8c8d; cursor: not-allowed; }

/* --- HOST LAYOUT --- */
.host-body {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    overflow: hidden;
}

body.host-page {
    display: grid;
    grid-template-columns: 320px 1fr; /* Fixed sidebar, flexible game area */
    height: 100vh;
    overflow: hidden;
}

.player-header {
    grid-column: 1 / span 2;
    background: #f8f9fa;
    padding: 10px;
    border-bottom: 1px solid #eee;
    min-height: 50px;
}

#player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding: 10px;
}

.player-pill {
    padding: 10px 22px;
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    background: linear-gradient(135deg, #42e695 0%, #3bb2b8 100%);
    color: white;
    border-radius: 50px;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 10px rgba(66, 230, 149, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
    opacity: 1;
}

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

.player-pill {
    animation: popIn 0.3s ease-out forwards;
}

/* --- THE "KNOCKOUT" STATE --- */
#player-list .player-pill.out {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%) !important; /* Soft Purple/Pink "Ghost" look */
    color: white !important;
    opacity: 0.7 !important;
    transform: scale(0.9) !important;
    text-decoration: none !important; /* Removing line-through so the name is readable with the ghost */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
}

.host-sidebar {
    background: #ffffff;
    padding: 30px;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
}

.main-display {
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fcfcfc;
}

#code {
    font-size: 3.5rem; 
    font-weight: 900;
    letter-spacing: 0.2rem;
    color: #333;
    display: block;
    margin: 10px 0;
}

.qr-container {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* --- BAR GRAPH STYLES --- */
.bar-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    align-items: flex-end;
    height: 300px;
    gap: 30px;
}

.bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    background: #6e8efb; /* Matching start btn color */
    border-radius: 12px 12px 0 0;
    transition: height 0.3s ease;
}

.bar-label {
    margin-top: 15px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #444;
}

/* --- SCREENS --- */


#game-screen {
    justify-content: flex-start; /* Keeps the timer at the top */
    padding-top: 40px;           /* Gives the timer some breathing room */
}

.options-grid {
    display: grid;
    gap: 15px;
    margin-top: 30px;
    width: 100%;
    max-width: 400px;       /* Matches the card width for consistency */
}

.timer-bar-container {
    width: 100%;
    max-width: 400px;
    height: 16px; /* Increased height for better visibility */
    background: rgba(0, 0, 0, 0.2); /* Darker track */
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 30px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.timer-fill {
    height: 100%;
    width: 100%; 
    background: #f1c40f;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.join-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- HOST LOGO STYLING --- */
.logo-container {
    margin-bottom: 40px;
}

.host-logo {
    max-width: 400px;
    height: auto;
}

#start-btn {
    padding: 20px 40px;
    font-size: 1.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(110, 142, 251, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
}

#start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(110, 142, 251, 0.5);
    filter: brightness(1.1);
}

/* --- STUDENT STATUS BAR --- */
.status-bar {
    width: 100%;
    padding: 12px;
    text-align: center;
    font-weight: 800;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 12px;
    margin-bottom: 20px;
    transition: all 0.5s ease;
}

/* Green state when playing */
.status-bar.active-state {
    background: linear-gradient(135deg, #42e695 0%, #3bb2b8 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(66, 230, 149, 0.2);
}

/* Red state when knocked out */
.status-bar.eliminated-state {
    background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(110, 142, 251, 0.2);
}

/* IMPORTANT: Remove or Comment Out the pointer-events: none */
.screen.player-out .options-grid {
    opacity: 0.8; /* Slightly dimmed but still clear */
    pointer-events: auto; /* ALLOW CLICKS */
}

/* Add a "Ghost" label to the options if they are out */
.screen.player-out .option-btn {
    border: 1px dashed rgba(255,255,255,0.5);
}

.feedback-text {
    margin-top: 20px;
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    min-height: 1.6rem; /* Prevents layout jump when text appears */
}

/* --- CHAMPION STYLING --- */
.champion-text {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 10px 0;
    animation: crownPulse 1.5s infinite;
}

#winner-celebration.card {
    border: 5px solid #f1c40f;
    background: #fffdf0; /* Very light yellow tint */
}

@keyframes crownPulse {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.2); }
    100% { transform: scale(1); filter: brightness(1); }
}   

/* --- PLAYER/STUDENT UI SPECIFIC --- */
.card { background: white; color: #333; padding: 2rem; border-radius: 15px; }
.options-grid { display: grid; gap: 15px; margin-top: 20px; width: 100%; }
.option-btn { 
    padding: 20px; font-size: 1.2rem; background: #ecf0f1; border: none; 
    border-radius: 12px; font-weight: 700; 
}
.option-btn.selected { background: #3498db; color: white; }

/* JOIN SCREEN OVERHAUL */
/* CLEAN WHITE JOIN SCREEN */
#login-screen {
    background-color: #ffffff; /* Pure white background */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.join-card {
    background: #ffffff;
    padding: 2rem;
    border-radius: 20px;
    /* Soft shadow to make it pop against the white background */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); 
    border: 1px solid #f0f0f0;
    width: 90%;
    max-width: 380px;
    text-align: center;
}

.join-logo {
    max-width: 100%; /* Adjust based on your logo shape */
    height: auto;
    margin-bottom: 2.5rem;
}

/* INPUT STYLING */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    padding: 16px;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.input-group label {
    position: absolute;
    left: 16px;
    top: 16px;
    color: #aaa;
    pointer-events: none;
    transition: all 0.2s ease;
}

/* Floating Label Animation */
.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
    top: -12px;
    left: 12px;
    background: white;
    padding: 0 8px;
    font-size: 0.85rem;
    color: #4a90e2; /* Modern blue accent */
    font-weight: 600;
}

.input-group input:focus {
    border-color: #4a90e2;
}

/* BUTTON STYLING */
.glow-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 10px;
    background: #222222; /* Dark professional button */
    color: white;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 0.5rem;
}

.glow-btn:hover {
    background: #444444;
}

.glow-btn:active {
    transform: scale(0.98);
}

/* --- WINNER SCREEN OVERLAY --- */
#winner-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

.winner-card {
    text-align: center;
    animation: celebratePop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* TROPHY ANIMATION */
.trophy-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 2rem;
}

.floating-trophy {
    font-size: 10rem;
    display: block;
    animation: floatTrophy 3s ease-in-out infinite;
}

.trophy-shadow {
    width: 80px;
    height: 15px;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
    margin: 0 auto;
    filter: blur(5px);
    animation: shadowPulse 3s ease-in-out infinite;
}

/* TYPOGRAPHY */
.winner-label {
    font-size: 1.5rem;
    letter-spacing: 5px;
    color: #f39c12;
    font-weight: 900;
    margin-bottom: 0;
}

#winner-name {
    font-size: 6rem;
    margin: 0;
    background: linear-gradient(to bottom, #222, #555);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.winner-subtext {
    font-size: 1.2rem;
    color: #888;
    margin-bottom: 3rem;
}

/* RESTART BUTTON */
.restart-btn {
    background: #222;
    color: white;
    border: none;
    padding: 18px 60px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.restart-btn:hover {
    background: #444;
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

/* KEYFRAMES */
@keyframes celebratePop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes floatTrophy {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes shadowPulse {
    0%, 100% { transform: scale(1); opacity: 0.1; }
    50% { transform: scale(1.5); opacity: 0.05; }
}

#question-header {
    font-size: 3rem;
    color: #222;
    text-align: center;
    margin: 20px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}