/* Virtual Fitness World — estilos. Pensado para PC y TV (HDMI): objetivos grandes, foco muy visible. */
:root {
  --bg: #0e1622; --bg2: #152033; --card: #1a2740; --card2: #22314f; --line: #2c3d5e;
  --text: #eef3fb; --muted: #9fb0c9; --accent: #3ddc97; --accent2: #5aa9ff; --warn: #ffb547; --danger: #ff6b6b;
  --sim: #c792ff; --est: #ffd166; --radius: 16px; --focus: #ffffff;
  font-size: clamp(16px, 1.05vw + 8px, 22px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overflow-x: hidden; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.15; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; line-height: 1.45; }
a { color: var(--accent2); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.hidden { display: none !important; }

.app { min-height: 100vh; }
.view { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 3rem; outline: none; }
.view.full { max-width: none; padding: 0; }

/* Barra superior */
.topbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .6rem 0 1rem; }
.topbar .brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; margin-right: auto; color: var(--text); text-decoration: none; display: flex; gap: .5rem; align-items: center; }
.brand .logo { width: 1.7rem; height: 1.7rem; }
.who { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.avatar { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: inline-grid; place-items: center; font-size: 1.2rem; background: var(--accent2); }

/* Botones */
.btn { appearance: none; border: 2px solid var(--line); background: var(--card2); color: var(--text); font: inherit; font-weight: 650;
  padding: .7rem 1.15rem; border-radius: 12px; cursor: pointer; min-height: 2.9rem; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; text-decoration: none; }
.btn:hover { border-color: var(--accent2); }
.btn:focus-visible, .tile-btn:focus-visible, .route-card:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 4px solid var(--focus); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #05281a; }
.btn-primary:hover { border-color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #2a0707; }
.btn-ghost { background: transparent; }
.btn-lg { font-size: 1.2rem; min-height: 3.6rem; padding: .9rem 1.6rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }

/* Tarjetas y rejillas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hero { display: grid; gap: 1rem; }

/* Formularios */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label, .field .label { font-weight: 650; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--bg2); border: 2px solid var(--line); border-radius: 12px; padding: .65rem .8rem; min-height: 2.9rem; width: 100%; }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 2rem; }
.view > .warn-box, .view > .ok-box, .view > .error-box { margin: .75rem 0; }
.error-box { background: #3a1c24; border: 1px solid var(--danger); color: #ffd6d6; padding: .75rem 1rem; border-radius: 12px; }
.ok-box { background: #123a2a; border: 1px solid var(--accent); padding: .75rem 1rem; border-radius: 12px; }
.warn-box { background: #3a2e12; border: 1px solid var(--warn); padding: .75rem 1rem; border-radius: 12px; }
.field-error { color: var(--danger); font-size: .85rem; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 650; padding: .6rem 1rem; cursor: pointer; min-height: 2.8rem; }
.seg button[aria-pressed=true] { background: var(--accent2); color: #06182e; }
.seg button:focus-visible { outline: 4px solid var(--focus); outline-offset: -4px; }

/* Perfiles */
.profile-card { text-align: center; cursor: pointer; padding: 1.4rem; }
.profile-card .avatar { width: 4.5rem; height: 4.5rem; font-size: 2.4rem; margin: 0 auto .6rem; }

/* Catálogo de rutas */
.route-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; cursor: pointer; color: inherit; font: inherit; border: 2px solid var(--line); background: var(--card); border-radius: var(--radius); }
.route-card:hover { border-color: var(--accent2); }
.route-art { height: 7.5rem; position: relative; }
.route-body { padding: .9rem 1.1rem 1.1rem; display: grid; gap: .35rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { font-size: .78rem; padding: .15rem .55rem; border-radius: 999px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.dots { letter-spacing: .1em; color: var(--warn); }

/* Estadísticas */
.stat { display: grid; gap: .15rem; }
.stat .v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .l { color: var(--muted); font-size: .85rem; }
.bar { height: .7rem; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--accent); }
.chart { width: 100%; height: auto; display: block; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.badge { display: inline-block; font-size: .7rem; font-weight: 800; padding: .1rem .4rem; border-radius: 6px; letter-spacing: .05em; vertical-align: middle; }
.badge.sim { background: var(--sim); color: #20103a; } .badge.est { background: var(--est); color: #3a2d00; }
.badge.demo { background: var(--sim); color: #20103a; }

/* Entrenamiento (HUD sobre el 3D) */
.training { position: fixed; inset: 0; background: #000; overflow: hidden; font-size: clamp(12px, .6vw + 7px, 18px); }
.training .stage { position: absolute; inset: 0; }
.training .stage canvas { width: 100%; height: 100%; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: max(.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(.8rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.hud button, .hud input, .hud select, .hud .interactive { pointer-events: auto; }
.hud-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; align-items: start; }
.hud-bottom { display: flex; gap: .6rem; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; }
.hud-tiles { display: flex; gap: .4rem; flex-wrap: wrap; }
.mtile { background: rgba(10, 18, 32, .72); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: .3rem .65rem; min-width: 6rem; text-align: left; }
.mtile .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; gap: .3rem; align-items: center; }
.mtile .v { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mtile .u { font-size: .8rem; color: var(--muted); margin-left: .25rem; font-weight: 600; }
.mtile.na .v { color: #6d7d99; }
.mtile.big .v { font-size: 2.3rem; }
.hud-panel { background: rgba(10, 18, 32, .72); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: .55rem .85rem; }
.hud-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.hud .btn { background: rgba(10, 18, 32, .78); min-height: 2.4rem; padding: .35rem .8rem; }
.hud select { width: auto; min-height: 2.4rem; padding: .3rem .6rem; background: rgba(10,18,32,.85); }
.hud-panel .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hud-panel .v { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud .btn-primary { background: var(--accent); }
.hud .btn-danger { background: var(--danger); }
.progress-line { height: .45rem; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden; min-width: 12rem; }
.progress-line > i { display: block; height: 100%; background: var(--accent); }
.banner { position: absolute; left: 50%; top: 28%; transform: translateX(-50%); text-align: center; background: rgba(10,18,32,.86); border: 2px solid var(--warn); border-radius: 18px; padding: 1rem 1.6rem; pointer-events: none; max-width: 90vw; }
.banner h2 { margin: 0 0 .25rem; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9rem; font-weight: 900; text-shadow: 0 4px 30px #000; pointer-events: none; }
.sim-panel { display: grid; gap: .3rem; width: 17rem; }
.grade-pill { font-weight: 800; font-variant-numeric: tabular-nums; }
.no-webgl { position: absolute; inset: 0; display: grid; place-items: center; padding: 2rem; text-align: center; background: linear-gradient(#17304f, #0e1622); }

/* Avisos y diálogos */
.toast-host { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 90; max-width: min(28rem, 92vw); }
.toast { background: var(--card2); border: 1px solid var(--line); border-left: 6px solid var(--accent2); padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4); transition: opacity .4s, transform .4s; }
.toast-ok { border-left-color: var(--accent); } .toast-warn { border-left-color: var(--warn); } .toast-error { border-left-color: var(--danger); }
.toast-out { opacity: 0; transform: translateY(8px); }
.modal-overlay { position: fixed; inset: 0; background: rgba(3,8,16,.7); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.4rem 1.6rem; max-width: 34rem; width: 100%; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* Diagnóstico Bluetooth */
.log { background: #0a111d; border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; font: .8rem/1.45 ui-monospace, Consolas, monospace; max-height: 22rem; overflow: auto; white-space: pre-wrap; }
.log .warn { color: var(--warn); } .log .error { color: var(--danger); } .log .data { color: #8be9fd; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; }
code { background: var(--bg2); padding: .05rem .35rem; border-radius: 6px; font-size: .85em; }

@media (max-width: 640px) {
  .mtile { min-width: 5.6rem; padding: .35rem .6rem; } .mtile .v { font-size: 1.5rem; } .mtile.big .v { font-size: 1.9rem; }
  .view { padding-inline: .8rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.card > .seg { margin-bottom: 1rem; }

@media (max-width: 700px) {
  .hud-top { grid-template-columns: 1fr; }
  .hud-top > .hud-panel { order: -1; display: flex; gap: .6rem; justify-content: space-between; align-items: center; text-align: left !important; flex-wrap: wrap; }
  .hud-tiles { gap: .3rem; }
  .mtile { min-width: 4.4rem; padding: .2rem .45rem; }
  .mtile .v { font-size: 1.25rem; } .mtile.big .v { font-size: 1.5rem; }
  .mtile .l { font-size: .62rem; }
  .sim-panel { width: 100%; }
  .hud-bottom { flex-direction: column; align-items: stretch; }
}
