:root {
  --bg-dark: #050505;
  --bg-card: #111111;
  --bg-card-hover: #1a1a1a;
  --border-color: #222222;
  --cyan: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.35);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --green-snake-bar: #166534;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  user-select: none;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ================= HUECOS PUBLICITARIOS ================= */
.ad-slot {
  background: rgba(15, 15, 15, 0.8);
  border: 1px dashed #333;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}
.ad-tag {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.6rem;
  color: #555;
  text-transform: uppercase;
}
.ad-top-wrapper {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
  background: #000;
  border-bottom: 1px solid var(--border-color);
}
.ad-728x90 { width: 728px; height: 90px; }
.ad-skyscraper { width: 160px; min-height: 600px; position: sticky; top: 1.5rem; }
.ad-infeed { width: 100%; height: 90px; margin-top: 2.5rem; }
.ad-bottom-ingame { width: 100%; height: 90px; margin-top: 2rem; }

/* ================= NAVBAR SOFISTICADO ================= */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2.5rem;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  letter-spacing: 1px;
}
.brand-accent {
  color: var(--cyan);
}
.btn-menu {
  background: transparent;
  color: #fff;
  border: 1px solid var(--border-color);
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}
.btn-menu:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 15px var(--cyan-glow);
}

/* ================= LAYOUT ================= */
.site-container {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 2rem;
  padding: 2rem 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.main-content {
  flex: 1;
  max-width: 780px;
  display: flex;
  flex-direction: column;
}

/* Paneles de Vistas */
.view-panel {
  display: none;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 2rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
  animation: fadeIn 0.4s ease forwards;
}
.view-panel.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= MENÚ HUB (TARJETAS INMERSIVAS) ================= */
.hub-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}
.hub-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #fff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hub-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

/* Tarjeta Base */
.game-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  min-height: 220px;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.4s ease;
  border: 1px solid #333;
}

/* Capa oscura encima de la imagen */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.4) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem;
  transition: background 0.3s ease;
}

/* Animaciones de Hover en la tarjeta */
.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 15px 30px rgba(0, 240, 255, 0.15);
  border-color: #444;
}

/* Efecto sutil de zoom en la imagen de fondo */
.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: inherit;
  background-size: cover;
  background-position: center;
  transition: transform 0.5s ease;
  z-index: -1;
}
.game-card:hover::before {
  transform: scale(1.1);
}

.card-content h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.3rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.card-content p {
  font-size: 0.85rem;
  color: #ccc;
  line-height: 1.4;
  margin-bottom: 0.8rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.card-record {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 1rem;
}

/* Botones Premium */
.btn-play, .btn-primary {
  position: relative;
  background: #fff;
  color: #000;
  font-weight: 800;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  align-self: flex-start;
}
.btn-primary { align-self: auto; }

.btn-play:hover, .btn-primary:hover {
  background: var(--cyan);
  box-shadow: 0 0 15px var(--cyan-glow);
}

/* Destello en el botón al hacer hover */
.btn-flare {
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.8), transparent);
  transform: skewX(-25deg);
  transition: 0s;
}
.game-card:hover .btn-flare {
  left: 200%;
  transition: 0.7s ease-in-out;
}

.btn-secondary {
  background: #1a1a1a;
  color: var(--text-main);
  border: 1px solid #333;
  padding: 0.5rem 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: #2a2a2a;
  border-color: #555;
}

/* ================= CABECERAS Y HUD DE JUEGOS ================= */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #222;
}
.panel-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
}
.google-snake-bar {
  background: var(--green-snake-bar);
  border-bottom: none;
  border-radius: 8px;
  padding: 1rem;
}
.score-pill { font-size: 1.2rem; font-weight: 700; color: #fff;}

.hud-badges { display: flex; gap: 0.5rem; }
.hud-pill {
  background: #0a0a0a;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  border: 1px solid #222;
  color: #ccc;
}
.hud-pill b { color: #fff; }
.controls-hint {
  text-align: center;
  font-size: 0.85rem;
  color: #777;
  margin-top: 1rem;
}

/* ================= JUEGO 1: TEST DE VELOCIDAD ================= */
.reaction-arena {
  height: 300px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid #222;
}
.reaction-arena.waiting { background: #1d4ed8; }
.reaction-arena.ready   { background: #b91c1c; }
.reaction-arena.go      { background: #15803d; }
.status-indicator { font-size: 3rem; margin-bottom: 0.5rem; }

/* Tabla de Registro */
.reaction-history-container {
  margin-top: 1.5rem;
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: 10px;
  padding: 1.25rem;
}
.history-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.history-actions { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.table-scroll-wrapper { max-height: 180px; overflow-y: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: left; }
.history-table th { padding: 0.5rem; color: #777; border-bottom: 1px solid #222; }
.history-table td { padding: 0.6rem 0.5rem; border-bottom: 1px solid #1a1a1a; }
.history-table tr:hover { background: rgba(255,255,255,0.03); }
.tag-excellent { color: #22c55e; font-weight: 700; }
.tag-good      { color: var(--cyan); font-weight: 700; }
.tag-average   { color: #f59e0b; font-weight: 700; }
.tag-slow      { color: #ef4444; font-weight: 700; }

/* ================= JUEGO 2: AGILIDAD DEL MOUSE ================= */
#trace-canvas { cursor: none !important; border-radius: 8px; border: 1px solid #222;}
.trace-hud-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem;
}
.hud-stat-box {
  background: #0a0a0a; border: 1px solid #222; border-radius: 8px; padding: 0.8rem;
}
.hud-stat-box .stat-title { font-size: 0.75rem; color: #777; margin-bottom: 0.3rem; display: block;}
.hud-stat-box .stat-value { font-size: 1.5rem; font-weight: 900; color: #fff; }
.trace-footer-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; font-size: 0.85rem; color: #777;}

/* Reporte Trazado */
.trace-report-box { background: #0a0a0a; border: 1px solid #222; border-radius: 12px; padding: 2rem; }
.report-header-title { text-align: center; margin-bottom: 2rem; }
.big-score-display { font-size: 3.5rem; font-weight: 900; color: var(--cyan); }
.report-routes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.route-card { background: #111; border: 1px solid #222; border-radius: 10px; padding: 1.25rem; }
.route-card-head { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.6rem; }
.route-acc { color: var(--cyan); }
.route-bar-track { width: 100%; height: 6px; background: #222; border-radius: 4px; margin-bottom: 0.6rem; }
.route-bar-fill { height: 100%; border-radius: 4px; }
.green-fill { background: #34d399; } .red-fill { background: #f87171; }
.route-canvas-box { background: #050505; border: 1px solid #222; border-radius: 8px; padding: 0.5rem; display: flex; justify-content: center;}
.report-footer-actions { display: flex; justify-content: space-between; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #222;}
.all-routes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; max-height: 300px; overflow-y: auto; margin-top:1rem;}
.all-routes-item { background: #111; border: 1px solid #222; padding: 0.75rem; border-radius: 8px; text-align: center;}
.all-routes-item-title { font-size: 0.8rem; margin-bottom: 0.5rem; color:#aaa;}

/* ================= JUEGOS RESTANTES (CANVAS) ================= */
.aim-arena {
  position: relative; height: 380px; background: #0a0a0a; border-radius: 12px; overflow: hidden; cursor: crosshair; border: 1px solid #222;
}
.aim-target {
  position: absolute; width: 44px; height: 44px; background: radial-gradient(circle, #f43f5e 35%, #be123c 100%); border-radius: 50%; box-shadow: 0 0 15px rgba(244,63,94,0.5); border: 2px solid #fff; cursor: pointer;
}
.aim-target:active { transform: scale(0.9); }
.arena-splash { position: absolute; inset: 0; background: rgba(5,5,5,0.9); display: flex; flex-direction: column; align-items: center; justify-content: center; }

.hunger-bar-container { margin-bottom: 1rem; width: 100%; }
.hunger-label { font-size: 0.75rem; font-weight: 800; color: #fbbf24; letter-spacing: 1px; }
.hunger-bar-track { width: 100%; height: 12px; background: #000; border-radius: 6px; border: 1px solid #333; margin-top: 4px; overflow: hidden;}
.hunger-bar-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e); }

.relative-container { position: relative; display: flex; justify-content: center; }
.click-to-play-overlay {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; border-radius: 8px; z-index: 20; cursor: pointer;
}
.click-to-play-overlay span {
  background: var(--cyan); color: #000; padding: 0.8rem 1.5rem; border-radius: 6px; font-weight: 800; box-shadow: 0 0 25px var(--cyan-glow);
}

canvas { background: #0a0a0a; border-radius: 8px; border: 1px solid #222; max-width: 100%; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.interstitial-box {
  width: 440px; background: #111; border: 1px solid var(--cyan); border-radius: 12px; padding: 2rem; box-shadow: 0 0 40px var(--cyan-glow); text-align: center;
}
.interstitial-fake-creative { background: #050505; border: 1px dashed #333; border-radius: 8px; padding: 2.5rem 1rem; margin: 1.5rem 0; }
.interstitial-footer { display: flex; justify-content: space-between; align-items: center; min-height: 40px; color: #777; font-size: 0.9rem;}
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 1100px) { .ad-skyscraper { display: none; } }
@media (max-width: 768px) {
  .games-grid { grid-template-columns: 1fr; }
  .ad-728x90 { display: none; }
  .site-container { padding: 1rem 0.5rem; }
  .report-routes-grid { grid-template-columns: 1fr; }
  .all-routes-grid { grid-template-columns: 1fr; }
}