/* Las fuentes se cargan desde <head> en index.html (evita un @import en cascada) */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c1: #00d4ff;
  --c2: #7c3aed;
  --c3: #f0abfc;
  --glass: rgba(4,4,28,.80);
  --border: rgba(0,212,255,.13);
  --text: #e2e8f0;
  --dim: rgba(226,232,240,.50);
}

body {
  overflow: hidden;
  background: #020212;
  font-family: 'Exo 2', sans-serif;
  color: var(--text);
  user-select: none;
}

/* ── CANVAS ──────────────────────────────────────── */
#mainCanvas {
  display: block;
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  cursor: crosshair;
}

/* ── LOADING ─────────────────────────────────────── */
#loading {
  position: fixed; inset: 0;
  background: #020212;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; z-index: 999;
  transition: opacity .6s ease;
}
#loading.fade-out { opacity: 0; pointer-events: none; }

.loading-ring {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--c1);
  border-right-color: var(--c2);
  animation: spin 1s linear infinite;
  box-shadow: 0 0 30px rgba(0,212,255,.4);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 22px; font-weight: 900; letter-spacing: 10px;
  background: linear-gradient(135deg, var(--c1), var(--c3), var(--c2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 16px rgba(0,212,255,.6));
}
.loading-label {
  font-size: 11px; letter-spacing: 5px; color: var(--dim);
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:.4} 50%{opacity:1} }
.loading-bar { width: 200px; height: 2px; background: rgba(255,255,255,.08); border-radius: 2px; overflow: hidden; }
.loading-fill { height: 100%; background: linear-gradient(90deg, var(--c2), var(--c1)); animation: fillBar .9s ease-out forwards; }
@keyframes fillBar { from{width:0} to{width:100%} }

/* ── HUD ─────────────────────────────────────────── */
#hud {
  position: fixed; top: 22px; left: 50%;
  transform: translateX(-50%);
  text-align: center; pointer-events: none; z-index: 10;
}
.hud-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(14px, 2.5vw, 28px); font-weight: 900; letter-spacing: 10px;
  background: linear-gradient(135deg, var(--c1), var(--c3), var(--c2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(0,212,255,.5));
}
.hud-sub {
  font-size: 9px; letter-spacing: 4px; color: var(--dim); margin-top: 4px;
}

/* ── PANEL DE CONTROL ───────────────────────────── */
#controls {
  position: fixed; top: 50%; right: 18px;
  transform: translateY(-50%);
  width: 220px;
  background: var(--glass);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 16px 14px;
  z-index: 10;
  max-height: 96vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(0,212,255,.3) transparent;
  box-shadow:
    0 0 50px rgba(0,212,255,.07),
    0 30px 60px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.04);
}

.panel-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px; letter-spacing: 5px; color: var(--c1);
  text-align: center; margin-bottom: 13px;
}

/* ── BOTON CAMARA ───────────────────────────────── */
.cam-toggle-wrap { margin-bottom: 10px; }

.btn-cam {
  width: 100%;
  padding: 11px;
  background: rgba(0,255,100,.1);
  border: 1px solid rgba(0,255,100,.25) !important;
  color: #4eff91 !important;
  font-size: 11px !important;
  letter-spacing: 2px;
  transition: all .25s !important;
  position: relative; overflow: hidden;
}
.btn-cam::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(0,255,100,.15), transparent 70%);
  opacity: 0; transition: opacity .2s;
}
.btn-cam:hover::before { opacity: 1; }
.btn-cam:hover {
  background: rgba(0,255,100,.22) !important;
  border-color: rgba(0,255,100,.5) !important;
  box-shadow: 0 0 20px rgba(0,255,100,.3) !important;
}
.btn-cam.cam-on {
  background: rgba(0,255,100,.2) !important;
  border-color: #4eff91 !important;
  box-shadow: 0 0 20px rgba(0,255,100,.4), 0 0 40px rgba(0,255,100,.15) !important;
  animation: camPulse 2s ease-in-out infinite;
}
@keyframes camPulse {
  0%,100% { box-shadow: 0 0 20px rgba(0,255,100,.4), 0 0 40px rgba(0,255,100,.15); }
  50%      { box-shadow: 0 0 30px rgba(0,255,100,.6), 0 0 60px rgba(0,255,100,.25); }
}

.cam-status {
  font-size: 9px; letter-spacing: 2px; color: var(--dim);
  text-align: center; margin-top: 5px;
  min-height: 14px;
}

/* ── DISPLAY DE GESTO ───────────────────────────── */
.gesture-wrap {
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  text-align: center;
}
.gesture-label-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 7px; letter-spacing: 3px; color: var(--dim);
  margin-bottom: 5px;
}
.gesture-display {
  font-size: 13px; min-height: 20px;
  color: rgba(255,255,255,.3);
  transition: color .3s;
  font-weight: 600;
}

/* ── SLIDERS ─────────────────────────────────────── */
.ctrl-group { margin-bottom: 12px; }
.ctrl-group label {
  display: flex; justify-content: space-between;
  font-size: 9.5px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--dim); text-transform: uppercase; margin-bottom: 5px;
}
.ctrl-group label span { color: var(--c1); font-family: 'Orbitron', sans-serif; font-size: 9.5px; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px;
  background: rgba(255,255,255,.1); border-radius: 2px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--c2), var(--c1));
  height: 3px; border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px var(--c1), 0 0 10px var(--c1);
  cursor: pointer; transition: transform .15s, box-shadow .15s; margin-top: -5px;
}
input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.35); box-shadow: 0 0 0 2px var(--c1), 0 0 20px var(--c1);
}

/* ── BOTONES ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 10px 0; }

.btn-row { display: flex; gap: 6px; margin-bottom: 6px; }
.btn {
  flex: 1; padding: 8px 4px;
  background: rgba(0,212,255,.08); border: 1px solid rgba(0,212,255,.2);
  border-radius: 8px; color: var(--c1);
  font-family: 'Orbitron', sans-serif; font-size: 8px; font-weight: 700;
  letter-spacing: 1px; cursor: pointer; transition: all .2s;
}
.btn:hover {
  background: rgba(0,212,255,.2); border-color: var(--c1);
  box-shadow: 0 0 12px rgba(0,212,255,.3); transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn.btn-active {
  background: rgba(124,58,237,.3); border-color: var(--c2);
  color: var(--c3); box-shadow: 0 0 12px rgba(124,58,237,.4);
}
.btn.btn-red {
  background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.28); color: #f87171;
}
.btn.btn-red:hover {
  background: rgba(239,68,68,.25); border-color: #f87171; box-shadow: 0 0 12px rgba(239,68,68,.4);
}
.btn.btn-dim {
  background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.1); color: var(--dim);
}
.btn.btn-dim:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); }

/* ── LEYENDA DE GESTOS ──────────────────────────── */
.gesture-legend { font-size: 9.5px; line-height: 2; color: var(--dim); }
.legend-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 7px; letter-spacing: 3px; color: var(--dim);
  margin-bottom: 4px;
}
.legend-item { display: flex; align-items: center; gap: 7px; }

/* ── HINTS ───────────────────────────────────────── */
.hints { font-size: 9px; color: var(--dim); line-height: 2; }

/* ── WEBCAM PREVIEW ─────────────────────────────── */
.cam-panel {
  position: fixed; bottom: 18px; right: 18px;
  width: 242px;
  background: var(--glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0,255,100,.2);
  border-radius: 14px; overflow: hidden;
  z-index: 10;
  box-shadow: 0 0 30px rgba(0,255,100,.12), 0 20px 40px rgba(0,0,0,.5);
  transition: opacity .4s, transform .4s;
}
.cam-panel.hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }

.cam-panel-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 8px; letter-spacing: 4px; color: #4eff91;
  text-align: center; padding: 6px 0;
  border-bottom: 1px solid rgba(0,255,100,.15);
}
#camPreview {
  display: block; width: 240px; height: 180px;
  border-radius: 0 0 14px 14px;
}

/* ── STATS ───────────────────────────────────────── */
#stats {
  position: fixed; bottom: 18px; left: 18px;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px; letter-spacing: 3px;
  color: rgba(0,212,255,.4); line-height: 2;
  z-index: 10; pointer-events: none;
}
#stats span { color: rgba(0,212,255,.8); }

/* ── NAVEGACION A LAS OTRAS APPS ─────────────────── */
/* Antes eran 4 bloques de estilos en linea repetidos con handlers onmouseover */
.app-links { display: flex; flex-direction: column; gap: 6px; }

.app-link {
  display: block; width: 100%;
  padding: 8px 4px;
  border-radius: 9px;
  font-family: 'Orbitron', sans-serif;
  font-size: 8px; font-weight: 700; letter-spacing: 1px;
  text-align: center; text-decoration: none;
  background: var(--link-bg);
  border: 1px solid var(--link-border);
  color: var(--link-fg);
  cursor: pointer;
  transition: background .2s, transform .2s, box-shadow .2s;
}
.app-link:hover,
.app-link:focus-visible {
  background: var(--link-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--link-bg-hover);
}

.app-link-cyan  { --link-bg: rgba(0,212,255,.14);  --link-bg-hover: rgba(0,212,255,.28); --link-border: rgba(0,212,255,.35); --link-fg: #00d4ff; }
.app-link-green { --link-bg: rgba(0,255,136,.14);  --link-bg-hover: rgba(0,255,136,.28); --link-border: rgba(0,255,136,.35); --link-fg: #00ff88; }
.app-link-pink  { --link-bg: rgba(255,51,102,.12); --link-bg-hover: rgba(255,51,102,.25); --link-border: rgba(255,51,102,.30); --link-fg: #ff3366; }
.app-link-dim   { --link-bg: rgba(0,212,255,.10);  --link-bg-hover: rgba(0,212,255,.22); --link-border: rgba(0,212,255,.25); --link-fg: #00d4ff; }

/* ── ACCESIBILIDAD ───────────────────────────────── */
/* Antes no habia ningun indicador de foco: la UI era inusable con teclado */
:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

/* Respetar a quien pide menos movimiento en el sistema */
@media (prefers-reduced-motion: reduce) {
  .loading-ring { animation: none; }
  .app-link { transition: none; }
  .app-link:hover, .app-link:focus-visible { transform: none; }
}
