* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #0b0e14;
  color: #e6edf3;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
}

/* --- BARRA SUPERIOR DE NAVEGACIÓN --- */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(13, 17, 23, 0.95);
  border-bottom: 1px solid #30363d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-modes {
  display: flex;
  gap: 10px;
}

.nav-btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: #30363d;
  color: #ffffff;
}

.nav-btn.active {
  background: #1f6feb;
  color: #fff;
  border-color: #388bfd;
  box-shadow: 0 0 12px rgba(31, 111, 235, 0.4);
}

.special-btn {
  border-color: #a371f7;
  color: #d2a8ff;
}

.special-btn.active {
  background: #8957e5;
  border-color: #a371f7;
  box-shadow: 0 0 16px rgba(163, 113, 247, 0.5);
}

/* Selector de Dificultad */
.difficulty-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(22, 27, 34, 0.8);
  border: 1px solid #30363d;
  padding: 4px 10px;
  border-radius: 8px;
}

.diff-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.diff-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #8b949e;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn:hover {
  color: #f0f6fc;
}

.diff-btn.active {
  background: #238636;
  color: #ffffff;
  border-color: #3fb950;
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.3);
}

#btnDiffReal.diff-btn.active {
  background: #da3633;
  border-color: #f85149;
  box-shadow: 0 0 10px rgba(248, 81, 73, 0.4);
}

.countdown-badge {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #f0883e;
  padding: 6px 14px;
  background: rgba(240, 136, 62, 0.15);
  border: 1px solid rgba(240, 136, 62, 0.4);
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(240, 136, 62, 0.2);
}

/* --- GUÍA VISUAL DE LA ÓRBITA EN EL CENTRO --- */
.orbit-visual-guide {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 560px;  /* 2 * Radio (280px) */
  height: 560px;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.5s ease;
}

/* Anillo orbital (verde neón como tu boceto) */
.orbit-ring {
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(46, 204, 113, 0.45);
  border-radius: 50%;
  box-shadow: 0 0 25px rgba(46, 204, 113, 0.2), inset 0 0 25px rgba(46, 204, 113, 0.1);
  animation: pulseRing 3s ease-in-out infinite;
}

/* Punto central (rojo como tu boceto) */
.orbit-center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #ff4757;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 16px #ff4757;
}

@keyframes pulseRing {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.02); }
}

/* --- BOTÓN FLOTANTE SIDEBAR --- */
.sidebar-toggle-btn {
  position: fixed;
  top: 76px;
  left: 20px;
  background: #161b22;
  border: 1px solid #30363d;
  color: #58a6ff;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 50;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.sidebar-toggle-btn:hover {
  background: #21262d;
  border-color: #58a6ff;
}

/* --- PANEL LATERAL COLAPSABLE --- */
.control-panel {
  position: fixed;
  top: 125px;
  bottom: 60px;
  left: 20px;
  width: 440px;
  max-width: calc(100vw - 40px);
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 40;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.control-panel.collapsed {
  transform: translateX(calc(-100% - 30px));
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid #21262d;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title-wrap .badge {
  font-size: 0.65rem;
  letter-spacing: 2px;
  font-weight: 800;
  color: #58a6ff;
  display: block;
}

.title-wrap h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0f6fc;
}

.status-indicator {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(35, 134, 54, 0.2);
  color: #3fb950;
  border: 1px solid rgba(63, 185, 80, 0.4);
}

.status-indicator.busy {
  background: rgba(163, 113, 247, 0.2);
  color: #d2a8ff;
  border-color: rgba(210, 168, 255, 0.4);
}

.speed-selector {
  padding: 10px 18px;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: #8b949e;
}

.speed-buttons {
  display: flex;
  gap: 6px;
}

.btn-speed {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.btn-speed.active {
  background: #1f6feb;
  color: #fff;
  border-color: #388bfd;
}

.panel-scroll {
  padding: 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.pattern-group h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #8b949e;
  margin-bottom: 8px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.button-grid button {
  padding: 8px 10px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #f0f6fc;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.button-grid button:hover:not(:disabled) {
  background: #30363d;
  border-color: #8b949e;
}

.button-grid button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.highlight-btn {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(31, 111, 235, 0.2), rgba(137, 87, 229, 0.2)) !important;
  border-color: #8957e5 !important;
}

.reset-area {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #21262d;
}

.btn-reset {
  width: 100%;
  padding: 10px;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ff7b72;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
}

/* --- ESCENARIO DE LAS 8 LLAVES --- */
.grid-stage {
  position: fixed;
  top: 50%;
  left: 75vw; /* Por defecto en el sector derecho */
  transform: translate(-50%, -50%);
  width: 232px;
  height: 496px;
  transform-origin: center center;
  transition: left 0.85s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 10;
}

/* Se traslada al centro exacto de la pantalla (50vw, 50vh) */
.grid-stage.orbit-centered {
  left: 50vw !important;
}

/* Bloques compactos: se reduce el bloque manteniendo el centro de la casilla */
.block {
  position: absolute;
  top: 0;
  left: 0;
  width: 72px;
  height: 72px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  user-select: none;
  will-change: transform;
  /* Transición nula en transform para cero retardo entre movimientos */
  transition: background-color 0.2s ease, filter 0.2s ease !important;
}

/* 8 COLORES */
.color-1 { background-color: #EF4444; }
.color-2 { background-color: #F97316; }
.color-3 { background-color: #EAB308; }
.color-4 { background-color: #10B981; }
.color-5 { background-color: #06B6D4; }
.color-6 { background-color: #3B82F6; }
.color-7 { background-color: #8B5CF6; }
.color-8 { background-color: #EC4899; }

/* ESTADO EN GRIS */
.block.is-grey {
  background-color: #334155 !important;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3) !important;
}

body.mode-practice .block .block-num {
  opacity: 0;
}

/* Al terminar la práctica, los números vuelven a verse */
body.mode-practice.reveal-numbers .block .block-num {
  opacity: 1 !important;
}

/* FOCUS */
.block.focus-flash {
  filter: brightness(1.7) drop-shadow(0 0 25px #ffffff) !important;
  z-index: 20;
}

/* INTERACCIÓN FINAL */
.grid-stage.interactive .block {
  cursor: pointer;
  pointer-events: auto;
}

.grid-stage.interactive .block:hover {
  filter: brightness(1.3) scale(1.08);
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

/* --- BARRA INFERIOR --- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #0d1117;
  border-top: 1px solid #21262d;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.target-indicator {
  font-size: 0.92rem;
  font-weight: 700;
  color: #58a6ff;
  letter-spacing: 0.5px;
}

/* --- MODAL POPUP RESULTADO --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon { font-size: 3.5rem; margin-bottom: 12px; }
.modal-title { font-size: 1.6rem; font-weight: 900; margin-bottom: 8px; }
.modal-card.win .modal-title { color: #3fb950; }
.modal-card.lose .modal-title { color: #f85149; }
.modal-msg { color: #8b949e; font-size: 0.95rem; margin-bottom: 24px; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-btn-primary {
  padding: 12px;
  border-radius: 10px;
  font-weight: 800;
  background: #238636;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.modal-btn-primary:hover { background: #2ea043; }

.modal-btn-sec {
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  background: transparent;
  color: #8b949e;
  border: 1px solid #30363d;
  cursor: pointer;
  font-size: 0.88rem;
}

.modal-btn-sec:hover { background: #21262d; color: #fff; }

.hidden { display: none !important; }