@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Rajdhani:wght@400;500;600;700&display=swap');

/* ===== Variables ===== */
:root {
  --bg: #1a1f2e;
  --bg2: #222840;
  --bg3: #2a3150;
  --card: #1e2438;
  --border: #3a4468;
  --gold: #f5c842;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --cyan: #4dd9e8;
  --red: #e84d6a;
  --green: #4de87a;
  --text: #d8dff0;
  --text2: #8a96b8;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'Rajdhani', sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(74, 100, 168, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 100, 168, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Subtle scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 0;
}

/* ===== Layout ===== */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1rem;
  position: relative;
  z-index: 1;
}

main { padding: 1.5rem 0 3rem; }

/* ===== Navbar ===== */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-brand {
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  color: var(--cyan);
  text-decoration: none;
  letter-spacing: 1px;
}

.navbar-brand span { color: var(--gold); }

.navbar-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ===== Ticker ===== */
.ticker-wrap {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.ticker-label {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--cyan);
  padding: 0 0.75rem;
  background: var(--bg3);
  border-right: 1px solid var(--border);
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  z-index: 2;
}

.ticker-track {
  display: flex;
  gap: 3rem;
  padding: 0.45rem 0 0.45rem 6rem;
  animation: ticker-scroll 40s linear infinite;
  white-space: nowrap;
}

.ticker-track:hover { animation-play-state: paused; }

.ticker-item {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--text2);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ticker-item .initials { color: var(--cyan); }
.ticker-item .tiempo { color: var(--gold); }
.ticker-item .ruta-name { color: var(--text); }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-body { padding: 1.25rem; }

/* ===== Ruta cards ===== */
.ruta-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s, transform 0.1s;
}

.ruta-card:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.ruta-card-header {
  padding: 1rem 1.25rem 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.ruta-card-title {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--cyan);
  line-height: 1.5;
}

.ruta-card-body { padding: 0.75rem 1.25rem 1rem; }

.ruta-meta {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.ruta-meta span { display: flex; align-items: center; gap: 0.25rem; }

/* ===== Difficulty badge ===== */
.badge {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  padding: 0.3em 0.6em;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.badge-facil { background: rgba(77, 232, 122, 0.15); color: var(--green); border: 1px solid var(--green); }
.badge-intermedio { background: rgba(245, 200, 66, 0.15); color: var(--gold); border: 1px solid var(--gold); }
.badge-dificil { background: rgba(232, 77, 106, 0.15); color: var(--red); border: 1px solid var(--red); }

/* ===== Leaderboard ===== */
.leaderboard { list-style: none; }

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(58, 68, 104, 0.5);
}

.leaderboard-entry:last-child { border-bottom: none; }

.rank {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  min-width: 2rem;
  text-align: center;
}

.rank-1 { color: var(--gold); }
.rank-2 { color: var(--silver); }
.rank-3 { color: var(--bronze); }
.rank-other { color: var(--text2); }

.lb-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
}

.lb-initials {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--cyan);
}

.lb-time {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--gold);
  text-align: right;
}

.lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  padding: 0.65em 1.2em;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  letter-spacing: 0.5px;
  transition: filter 0.15s, transform 0.1s;
  line-height: 1.6;
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--cyan); color: var(--bg); }
.btn-gold { background: var(--gold); color: var(--bg); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-google { background: #4285f4; color: #fff; }
.btn-facebook { background: #1877f2; color: #fff; }

.btn-start {
  font-size: 0.8rem;
  padding: 1em 2em;
  background: var(--green);
  color: var(--bg);
  width: 100%;
  justify-content: center;
  margin-top: 1rem;
}

/* ===== GPS warning ===== */
.gps-status {
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 3px;
  text-align: center;
  margin: 1rem 0;
  line-height: 1.8;
}

.gps-waiting { background: rgba(245, 200, 66, 0.1); border: 1px solid var(--gold); color: var(--gold); }
.gps-ok { background: rgba(77, 232, 122, 0.1); border: 1px solid var(--green); color: var(--green); }
.gps-fail { background: rgba(232, 77, 106, 0.1); border: 1px solid var(--red); color: var(--red); }

/* ===== Timer ===== */
.timer-display {
  font-family: var(--font-pixel);
  font-size: 2.5rem;
  color: var(--cyan);
  text-align: center;
  padding: 1.5rem 0;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(77, 217, 232, 0.4);
}

.timer-label {
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  color: var(--text2);
  text-align: center;
  margin-bottom: 0.25rem;
}

/* ===== Resultado screen ===== */
.resultado-time {
  font-family: var(--font-pixel);
  font-size: 2rem;
  color: var(--gold);
  text-align: center;
  padding: 2rem 0 1rem;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(245, 200, 66, 0.5);
}

.resultado-label {
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  color: var(--text2);
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

/* ===== Modal arcade ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-arcade {
  background: var(--bg2);
  border: 2px solid var(--gold);
  border-radius: 4px;
  padding: 2rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal-title {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}

.initials-input {
  font-family: var(--font-pixel);
  font-size: 2rem;
  background: var(--bg);
  border: 2px solid var(--cyan);
  color: var(--cyan);
  text-align: center;
  width: 8rem;
  padding: 0.5rem;
  letter-spacing: 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

.initials-input:focus { outline: none; border-color: var(--gold); }

/* ===== Map ===== */
#map {
  height: 280px;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin: 1rem 0;
}

/* ===== Admin ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-table th {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--text2);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(58, 68, 104, 0.4);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  color: var(--text2);
  margin-bottom: 0.5rem;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--cyan);
}

select.form-control { cursor: pointer; }

/* ===== Headings ===== */
h1, h2, h3 {
  font-family: var(--font-pixel);
  line-height: 1.5;
}

h1 { font-size: 0.9rem; color: var(--cyan); margin-bottom: 1rem; }
h2 { font-size: 0.7rem; color: var(--text); margin-bottom: 0.75rem; }
h3 { font-size: 0.55rem; color: var(--text2); margin-bottom: 0.5rem; }

/* ===== Section spacing ===== */
.section { margin-bottom: 2rem; }

/* ===== Flash messages ===== */
.flash-messages { list-style: none; margin-bottom: 1rem; }

.flash-msg {
  padding: 0.65rem 1rem;
  border-radius: 3px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  background: rgba(232, 77, 106, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
}

/* ===== QR print ===== */
.qr-block {
  text-align: center;
  padding: 1.5rem;
}

.qr-block img {
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
}

.qr-label {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  margin-top: 0.75rem;
  letter-spacing: 2px;
}

/* ===== Stats cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-family: var(--font-pixel);
  font-size: 1.2rem;
  color: var(--cyan);
  display: block;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-family: var(--font-pixel);
  font-size: 0.4rem;
  color: var(--text2);
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-cyan { color: var(--cyan); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-muted { color: var(--text2); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.pixel { font-family: var(--font-pixel); font-size: 0.6rem; }

/* ===== Print ===== */
@media print {
  .navbar, .ticker-wrap, .no-print { display: none !important; }
  body { background: white; color: black; }
  body::before, body::after { display: none; }
  .qr-block img { width: 250px; height: 250px; }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .timer-display { font-size: 1.8rem; }
  .resultado-time { font-size: 1.5rem; }
}
