:root {
    --bg: #12122b;
    --bg-2: #1b1b3a;
    --card: #22224a;
    --primary: #7c3aed;
    --primary-2: #a855f7;
    --accent: #22d3ee;
    --success: #22c55e;
    --danger: #ef4444;
    --text: #f4f4ff;
    --text-dim: #b7b7d9;
    --opt-a: #e21b3c;
    --opt-b: #1368ce;
    --opt-c: #d89e00;
    --opt-d: #26890c;
    --radius: 14px;
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(circle at top, var(--bg-2), var(--bg));
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

h1, h2, h3 { margin: 0 0 12px; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, filter .12s ease;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-success { background: var(--success); color: #05260f; }
.btn-danger { background: var(--danger); color: #2b0505; }
.btn-outline { background: transparent; border: 2px solid var(--primary-2); color: var(--text); }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 16px 28px; font-size: 1.15rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Cards / forms ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 10px 30px rgba(0,0,0,.35);
    margin-bottom: 20px;
}

label { display: block; margin: 14px 0 6px; font-weight: 600; color: var(--text-dim); font-size: .9rem; }

input[type=text], input[type=password], input[type=number], textarea, select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid #333366;
    background: #0f0f26;
    color: var(--text);
    font-size: 1rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary-2); }
textarea { resize: vertical; min-height: 70px; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.alert-error { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid var(--danger); }
.alert-success { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid var(--success); }

/* ---------- Auth pages ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); padding: 32px; border-radius: var(--radius); box-shadow: 0 15px 40px rgba(0,0,0,.4); }
.auth-card h1 { text-align: center; font-size: 1.4rem; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; background: rgba(0,0,0,.2);
}
.topbar .brand { font-weight: 800; font-size: 1.3rem; display:flex; align-items:center; gap:8px; }
.topbar nav a { margin-left: 16px; color: var(--text-dim); font-weight: 600; }
.topbar nav a:hover { color: var(--text); }

/* ---------- Dashboard grid ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.quiz-card { position: relative; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.badge-draft { background: #444; }
.badge-lobby { background: #1368ce; }
.badge-question, .badge-reveal, .badge-ranking { background: var(--success); color: #052e12; }
.badge-finished { background: var(--primary); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #33335a; }
th { color: var(--text-dim); font-size: .85rem; text-transform: uppercase; }

/* ---------- Options (Kahoot-style shapes) ---------- */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
@media (max-width: 640px) { .options-grid { grid-template-columns: 1fr; } }

.option-btn {
    display: flex; align-items: center; gap: 14px;
    padding: 22px; border: none; border-radius: 12px;
    font-size: 1.15rem; font-weight: 700; color: #fff; cursor: pointer;
    transition: transform .1s ease, filter .1s ease;
    text-align: left;
}
.option-btn:hover:not(:disabled) { transform: scale(1.02); filter: brightness(1.12); }
.option-btn:disabled { opacity: .55; cursor: not-allowed; }
.option-a { background: var(--opt-a); }
.option-b { background: var(--opt-b); }
.option-c { background: var(--opt-c); }
.option-d { background: var(--opt-d); }
.option-shape { width: 26px; height: 26px; flex-shrink: 0; display:flex; align-items:center; justify-content:center; font-size: 1.1rem;}
.option-btn.selected { outline: 4px solid #fff; }
.option-btn.correct-answer { outline: 4px solid #fff; box-shadow: 0 0 25px 4px rgba(34,197,94,.9); }
.option-btn.wrong-answer { opacity: .4; }

/* ---------- Presenter screen ---------- */
.presenter { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
@media (max-width: 480px) { .presenter { padding: 16px; } }
.presenter .room-code { font-size: clamp(1.8rem, 9vw, 3rem); font-weight: 900; letter-spacing: clamp(2px, 1vw, 6px); color: var(--accent); }
.presenter .question-progress { color: var(--text-dim); font-weight: 700; letter-spacing: 2px; margin-bottom: 6px; }
.presenter .question-text { font-size: clamp(1.3rem, 4vw + .6rem, 2.3rem); font-weight: 800; max-width: 1000px; margin: 10px auto 20px; }
.timer-ring { width: 90px; height: 90px; margin: 10px auto; position: relative; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 8; }
.timer-ring .bg { stroke: #333366; }
.timer-ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-ring .label { position: absolute; inset: 0; display:flex; align-items:center; justify-content:center; font-size: 1.6rem; font-weight: 800; }

.qr-box { background: #fff; padding: 14px; border-radius: 12px; display: inline-block; margin: 16px 0; }

.participants-live { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 800px; margin-top: 20px;}
.participant-chip { background: var(--card); padding: 8px 16px; border-radius: 20px; font-weight: 700; }

/* ---------- Ranking ---------- */
.ranking-list { list-style: none; margin: 20px auto; padding: 0; max-width: 560px; text-align: left; }
.ranking-list li {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); padding: 14px 20px; border-radius: 10px; margin-bottom: 10px;
    font-size: 1.2rem; font-weight: 700; animation: slideIn .4s ease;
}
.ranking-list li .pos { color: var(--accent); width: 40px; }
.ranking-list li .score { color: var(--success); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-30px);} to { opacity: 1; transform: translateX(0);} }

/* ---------- Podium ---------- */
.podium-wrap { display:flex; align-items:flex-end; justify-content:center; gap: 24px; margin-top: 50px; min-height: 320px; }
.podium-place { display:flex; flex-direction:column; align-items:center; animation: riseUp 1s ease both; }
.podium-place .medal { font-size: 3rem; }
.podium-place .name { font-weight: 800; font-size: 1.3rem; margin: 8px 0; }
.podium-place .score { color: var(--success); font-weight: 700; margin-bottom: 8px;}
.podium-bar { width: 140px; border-radius: 10px 10px 0 0; display:flex; align-items:flex-start; justify-content:center; padding-top:10px; font-weight:900; font-size:1.4rem;}
.podium-1 .podium-bar { height: 220px; background: linear-gradient(180deg,#ffd94a,#e0a900); order:2; }
.podium-2 .podium-bar { height: 160px; background: linear-gradient(180deg,#dfe4ea,#a9b0bd); order:1; }
.podium-3 .podium-bar { height: 120px; background: linear-gradient(180deg,#e79a5b,#b4652a); order:3; }
.podium-1 { order: 2; }
.podium-2 { order: 1; }
.podium-3 { order: 3; }
@keyframes riseUp { from { opacity:0; transform: translateY(60px);} to { opacity:1; transform: translateY(0);} }

@media (max-width: 560px) {
    .podium-wrap { gap: 8px; min-height: 240px; }
    .podium-bar { width: 92px; font-size: 1.05rem; padding-top: 6px; }
    .podium-1 .podium-bar { height: 160px; }
    .podium-2 .podium-bar { height: 120px; }
    .podium-3 .podium-bar { height: 92px; }
    .podium-place .medal { font-size: 2.1rem; }
    .podium-place .name { font-size: .95rem; margin: 4px 0; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Participant screen ---------- */
.participant-page { display:flex; align-items:center; justify-content:center; min-height:100vh; padding: 20px;}
.waiting-box { text-align:center; }
.waiting-box .big-icon { font-size: 4rem; }
.status-answered { text-align:center; }
.status-answered .check { font-size: 4.5rem; color: var(--success); }
.my-score { font-size: 2.4rem; font-weight: 900; }

/* ---------- Control room ---------- */
.control-actions { display:flex; flex-wrap:wrap; gap: 12px; margin-bottom: 20px; }
.live-panel { display:grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .live-panel { grid-template-columns: 1fr; } }
.stat-box { background: var(--card); border-radius: 12px; padding: 16px; text-align:center; }
.stat-box .num { font-size: 2rem; font-weight: 900; color: var(--accent); }

/* ---------- Modais (perguntas, novo quiz, etc.) ---------- */
/* "align-items: safe center" evita o bug clássico de flexbox em que,
   quando o conteúdo é mais alto que a tela, o topo do modal fica
   cortado e inacessível mesmo com scroll — em telas baixas/estreitas
   (celular, notebook pequeno) isso deixava o formulário "desajustado". */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
    align-items: center; align-items: safe center; justify-content: center;
    z-index: 50; overflow-y: auto; padding: 24px 16px;
}
.modal-overlay.open { display: flex; }
.modal-card { width: 100%; margin: auto 0; }
@media (max-width: 480px) {
    .modal-overlay { padding: 14px 10px; }
    .modal-card { padding: 16px; }
}

/* Duas colunas (ex.: tempo/pontuação) que empilham em telas estreitas */
.field-row { display: flex; gap: 14px; }
.field-row > div { flex: 1; min-width: 0; }
@media (max-width: 420px) {
    .field-row { flex-direction: column; gap: 0; }
}

.small-text { color: var(--text-dim); font-size: .85rem; }
.flex-between { display:flex; align-items:center; justify-content:space-between; flex-wrap: wrap; gap: 10px; }
.icon-btn { background: none; border: none; color: var(--text-dim); cursor:pointer; font-size: 1.1rem; }
.icon-btn:hover { color: var(--danger); }
