:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #232c38;
  --accent: #2f6df6;
  --accent-2: #00c2a8;
  --text: #e7edf3;
  --muted: #9aa7b4;
  --border: #2c3743;
  --ok: #2ecc71;
  --warn: #f0a020;
  --radius: 14px;
  --field-bg: #2e3a49;
  --field-text: #e7edf3;
  --field-border: #3d4b5c;
  --field-placeholder: #8794a3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 24px; }
.center { max-width: 460px; margin: 0 auto; padding: 32px 24px; }
.stage { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: none;
  padding: 12px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); white-space: pre-line; }
.btn.ghost:hover { background: var(--panel-2); }

/* Botones diferenciados por color (variantes sobre .btn.ghost) */
.btn.tint-img { border-color: rgba(28,168,196,.55); color: #52c7de; }
.btn.tint-img:hover { background: rgba(28,168,196,.12); border-color: #1CA8C4; }
.btn.tint-video { border-color: rgba(139,92,246,.55); color: #b39bf7; }
.btn.tint-video:hover { background: rgba(139,92,246,.12); border-color: #8b5cf6; }
.btn.tint-add { border-color: rgba(0,194,168,.55); color: #3fd8c4; }
.btn.tint-add:hover { background: rgba(0,194,168,.12); border-color: var(--accent-2); }
.btn.tint-danger { border-color: rgba(229,72,77,.5); color: #ef8f92; }
.btn.tint-danger:hover { background: rgba(229,72,77,.12); border-color: #e5484d; }
.btn.block { width: 100%; }
.btn.lg { padding: 16px 22px; font-size: 18px; }

.input, .select, textarea {
  width: 100%; background: var(--field-bg); color: var(--field-text);
  border: 1px solid var(--field-border); border-radius: 10px; padding: 12px 14px;
  font-size: 15px; font-family: inherit;
}
.input::placeholder, textarea::placeholder { color: var(--field-placeholder); opacity: 1; }
.input:focus, .select:focus, textarea:focus {
  outline: none; border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(0,194,168,.18);
}
textarea { resize: vertical; min-height: 70px; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.stack > * + * { margin-top: 14px; }

.tag {
  display: inline-block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; padding: 3px 8px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
}

.code-badge {
  font-size: 44px; font-weight: 800; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; color: var(--accent-2);
}

.qr { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.qr img { display: block; width: 220px; height: 220px; }

/* Resultados */
.bar-row { margin: 10px 0; }
.bar-label { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 14px; }
.bar-track { background: var(--panel-2); border-radius: 8px; height: 30px; overflow: hidden; }
.bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 8px; transition: width .4s ease; min-width: 2px;
}

.cloud { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: baseline; padding: 8px 0; }
.cloud span { font-weight: 700; line-height: 1; color: var(--text); white-space: pre-line; }

.open-list { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow: auto; }
.open-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.open-item .who { font-size: 12px; color: var(--muted); margin-top: 6px; }

.choice-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.choice-btn {
  text-align: left; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 16px; border-radius: 12px; font-size: 16px; cursor: pointer;
}
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.sel { border-color: var(--accent-2); background: rgba(0,194,168,.12); }

.scale-row { display: flex; gap: 10px; }
.scale-btn {
  flex: 1; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 20px; font-weight: 700; cursor: pointer;
}
.scale-btn.sel { border-color: var(--accent-2); background: rgba(0,194,168,.12); }

.q-editor { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--panel-2); }
.q-editor .row { margin-bottom: 8px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }

.notice { padding: 12px 14px; border-radius: 10px; background: rgba(240,160,32,.12); border: 1px solid var(--warn); color: var(--text); white-space: pre-line; }
.error { padding: 12px 14px; border-radius: 10px; background: rgba(231,76,60,.14); border: 1px solid #e74c3c; }

a.link { color: var(--accent-2); }

@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .panel { padding: 16px; }
  .stage { padding: 16px; }
  .code-badge { font-size: 36px; }
}

/* ---------- Nube de palabras ---------- */
.wordcloud { width: 100%; height: 360px; display: block; }
.wc-word {
  font-weight: 800; font-family: "Inter","Segoe UI",sans-serif; cursor: default;
  transition: transform .6s cubic-bezier(.2,.7,.2,1), font-size .4s ease, fill .4s ease;
}

/* ---------- Login / Dashboard ---------- */
.qcard { padding: 16px 20px; }
.qcard + .qcard { margin-top: 10px; }

/* ---------- Editor: respuesta correcta ---------- */
/* Fila de opción compacta: radio + campo + quitar en una sola línea */
.opt-row { align-items: center; flex-wrap: nowrap; gap: 8px; }
.opt-input { flex: 1 1 auto; min-width: 0; }
.opt-del { flex: 0 0 auto; width: 40px; padding: 10px 0; font-size: 18px; line-height: 1; }
/* Botones más compactos dentro del editor */
.q-editor .btn.small { padding: 8px 12px; }
.radio { display: inline-flex; align-items: center; cursor: pointer; }
.radio input { display: none; }
.radio span {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--field-border);
  background: var(--field-bg);
  display: inline-block; position: relative; flex: 0 0 auto;
}
.radio input:checked + span { border-color: var(--ok); background: var(--ok); }
.radio input:checked + span::after {
  content: "✓"; color: #08210f; font-size: 13px; font-weight: 800;
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.switch input { width: 18px; height: 18px; accent-color: var(--accent-2); }
.switch.locked { cursor: default; color: var(--accent-2); font-weight: 600; }
.switch.locked::before { content: "🔒"; font-size: 12px; }

.tag.eval { background: rgba(46,204,113,.14); color: var(--ok); border-color: var(--ok); }

/* ---------- Resultados: barra correcta ---------- */
.bar-row.correct .bar-label { color: var(--ok); }
.bar-fill.ok { background: linear-gradient(90deg, #1e9e57, var(--ok)); }
.check { color: var(--ok); font-size: 12px; font-weight: 700; margin-left: 6px; }

/* ---------- Participante: revelado ---------- */
.choice-btn.ok { border-color: var(--ok); background: rgba(46,204,113,.16); }
.choice-btn.bad { border-color: #e74c3c; background: rgba(231,76,60,.14); }
.notice.good { background: rgba(46,204,113,.14); border-color: var(--ok); }
.notice.timeout { background: rgba(231,76,60,.16); border-color: #e74c3c; color: var(--text); font-weight: 600; }

/* ---------- Imágenes en preguntas ---------- */
.q-image { width: 100%; max-width: 480px; height: auto; border-radius: 12px; display: block; margin: 0 auto 16px; border: 1px solid var(--border); object-fit: contain; }
.q-thumb { height: 56px; width: auto; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.img-control { margin-bottom: 10px; }
/* Controles de imagen y video en una misma fila */
.media-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.media-controls .img-control { margin-bottom: 0; }
.error.small { padding: 4px 8px; font-size: 12px; }

/* ---------- Marca / Logo (TanTTeo by NGS·AI) ---------- */
.brand { display: inline-flex; align-items: center; gap: 14px; }
.brand.lg { gap: 18px; }
.brand-mark { width: 44px; height: 44px; flex: 0 0 auto; display: block; }
.brand.lg .brand-mark { width: 62px; height: 62px; }
.brand-text { display: flex; flex-direction: column; text-align: left; }
.brand-name { font-weight: 800; font-size: 28px; line-height: 1; letter-spacing: .5px; color: #E7EDF3; }
.brand.lg .brand-name { font-size: 42px; }
.brand-name > span { color: #34C8DC; }
.brand-by { display: flex; align-items: center; gap: 7px; margin-top: 7px; }
.brand.lg .brand-by { margin-top: 9px; }
.brand-by .by { font-weight: 400; font-size: 13px; color: #8294a8; }
.brand-ngs { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.brand.lg .brand-ngs { width: 19px; height: 19px; }
.brand-by .ngs { font-weight: 700; font-size: 14px; letter-spacing: .5px; color: #C7D2E0; }
.brand-by .ngs > span { color: #34C8DC; }

/* ---------- Temporizador (cuenta regresiva) ---------- */
.timer-control { align-items: center; margin-top: 4px; }
.timer-input { max-width: 92px; text-align: center; }
.countdown { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.countdown svg { width: 100%; height: 100%; display: block; }
.cd-arc { transition: stroke-dashoffset .25s linear, stroke .4s ease; }
.cd-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.countdown.urgent { animation: cd-pulse .9s ease-in-out infinite; }
/* Contador flotante: sigue visible al hacer scroll en preguntas extensas, anclado a la esquina y sin tapar el contenido. */
.timer-float { position: sticky; top: 10px; z-index: 20; display: flex; justify-content: flex-end; margin-bottom: 2px; pointer-events: none; }
.timer-float .countdown { background: rgba(26,33,43,.82); border: 1px solid var(--border); border-radius: 50%; box-shadow: 0 6px 18px rgba(0,0,0,.4); backdrop-filter: blur(3px); pointer-events: auto; }
@keyframes cd-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* ---------- Multiusuario: formularios y avatares ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex: 0 0 auto; }
.avatar.lg { width: 72px; height: 72px; }
.avatar-ph { display: flex; align-items: center; justify-content: center; background: var(--panel-2); color: var(--accent-2); font-weight: 800; font-size: 20px; }
.avatar.lg.avatar-ph { font-size: 30px; }


/* ---------- Aviso de tratamiento (Art. 14 ter) ---------- */
.notice-card { text-align: left; }
.notice-dl { margin: 0; display: grid; gap: 2px; }
.notice-dl dt { font-weight: 700; color: var(--accent-2); font-size: 13px; margin-top: 9px; }
.notice-dl dd { margin: 0; color: var(--text); font-size: 14px; line-height: 1.45; }
.notice-ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.notice-ul li { font-size: 13.5px; line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }


/* ---------- Justificativo de la respuesta ---------- */
.justify-box { background: rgba(28,168,196,0.10); border-left: 3px solid var(--accent-2); border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-line; }
.justify-box b { color: var(--accent-2); }


/* ---------- Video de la pregunta ---------- */
.q-video { width: 100%; max-width: 560px; height: auto; border-radius: 12px; display: block; margin: 0 auto 16px; border: 1px solid var(--border); background: #000; }
video.q-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #000; }


/* ---------- Modo competencia ---------- */
.comp-toggle { display: flex; align-items: flex-start; gap: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.comp-toggle input { margin-top: 3px; flex: 0 0 auto; width: 18px; height: 18px; accent-color: var(--accent-2); }
.alias-input { text-align: center; font-size: 18px; letter-spacing: .02em; }
.comp-bar { align-items: center; }
.score-badge { font-weight: 800; color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* Tabla de líderes */
.lb-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.lb-title { font-weight: 700; font-size: 15px; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.lb-pos { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); color: var(--muted); font-weight: 800; font-size: 14px; }
.lb-row.top .lb-pos { background: var(--accent-2); color: #06222a; }
.lb-row.winner .lb-pos { background: transparent; font-size: 20px; }
/* Barra proporcional al puntaje, con color por participante (estilo Mentimeter) */
.lb-bar { position: relative; height: 34px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; display: flex; align-items: center; }
.lb-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 9px 0 0 9px; opacity: .9; transition: width .7s cubic-bezier(.22,.61,.36,1); }
.lb-row.winner .lb-bar { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(28,168,196,.35); }
.lb-alias { position: relative; z-index: 1; padding-left: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,.55); }
.lb-winner-tag { position: relative; z-index: 1; margin-left: auto; margin-right: 10px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #06222a; background: var(--accent-2); padding: 2px 8px; border-radius: 999px; }
.lb-score { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.lb-row.winner .lb-score { color: var(--accent-2); }
.lb-final-panel { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(0,194,168,.25); }
/* Pantalla intermedia de puntaje (entre preguntas, estilo Mentimeter) */
.lb-interstitial { border-color: var(--accent-2); }

/* Podio del resultado final (1.º, 2.º, 3.º) */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 12px 0 6px; }
.podium-slot { display: flex; flex-direction: column; align-items: center; width: 96px; max-width: 30%; }
.podium-medal { font-size: 30px; line-height: 1; margin-bottom: 4px; }
.podium-alias { font-weight: 700; font-size: 14px; margin-bottom: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-bar { width: 100%; border-radius: 10px 10px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; opacity: .92; }
.podium-rank { font-size: 20px; font-weight: 800; color: rgba(0,0,0,.55); }
.podium-slot.p1 .podium-bar { height: 104px; }
.podium-slot.p2 .podium-bar { height: 76px; }
.podium-slot.p3 .podium-bar { height: 54px; }
.podium-score { font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* Sala de espera: participantes unidos */
.lobby-roster { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.roster-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.roster-chip { background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 14px; }
.lobby-count { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
