@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&display=swap');

/* ============================================================
   TOKENS — dirección "expedición editorial" (luz de amanecer)
   ============================================================ */
:root {
  --bg-1: #f6ead8;
  --bg-2: #d9e4ef;
  --ink: #1b2430;
  --ink-soft: rgba(27,36,48,0.62);
  --ink-faint: rgba(27,36,48,0.38);
  --accent: #e2601f;
  --accent-ink: #ffffff;
  --success: #235c3a;
  --danger: #b23a2e;
  --panel-dark: #12161d;
  --panel-dark-line: rgba(255,255,255,0.1);
  --line: rgba(27,36,48,0.14);
  --paper: #fffdf9;
  --font-display: "Space Grotesk", -apple-system, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  overflow-x: hidden;
}

/* Silueta de montañas fija al fondo — nod a la referencia, tema de expedición */
.mountains-bg {
  position: fixed;
  bottom: 0; left: 0; width: 100%; height: 22vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}

/* ============================================================
   HEADER / LOGO
   ============================================================ */
.topbar {
  position: fixed;
  top: 20px; left: 24px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
}
.patch { height: 77px; width: auto; max-width: 220px; object-fit: contain; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

@media (max-width: 600px) {
  .patch { height: 60px; }
}

/* ============================================================
   STAGE LAYOUT: gauge de ruta + tarjeta
   ============================================================ */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 130px 20px 60px;
}
.stage-card-wrap { width: 100%; max-width: 620px; }
.side-panel { width: 100%; }
.leaderboard-row {
  display: flex; gap: 20px;
  width: 100%; max-width: 620px; margin: 0 auto;
}
.leaderboard-row .side-panel { flex: 1 1 0; min-width: 0; }

@media (max-width: 640px) {
  .leaderboard-row { flex-direction: column; }
}

@media (max-width: 600px) {
  .stage { padding-top: 110px; }
}

.hidden { display: none !important; }

.screen {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(27,36,48,0.12);
  padding: 40px;
  width: 100%;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.subtitle { color: var(--ink-soft); margin: 0 0 26px; font-size: 15px; }

/* ============================================================
   ROUTE GAUGE (equivalente al "ALT" de la referencia) — horizontal
   a propósito: la mayoría entra desde el celular, y un eje horizontal
   es más simple de hacer bien en pantallas angostas que uno vertical.
   ============================================================ */
.route-bar { width: 100%; margin: 0 0 26px; font-family: var(--font-mono); }
.route-track { position: relative; height: 4px; background: var(--line); border-radius: 2px; margin: 0 6px; }
.route-tick {
  position: absolute; top: 50%;
  width: 3px; height: 10px;
  background: var(--ink-faint);
  transform: translate(-50%, -50%);
}
.route-marker {
  position: absolute; top: 50%;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 2px var(--accent);
  transform: translate(-50%, -50%);
  transition: left 0.5s ease;
}
.route-label {
  margin-top: 10px; font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft); text-align: center;
}

@media (max-width: 760px) {
  .stage { padding-top: 110px; }
}

/* ============================================================
   SELECCIÓN DE JUGADOR
   ============================================================ */
.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.player-btn:hover { border-color: var(--accent); background: rgba(226,96,31,0.06); transform: translateY(-2px); }

/* ============================================================
   PANEL OSCURO ("instrumento") — roster / estado en vivo
   ============================================================ */
.status-terminal {
  background: var(--panel-dark);
  color: #e9e9ee;
  border-radius: 14px;
  overflow: hidden;
  margin: 20px 0;
  font-family: var(--font-mono);
}
.terminal-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-dark-line);
}
.terminal-title { margin-left: 8px; font-size: 10.5px; color: rgba(233,233,238,0.5); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.red { background: #ff6b5e; } .dot.yellow { background: #ffd166; } .dot.green { background: #6fd88a; }
.status-list { padding: 14px; font-size: 12.5px; line-height: 1.9; }
.status-row { display: flex; justify-content: space-between; }
.status-row .name.me { color: #ffb27a; font-weight: 700; }
.pill.online { color: #6fd88a; } .pill.offline { color: rgba(233,233,238,0.4); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn-master, .btn-secondary {
  width: 100%; margin-top: 10px; padding: 16px;
  border-radius: 12px; border: none;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.03em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-master { background: var(--accent); color: white; }
.btn-master:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(226,96,31,0.35); }
.btn-secondary { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink); }

.waiting-msg { color: var(--ink-soft); font-size: 14px; text-align: center; margin: 16px 0; }

/* ============================================================
   MÓDULO 1 — inputs, tarjeta de contenido, votación, revelación
   ============================================================ */
.toggle-group { display: flex; gap: 8px; margin-bottom: 16px; }
.toggle-btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line);
  background: transparent; font-family: var(--font-mono); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; color: var(--ink-soft);
}
.toggle-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(226,96,31,0.08); }

textarea, input[type="text"] {
  width: 100%; font-family: var(--font-body); font-size: 15px;
  padding: 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--paper); color: var(--ink); resize: vertical;
}
input[type="file"] { font-family: var(--font-mono); font-size: 12px; }

.progress-bar-track {
  width: 100%; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 14px 0;
}
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s ease; }

.content-frame {
  border-radius: 12px; overflow: hidden; margin: 16px 0;
  border: 1.5px solid var(--line);
}
.content-frame img { width: 100%; display: block; }
.content-frame iframe { width: 100%; aspect-ratio: 16/9; border: none; display: block; }
.content-text {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  padding: 24px; text-align: center; background: var(--paper);
}

select {
  width: 100%; padding: 14px; border-radius: 10px; border: 1.5px solid var(--line);
  font-family: var(--font-body); font-size: 15px; background: var(--paper); color: var(--ink);
  margin-bottom: 10px;
}

.reveal-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.tag { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.tag.hit { background: rgba(35,92,58,0.12); color: var(--success); }
.tag.miss { background: rgba(178,58,46,0.12); color: var(--danger); }

.author-reveal {
  text-align: center; font-family: var(--font-display); font-size: 20px; font-weight: 700;
  margin-bottom: 18px; padding: 14px; background: rgba(226,96,31,0.08); border-radius: 10px;
}

/* ============================================================
   PANTALLA DE PERFIL (apodo + avatar)
   ============================================================ */
.avatar-picker { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--line); border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: var(--ink-soft);
  overflow: hidden; flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.hint-text { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); margin: 6px 0 0; }

.avatar-thumb {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  vertical-align: middle; margin-right: 6px; border: 1px solid var(--panel-dark-line);
}
.avatar-thumb-lg {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); flex-shrink: 0;
}
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--ink-soft);
  font-family: var(--font-mono); font-weight: 700;
}
.avatar-thumb.avatar-fallback { font-size: 10px; }
.avatar-thumb-lg.avatar-fallback { font-size: 11px; }

/* ============================================================
   CUPOS (Root Cause)
   ============================================================ */
.quota-block { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.quota-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.quota-label { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); }
#video-input-area, #meme-input-area { display: flex; gap: 8px; }
#video-input-area input, #meme-input-area input[type="file"] { flex: 1; }
#video-input-area button, #meme-input-area button { width: auto; padding: 12px 18px; margin: 0; white-space: nowrap; }

/* (estilos de marcadores en vivo consolidados más abajo) */

/* ============================================================
   ORB LOADER — inspirado en loaders de puntitos, hecho propio
   ============================================================ */
.orb-loader {
  display: flex; justify-content: center; align-items: center; gap: 8px;
  padding: 20px 0;
}
.orb-loader span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  animation: orb-bounce 1s ease-in-out infinite;
}
.orb-loader span:nth-child(2) { animation-delay: 0.15s; }
.orb-loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes orb-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1.15); opacity: 1; }
}

/* ============================================================
   GALERÍA DE AVATARES (curada por el host, subida a Storage)
   ============================================================ */
.gallery-label {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 10px;
}
.avatar-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px; margin-bottom: 20px; max-height: 230px; overflow-y: auto; padding: 2px;
}
.gallery-thumb {
  padding: 0; border: 3px solid transparent; border-radius: 50%;
  width: 56px; height: 56px; cursor: pointer; overflow: hidden; background: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.gallery-thumb:hover { transform: translateY(-2px); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb.selected { border-color: var(--accent); }

/* ============================================================
   MARCADORES EN VIVO — lista compacta (como al principio)
   ============================================================ */
.lb-col { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; }
.lb-title { font-family: var(--font-mono); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 14px; }

.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--line);
}
.lb-row:last-child { border-bottom: none; }

.lb-rank { font-family: var(--font-mono); font-size: 13px; color: var(--ink-faint); width: 14px; flex-shrink: 0; }
.lb-name-text { flex: 1; font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); }
.lb-points { font-family: var(--font-mono); font-weight: 700; color: var(--accent); font-size: 15px; }