/* Arboria, alojada en el propio servidor (public/fonts). */
@font-face { font-family: "Arboria"; src: url("/fonts/Arboria-Book.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Arboria"; src: url("/fonts/Arboria-BookItalic.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Arboria"; src: url("/fonts/Arboria-Medium.woff") format("woff"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Arboria"; src: url("/fonts/Arboria-Bold.woff") format("woff"); font-weight: 600 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Arboria"; src: url("/fonts/Arboria-Black.woff") format("woff"); font-weight: 800 900; font-style: normal; font-display: swap; }

/* ==========================================================
   Branding Amichi — tokens tomados del Manual de Marca.
   Institucional: azul Pantone 284C (#091D60), celeste Pantone 280C (#88B8F8),
   celeste claro #D2E6F9, grises #666666 / #CCCCCC. Tipografía: Arboria.
   ========================================================== */
:root {
  --brand: #091d60;
  --brand-strong: #061447;
  --brand-soft: #d2e6f9;
  --accent: #88b8f8;
  --accent-strong: #6aa3f2;
  --accent-ink: #091d60;

  --bg: #f3f7fc;
  --surface: #ffffff;
  --ink: #0c1a45;
  --muted: #666666;
  --line: #cccccc;
  --ok: #2e8540;
  --danger: #c0392b;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(9, 29, 96, .06), 0 4px 16px rgba(9, 29, 96, .08);
  --font: "Arboria", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.4; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
a { color: var(--brand); }

/* ---- Componentes base ---- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--brand); color: #fff; }
.topbar .logo { height: 28px; }
.topbar .event-name { font-weight: 600; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 700; color: var(--brand); margin: 0 0 6px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; color: inherit;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: 0; border-radius: 10px; font: inherit; font-weight: 600;
  background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--line); }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--line); color: var(--muted); }
.badge-open { background: #d9f2e4; color: var(--ok); }
.badge-live { background: var(--accent); color: var(--accent-ink); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 10; max-width: calc(100% - 32px); }

/* ---- Barras de resultados ---- */
.bars { display: grid; gap: 12px; margin-top: 16px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; margin-bottom: 4px; }
.bar-num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 12px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .5s ease; }
.bar.is-mine .bar-fill { background: var(--accent); }

/* ---- Participante ---- */
.page-join .container h1 { font-size: 1.6rem; }
.code-input { font-size: 2rem; text-align: center; letter-spacing: .3em; font-weight: 700; }
.hello { color: var(--muted); margin: 0 0 12px; }
.q-text { font-size: 1.35rem; }
.options { display: grid; gap: 10px; margin-top: 16px; }
.option {
  text-align: left; padding: 16px; font: inherit; font-weight: 600; font-size: 1.05rem; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
}
.option:hover, .option:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }
.note { margin: 16px 0 0; padding: 12px; background: var(--brand-soft); border-radius: 10px; }
.waiting { text-align: center; padding: 40px 20px; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); margin: 0 auto 16px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(136, 184, 248, .7); } 100% { box-shadow: 0 0 0 18px rgba(136, 184, 248, 0); } }

/* ---- Pantalla de presentación ---- */
.page-screen { background: var(--brand-strong); color: #fff; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.screen-top { display: flex; align-items: center; gap: 24px; padding: 2vh 3vw; }
.screen-top .logo { height: 5vh; min-height: 32px; }
.screen-top h1 { font-size: 2.6vh; margin: 0; opacity: .85; flex: 1; }
.join-hint { display: flex; align-items: center; gap: 14px; font-size: 2.2vh; background: rgba(255, 255, 255, .08); padding: 1vh 1.4vw; border-radius: 12px; }
.join-hint img { height: 8vh; background: #fff; border-radius: 6px; padding: 4px; }
.join-hint strong { color: var(--accent); font-size: 3vh; letter-spacing: .08em; }
#stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2vh 6vw 6vh; }
.lobby { display: flex; align-items: center; gap: 6vw; }
.lobby .qr { width: 42vh; height: 42vh; background: #fff; border-radius: 20px; padding: 2vh; }
.lobby .big-label { font-size: 3vh; opacity: .8; margin: 0; }
.lobby .big-url { font-size: 4.5vh; font-weight: 700; margin: .5vh 0 4vh; }
.lobby .big-code { font-size: 14vh; font-weight: 800; letter-spacing: .08em; color: var(--accent); line-height: 1; margin: 0 0 4vh; }
.lobby .count { font-size: 3vh; opacity: .85; }
.screen-q { width: 100%; max-width: 1400px; }
.screen-q h2 { font-size: 6vh; margin-bottom: 5vh; }
.screen-q .bars { gap: 3vh; }
.screen-q .bar-label { font-size: 3.4vh; margin-bottom: 1vh; }
.screen-q .bar-num { color: rgba(255, 255, 255, .8); }
.screen-q .bar-track { height: 4.5vh; background: rgba(255, 255, 255, .12); }
.screen-q .bar-fill { background: var(--accent); }
.screen-q .vote-now { font-size: 4vh; opacity: .9; }
.screen-q .vote-count { font-size: 10vh; font-weight: 800; color: var(--accent); margin: 2vh 0 0; }
.screen-q .options-list { display: grid; gap: 2vh; font-size: 3.6vh; margin: 0 0 5vh; padding: 0; list-style: none; }
.screen-q .options-list li { background: rgba(255, 255, 255, .08); padding: 2vh 2vw; border-radius: 14px; }
.screen-q .closed-tag { display: inline-block; font-size: 2.4vh; background: rgba(255, 255, 255, .15); padding: .6vh 1.2vw; border-radius: 99px; margin-bottom: 2vh; }
.screen-msg { font-size: 4vh; opacity: .8; }

/* ---- Administración ---- */
.page-admin .layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 52px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 16px; }
.sidebar h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.event-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.event-list button { width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; font: inherit; cursor: pointer; color: var(--ink); }
.event-list button:hover { background: var(--bg); }
.event-list button.is-active { background: var(--brand-soft); color: var(--brand); }
.event-list small { display: block; color: var(--muted); }
.admin-main { padding: 24px 32px 64px; max-width: 980px; }
.event-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.event-head .qr { width: 132px; height: 132px; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--line); }
.event-head .meta { flex: 1; min-width: 240px; }
.event-head .code { font-size: 2rem; font-weight: 800; letter-spacing: .08em; color: var(--brand); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.stats { display: flex; gap: 12px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 14px; }
.stat b { font-size: 1.3rem; display: block; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 12px; }
.q-list { display: grid; gap: 14px; }
.q-card.is-live { outline: 2px solid var(--accent); }
.q-card header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.q-card h3 { font-size: 1.1rem; margin: 0 0 4px; }
.q-card .bars { margin-top: 10px; }
.q-card .total { color: var(--muted); font-size: .9rem; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.empty { text-align: center; padding: 32px; color: var(--muted); }
.login-wrap { max-width: 380px; margin: 10vh auto; padding: 0 16px; }

@media (max-width: 800px) {
  .page-admin .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-main { padding: 20px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Pantalla vertical o casi cuadrada: QR arriba, datos abajo. */
@media (max-aspect-ratio: 5/4) {
  .lobby { flex-direction: column; text-align: center; gap: 3vh; }
  .lobby .qr { width: 32vh; height: 32vh; }
  .lobby .big-code { font-size: 9vh; }
  .lobby .big-url { margin-bottom: 2vh; }
  .lobby .big-code { margin-bottom: 2vh; }
}

/* ==========================================================
   Etapa 2: quiz, pregunta abierta, ranking, moderación
   ========================================================== */
:root {
  /* Colores de las opciones del quiz (A–F): paleta institucional y de destinos del manual. */
  --q0: #8a46ad; /* violeta institucional */
  --q1: #519ebc; /* destino BAR */
  --q2: #6d152a; /* destino MZA */
  --q3: #608e3d; /* destino IGR */
  --q4: #9079d8; /* lavanda institucional */
  --q5: #0080be;
}
.c0 { --opt: var(--q0); } .c1 { --opt: var(--q1); } .c2 { --opt: var(--q2); }
.c3 { --opt: var(--q3); } .c4 { --opt: var(--q4); } .c5 { --opt: var(--q5); }

.bar.is-correct .bar-fill { background: var(--ok); }
.bar.is-correct .bar-text { color: var(--ok); }
.page-screen .bar.is-correct .bar-fill { background: #3ccf7e; }
.page-screen .bar.is-correct .bar-text { color: #7ff0b0; }
.page-screen .bar:not(.is-correct) .bar-fill { opacity: .55; }
.page-screen .bars:not(:has(.is-correct)) .bar .bar-fill { opacity: 1; }

/* Quiz en el celular */
.quiz-options { grid-template-columns: 1fr; }
.quiz-opt.option { display: flex; align-items: center; gap: 12px; background: var(--opt); border-color: var(--opt); color: #fff; }
.quiz-opt.option:hover, .quiz-opt.option:focus-visible { background: var(--opt); border-color: var(--ink); filter: brightness(1.08); }
.quiz-opt.option:disabled { opacity: .45; }
.quiz-opt.option.is-picked { opacity: 1; outline: 3px solid var(--ink); outline-offset: 2px; }
.letter { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px; background: rgba(255, 255, 255, .25); font-weight: 800; }
.timer { height: 8px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.timer-bar { height: 100%; width: 100%; background: var(--accent); transition: width .2s linear; }
.timer-num { text-align: right; font-weight: 700; color: var(--muted); margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.verdict { margin-top: 12px; padding: 16px; border-radius: 12px; font-size: 1.2rem; font-weight: 700; text-align: center; background: var(--bg); }
.verdict.ok { background: #d9f2e4; color: var(--ok); }
.verdict.bad { background: #fdecea; color: var(--danger); }
.me-score { font-weight: 600; color: var(--brand); margin: 12px 0 0; }
.me-score:empty { display: none; }

/* Pregunta abierta en el celular */
.open-form { margin-top: 16px; }
.open-form textarea { margin-top: 0; min-height: 110px; }
.open-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.answers { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.answer { background: var(--bg); border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; }

/* Ranking */
.ranking { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.ranking li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.ranking li.is-me { background: var(--brand-soft); outline: 2px solid var(--brand); }
.ranking .pos { width: 28px; text-align: center; font-weight: 800; color: var(--brand); }
.ranking .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .pts { font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking li:nth-child(1) .pos { color: var(--brand); font-size: 1.15em; }
.empty-rank { justify-content: center; color: var(--muted); }

/* Pantalla: quiz, muro de respuestas y ranking */
.timer-big { height: 2vh; background: rgba(255, 255, 255, .12); margin: 0 0 1vh; }
.timer-num-big { font-size: 6vh; font-weight: 800; color: var(--accent); margin: 0 0 3vh; font-variant-numeric: tabular-nums; }
.quiz-grid { list-style: none; padding: 0; margin: 0 0 4vh; display: grid; grid-template-columns: 1fr 1fr; gap: 2vh; }
.quiz-grid .quiz-opt { display: flex; align-items: center; gap: 1.5vw; background: var(--opt); padding: 2.4vh 2vw; border-radius: 14px; font-size: 3.4vh; font-weight: 700; }
.quiz-grid .letter { width: 6vh; height: 6vh; border-radius: 10px; font-size: 3vh; }
.wall { list-style: none; padding: 0; margin: 0; columns: 3 22vw; column-gap: 2vh; }
.wall .answer { break-inside: avoid; margin-bottom: 2vh; background: rgba(255, 255, 255, .1); color: #fff; font-size: 2.8vh; padding: 2vh 1.6vw; border-radius: 14px; }
/* Top 10 en dos columnas (1–5 y 6–10) para que entre completo en un proyector 16:9. */
.ranking-big { gap: 1.6vh 3vw; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(5, auto); grid-auto-flow: column; }
.ranking-big:has(.empty-rank) { grid-template-columns: 1fr; }
.ranking-big li { background: rgba(255, 255, 255, .08); padding: 1.6vh 2vw; font-size: 3.4vh; border-radius: 14px; }
.ranking-big .pos { width: 6vh; color: var(--accent); }
.ranking-big li:nth-child(1) { background: rgba(136, 184, 248, .28); }
.ranking-big .empty-rank { color: rgba(255, 255, 255, .7); }

/* Admin: formulario de pregunta */
.type-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding: 4px; background: var(--bg); border-radius: 12px; width: fit-content; }
.type-tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.type-tabs button.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.field-label { font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
.option-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.option-row { display: flex; align-items: center; gap: 8px; }
.option-row .opt-text { margin-top: 0; flex: 1; }
.option-row [type=radio] { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--ok); }
.opt-letter { width: 26px; text-align: center; font-weight: 700; color: var(--muted); }
#qForm .only-quiz, #qForm .only-open, #qForm .option-row [type=radio] { display: none; }
#qForm[data-type="quiz"] .only-quiz, #qForm[data-type="open"] .only-open { display: block; }
#qForm[data-type="quiz"] span.only-quiz { display: inline; }
#qForm[data-type="quiz"] .option-row [type=radio] { display: block; }
#qForm[data-type="open"] .only-choice { display: none; }
#qForm .only-choice, #qForm .only-quiz, #qForm .only-open { margin-bottom: 14px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
#qForm[data-type="open"] label.check { display: flex; }

/* Admin: moderación */
.mod-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 420px; overflow: auto; }
.mod-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; background: var(--bg); border-left: 4px solid var(--ok); }
.mod-row.is-pending { border-left-color: var(--accent); background: #fff7e6; }
.mod-row.is-hidden { border-left-color: var(--line); opacity: .6; }
.mod-text { min-width: 0; }
.mod-text p { margin: 0; overflow-wrap: anywhere; }
.mod-text small { color: var(--muted); }
.mod-actions { display: flex; gap: 6px; flex: none; }

/* Diálogo de confirmación (eliminar evento) */
.dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 12px 48px rgba(9, 29, 96, .3); color: var(--ink); }
.dialog::backdrop { background: rgba(6, 20, 71, .55); }
.dialog h2 { font-size: 1.3rem; }
.dialog p { margin: 0 0 12px; }
.dialog .warn { color: var(--danger); font-weight: 600; }
.dialog label { margin-top: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn-delete { background: var(--danger); }
.btn-delete:hover { background: #a03024; }

/* Pantalla de cierre del evento */
.final { text-align: center; padding: 40px 24px; }
.final-iso { width: 72px; height: auto; margin-bottom: 16px; }
.final h2 { font-size: 1.6rem; }
.final .me-score { font-size: 1.1rem; margin: 8px 0 16px; }
.final-screen { text-align: center; width: 100%; max-width: 1200px; }
.final-logo { height: 9vh; margin-bottom: 5vh; }
.final-screen h2 { font-size: 7vh; margin-bottom: 6vh; }
.podium { list-style: none; padding: 0; margin: 0 auto; display: grid; gap: 1.6vh; max-width: 900px; }
.podium li { display: flex; align-items: center; gap: 2vw; background: rgba(255, 255, 255, .08); border-radius: 16px; padding: 2vh 2.4vw; font-size: 3.8vh; }
.podium .medal { font-size: 5vh; }
.podium .name { flex: 1; text-align: left; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .pts { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.podium .podium-1 { background: rgba(136, 184, 248, .28); font-size: 4.4vh; }

/* Admin: aviso de evento finalizado */
.ended-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px 18px; border-radius: var(--radius); background: var(--brand-soft); border: 1.5px solid var(--accent); }
.ended-banner q { font-style: italic; }
