:root {
    --primary-color: #fbca00;
    --secondary-color: #f7a938;
    --correct-color: #28a745;
    --incorrect-color: #dc3545;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #333333;
    color: white;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

main {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

.hidden { display: none !important; }

/* --- ESTILOS DE LOGIN/CADASTRO --- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    width: 100%;
    max-width: 1100px;
    flex-wrap: wrap;
}
.event-logo-column {
    flex: 1 1 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.event-logo-column img {
    width: 100%;
    max-width: 450px;
    height: auto;
}
.login-box {
    background: #3a3a3a;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    flex: 1 1 400px;
}
.logo {
    max-width: 250px;
    height: auto;
    margin-bottom: 20px;
}
@media (max-width: 900px) {
    .event-logo-column {
        display: none;
    }
    .login-container {
        justify-content: center;
    }
}

/* --- CAIXAS DE CONTEÚDO --- */
.menu-box {
    background: #333433;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}
h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}
input {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border: 2px solid transparent;
    border-radius: 8px;
    outline: none;
    font-size: 1rem;
    box-sizing: border-box;
    background-color: #615f5f;
    color: white;
    transition: border-color 0.3s ease-in-out;
}
input:focus {
    border-color: var(--primary-color);
}

/* --- BOTÕES --- */
.main-button, .secondary-button {
    border: none;
    padding: 15px;
    width: 100%;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    margin-bottom: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.main-button:hover, .secondary-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.main-button {
    background-color: #659b26;
}
.main-button:hover {
    background-color: #7cb32f;
}
.secondary-button {
    background-color: #fbca00;
    color: #333;
}
.secondary-button:hover {
    background-color: #ffda46;
    color: #333;
}

/* --- LAYOUT DO MENU (LOBBY) --- */
.main-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
    width: 100%;
    margin-bottom: 10px;
}
.main-menu-grid .main-button {
    margin-bottom: 0;
}

/* --- QUIZ E RESPOSTAS --- */
.timer {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem auto;
}
.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}
.timer-progress {
    fill: none;
    stroke: var(--secondary-color);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}
#timer-text, #live-timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: bold;
}
.answer-buttons-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 25px;
}
@media (min-width: 768px) {
    .answer-buttons-grid {
        grid-template-columns: 1fr 1fr;
    }
}
.answer-button {
    background-color: #4a5568;
    color: white;
    border: none;
    padding: 15px 20px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-align: left;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.answer-button:hover:not(:disabled) {
    background-color: #6a768d;
    transform: translateY(-2px);
}
.answer-button:disabled {
    cursor: not-allowed;
    background-color: #3e4756;
    color: #8a93a2;
    transform: none;
    box-shadow: none;
}
.answer-button.selected {
    background-color: var(--secondary-color) !important;
    color: #333 !important;
}
.answer-button.correct {
    background-color: var(--correct-color) !important;
    color: white !important;
    font-weight: bold;
}
.answer-button.incorrect {
    background-color: var(--incorrect-color) !important;
    color: white !important;
    font-weight: bold;
}

/* --- AVATAR COM ANIMAÇÃO --- */
.avatar-container {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #FFD700, #FFA500, #FFD700);
    box-shadow: 0 0 15px rgba(251, 202, 0, 0.6), 0 0 25px rgba(255, 165, 0, 0.4);
    animation: neon-border 1.5s infinite alternate, float 4s ease-in-out infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    flex-shrink: 0; 
}
#welcome-avatar, #current-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 3px solid #333433;
}
@keyframes neon-border {
    from { box-shadow: 0 0 10px rgba(251, 202, 0, 0.5), 0 0 15px rgba(255, 165, 0, 0.3); }
    to { box-shadow: 0 0 20px rgba(251, 202, 0, 0.8), 0 0 30px rgba(255, 165, 0, 0.6); }
}
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-7px); }
    100% { transform: translateY(0px); }
}
#profile-section .avatar-container {
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

/* --- MODAL DE REGRAS --- */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: #444;
    margin: auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    position: relative;
    animation: fadeIn 0.3s ease-out;
    text-align: left;
}
.modal-content h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-button:hover {
    color: white;
}
.rules-text {
    background-color: #333433;
    padding: 15px;
    border-radius: 8px;
    max-height: 50vh;
    overflow-y: auto;
}
.rules-text p {
    color: #ddd;
    line-height: 1.6;
    margin-bottom: 12px;
}
.rules-text p:last-child {
    margin-bottom: 0;
}

/* --- ESTILOS PARA PERFIL (HISTÓRICO E CONQUISTAS) --- */
.profile-extra-info {
    margin-top: 2.5rem;
    text-align: left;
}
#achievements-section, #history-section {
    margin-bottom: 2rem;
}
#achievements-section h3, #history-section h3 {
    color: var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}
#achievements-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}
.achievement-badge {
    display: flex;
    align-items: center;
    background-color: #444;
    padding: 1rem;
    border-radius: 8px;
    border-left: 5px solid var(--secondary-color);
}
.achievement-badge i {
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-right: 1rem;
    width: 40px;
    text-align: center;
}
.achievement-badge .badge-text strong {
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.25rem;
}
.achievement-badge .badge-text p {
    font-size: 0.9rem;
    color: #ccc;
    margin: 0;
}

#history-container .history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
#history-container .history-table th, #history-container .history-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #555;
    text-align: left;
}
#history-container .history-table th {
    background-color: #3a3a3a;
    font-weight: bold;
}
#history-container .history-table td:nth-child(3),
#history-container .history-table td:nth-child(4) {
    text-align: center;
    font-weight: bold;
}

/* --- SEÇÃO DE PERFIL CORRIGIDA --- */
.profile-avatar-section {
    margin-bottom: 1.5rem;
    text-align: center;
}
.avatar-upload-label {
    position: relative;
    display: inline-block;
    cursor: pointer;
}
#profile-section h3 {
    font-size: 1rem;
    color: #ccc;
    font-weight: normal;
    margin-top: 1rem;
}
.profile-username-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 0.5rem;
}
#username-edit-box {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}
/* NOVAS REGRAS PARA ESPAÇAMENTO DA ESCOLA */
.profile-school-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
.profile-school-section h4 {
    color: #ddd;
    font-size: 1.1rem;
    font-weight: normal;
    margin: 0;
}
#school-edit-box {
    display: flex;
    gap: 10px;
    margin-bottom: 2.5rem; /* AUMENTA O ESPAÇO ATÉ A FOTO */
}
#live-answer-status {
    margin-top: 20px;
    font-weight: bold;
}
.error-message {
    color: var(--incorrect-color);
}
.success-message {
    color: var(--primary-color);
}

/* --- OUTROS --- */
.spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto 0 auto;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.welcome-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 2rem;
}
#welcome-user-message {
    font-size: 2.2em;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0;
}
#live-event-notice {
    padding: 15px;
    background-color: rgba(84, 149, 26, 0.2);
    border: 1px solid #54951a;
    border-radius: 10px;
    margin-bottom: 10px;
}