/* Carismatín — mobile first, oscuro por defecto, con tema claro opcional. */

:root {
  --bg: #0e1014;
  --surface: #171b22;
  --surface-2: #1f2530;
  --border: #2a313d;
  --text: #e9ecf1;
  --muted: #98a2b3;
  --accent: #ff6b4a;
  --accent-soft: rgba(255, 107, 74, 0.14);
  --good: #38c793;
  --good-soft: rgba(56, 199, 147, 0.14);
  --bad: #f2616f;
  --bad-soft: rgba(242, 97, 111, 0.14);
  --gold: #f5c04a;
  --blue: #5b9bf5;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --nav-h: 64px;
}

[data-theme='light'] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dde1e8;
  --text: #14171d;
  --muted: #616b7c;
  --accent-soft: rgba(255, 107, 74, 0.12);
  --good-soft: rgba(56, 199, 147, 0.16);
  --bad-soft: rgba(242, 97, 111, 0.14);
  --shadow: 0 6px 20px rgba(20, 23, 29, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; line-height: 1.55; }

/* ---------- Encabezado ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 18px;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}
.brand span { color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.streak { color: var(--gold); }
.chip.level { color: var(--blue); }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 15px;
}

/* ---------- Layout ---------- */

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.view { animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin: 24px 0 10px;
}
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.tag.alt { color: var(--blue); background: rgba(91, 155, 245, 0.14); }
.tag.gold { color: var(--gold); background: rgba(245, 192, 74, 0.14); }
.tag.good { color: var(--good); background: var(--good-soft); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #14171d; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- Menú inferior ---------- */

nav.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
nav.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
nav.tabbar button .ico { font-size: 19px; line-height: 1; }
nav.tabbar button.active { color: var(--accent); }

/* ---------- Barra de progreso ---------- */

.bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar.good > i { background: linear-gradient(90deg, var(--good), var(--blue)); }

/* ---------- Home ---------- */

.hero {
  background: linear-gradient(150deg, rgba(255, 107, 74, 0.18), rgba(91, 155, 245, 0.12));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 16px;
}
.hero h1 { font-size: 22px; letter-spacing: -0.02em; }
.hero p { margin-top: 6px; color: var(--muted); font-size: 14px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.stat span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.mode-card:active { transform: scale(0.99); }
.mode-card .emoji {
  width: 44px; height: 44px;
  flex: none;
  display: grid; place-items: center;
  font-size: 22px;
  border-radius: 12px;
  background: var(--surface-2);
}
.mode-card b { display: block; font-size: 15.5px; }
.mode-card small { color: var(--muted); font-size: 13px; }

/* ---------- Cartas de contenido ---------- */

.content-card h3 { font-size: 18px; letter-spacing: -0.01em; margin-bottom: 8px; }
.content-card .body { font-size: 15px; line-height: 1.6; }
.usar {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 13.5px;
  line-height: 1.5;
  border-left: 3px solid var(--accent);
}
.usar b { color: var(--accent); }

.story-part { margin-top: 14px; }
.story-part .label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 4px;
}
.story-part.remate { border-left: 3px solid var(--gold); padding-left: 12px; }
.story-part.remate .label { color: var(--gold); }

.joke-setup { font-size: 16px; line-height: 1.5; }
.joke-remate { font-size: 18px; font-weight: 700; margin-top: 12px; color: var(--gold); line-height: 1.4; }

.est-block { margin-top: 14px; }
.est-block .label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 4px;
}
.guion {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  background: var(--surface-2);
  padding: 11px 13px;
  border-radius: 10px;
  line-height: 1.55;
}
.error-box {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--bad-soft);
  font-size: 13.5px;
  line-height: 1.5;
}
.error-box b { color: var(--bad); }

/* ---------- Opciones (quiz / escenarios) ---------- */

.option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 13px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  margin-bottom: 10px;
  font-size: 14.5px;
  line-height: 1.5;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.option:active { transform: scale(0.99); }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.dim { opacity: 0.5; }
.option .fb {
  display: block;
  margin-top: 9px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 9px;
}
.option .pts { float: right; font-weight: 800; font-size: 13px; margin-left: 10px; }

/* ---------- Quiz cabecera ---------- */

.quiz-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.quiz-head .bar { flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; }
.timer.low { color: var(--bad); }

.q-text { font-size: 19px; font-weight: 700; line-height: 1.35; margin: 6px 0 18px; letter-spacing: -0.01em; }

/* ---------- Listas ---------- */

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  margin-bottom: 8px;
}
.list-item .txt { flex: 1; min-width: 0; }
.list-item b { display: block; font-size: 14.5px; line-height: 1.35; }
.list-item small { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }
.list-item .right { flex: none; color: var(--muted); font-size: 12px; font-weight: 700; }

.check {
  width: 24px; height: 24px; flex: none;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  font-size: 13px;
}
.check.on { background: var(--good); border-color: var(--good); color: #0e1014; }

.pill-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.pill-row::-webkit-scrollbar { display: none; }
.pill {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.pill.active { background: var(--accent); color: #14171d; border-color: transparent; }

/* ---------- Logros ---------- */

.ach {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--border);
  margin-bottom: 8px;
}
.ach.locked { opacity: 0.42; }
.ach .ico { font-size: 24px; width: 40px; text-align: center; }
.ach b { display: block; font-size: 14.5px; }
.ach small { color: var(--muted); font-size: 12.5px; }

/* ---------- Resultado ---------- */

.result { text-align: center; padding: 28px 16px; }
.result .big { font-size: 46px; font-weight: 800; letter-spacing: -0.03em; }
.result .xp { color: var(--gold); font-weight: 800; font-size: 17px; margin-top: 6px; }

/* ---------- Toast ---------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
}
.toast.gold { border-color: var(--gold); color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Utilidades ---------- */

.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
.hidden { display: none !important; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 14px; }
.empty .em { font-size: 34px; display: block; margin-bottom: 10px; }

.field {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  margin-top: 8px;
}
label.lbl { font-size: 13px; font-weight: 700; color: var(--muted); display: block; margin-top: 14px; }

.swipe-hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }

@media (min-width: 700px) {
  .grid2 { gap: 14px; }
  main { padding-top: 22px; }
}
