:root {
    --bg-color: #46178F; --card-color: white; --text-color: #333;
    --red: #e74c3c; --blue: #3498db; --green: #2ecc71; --yellow: #f1c40f;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: 'Helvetica Neue', sans-serif; background-color: var(--bg-color); color: var(--text-color);
    margin: 0; text-align: center;
}
/* Main layout fix for mobile scrolling */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    overflow-y: auto; /* Always allow scrolling if needed */
}
.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Content starts from the top */
    align-items: center;
}

/* --- Setup Screen --- */
#setup-screen { background: linear-gradient(135deg, #6e48aa, #3a1e63); color: white; justify-content: center; }
#setup-screen h1 { font-size: 3rem; margin-bottom: 20px; }
#resume-game-container p { font-size: 1.2rem; }
#resume-game-container button { margin: 10px; }
.team-name {
    display: block; margin: 10px auto; padding: 12px; font-size: 1.1rem;
    border-radius: 5px; border: none; width: 80%; max-width: 400px;
}
.settings {
    position: relative;
    display: inline-block;
    margin: 20px 0;
    width: 80%;
    max-width: 400px;
}
.settings::after { /* Custom dropdown arrow */
    content: '▼';
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    color: #333;
}
.settings select {
    appearance: none; -webkit-appearance: none; display: block; margin: 0 auto;
    padding: 12px; font-size: 1.1rem; font-family: inherit; border-radius: 8px;
    border: none; width: 100%; background-color: #f1f1f1; color: #333; cursor: pointer;
}
button {
    padding: 15px 30px; font-size: 1.2rem; border: none; border-radius: 8px; cursor: pointer;
    background-color: var(--green); color: white; transition: transform 0.1s ease;
}
button:hover { transform: scale(1.05); }
#add-team-btn { background-color: var(--blue); }
button.secondary { background-color: #7f8c8d; }

/* --- Quiz Screen Layout Fixes --- */
.quiz-header {
    width: 100%;
    max-width: 900px;
    color: white;
    margin-bottom: 20px;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
#scoreboard {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
    padding: 10px; background: rgba(0,0,0,0.2); border-radius: 10px;
    width: 100%;
}
.team-score { padding: 5px 15px; border-radius: 5px; background: #333; font-size: 0.9rem; }
.team-score span { font-weight: bold; color: var(--yellow); }
#question-counter {
    font-size: 1rem;
    color: rgba(255,255,255,0.75);
}
.quiz-main {
    width: 100%;
    max-width: 800px;
    margin-bottom: 30px; /* Space between main content and host controls */
}

/* --- Host Controls Layout Fix --- */
#host-controls {
    width: 100%;
    max-width: 800px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0.7));
    backdrop-filter: blur(8px);
    padding: 20px;
    border-top: 2px solid rgba(255,255,255,0.1);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    color: white;
    border-radius: 10px; /* Rounded corners look better now */
}
#host-controls.timer-mode #scoring-controls { display: none; }
#host-controls.scoring-mode #timer-controls { display: none; }
#team-point-buttons button { margin: 5px; padding: 10px 15px; background-color: var(--blue); }
#next-question-btn { background-color: var(--yellow); color: black; margin-top: 10px; }
#skip-timer-btn { background-color: var(--red); }
#infobox {
    background: rgba(0,0,0,0.25); padding: 15px; border-radius: 8px;
    border-left: 4px solid var(--yellow); margin: 0 auto 15px auto;
    max-width: 700px; font-size: 1rem; line-height: 1.5; text-align: left;
    animation: fadeIn 0.3s ease-in-out;
}
#infobox strong { color: var(--yellow); display: block; margin-bottom: 5px; }

/* --- Timer & Answer Styles (Mostly Unchanged) --- */
#timer {
    position: relative; font-size: 3rem; font-weight: bold; color: white;
    width: 90px; height: 90px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    margin: 0 auto 20px; border: 4px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
    animation: countdownPulse 1s infinite;
}
#timer::before {
    content: ''; position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px;
    border: 4px solid var(--green); border-radius: 50%;
    animation: countdownProgress linear forwards;
    animation-duration: var(--timer-duration, 20s); /* Set by JS, with a 20s fallback */
}
.timer-stopped { animation: none !important; }
.timer-stopped::before { display: none; }
@keyframes countdownPulse { 50% { transform: scale(1.1); } }
@keyframes countdownProgress {
    from { clip-path: inset(0 0 0 0); }
    to { clip-path: inset(0 100% 0 0); }
}
#question-container { background: var(--card-color); padding: 20px; border-radius: 10px; width: 100%; margin: 0 auto; min-height: 150px; }
#question-category { color: #888; margin: 0 0 10px; }
#question-text { font-size: 1.5rem; margin: 0; }
#question-image-container img { max-width: 100%; max-height: 150px; margin-top: 15px; border-radius: 5px; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; margin: 20px auto 0; }
.answer-btn { color: white; font-size: 1.2rem; padding: 20px; border: none; border-radius: 8px; min-height: 80px; display: flex; align-items: center; justify-content: center; }
.answer-btn.correct { border: 5px solid white; transform: scale(1.05); }
.answer-btn:nth-child(1) { background-color: var(--red); } .answer-btn:nth-child(2) { background-color: var(--blue); }
.answer-btn:nth-child(3) { background-color: var(--yellow); } .answer-btn:nth-child(4) { background-color: var(--green); }

/* --- Winner Screen --- */
#winner-screen { background: linear-gradient(135deg, #2980b9, #6dd5fa); color: white; justify-content: flex-start; padding-top: 3vh; }
#winner-announcement h2 { margin: 0; font-size: 1.5rem; font-weight: 500; }
#winner-name { font-size: clamp(2rem, 10vw, 4.5rem); font-weight: bold; color: var(--yellow); text-shadow: 3px 3px 5px rgba(0,0,0,0.25); animation: winnerZoom 1s ease-out; margin: 0; }
@keyframes winnerZoom { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#final-leaderboard, #stats-breakdown { background: rgba(0,0,0,0.3); border-radius: 10px; padding: 20px; margin-top: 25px; width: 100%; max-width: 800px; text-align: left; }
#final-leaderboard h3, #stats-breakdown h3 { margin-top: 0; text-align: center; color: var(--yellow); border-bottom: 2px solid rgba(255, 255, 255, 0.5); padding-bottom: 10px; }
.leaderboard-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 1.2rem; border-bottom: 1px solid rgba(255,255,255,0.2); }
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-score { font-weight: bold; }
#stats-breakdown .team-stats { margin-bottom: 20px; }
#stats-breakdown .team-stats:last-child { margin-bottom: 0; }
#stats-breakdown .team-stats h4 { margin-top: 0; margin-bottom: 10px; color: #fff; background: rgba(0,0,0,0.2); padding: 5px 10px; border-radius: 5px; }
#stats-breakdown .category-stat { display: flex; justify-content: space-between; padding: 4px 10px; }
#stats-breakdown .category-stat:nth-child(even) { background: rgba(0,0,0,0.1); }
#confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; width: 10px; height: 20px; opacity: 0; animation: fall 5s ease-out forwards; }
@keyframes fall { 0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; } 100% { transform: translateY(110vh) rotate(720deg); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.hide { display: none !important; }

/* Media Query for small screens */
@media (max-width: 600px) {
    .answer-grid { grid-template-columns: 1fr; /* Stack buttons vertically */ }
    #question-text { font-size: 1.3rem; }
}

