/* Entrenamiento Gamificado (beta) — tema Sistema, oscuro, mobile-first.
   Tres apariencias reversibles: clasica / limpia / esencial.
   Se cambia con data-appearance en <html>. La lógica no cambia. */
:root {
  --radius: 14px;
  --radius-sm: 9px;
  --nav-h: 64px;
  --max-w: 860px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html[data-appearance="clasica"] {
  --bg: #070b16;
  --bg2: #0b1226;
  --surface: #111a33;
  --surface2: #16223f;
  --border: #26355e;
  --text: #e8eefc;
  --muted: #93a3c4;
  --accent: #6ea8fe;
  --accent2: #a78bfa;
  --gold: #f5c542;
  --success: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --glow: 0 0 24px rgba(110, 168, 254, .25);
}
html[data-appearance="limpia"] {
  --bg: #0e1218;
  --bg2: #141a22;
  --surface: #181f2a;
  --surface2: #1e2733;
  --border: #2c3848;
  --text: #eef2f7;
  --muted: #9aa8ba;
  --accent: #2dd4bf;
  --accent2: #7dd3fc;
  --gold: #fbbf24;
  --success: #34d399;
  --danger: #f87171;
  --warn: #f59e0b;
  --shadow: 0 6px 18px rgba(0, 0, 0, .35);
  --glow: none;
}
html[data-appearance="esencial"] {
  --bg: #050505;
  --bg2: #0a0a0a;
  --surface: #101010;
  --surface2: #161616;
  --border: #262626;
  --text: #e5e5e5;
  --muted: #8a8a8a;
  --accent: #8b7fd4;
  --accent2: #6b6b6b;
  --gold: #d4af37;
  --success: #4ade80;
  --danger: #ef4444;
  --warn: #d4af37;
  --shadow: none;
  --glow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 24px; letter-spacing: .04em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.gold { color: var(--gold); }
.accent { color: var(--accent); }
.game-icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.game-icon.lg { width: 28px; height: 28px; }
.game-icon.sm { width: 16px; height: 16px; }

/* ---------- Vistas ---------- */
.view { display: none; }
.view.active { display: block; }
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 16px 14px calc(var(--nav-h) + 28px); }
.center-wrap { max-width: 480px; margin: 0 auto; padding: 24px 16px 40px; }

/* ---------- Cabecera ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .14em; font-size: 15px; }
.brand .game-icon { color: var(--accent); }
.hunter-chip { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600;
}
.chip .game-icon { width: 15px; height: 15px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 50%; width: 38px; height: 38px; display: inline-flex;
  align-items: center; justify-content: center; position: relative; flex: none;
}
.badge-dot {
  position: absolute; top: -2px; right: -2px; min-width: 17px; height: 17px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.xpbar { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.xpbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.xp-line { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Subnavegación ---------- */
.subnav {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 4px;
  max-width: var(--max-w); margin: 0 auto; scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav button {
  flex: none; background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
}
.subnav button.active { background: var(--accent); border-color: var(--accent); color: #06101f; }
html[data-appearance="limpia"] .subnav button.active { color: #04211c; }
html[data-appearance="esencial"] .subnav button.active { color: #fff; }

/* ---------- Tarjetas y botones ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin: 12px 0; box-shadow: var(--shadow);
}
.card h2, .card h3 { display: flex; align-items: center; gap: 8px; }
.card h2 .game-icon, .card h3 .game-icon { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #06101f; border: none; border-radius: var(--radius-sm);
  padding: 11px 16px; font-size: 15px; font-weight: 700; text-decoration: none;
}
html[data-appearance="esencial"] .btn { color: #fff; }
.btn.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.gold { background: var(--gold); color: #241a00; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row .btn { flex: 1; min-width: 120px; }
.empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 20px 14px; text-align: center; color: var(--muted); margin: 12px 0;
}
.empty .game-icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 6px; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
}
.tag.gold { color: var(--gold); border-color: var(--gold); }
.tag.accent { color: var(--accent); border-color: var(--accent); }
.tag.locked { color: var(--warn); border-color: var(--warn); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat-box b { display: block; font-size: 20px; }
.stat-box span { font-size: 12px; color: var(--muted); }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
details.workout { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 8px 0; background: var(--surface); }
details.workout summary { cursor: pointer; padding: 11px 12px; list-style: none; display: flex; gap: 8px; align-items: center; }
details.workout summary::-webkit-details-marker { display: none; }
details.workout .body { padding: 0 12px 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
table.data tr.row-user td { background: rgba(212, 175, 55, 0.10); font-weight: 600; }
.progress { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* ---------- TU SEMANA ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.week-day {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); padding: 8px 2px 6px; text-align: center; min-width: 0;
}
.week-day .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.week-day .dnum { font-size: 17px; font-weight: 800; line-height: 1.2; }
.week-day .mark { font-size: 12px; min-height: 17px; color: var(--success); font-weight: 700; }
.week-day .xp { font-size: 10px; color: var(--gold); min-height: 13px; }
.week-day.today { border-color: var(--accent); box-shadow: var(--glow); background: var(--surface); }
.week-day.today .dow { color: var(--accent); }
.week-day.trained { border-color: var(--success); }

/* ---------- Navegación inferior ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.bottomnav-inner {
  max-width: var(--max-w); margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: end;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}
.nav-btn {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; padding: 6px 2px;
}
.nav-btn .game-icon { width: 22px; height: 22px; }
.nav-btn.active { color: var(--accent); }
.nav-central {
  width: 58px; height: 58px; border-radius: 50%; margin: -26px 8px 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 3px solid var(--bg); color: #06101f;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow);
}
html[data-appearance="esencial"] .nav-central { color: #fff; }
.nav-central .game-icon { width: 26px; height: 26px; }

/* ---------- Menú rápido, modales, tutorial ---------- */
.sheet-backdrop, .modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .65);
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open, .modal-backdrop.open { display: flex; }
.sheet {
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  border-radius: 18px 18px 0 0; width: 100%; max-width: var(--max-w);
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet h3 { text-align: center; margin-bottom: 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-action {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 14px 6px; display: flex; flex-direction: column;
  align-items: center; gap: 7px; font-size: 12px; font-weight: 600; text-align: center;
}
.quick-action .game-icon { width: 26px; height: 26px; color: var(--accent); }
.modal-backdrop { align-items: center; padding: 16px; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow);
}
.modal h2 { display: flex; align-items: center; gap: 8px; }
.system-msg {
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--bg2); padding: 12px; margin: 10px 0; font-size: 15px;
}
.system-msg b { color: var(--accent); letter-spacing: .08em; }
.tutorial-spot { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
#tutorialCard {
  position: fixed; z-index: 90; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 14px);
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); max-width: 480px; margin: 0 auto;
}
#tutorialCard .steps { font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--nav-h) + 16px); z-index: 120;
  background: var(--surface2); border: 1px solid var(--accent); color: var(--text);
  border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Auth / landing / onboarding ---------- */
.hero { text-align: center; padding: 28px 0 8px; }
.hero .logo { width: 72px; height: 72px; color: var(--accent); margin: 0 auto 8px; }
.hero .logo svg { width: 100%; height: 100%; }
.hero h1 { font-size: 28px; letter-spacing: .06em; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.auth-error {
  display: none; background: rgba(248, 113, 113, .12); border: 1px solid var(--danger);
  color: var(--danger); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; font-size: 14px;
}
.auth-error.show { display: block; }
.auth-ok {
  display: none; background: rgba(52, 211, 153, .12); border: 1px solid var(--success);
  color: var(--success); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; font-size: 14px;
}
.auth-ok.show { display: block; }
.tabs-auth { display: flex; gap: 8px; margin-bottom: 6px; }
.tabs-auth button {
  flex: 1; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); font-weight: 700;
}
.tabs-auth button.active { background: var(--accent); color: #06101f; border-color: var(--accent); }
html[data-appearance="esencial"] .tabs-auth button.active { color: #fff; }
.steps-dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.steps-dots span { width: 26px; height: 6px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); }
.steps-dots span.on { background: var(--accent); border-color: var(--accent); }
.appearance-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.appearance-pick button {
  border: 2px solid var(--border); background: var(--surface2); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 6px; font-weight: 700; font-size: 13px;
}
.appearance-pick button.on { border-color: var(--accent); color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch {
  position: relative; width: 46px; height: 26px; flex: none; appearance: none;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--muted); transition: left .15s, background .15s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { left: 22px; background: #06101f; }
.radar-wrap { display: flex; justify-content: center; }
.radar-wrap svg { max-width: 100%; height: auto; }
.admin-box { border: 1px dashed var(--warn); border-radius: var(--radius); padding: 12px; margin: 12px 0; }
.admin-box h3 { color: var(--warn); }
.notif-unread { border-left: 3px solid var(--accent); }
@media (min-width: 640px) {
  .wrap { padding-left: 20px; padding-right: 20px; }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
}
